/* MejAI — design tokens & base */
:root {
  /* palette */
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1c1c1c;
  --ink-soft: #4a4a4a;
  --accent: #c95b3c;        /* muted clay */
  --accent-soft: #f3e3db;
  --ok: #3d7a4f;
  --warn: #b98a2e;
  --err: #b33a2a;
  --line: #e5dfd6;

  /* type */
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-base: 16px;
  --fs-meta: 13px;

  /* rhythm */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.brand { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; margin-bottom: var(--sp-4); }
.brand .dot { color: var(--accent); }

.nav-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-3);
  border-radius: 8px;
  border: none; background: none;
  color: var(--ink-soft);
  text-align: left; width: 100%;
  min-height: 44px;
}
.nav-item:hover { background: var(--accent-soft); }
.nav-item.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
}
.chat-area { flex: 1; overflow-y: auto; padding: var(--sp-5); }

/* Composer */
.composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: var(--sp-4) var(--sp-5);
}
.composer textarea {
  width: 100%; min-height: 52px; max-height: 160px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: var(--sp-3);
  font: inherit; resize: vertical;
}
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: var(--sp-2); }
.btn-send {
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 10px var(--sp-5);
  min-height: 44px; font-weight: 600;
}
.btn-send:hover { filter: brightness(0.95); }
.hint { color: var(--ink-soft); font-size: var(--fs-meta); }

/* Messages */
.msg { max-width: 720px; margin: 0 auto var(--sp-4); }
.msg-user { text-align: right; }
.msg-user .bubble {
  display: inline-block; background: var(--ink); color: #fff;
  padding: var(--sp-3) var(--sp-4); border-radius: 14px 14px 4px 14px;
  text-align: left; max-width: 80%;
}
.msg-assistant .bubble {
  background: var(--surface); border: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4); border-radius: 14px 14px 14px 4px;
}

/* Mobile */
@media (max-width: 720px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .menu-toggle { display: block; }
}
.menu-toggle { display: none; border: none; background: none; font-size: 22px; min-height: 44px; min-width: 44px; }

/* Workflow view */
.view-panel { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.view-title { margin: 0 0 var(--sp-3); font-size: 20px; }
.view-sub { margin: var(--sp-5) 0 var(--sp-3); font-size: 16px; }
.wf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-3);
}
.wf-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-1);
}
.wf-card .wf-name { font-weight: 600; font-size: 14px; }
.wf-card .wf-role { font-size: 12px; color: var(--ink-soft); }
.wf-card .wf-status {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
}
.wf-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.wf-dot.work { background: var(--warn); animation: pulse 1.2s infinite; }
.wf-dot.ok { background: var(--ok); }
.wf-dot.idle { background: #b9b2a6; }
.wf-dot.fail { background: var(--err); }
.wf-stage { font-size: 11px; color: var(--ink-soft); font-family: ui-monospace, monospace; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.wf-approvals { display: flex; flex-direction: column; gap: var(--sp-2); }
.wf-approval-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: var(--sp-3); display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2);
}
