/* pice · diligence: strictly black and white, greys only. */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --g1: #5c5c5c;   /* secondary text, 6.6:1 on white */
  --g2: #8a8a8a;   /* tertiary, large text only */
  --rule: #e6e6e6; /* hairlines */
  --soft: #f5f5f5; /* quiet fills */
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --rail: 232px;
  --measure: 760px;
}
:root[data-theme="dark"] {
  --bg: #000000; --fg: #ffffff; --g1: #a8a8a8; --g2: #7a7a7a; --rule: #222222; --soft: #0d0d0d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --fg: #ffffff; --g1: #a8a8a8; --g2: #7a7a7a; --rule: #222222; --soft: #0d0d0d;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 300 15px/1.65 var(--sans); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.chrome, .chrome *, .chrome ::placeholder, textarea::placeholder, input::placeholder { text-transform: lowercase; }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--fg); color: var(--bg); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- layout ---------- */
.shell {
  display: grid; min-height: 100vh;
  grid-template-columns: var(--rail) 1fr;
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "top top" "rail main" "rail composer" "rail foot";
}
.top {
  grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 26px 40px 22px; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.wordmark { font-size: 26px; font-weight: 300; letter-spacing: -0.03em; text-decoration: none; }
.wordmark .dot { display: inline-block; margin: 0 .32em; color: var(--g2); }
.wordmark.small { font-size: 17px; margin: 0 0 28px; }
.meta { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--g1); min-width: 0; }
.who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.chip { border: 1px solid var(--rule); border-radius: 999px; padding: 3px 11px; font-size: 11.5px; color: var(--fg); white-space: nowrap; }
.ghost { background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 3px 11px; font-size: 12px; color: var(--g1); }
.ghost:hover { color: var(--fg); border-color: var(--fg); }

.rail { grid-area: rail; border-right: 1px solid var(--rule); padding: 28px 0 28px; position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 80px); overflow-y: auto; }
.rail-title { margin: 0 24px 14px 32px; font-size: 11px; letter-spacing: .08em; color: var(--g1); }
.rail ol { list-style: none; margin: 0; padding: 0; }
.rail button {
  display: flex; gap: 14px; width: 100%; text-align: left; background: none; border: 0;
  padding: 7px 24px 7px 32px; font-size: 13.5px; font-weight: 400; color: var(--g1);
  border-left: 1px solid transparent; margin-left: -1px; transition: color .15s, border-color .15s;
}
.rail button .n { font-family: var(--mono); font-size: 11px; color: var(--g2); width: 16px; padding-top: 2px; }
.rail button:hover, .rail button[aria-current="true"] { color: var(--fg); border-left-color: var(--fg); }

.conv { grid-area: main; padding: 48px 40px 24px; min-width: 0; }
.empty, .log { max-width: var(--measure); margin: 0 auto; }
.lede { font-size: 34px; font-weight: 300; letter-spacing: -0.03em; line-height: 1.2; margin: 6vh 0 12px; }
.hint { color: var(--g1); margin: 0 0 30px; max-width: 520px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px;
  font-size: 13px; color: var(--g1); transition: color .15s, border-color .15s; text-align: left;
}
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--g1); }
.chips button:hover { color: var(--fg); border-color: var(--fg); }

/* ---------- conversation ---------- */
.log { list-style: none; padding: 0; }
.turn { padding: 28px 0 30px; border-top: 1px solid var(--rule); animation: rise .45s ease both; }
.turn:first-child { border-top: 0; padding-top: 0; }
.q { font-size: 21px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.35; margin: 0 0 18px; }
.label { font-size: 11px; letter-spacing: .08em; color: var(--g1); margin-bottom: 6px; text-transform: lowercase; }
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--g1); text-transform: lowercase; min-height: 22px; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--fg); animation: pulse 1.2s ease-in-out infinite; }
.answer { font-size: 15.5px; font-weight: 400; line-height: 1.7; }
.answer.streaming { white-space: pre-wrap; }
.answer.final { animation: fade .5s ease both; }
.caret { display: inline-block; width: .55ch; height: 1.05em; background: var(--fg); vertical-align: -0.15em; margin-left: 1px; animation: blink 1s steps(1) infinite; }
.answer p { margin: 0 0 12px; }
.answer h3, .answer h4 { font-size: 13px; font-weight: 500; letter-spacing: .04em; margin: 22px 0 8px; text-transform: lowercase; }
.answer ul, .answer ol { margin: 0 0 14px; padding-left: 1.2em; }
.answer li { margin: 3px 0; }
.answer li::marker { color: var(--g2); }
.answer strong { font-weight: 600; }
.answer code { font-family: var(--mono); font-size: .88em; background: var(--soft); padding: 1px 5px; }
.num { font-family: var(--mono); font-size: .93em; letter-spacing: -0.01em; }
.src {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; line-height: 1.5; color: var(--g1);
  border: 1px solid var(--rule); border-radius: 3px; padding: 0 6px; margin: 0 2px; vertical-align: 1px; white-space: nowrap;
}
.tablewrap { overflow-x: auto; margin: 6px 0 16px; border-top: 1px solid var(--fg); border-bottom: 1px solid var(--fg); }
.answer table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 12.5px; }
.answer th { text-align: left; font-weight: 500; padding: 9px 12px 8px; border-bottom: 1px solid var(--fg); white-space: nowrap; }
.answer td { padding: 7px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.answer tr:last-child td { border-bottom: 0; }
.answer td.r, .answer th.r { text-align: right; }
.answer td .num { font-size: 1em; }

.chart { margin: 18px 0 6px; }
.chart svg { width: 100%; height: 132px; display: block; overflow: visible; }
.chart .bar { fill: var(--g2); }
.chart .bar.last { fill: var(--fg); }
.chart .line { fill: none; stroke: var(--fg); stroke-width: 1.4; stroke-linejoin: round; }
.chart .base { stroke: var(--rule); stroke-width: 1; }
.chart .pt { fill: var(--fg); }
.chart .cap { font-family: var(--mono); font-size: 11px; color: var(--g1); display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.sources { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--g1); }
.sources .label { margin-bottom: 4px; }
.sources ul { list-style: none; margin: 0; padding: 0; }
.sources li { font-family: var(--mono); font-size: 11.5px; margin: 2px 0; }
.status-note { margin-top: 12px; font-size: 12px; color: var(--g1); text-transform: lowercase; }

/* ---------- composer ---------- */
.composer {
  grid-area: composer; position: sticky; bottom: 0; background: var(--bg);
  display: flex; align-items: flex-end; gap: 12px;
  max-width: calc(var(--measure) + 80px); width: 100%; margin: 0 auto; padding: 14px 40px 10px;
}
.composer { flex-wrap: wrap; }
.sugg { flex: 0 0 100%; order: -1; border: 1px solid var(--rule); border-radius: 14px; padding: 12px 14px 14px; margin-bottom: 4px;
  max-height: 42vh; overflow-y: auto; background: var(--bg); animation: rise .25s ease both; }
.sugg[hidden] { display: none; }
.sugg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.sugg-title { margin: 0; font-size: 11px; letter-spacing: .06em; color: var(--g1); }
.sugg-head .link { background: none; border: 0; padding: 0; font-size: 12px; color: var(--g1); text-decoration: underline; text-underline-offset: 3px; border-radius: 0; }
.sugg-head .link:hover { color: var(--fg); }
.sugg .chips button { background: none; color: var(--g1); border: 1px solid var(--rule); font-weight: 400; padding: 6px 14px; font-size: 13px; }
.sugg .chips button:hover { color: var(--fg); border-color: var(--fg); }
.composer textarea {
  flex: 1; resize: none; border: 0; border-bottom: 1px solid var(--fg); background: transparent; color: var(--fg);
  font: 400 16px/1.5 var(--sans); padding: 10px 0; max-height: 180px; outline: none;
}
.composer textarea:focus-visible { outline: none; border-bottom-width: 2px; padding-bottom: 9px; }
.composer button {
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg); border-radius: 999px;
  padding: 8px 18px; font-size: 13px; font-weight: 500;
}
.composer button:disabled { opacity: .35; cursor: default; }
.foot { grid-area: foot; text-align: center; font-size: 11.5px; color: var(--g1); padding: 6px 40px 22px; letter-spacing: .01em; }

/* ---------- sign in ---------- */
.signin { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 20; }
.signin-card { width: min(380px, 100% - 32px); display: flex; flex-direction: column; }
.signin h2 { font-size: 28px; font-weight: 300; letter-spacing: -0.03em; margin: 0 0 24px; }
.signin label { font-size: 11px; letter-spacing: .08em; color: var(--g1); margin-bottom: 6px; }
.signin input { border: 0; border-bottom: 1px solid var(--fg); background: transparent; color: var(--fg); font: 400 15px var(--mono); padding: 8px 0; outline: none; }
.signin button { margin-top: 18px; align-self: flex-start; background: var(--fg); color: var(--bg); border: 0; border-radius: 999px; padding: 9px 22px; font-size: 13px; font-weight: 500; }
.err { min-height: 18px; font-size: 12px; color: var(--fg); margin: 8px 0 0; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: .35; } to { opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "top" "rail" "main" "composer" "foot"; }
  .top { padding: 16px; flex-wrap: wrap; }
  .wordmark { font-size: 21px; }
  .meta { gap: 8px; flex-wrap: wrap; }
  .who { max-width: 160px; }
  .rail { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); padding: 10px 0; overflow-x: auto; }
  .rail-title { display: none; }
  .rail ol { display: flex; gap: 2px; padding: 0 8px; }
  .rail button { white-space: nowrap; padding: 6px 10px; border-left: 0; border-bottom: 1px solid transparent; margin: 0; }
  .rail button:hover, .rail button[aria-current="true"] { border-bottom-color: var(--fg); }
  .conv { padding: 28px 16px 16px; }
  .lede { font-size: 27px; margin-top: 2vh; }
  .q { font-size: 18px; }
  .composer { padding: 10px 16px 8px; }
  .chips button { border-radius: 14px; }
  .foot { padding: 4px 16px 16px; }
}

/* ---------- login ---------- */
.login-body { min-height: 100vh; }
.login { min-height: 100vh; display: flex; flex-direction: column; padding: 26px 40px 22px; max-width: 1200px; margin: 0 auto; }
.login .wordmark { margin: 0; }
.login-card { width: min(400px, 100%); margin: 12vh auto 40px; display: flex; flex-direction: column; }
.login-card h1 { font-size: 34px; font-weight: 300; letter-spacing: -0.03em; line-height: 1.15; margin: 0 0 8px; }
.login-sub { color: var(--g1); margin: 0 0 34px; }
.login-card label { font-size: 11px; letter-spacing: .08em; color: var(--g1); margin: 0 0 6px; display: block; }
.login-card input {
  width: 100%; border: 0; border-bottom: 1px solid var(--fg); border-radius: 0; background: transparent; color: var(--fg);
  font: 400 16px var(--sans); padding: 9px 0; outline: none;
}
.login-card input:focus-visible { border-bottom-width: 2px; padding-bottom: 8px; }
.login-card .pin-input { font: 400 26px/1.2 var(--mono); letter-spacing: .32em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: 999px;
  padding: 11px 22px; font-size: 13.5px; font-weight: 500; text-decoration: none; cursor: pointer; width: 100%;
  border: 1px solid var(--fg); transition: background .15s, color .15s, opacity .15s;
}
.btn-solid { background: var(--fg); color: var(--bg); margin-top: 18px; }
.btn-line { background: transparent; color: var(--fg); }
.login-card .btn-primary-signin { margin-top: 28px; }
.btn-line:hover { background: var(--fg); color: var(--bg); }
.btn:disabled, .btn.disabled { opacity: .35; cursor: not-allowed; }
.btn.disabled:hover { background: transparent; color: var(--fg); }
.g-mark { font-family: var(--mono); font-size: 12px; width: 18px; height: 18px; border: 1px solid currentColor; border-radius: 50%; display: inline-grid; place-items: center; line-height: 1; }
.note { font-size: 12px; color: var(--g1); margin: 8px 0 0; }
.or { display: flex; align-items: center; gap: 14px; color: var(--g1); font-size: 11px; letter-spacing: .08em; margin: 26px 0 22px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.sent { margin: 0 0 22px; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.row { display: flex; align-items: center; gap: 18px; }
.row .btn { width: auto; flex: 0 0 auto; }
.link { background: none; border: 0; padding: 0; margin-top: 18px; font-size: 13px; color: var(--g1); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--fg); }
.token-box { margin-top: 30px; font-size: 13px; color: var(--g1); }
.token-box summary { cursor: pointer; }
.token-box form { margin-top: 14px; }
.token-box .btn { margin-top: 14px; }
.login-foot { margin-top: auto; text-align: center; font-size: 11.5px; color: var(--g1); }
.signout { background: none; border: 0; padding: 0; font-size: 12px; color: var(--g1); text-decoration: underline; text-underline-offset: 3px; }
.signout:hover { color: var(--fg); }
.adminlink { font-size: 12px; color: var(--g1); text-underline-offset: 3px; }
@media (max-width: 900px) {
  .login { padding: 16px; }
  .login-card { margin-top: 8vh; }
  .login-card h1 { font-size: 28px; }
}

/* ---------- intruder screen (login) ---------- */
.logged-note { display: block; margin-top: 4px; }
.intr { width: min(700px, 100%); margin: 9vh auto 56px; outline: none; animation: rise .5s ease both; }
.intr-lede { font-size: 34px; font-weight: 300; letter-spacing: -0.03em; line-height: 1.2; margin: 0 0 22px; }
.intr-lede a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.intr-lede a:hover { text-decoration-thickness: 2px; }
.intr-body { color: var(--g1); font-size: 15.5px; line-height: 1.7; max-width: 610px; margin: 0 0 44px; }
.dossier { border: 1px solid var(--fg); }
.dossier-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; background: var(--fg); color: var(--bg);
  padding: 11px 18px; font-size: 12px; letter-spacing: .06em; }
.dossier-head .mono { font-size: 11.5px; letter-spacing: 0; white-space: nowrap; }
.dossier-rows { margin: 0; padding: 4px 18px; }
.drow { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.drow:last-child { border-bottom: 0; }
.drow dt { font-size: 12px; letter-spacing: .04em; color: var(--g1); padding-top: 1px; }
.drow dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.drow.quiet dd { color: var(--g2); }
.dossier-foot { margin: 0; padding: 12px 18px; border-top: 1px solid var(--fg); font-size: 12px; color: var(--g1); }
.intr-signoff { font-size: 46px; font-weight: 500; letter-spacing: -0.045em; line-height: 1.05; margin: 52px 0 10px; }
.intr-back { margin-top: 26px; }
.intruding .login-foot { margin-top: 24px; }
@media (max-width: 900px) {
  .intr { margin-top: 5vh; }
  .intr-lede { font-size: 25px; }
  .intr-body { font-size: 15px; margin-bottom: 32px; }
  .dossier-head { flex-direction: column; gap: 2px; padding: 10px 14px; }
  .dossier-rows { padding: 2px 14px; }
  .dossier-foot { padding: 11px 14px; }
  .drow { grid-template-columns: 1fr; gap: 1px; padding: 8px 0; }
  .intr-signoff { font-size: 33px; margin-top: 40px; }
}

/* ---------- question history (right drawer) ---------- */
:root { --scrim: rgba(0, 0, 0, .16); }
:root[data-theme="dark"] { --scrim: rgba(0, 0, 0, .62); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --scrim: rgba(0, 0, 0, .62); } }
.ghost[aria-expanded="true"] { color: var(--bg); background: var(--fg); border-color: var(--fg); }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 29; opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s; }
.scrim.open { opacity: 1; visibility: visible; transition: opacity .25s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--bg); border-left: 1px solid var(--fg);
  z-index: 30; display: flex; flex-direction: column; transform: translateX(102%); visibility: hidden;
  transition: transform .3s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .3s; }
.drawer.open { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 26px 26px 4px; }
.drawer-head h2 { font-size: 26px; font-weight: 300; letter-spacing: -0.03em; margin: 0; }
.drawer-sub { margin: 0; padding: 0 26px 16px; font-size: 12.5px; color: var(--g1); }
.drawer-search { padding: 0 26px 6px; }
.drawer-search input { width: 100%; border: 0; border-bottom: 1px solid var(--fg); border-radius: 0; background: transparent; color: var(--fg);
  font: 400 14.5px var(--sans); padding: 9px 0; outline: none; -webkit-appearance: none; appearance: none; }
.drawer-search input:focus-visible { border-bottom-width: 2px; padding-bottom: 8px; }
.drawer-count { font: 400 11px var(--mono); color: var(--g1); padding: 8px 26px 0; margin: 0; }
.drawer-list { overflow-y: auto; flex: 1; padding: 0 26px 30px; overscroll-behavior: contain; }
.hday { font-size: 11px; letter-spacing: .08em; color: var(--g1); margin: 0; padding: 18px 0 6px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.hlist { list-style: none; margin: 0; padding: 0; }
.hitem > button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 11px 0 12px; border-top: 1px solid var(--rule); cursor: pointer; }
.hitem > button:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
.hitem .hq { display: block; font-size: 14.5px; font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: -0.01em; }
.hitem > button:hover .hq { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.hitem .hs { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; color: var(--g1);
  margin-top: 4px; text-transform: none; line-height: 1.5; }
.hitem .hm { display: flex; flex-wrap: wrap; gap: 4px 12px; font: 400 10.5px var(--mono); color: var(--g1); margin-top: 6px; }
.hitem .hm .on { color: var(--fg); }
.hempty { color: var(--g1); font-size: 13.5px; padding: 26px 0; }
.turn.from-history .hist-tag { display: flex; justify-content: space-between; gap: 12px; font: 400 11px var(--mono); color: var(--g1); margin: 0 0 8px; }
.turn.flash { animation: flash 1.4s ease both; }
@keyframes flash { 0% { background: var(--soft); } 100% { background: transparent; } }
body.drawer-open { overflow: hidden; }
@media (max-width: 900px) {
  .drawer { border-left: 0; }
  .drawer-head { padding: 18px 16px 2px; }
  .drawer-sub, .drawer-search, .drawer-count { padding-left: 16px; padding-right: 16px; }
  .drawer-list { padding: 0 16px 24px; }
}

/* legal links in footers */
.login-foot a, .foot a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--g2); }
.login-foot a:hover, .foot a:hover { color: var(--fg); text-decoration-color: var(--fg); }
