/* ============================================================
   Chattinc Console — "The Brief"
   A private secretary's briefing desk. Warm editorial paper,
   characterful serif voice, one burnt accent. Light + dark.
   ============================================================ */

:root {
  --paper:    #f4efe6;
  --paper-2:  #ede6d9;
  --card:     #fefcf7;
  --card-2:   #f9f5ec;
  --ink:      #211d17;
  --ink-2:    #6a6155;
  --ink-3:    #9d9384;
  --line:     rgba(33,29,23,.10);
  --line-2:   rgba(33,29,23,.16);

  --accent:   #b5502e;     /* burnt terracotta */
  --accent-2: #9a3f22;
  --accent-soft: rgba(181,80,46,.10);
  --accent-line: rgba(181,80,46,.30);

  --sage:  #5f7a54;        /* handled / ok */
  --sage-soft: rgba(95,122,84,.13);
  --amber: #b07d1e;        /* waiting on you */
  --amber-soft: rgba(176,125,30,.14);
  --rose:  #a8423a;        /* flagged / blocked */
  --rose-soft: rgba(168,66,58,.12);

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:  "Instrument Sans", ui-sans-serif, system-ui, sans-serif;

  --r: 14px; --r-sm: 9px;
  --rail: 250px;
  --shadow: 0 1px 2px rgba(33,29,23,.04), 0 8px 30px rgba(33,29,23,.06);
  --shadow-lg: 0 20px 60px rgba(33,29,23,.14);
}

:root[data-theme="dark"], html[data-theme="dark"] {
  --paper:    #17150f;
  --paper-2:  #1e1b14;
  --card:     #201d15;
  --card-2:   #262218;
  --ink:      #ece4d4;
  --ink-2:    #a89e8c;
  --ink-3:    #746c5c;
  --line:     rgba(236,228,212,.09);
  --line-2:   rgba(236,228,212,.15);
  --accent:   #e0794f;
  --accent-2: #ef8a60;
  --accent-soft: rgba(224,121,79,.13);
  --accent-line: rgba(224,121,79,.34);
  --sage:  #8fac7f; --sage-soft: rgba(143,172,127,.14);
  --amber: #d6a94e; --amber-soft: rgba(214,169,78,.15);
  --rose:  #d9756b; --rose-soft: rgba(217,117,107,.15);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 34px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:#17150f; --paper-2:#1e1b14; --card:#201d15; --card-2:#262218;
    --ink:#ece4d4; --ink-2:#a89e8c; --ink-3:#746c5c;
    --line:rgba(236,228,212,.09); --line-2:rgba(236,228,212,.15);
    --accent:#e0794f; --accent-2:#ef8a60; --accent-soft:rgba(224,121,79,.13); --accent-line:rgba(224,121,79,.34);
    --sage:#8fac7f; --sage-soft:rgba(143,172,127,.14); --amber:#d6a94e; --amber-soft:rgba(214,169,78,.15);
    --rose:#d9756b; --rose-soft:rgba(217,117,107,.15);
    --shadow:0 1px 2px rgba(0,0,0,.3),0 10px 34px rgba(0,0,0,.4); --shadow-lg:0 24px 70px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1100px 700px at 88% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 600px at -6% 108%, var(--sage-soft), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
::selection { background: var(--accent-soft); }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--sans); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.serif { font-family: var(--serif); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 26px 18px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 55%, transparent), transparent);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.seal {
  width: 34px; height: 34px; border-radius: 10px; flex: none; position: relative;
  background: radial-gradient(circle at 38% 34%, var(--accent-2), var(--accent) 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 14px var(--accent-soft);
  display: grid; place-items: center;
}
.seal::after { content: ""; width: 13px; height: 13px; border: 1.6px solid rgba(255,255,255,.9); border-radius: 50% 50% 50% 2px; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-top: -1px; }

.nav-label { padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px; transition: .15s; position: relative;
}
.nav a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; opacity: .8; }
.nav a:hover { background: var(--card-2); color: var(--ink); }
.nav a.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.nav a.active::before { content: ""; position: absolute; left: -18px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav a .count { margin-left: auto; font-family: var(--sans); font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.nav a .count.warn { background: var(--amber-soft); color: var(--amber); }

.rail-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.rail-foot .who { min-width: 0; }
.rail-foot .who b { font-size: 13.5px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot .who span { font-size: 11px; color: var(--ink-3); }
.theme-btn { margin-left: auto; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.theme-btn:hover { color: var(--accent); border-color: var(--accent-line); }
.theme-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* ---------- main ---------- */
.main { min-width: 0; padding: 40px clamp(28px, 5vw, 80px) 80px; max-width: 1180px; }
.main.wide { max-width: none; }

.dateline { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dateline .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 4px var(--sage-soft); }

h1.brief-hi { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 4.4vw, 50px); letter-spacing: -.02em; line-height: 1.02; margin: 0 0 14px; }
.brief-lede { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: clamp(17px, 2vw, 21px); color: var(--ink-2); max-width: 40ch; line-height: 1.45; margin: 0 0 30px; }
.brief-lede b { font-style: normal; font-weight: 600; color: var(--ink); }

/* stat row */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 44px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat .n { font-family: var(--serif); font-weight: 600; font-size: 40px; letter-spacing: -.02em; line-height: 1; }
.stat .k { margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.stat.accent .n { color: var(--amber); }
.stat .spark { position: absolute; right: 14px; top: 16px; opacity: .5; }

/* section */
.sec { margin-bottom: 40px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sec-head h2 { font-family: var(--serif); font-weight: 600; font-size: 20px; letter-spacing: -.01em; margin: 0; }
.sec-head .hint { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }

/* needs-you cards */
.needs { display: grid; gap: 12px; }
.need {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--amber);
  border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); transition: .16s;
}
.need:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); border-left-color: var(--accent); }
.need.flag { border-left-color: var(--rose); }
.need .body { min-width: 0; }
.need .who-line { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.need .who-line b { font-weight: 600; font-size: 15px; }
.need .reason { font-size: 12.5px; color: var(--ink-2); }
.need .snip { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.need .snip q { color: var(--ink); font-style: italic; }
.need .act { display: flex; gap: 8px; }

/* handled digest */
.digest { display: grid; gap: 2px; }
.topic { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.topic > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 15px 18px; }
.topic > summary::-webkit-details-marker { display: none; }
.topic .tick { width: 26px; height: 26px; border-radius: 8px; background: var(--sage-soft); color: var(--sage); display: grid; place-items: center; flex: none; }
.topic .tick svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.topic .t-name { font-weight: 600; font-size: 15px; }
.topic .t-sub { font-size: 12.5px; color: var(--ink-3); }
.topic .t-n { margin-left: auto; font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--ink-2); }
.topic .chev { color: var(--ink-3); transition: .2s; }
.topic[open] .chev { transform: rotate(90deg); }
.topic .rows { border-top: 1px solid var(--line); padding: 6px 18px 14px; }
.topic .row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.topic .row:last-child { border-bottom: 0; }
.topic .row .t { margin-left: auto; font-size: 11.5px; color: var(--ink-3); font-family: var(--sans); }

/* people / rows */
.people-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 16px; align-items: center; padding: 13px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 9px; }
.people-row .nm { font-weight: 600; font-size: 15px; }
.people-row .sub { font-size: 12px; color: var(--ink-3); font-family: var(--sans); }
.people-row .last { font-size: 12.5px; color: var(--ink-2); text-align: right; }

/* segmented autonomy control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 6px 12px; border-radius: 7px; display: flex; align-items: center; gap: 7px; transition: .14s; white-space: nowrap; }
.seg button .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg button.off[aria-pressed="true"]     { color: var(--ink-3); }
.seg button.observe[aria-pressed="true"] { color: var(--amber); }
.seg button.assist[aria-pressed="true"]  { color: var(--sage); }
.seg button[aria-pressed="true"] .d { opacity: 1; }

/* avatars, chips, buttons */
.av { width: 40px; height: 40px; border-radius: 11px; flex: none; display: grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 16px; color: #fff; }
.av.sm { width: 30px; height: 30px; font-size: 13px; border-radius: 9px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.chip.bot { background: var(--accent-soft); color: var(--accent); }
.chip.human { background: var(--sage-soft); color: var(--sage); }
.chip.wait { background: var(--amber-soft); color: var(--amber); }
.chip.flag { background: var(--rose-soft); color: var(--rose); }
.chip .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.btn { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 15px; border-radius: 9px; cursor: pointer; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); transition: .14s; }
.btn:hover { border-color: var(--accent-line); color: var(--accent); }
.btn.solid { background: var(--accent); border-color: transparent; color: #fff; }
.btn.solid:hover { background: var(--accent-2); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }

/* conversations two-pane */
.convo { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 0px); }
.clist { border-right: 1px solid var(--line); height: 100vh; overflow-y: auto; padding: 20px 14px; }
.clist .search { display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 13px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); margin-bottom: 14px; }
.clist .search input { border: 0; background: transparent; outline: none; font: inherit; font-size: 14px; color: var(--ink); width: 100%; }
.crow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 11px; cursor: pointer; transition: .13s; }
.crow:hover { background: var(--card-2); }
.crow.active { background: var(--card); box-shadow: var(--shadow); }
.crow .cn { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.crow .cp { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .rt { font-size: 11px; color: var(--ink-3); text-align: right; }
.crow .rt .dotm { width: 7px; height: 7px; border-radius: 50%; margin: 4px 0 0 auto; }

.thread-wrap { display: flex; flex-direction: column; height: 100vh; }
.thread-head { display: flex; align-items: center; gap: 14px; padding: 18px 26px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--card) 40%, transparent); }
.thread-head .nm { font-family: var(--serif); font-weight: 600; font-size: 18px; }
.thread-head .sub { font-size: 12px; color: var(--ink-3); }
.thread { flex: 1; overflow-y: auto; padding: 26px; display: flex; flex-direction: column; gap: 3px; }
.daysep { text-align: center; font-size: 11px; color: var(--ink-3); letter-spacing: .1em; text-transform: uppercase; margin: 18px 0 10px; font-weight: 600; }
.msg { max-width: 62%; padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.45; margin-bottom: 4px; position: relative; }
.msg .meta { font-size: 10.5px; margin-top: 5px; opacity: .6; }
.msg.in { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.human { align-self: flex-end; background: var(--sage); color: #fff; border-bottom-right-radius: 5px; }
.msg .tag { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; opacity: .8; display: block; margin-bottom: 3px; }
.composer { border-top: 1px solid var(--line); padding: 16px 26px; }
.composer .box { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line-2); background: var(--card); border-radius: 13px; padding: 6px 6px 6px 16px; }
.composer input { flex: 1; border: 0; background: transparent; outline: none; font: inherit; font-size: 14.5px; color: var(--ink); }
.composer .send { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--sage); color: #fff; cursor: pointer; display: grid; place-items: center; }
.composer .note { margin-top: 9px; font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }

/* sign-in + link + generic card */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.panel { width: min(94vw, 400px); background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 34px 34px 26px; }
.panel h1 { font-family: var(--serif); font-weight: 600; font-size: 26px; margin: 18px 0 6px; letter-spacing: -.01em; }
.panel p.sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 22px; }
.fld { display: block; margin-bottom: 13px; }
.fld span { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.fld input { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card-2); color: var(--ink); font: inherit; font-size: 14px; }
.fld input:focus { outline: none; border-color: var(--accent-line); }
/* selects + textareas: match the input look (they ignore it by default) */
.fld select, .fld textarea, select.fld, textarea.fld {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--card-2); color: var(--ink); font: inherit; font-size: 14px;
}
.fld select, select.fld {
  height: 42px; padding: 0 38px 0 14px; cursor: pointer; -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239d9384' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.fld textarea, textarea.fld { min-height: 84px; line-height: 1.5; resize: vertical; }
.fld select:focus, .fld textarea:focus, select.fld:focus, textarea.fld:focus { outline: none; border-color: var(--accent-line); }
.fld select option { color: var(--ink); background: var(--card); }

.qr { width: 210px; height: 210px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line-2); display: grid; place-items: center; margin: 0 auto; }
.code { font-family: var(--sans); font-weight: 700; letter-spacing: .3em; font-size: 30px; color: var(--accent); text-align: center; }

.pagehead { margin-bottom: 26px; }
.pagehead h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(26px,3.4vw,38px); letter-spacing: -.02em; margin: 0 0 6px; }
.pagehead p { color: var(--ink-2); font-size: 14px; margin: 0; max-width: 54ch; }

/* motion */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.d1{animation-delay:.04s}.d2{animation-delay:.1s}.d3{animation-delay:.16s}.d4{animation-delay:.22s}.d5{animation-delay:.28s}.d6{animation-delay:.34s}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .rail-foot { display: none; }
  .stats { grid-template-columns: 1fr; }
  .convo { grid-template-columns: 1fr; }
}
