/* ============================================================
   Triage — ADHD-friendly review queue
   Calm, high-contrast, generous spacing. System font stack.
   ============================================================ */

/* The app toggles every screen/overlay via the [hidden] attribute. Class rules that
   set `display` (e.g. .help-overlay{display:grid}) would otherwise override the UA
   `[hidden]{display:none}` rule and keep things visible. Make [hidden] authoritative. */
[hidden] { display: none !important; }

:root {
  /* bucket colors */
  --action: #e5484d;   /* 🔴 */
  --waiting: #f2a900;  /* 🟡 */
  --fyi: #8b95a5;      /* ⚪ */

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1d21;
  --text-soft: #5b6470;
  --text-faint: #8a93a0;
  --border: #e3e7ec;
  --primary: #2f6fed;
  --primary-ink: #ffffff;
  --good: #1f9d55;
  --shadow: 0 1px 2px rgba(20, 25, 35, .04), 0 6px 20px rgba(20, 25, 35, .06);
  --radius: 14px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f242d;
    --text: #eef1f5;
    --text-soft: #aab3c0;
    --text-faint: #79828f;
    --border: #2a313b;
    --primary: #4f8bff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 700; letter-spacing: -0.01em; }

button { font-family: inherit; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.06); }
.btn-good { background: var(--good); color: #fff; border-color: transparent; }
.btn-good:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--action);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-weight: 600;
  max-width: 92vw;
  text-align: center;
}
.toast.good { background: var(--good); }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo { font-size: 44px; }
.login h1 { margin: 6px 0 2px; }
.login-sub { color: var(--text-soft); margin: 0 0 20px; }
.login label { display: block; text-align: left; margin-bottom: 14px; }
.login label span { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; }
.login input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: var(--surface-2);
  color: var(--text);
}
.login input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.login-err { color: var(--action); font-weight: 600; margin: 14px 0 0; font-size: 14px; }
.login code { background: var(--surface-2); padding: 2px 5px; border-radius: 5px; font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo { font-size: 22px; }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-email { color: var(--text-faint); font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Progress ---------- */
.progress-wrap {
  max-width: var(--maxw);
  margin: 16px auto 0;
  padding: 0 18px;
}
.progress-meta { font-size: 15px; color: var(--text-soft); margin-bottom: 6px; }
.progress-meta strong { font-size: 18px; color: var(--text); }
.cleared-note { margin-left: 8px; color: var(--good); font-weight: 600; }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--good), #38c172);
  border-radius: 99px;
  transition: width .45s cubic-bezier(.2,.8,.2,1);
}

/* ---------- Queue ---------- */
.queue {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 18px 96px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Section headers */
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 2px 2px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.section-head:first-child { margin-top: 0; }
.section-count {
  background: var(--surface-2);
  border-radius: 99px;
  padding: 1px 9px;
  font-size: 12px;
  color: var(--text-soft);
}

/* ---------- Card ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 14px 22px;
  overflow: hidden;
  transition: box-shadow .15s ease, border-color .15s ease, transform .2s ease, opacity .2s ease;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--fyi);
}
.card.bucket-action::before { background: var(--action); }
.card.bucket-waiting::before { background: var(--waiting); }
.card.bucket-fyi::before { background: var(--fyi); }

.card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary), var(--shadow);
}

/* exit animation */
.card.leaving {
  opacity: 0;
  transform: translateX(40px) scale(.97);
  pointer-events: none;
}

.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.urgency {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
}
.urgency-today { background: rgba(229,72,77,.14); color: var(--action); }
.urgency-this-week { background: rgba(242,169,0,.16); color: #b07c00; }
.urgency-whenever { background: var(--surface-2); color: var(--text-faint); }

.tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Disposition badge ---------- */
.disp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  padding: 3px 10px;
  border-radius: 99px;
  margin: 0 0 8px;
  border: 1px solid transparent;
}
.disp-reply    { background: rgba(47,111,237,.12); color: var(--primary); }
.disp-research { background: rgba(99,102,241,.14); color: #5b5ef0; }   /* indigo */
.disp-handoff  { background: rgba(13,148,136,.14); color: #0d9488; }   /* teal */
.disp-do       { background: rgba(31,157,85,.14);  color: var(--good); }/* green */
.disp-note     { background: var(--surface-2);     color: var(--text-faint); border-color: var(--border); }

.headline { font-size: 19px; font-weight: 700; margin: 2px 0 4px; line-height: 1.3; }
.why { font-size: 13px; color: var(--text-faint); margin: 0 0 10px; }

.reco {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 10px;
}
.reco b { color: var(--text); font-weight: 700; }

/* ---------- Research findings ---------- */
.findings {
  background: rgba(99,102,241,.08);
  border: 1px solid rgba(99,102,241,.22);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 12px;
}
.findings-head { font-size: 12px; font-weight: 800; color: #5b5ef0; margin-bottom: 6px; letter-spacing: .02em; }
.findings-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;       /* preserve line breaks */
  word-break: break-word;
}

/* Researching in-flight pill */
.researching-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #5b5ef0;
  background: rgba(99,102,241,.10);
  border-radius: 99px;
  padding: 5px 12px;
  margin-bottom: 10px;
}

/* ---------- Needs-input (amber) ---------- */
.needs-input {
  background: rgba(242,169,0,.10);
  border: 1px solid rgba(242,169,0,.30);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 12px;
}
.needs-input-q { font-size: 14px; font-weight: 700; color: #9a6b00; margin-bottom: 8px; line-height: 1.4; }
@media (prefers-color-scheme: dark) { .needs-input-q { color: #f2c14e; } }
.answer-row { display: flex; gap: 8px; }
.answer-row .answer-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid rgba(242,169,0,.55);
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.answer-row .answer-input:focus-visible { outline: 2px solid var(--waiting); outline-offset: 1px; }

/* ---------- Forward / handoff block ---------- */
.forward-block {
  background: rgba(13,148,136,.07);
  border: 1px solid rgba(13,148,136,.22);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 12px;
}
.forward-to { font-size: 14px; color: var(--text); margin-bottom: 8px; }
.forward-to b { color: #0d9488; font-weight: 700; }
.forward-note {
  width: 100%;
  resize: vertical;
  min-height: 4.6em;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
}
.forward-note:focus { outline: 2px solid #0d9488; outline-offset: 1px; }

.draft-label { font-size: 12px; font-weight: 700; color: var(--text-faint); margin-bottom: 4px; }
.draft {
  width: 100%;
  resize: vertical;
  min-height: 4.6em;       /* ~3 lines collapsed */
  max-height: 4.6em;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: max-height .2s ease, background .15s ease;
}
.draft:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  max-height: 40em;
  min-height: 9em;
  background: var(--surface);
}
.draft.expanded { max-height: 40em; min-height: 9em; background: var(--surface); }

/* Clarify inline input */
.clarify-row { display: none; gap: 8px; margin-top: 10px; }
.clarify-row.show { display: flex; }
.clarify-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--primary);
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.clarify-row input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Action buttons */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .btn { flex: 1 1 auto; min-width: 92px; }
.actions .spacer { flex-basis: 100%; height: 0; }

/* ---------- Empty / loading ---------- */
.empty {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
  color: var(--text-soft);
}
.empty-emoji { font-size: 60px; }
.empty h2 { margin: 10px 0 4px; color: var(--text); }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Help overlay ---------- */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10,14,20,.55);
  display: grid;
  place-items: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.help-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  width: 100%;
  max-width: 420px;
}
.help-card h2 { margin: 0 0 14px; }
.help-list { list-style: none; margin: 0 0 18px; padding: 0; }
.help-list li { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 14px; color: var(--text-soft); }
.help-list li span { color: var(--text); }
kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 22px;
  text-align: center;
  color: var(--text);
}

/* ---------- Context & Instructions ---------- */
.context-screen {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 18px 96px;
}
.context-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
}
.context-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.context-head h2 { margin: 0; font-size: 20px; }
.context-sub { color: var(--text-soft); font-size: 14px; margin: 0 0 14px; line-height: 1.5; }
.context-text {
  width: 100%;
  min-height: 50vh;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.context-text:focus { outline: 2px solid var(--primary); outline-offset: 1px; background: var(--surface); }
.context-text[disabled] { opacity: .65; }
.context-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.context-status { font-size: 13px; color: var(--text-soft); }
.context-status.good { color: var(--good); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .topbar h1 { display: none; }
  .user-email { max-width: 30vw; }
  .actions .btn { flex: 1 1 calc(50% - 8px); }
  .headline { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .001ms !important; }
}
