@import url('/fonts/fonts.css');

/*
 * aischool design tokens.
 * Paddy green is the brand; marigold marks anything waiting on a person (unverified, pending);
 * red is only for errors. One family (Hind Siliguri) so English and Bangla sit on the same baseline.
 */
:root {
  --paper: #f2f5f3;
  --panel: #ffffff;
  --sunk: #e9efeb;
  --ink: #11241c;
  --muted: #5a6b63;
  --line: #d9e2dd;
  --brand: #006a4e;
  --brand-hover: #005640;
  --brand-deep: #0b3b2c;
  --brand-soft: #e2efe9;
  --brand-ink: #ffffff;
  --marigold: #d9930d;
  --marigold-ink: #7a4f00;
  --marigold-soft: #fbf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --info: #1f5f8b;
  --info-soft: #e5eff6;
  --font: 'Hind Siliguri', system-ui, -apple-system, 'Segoe UI', 'Noto Sans Bengali', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(17, 36, 28, .06), 0 8px 24px rgba(17, 36, 28, .06);
  /* legacy names still used inline by the console */
  --bg: var(--paper);
  --warn: var(--marigold-ink);
  --warn-soft: var(--marigold-soft);
  --radius: var(--r-md);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.55 var(--font); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); text-underline-offset: 2px; }
strong, b { font-weight: 600; }
::selection { background: var(--brand-soft); }

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: .5rem .95rem; border-radius: var(--r-sm); cursor: pointer; font-weight: 500;
  transition: background-color .12s, border-color .12s, color .12s; }
button:hover { border-color: #b9c8c0; background: #fafcfb; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--sunk); color: var(--ink); }
button:disabled { opacity: .5; cursor: progress; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

input, select, textarea { border: 1px solid var(--line); border-radius: var(--r-sm); padding: .55rem .7rem; background: var(--panel); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { font-family: var(--mono); font-size: 13px; min-height: 260px; }
label { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin: .7rem 0 .3rem; }
pre, code { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--brand-deep); color: #d6ebe2; padding: .75rem .9rem; border-radius: var(--r-sm); overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: .4rem 0; line-height: 1.5; }

.topbar { display: flex; align-items: center; gap: 1rem; height: 56px; padding: 0 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; }
.brand span { color: var(--brand); }
.brand small { margin-left: .45rem; font-weight: 500; font-size: .9rem; color: var(--muted); letter-spacing: 0; }
.spacer { flex: 1; }

.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--info-soft); color: var(--info); white-space: nowrap; }
.badge.ok { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--marigold-soft); color: var(--marigold-ink); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hidden { display: none !important; }
.error { color: var(--bad); font-size: 14px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13.5px; color: var(--muted); font-weight: 600; background: #f7faf8; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--r-sm); }

/* ---------- sign in (chat app and console) ---------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) 6fr; }
.signin .story { background: var(--brand-deep); color: #e5f1ec; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.signin .story .brand span { color: #7fd1ae; }
.signin .story h1 { font-size: clamp(2rem, 3.4vw, 2.9rem); line-height: 1.12; font-weight: 600; letter-spacing: -.02em; max-width: 13ch; margin: 0 0 1rem; }
.signin .story .bn { font-size: 1.35rem; color: #a9d6c2; margin: 0 0 1.6rem; }
.signin .story p { color: #b9d3c8; max-width: 38ch; }
.signin .story .fine { font-size: 14px; color: #8fb3a4; margin: 0; }
.signin .form { display: grid; place-items: center; padding: 2rem; }
.signin form { width: min(380px, 100%); }
.signin form h2 { font-size: 1.6rem; margin-bottom: .25rem; }
.signin form button.primary { width: 100%; margin-top: 1.2rem; padding: .7rem; font-size: 1rem; }
@media (max-width: 760px) { .signin { grid-template-columns: 1fr; } .signin .story { padding: 2rem 1.25rem; } .signin .story h1 { font-size: 1.9rem; } }

/* ---------- console ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 56px); }
.nav { background: var(--panel); border-right: 1px solid var(--line); padding: 1rem .7rem; }
.nav button { display: flex; width: 100%; text-align: left; border: 0; background: transparent; padding: .5rem .7rem; margin-bottom: 2px; border-radius: var(--r-sm); gap: .65rem; align-items: center; font-weight: 500; color: var(--muted); }
.nav button:hover { background: var(--sunk); color: var(--ink); }
.nav button .n { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 600; background: var(--sunk); color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.nav button.active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }
.nav button.active .n { background: var(--brand); color: #fff; }
.nav button.done .n { background: var(--brand-soft); color: var(--brand); }
main { padding: 1.75rem 2rem 3rem; max-width: 1200px; }
main section > h2:first-child, main section > .row:first-child h2 { font-size: 1.6rem; }
main section > p.muted { max-width: 75ch; }
.graph-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; }
#graph { height: 620px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); }
.side { max-height: 620px; overflow: auto; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 60px; margin: .4rem 0; }
.bars div { flex: 1; background: var(--brand); opacity: .75; min-height: 1px; border-radius: 2px 2px 0 0; }
.conf { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; }
.conf > div { height: 100%; background: var(--brand); }

/* ---------- chat app ---------- */
.chat-layout { display: grid; grid-template-columns: 272px 1fr; height: 100vh; height: 100dvh; }
.rail { background: var(--brand-deep); color: #d5e8df; display: flex; flex-direction: column; min-height: 0; }
.rail .brand { padding: 1.1rem 1.2rem .8rem; color: #fff; }
.rail .brand span { color: #7fd1ae; }
.rail .new { margin: .2rem .9rem .8rem; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); color: #fff; text-align: left; padding: .6rem .8rem; }
.rail .new:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.24); }
.rail .list { flex: 1; overflow-y: auto; padding: 0 .6rem 1rem; }
.rail .when { font-size: 13px; color: #86ab9b; padding: .9rem .6rem .25rem; font-weight: 500; }
.rail .item { display: flex; align-items: center; border-radius: var(--r-sm); }
.rail .item .open { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; color: #d5e8df; padding: .45rem .6rem; font-weight: 400; font-size: 15px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rail .item:hover { background: rgba(255,255,255,.07); }
.rail .item.active { background: rgba(127,209,174,.16); }
.rail .item.active .open { color: #fff; }
.rail .item .del { visibility: hidden; border: 0; background: transparent; color: #86ab9b; padding: .2rem .55rem; }
.rail .item:hover .del, .rail .item .del:focus-visible { visibility: visible; }
.rail .item .del:hover { color: #fff; }
.rail .empty-list { color: #86ab9b; font-size: 14px; padding: .6rem; }
.rail .me { border-top: 1px solid rgba(255,255,255,.1); padding: .9rem 1.1rem; display: flex; align-items: center; gap: .7rem; }
.rail .me .avatar { width: 34px; height: 34px; border-radius: 50%; background: #7fd1ae; color: var(--brand-deep); display: grid; place-items: center; font-weight: 700; flex: none; }
.rail .me .who { flex: 1; min-width: 0; line-height: 1.3; }
.rail .me .who b { display: block; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .me .who span { font-size: 13.5px; color: #9cc0b1; }
.rail .me button { border: 0; background: transparent; color: #9cc0b1; padding: .3rem .5rem; font-size: 14px; }
.rail .me button:hover { color: #fff; background: rgba(255,255,255,.08); }

.mobilebar, .scrim { display: none; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 2rem 1.5rem 1rem; }
.thread { max-width: 760px; margin: 0 auto; }
.msg { margin-bottom: 1.6rem; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: 80%; background: var(--sunk); padding: .55rem 1rem; border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg); white-space: pre-wrap; }
.msg.assistant .bubble { padding: .1rem 0 .1rem 1.1rem; border-left: 3px solid var(--line); }
.msg.assistant.checked .bubble { border-left-color: var(--brand); }
.msg.assistant.unchecked .bubble { border-left-color: var(--marigold); }
.msg.assistant .bubble p { max-width: 70ch; }
.msg.assistant .bubble ul, .msg.assistant .bubble ol { margin: .2rem 0 .8rem; padding-left: 1.3rem; }
.msg.assistant .bubble li { margin: .15rem 0; }
.msg.assistant .bubble h4 { font-size: 1.05rem; margin: 1rem 0 .3rem; }
.msg.assistant .table-wrap { border: 1px solid var(--line); margin: .5rem 0 .9rem; background: var(--panel); }
.msg.assistant .bubble code { background: var(--sunk); padding: .05rem .3rem; border-radius: 4px; }
.thinking { color: var(--muted); display: flex; align-items: center; gap: .6rem; }

/* the provenance line under every answer: what it was checked against */
.proof { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; margin-top: .7rem; font-size: 14px; color: var(--muted); }
.proof .seal { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; color: var(--brand); }
.proof .seal.no { color: var(--marigold-ink); }
.proof details { margin: 0; }
.proof details[open] { flex-basis: 100%; }
.proof summary { cursor: pointer; color: var(--muted); list-style: none; }
.proof summary::-webkit-details-marker { display: none; }
.proof summary:hover { color: var(--ink); text-decoration: underline; }
.proof .rate { display: inline-flex; gap: .1rem; margin-left: auto; }
.proof .rate button { border: 0; background: transparent; padding: .15rem .45rem; color: var(--muted); font-size: 14px; }
.proof .rate button:hover { background: var(--sunk); color: var(--ink); }
.trace { margin-top: .5rem; }
.trace .label { font-size: 13.5px; color: var(--muted); margin-top: .4rem; }
.viz { position: relative; height: 300px; margin: .8rem 0 .2rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: .8rem; }
.downloads { display: flex; gap: .4rem; align-items: center; margin-top: .6rem; font-size: 14px; color: var(--muted); }
.downloads button { padding: .2rem .7rem; font-size: 14px; }

.welcome { max-width: 760px; margin: 8vh auto 0; }
.welcome h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); margin-bottom: .3rem; }
.welcome > p { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }
.ideas { margin-top: 1.6rem; border-top: 1px solid var(--line); }
.ideas button { display: flex; width: 100%; justify-content: space-between; gap: 1rem; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: .85rem .2rem; font-weight: 400; font-size: 1.02rem; }
.ideas button:hover { background: transparent; color: var(--brand); }
.ideas button span { color: var(--muted); font-size: 14px; white-space: nowrap; }

.composer-wrap { padding: .6rem 1.5rem 1.2rem; }
.composer { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: .5rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: .45rem .45rem .45rem 1rem; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--brand); }
.composer textarea { flex: 1; border: 0; box-shadow: none; padding: .45rem 0; min-height: 0; max-height: 180px; resize: none; font: inherit; background: transparent; }
.composer textarea:focus { box-shadow: none; }
.composer button { border-radius: 12px; padding: .5rem 1.1rem; }
.composer-note { max-width: 760px; margin: .5rem auto 0; font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav button { width: auto; white-space: nowrap; }
  .graph-wrap, .grid2 { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .chat-layout { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 20; transform: translateX(-100%); transition: transform .2s ease; }
  .chat-layout.menu-open .rail { transform: none; }
  .chat-layout.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(11, 59, 44, .35); z-index: 15; }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 .5rem; border-bottom: 1px solid var(--line); background: var(--panel); }
  .messages { padding: 1.2rem 1rem .5rem; }
  .composer-wrap { padding: .5rem .75rem .9rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0s !important; } .spinner { animation: spin 1.6s linear infinite !important; } }
