@import url("./fonts.css");
/* ISQ design system. Brand fonts are bundled locally; no CDN dependencies. */

:root {
  color-scheme: light dark;

  /* light */
  --bg: #f7f7f8;
  --bg-elev: #ffffff;
  --bg-sunken: #f0f0f2;
  --bg-hover: #ececed;
  --border: #e3e3e6;
  --border-strong: #d1d1d6;
  --text: #18181b;
  --text-muted: #6b6b76;
  --text-faint: #9a9aa4;
  --accent: #2f5fe0;
  --accent-hover: #2450c9;
  --accent-soft: #eaf0ff;
  --accent-text: #ffffff;

  /* risk bands — sequential, single hue family so a higher score reads as
     "further along" rather than "different category" */
  --risk-low: #1f9d63;
  --risk-mid: #c9922b;
  --risk-high: #d1543f;
  --risk-low-soft: #e8f6ef;
  --risk-mid-soft: #fdf4e3;
  --risk-high-soft: #fbecea;

  --warn-bg: #fdf6e3;
  --warn-border: #ecd9a4;
  --warn-text: #7a5a12;
  --err: #c0392b;

  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 18, 27, .06), 0 1px 3px rgba(16, 18, 27, .04);
  --shadow-md: 0 4px 16px rgba(16, 18, 27, .08), 0 1px 3px rgba(16, 18, 27, .04);
  --shadow-lg: 0 12px 40px rgba(16, 18, 27, .12);

  --font: "Titillium Web", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas,
          "SF Mono", Menlo, monospace;

  --measure: 780px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --bg-elev: #17171b;
    --bg-sunken: #121216;
    --bg-hover: #1f1f25;
    --border: #26262d;
    --border-strong: #35353f;
    --text: #f2f2f4;
    --text-muted: #9d9daa;
    --text-faint: #6e6e7c;
    --accent: #6d92f5;
    --accent-hover: #85a4f8;
    --accent-soft: #1a2340;
    --accent-text: #0e0e11;

    --risk-low: #3fbd82;
    --risk-mid: #e0ad4a;
    --risk-high: #ec6f58;
    --risk-low-soft: #10241b;
    --risk-mid-soft: #241d0e;
    --risk-high-soft: #2a1512;

    --warn-bg: #241d0e;
    --warn-border: #4a3c18;
    --warn-text: #e0c780;
    --err: #f06a5a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hide { display: none !important; }

/* ---------- header ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -.01em;
  font-size: 14.5px;
}

.brand .mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.topbar .spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  font-family: var(--mono);
  white-space: nowrap;
}

.chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--risk-low);
}

.chip.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.chip.warn .dot { background: var(--warn-text); }

.topbar a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  padding: 6px 10px;
  border-radius: var(--radius);
  transition: background .15s var(--ease), color .15s var(--ease);
}

.topbar a:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- layout ---------- */

/* The chat page has exactly ONE scroll container: .stream.
 *
 * min-height here instead of height lets .shell grow past the viewport, at
 * which point .stream has no bounded height, cannot scroll, and the BODY
 * scrolls instead — so the sticky composer drifts up the page and the header
 * overlaps content. body.app kills the outer scroller; min-height:0 on the
 * flex child is what actually lets the inner one work. */
body.app { overflow: hidden; }

.shell {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 56px);
  min-height: 0;
}

.stream {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 32px 20px 8px;
  overscroll-behavior: contain;
}

.col {
  max-width: var(--measure);
  margin: 0 auto;
}

/* ---------- empty state ---------- */

.hero {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 8vh 0 24px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -.025em;
}

.hero p {
  margin: 0 auto;
  max-width: 54ch;
  color: var(--text-muted);
  font-size: 15px;
}

.hero .sep {
  width: 40px;
  height: 1px;
  margin: 26px auto;
  background: var(--border-strong);
}

.cues {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.cue {
  padding: 7px 13px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s var(--ease);
}

.cue:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ---------- messages ---------- */

.msg { margin-bottom: 26px; }

.msg .who {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.msg.user .body {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.model .body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.system .body {
  color: var(--text-muted);
  font-size: 13.5px;
  border-left: 2px solid var(--border-strong);
  padding-left: 12px;
}

/* ---------- assessment card ---------- */

.assess {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.assess-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.assess-score {
  font-size: 44px;
  line-height: 1;
  font-weight: 650;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.assess-of {
  font-size: 15px;
  color: var(--text-faint);
  font-weight: 400;
  letter-spacing: 0;
}

.assess-meta { flex: 1; }

.assess-band {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.band-low { background: var(--risk-low-soft); color: var(--risk-low); }
.band-mid { background: var(--risk-mid-soft); color: var(--risk-mid); }
.band-high { background: var(--risk-high-soft); color: var(--risk-high); }

.assess-sub {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.assess-body { padding: 18px 22px; }

.assess-body .summary { margin: 0 0 4px; }

/* factor rows */

.factors { margin-top: 18px; }

.factor {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.factor:first-child { border-top: none; }

.factor .fname {
  font-weight: 550;
  font-size: 14px;
}

.factor .fid {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-right: 7px;
}

.factor .fscore {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.factor .fwt {
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 400;
  font-family: var(--mono);
}

.factor .frat {
  grid-column: 1 / -1;
  font-size: 13.5px;
  color: var(--text-muted);
}

.factor .refs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.ref {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.meter {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 2px;
  background: var(--bg-sunken);
  overflow: hidden;
  margin-top: 2px;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width .5s var(--ease);
}

/* ---------- verdict pill ---------- */

.verdict {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 550;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-muted);
}

.verdict.evidence { background: var(--risk-low-soft); border-color: transparent; color: var(--risk-low); }
.verdict.blocked { background: var(--bg-sunken); color: var(--text-muted); }
.verdict.violation { background: var(--risk-high-soft); border-color: transparent; color: var(--risk-high); }

/* ---------- details / disclosure ---------- */

details.disclose {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

details.disclose > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

details.disclose > summary::-webkit-details-marker { display: none; }

details.disclose > summary::before {
  content: "›";
  display: inline-block;
  transition: transform .2s var(--ease);
  font-size: 15px;
}

details.disclose[open] > summary::before { transform: rotate(90deg); }

details.disclose > summary:hover { color: var(--text); }

.trail {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.trail li {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px dashed var(--border);
  color: var(--text-muted);
}

.trail li:first-child { border-top: none; }

.trail .actor {
  font-family: var(--mono);
  font-size: 11px;
  min-width: 52px;
  color: var(--text-faint);
}

.trail .move {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  min-width: 76px;
}

/* ---------- composer ---------- */

.composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 12px 20px 20px;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}

.composer {
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  padding: 14px 16px 4px;
  font: inherit;
  color: var(--text);
  max-height: 260px;
  overflow-y: auto;
}

.composer textarea:focus { outline: none; }

.composer textarea::placeholder { color: var(--text-faint); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px 12px;
}

.composer-bar .grow { flex: 1; }

.hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* attachment chips */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 12px 0;
}

.att {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: 12.5px;
}

.att .kind {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
}

.att .fn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att .sz { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; }

.att.pending { opacity: .6; }

.att.bad { border-color: var(--warn-border); background: var(--warn-bg); }

.att .x {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}

.att .x:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- buttons ---------- */

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all .15s var(--ease);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 550;
  font-size: 14px;
}

.btn:hover:not(:disabled) { background: var(--accent-hover); }

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) { background: var(--bg-hover); }

.btn.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 7px 10px;
}

.btn.quiet:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn.icon {
  padding: 8px;
  width: 34px;
  height: 34px;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn.icon:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn.send {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-text);
}

.btn.send:disabled { background: var(--bg-sunken); color: var(--text-faint); }

/* ---------- notices ---------- */

.notice {
  max-width: var(--measure);
  margin: 0 auto 20px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 13px;
}

.notice code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, .06);
  padding: 1px 4px;
  border-radius: 4px;
}

.err { color: var(--err); font-size: 13.5px; }

.muted { color: var(--text-muted); }

/* ---------- team score panel ---------- */

.team {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.team h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.team p { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }

.team-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.team input[type="number"] {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.team input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
}

.team input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.delta {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.delta .pair { display: flex; flex-direction: column; gap: 2px; }

.delta .pair .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
}

.delta .pair .v {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- thinking indicator ---------- */

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.thinking .pulse {
  display: flex;
  gap: 3px;
}

.thinking .pulse i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.2s infinite ease-in-out;
}

.thinking .pulse i:nth-child(2) { animation-delay: .15s; }
.thinking .pulse i:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.msg, .assess { animation: rise .35s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- review page ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 32px 20px 60px; }

.page h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 4px;
}

.page > p.muted { margin: 0 0 24px; font-size: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.stat {
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
}

.stat .v {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}

table.grid th {
  text-align: left;
  padding: 11px 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  font-weight: 600;
  white-space: nowrap;
}

table.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.grid tr:last-child td { border-bottom: none; }

table.grid tbody tr:hover { background: var(--bg-hover); }

table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }

table.grid .mono { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.tag.bad { background: var(--risk-high-soft); color: var(--risk-high); border-color: transparent; }

@media (max-width: 620px) {
  .hero { padding-top: 6vh; }
  .hero h1 { font-size: 24px; }
  .assess-score { font-size: 36px; }
  .stream { padding: 20px 14px 8px; }
  .composer-wrap { padding: 10px 14px 14px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .chip { display: none; }
}
