/* Sales Order site. Colours, type and table styles follow the Bible (cf-bible site/shared/bible.css); copied from the accepted mock-up.
   Fraunces / IBM Plex fall back to Georgia / system-ui here so the file stays self-contained. */
:root {
  --bg: #eef1ec; --surface: #fbfcfa; --surface-2: #e3e8e0; --surface-3: #d8dfd4; --line: #d2d9ce; --line-soft: #e6eae3;
  --fg: #17221b; --muted: #5b685e; --faint: #849086;
  --accent: #1a4d2e; --accent-hover: #24613b; --accent-soft: #dce8db; --on-accent: #fbfcfa;
  --ribbon: #b8692f; --ribbon-soft: #f4e4d6;
  --good: #2f7a45; --good-soft: #dcefe0; --warn: #9a640f; --warn-soft: #f6ead2; --bad: #b4432a; --bad-soft: #f7e1db;
  --row-hover: #f1f4ef; --row-sel: #e2ecdf; --row-alt: #f6f8f4;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 10px 30px rgba(18, 33, 24, .16);
  --scrim: rgba(10, 20, 14, .32); --foot-shadow: 0 -6px 18px rgba(0, 0, 0, .06);
  /* GLaDOS's eye: the same red on every site and theme (her mark, not a page colour) */
  --eye: #e0533a; --eye-hi: #ffd6c9; --eye-lo: #5a1408; --eye-glow: rgba(224, 83, 58, .55);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111814; --surface: #171f1a; --surface-2: #1e2822; --surface-3: #26322b; --line: #2c3931; --line-soft: #222d26;
  --fg: #e4ebe3; --muted: #9aa89d; --faint: #6f7c72;
  --accent: #6fae80; --accent-hover: #82c093; --accent-soft: #233328; --on-accent: #0f1712;
  --ribbon: #d99257; --ribbon-soft: #3a2a1d;
  --good: #6cc488; --good-soft: #1d3324; --warn: #e0a84a; --warn-soft: #3a2f1a; --bad: #ec8670; --bad-soft: #3d221c;
  --row-hover: #1c2620; --row-sel: #24352a; --row-alt: #19221c;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .55); --foot-shadow: 0 -6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #111814; --surface: #171f1a; --surface-2: #1e2822; --surface-3: #26322b; --line: #2c3931; --line-soft: #222d26;
  --fg: #e4ebe3; --muted: #9aa89d; --faint: #6f7c72;
  --accent: #6fae80; --accent-hover: #82c093; --accent-soft: #233328; --on-accent: #0f1712;
  --ribbon: #d99257; --ribbon-soft: #3a2a1d;
  --good: #6cc488; --good-soft: #1d3324; --warn: #e0a84a; --warn-soft: #3a2f1a; --bad: #ec8670; --bad-soft: #3d221c;
  --row-hover: #1c2620; --row-sel: #24352a; --row-alt: #19221c;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .55); --foot-shadow: 0 -6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 13px; line-height: 1.45;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
.quiet { color: var(--muted); }
.small { font-size: 12px; }

.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; cursor: pointer; white-space: nowrap; line-height: 1.4; }
.btn:hover:not(:disabled) { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkish.danger { color: var(--bad); }
.pill { display: inline-block; padding: 0 6px; line-height: 17px; border-radius: 4px; font-size: 11.5px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.rib { background: var(--ribbon-soft); color: var(--ribbon); }

/* ── header ── */
.top { display: flex; align-items: center; gap: 6px 16px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 15; }
.wordmark { font-family: var(--display); font-weight: 600; font-size: 21px; letter-spacing: -.01em; position: relative; padding-right: 14px; color: var(--accent); }
.wordmark::after { content: ""; position: absolute; right: 2px; top: -8px; width: 6px; height: 21px; background: var(--ribbon); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); }
.badge { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--line); border-radius: 12px; padding: 1px 10px; font-size: 12px; font-weight: 500; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 3px 11px; cursor: pointer; border-right: 1px solid var(--line); font-size: 12.5px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; color: var(--accent); }
.chip-av { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-grid; place-items: center; font-weight: 600; font-size: 11px; }

/* ── page ── */
main { padding: 12px 16px calc(var(--foot-h, 50px) + 40px); max-width: 1600px; margin: 0 auto; }
h1.t { font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.25; margin: 0; overflow-wrap: anywhere; }
h2.t { font-family: var(--display); font-weight: 600; font-size: 17px; margin: 0 0 8px; }
h3.s { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--accent); }
.row { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.lf { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); font-weight: 600; min-width: 0; }
.lf > input, .lf > select, .lf > textarea, .lf .ctl { padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font: inherit; font-size: 13px; font-weight: 400; color: var(--fg); min-width: 0; width: 100%; }
.lf.ro .ctl { background: var(--bg); color: var(--muted); }
input.bad, select.bad, textarea.bad { border-color: var(--bad) !important; box-shadow: inset 3px 0 0 var(--bad); }
.changed > input, .changed > select, .changed > textarea, input.changed, textarea.changed, select.changed { border-color: var(--ribbon) !important; box-shadow: inset 3px 0 0 var(--ribbon); }
.check { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; white-space: nowrap; background: var(--surface); font-size: 12.5px; }
.check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.check input { margin: 0; accent-color: var(--accent); }
.check.changed { border-color: var(--ribbon); box-shadow: inset 3px 0 0 var(--ribbon); }
.err { color: var(--bad); font-size: 12.5px; }
.err:empty { display: none; }
.msgline { background: var(--bad-soft); color: var(--bad); border-radius: 6px; padding: 6px 10px; margin: 6px 0; font-size: 12.5px; }
.msgline:empty { display: none; }
.note-ro { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 6px 10px; margin: 0 0 8px; }

/* ── tables ── */
.scroll { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.scroll.tall { max-height: min(62vh, 720px); }
.scroll.mid { max-height: 340px; }
table.tb { border-collapse: collapse; font-size: 12.5px; width: 100%; }
table.tb.w { width: max-content; min-width: 100%; }
.tb th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 11px; font-weight: 600; text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tb td { padding: 4px 6px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
.tb .num, .tb th.num { text-align: right; }
.tb .c, .tb th.c { text-align: center; }
.tb tbody tr.click { cursor: pointer; }
.tb tbody tr.click:hover td { background: var(--row-hover); }
.tb tbody tr.sel td { background: var(--row-sel); }
.tb tbody tr.alt td { background: var(--row-alt); }
.tb .ell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tb td.mk { width: 6px; padding: 0; }
tr.pend td.mk { box-shadow: inset 4px 0 0 var(--ribbon); }
tr.refd td.mk { box-shadow: inset 4px 0 0 var(--bad); }
tr.chk td.mk { box-shadow: inset 4px 0 0 var(--warn); }
tr.gone td { text-decoration: line-through; color: var(--faint); }
.att { color: var(--warn); font-weight: 600; background: var(--warn-soft) !important; }
.tb input, .tb select { padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font: inherit; min-width: 0; }
.tb input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.tb input.n { width: 64px; text-align: right; }
.tb input.m { width: 70px; text-align: right; }
.tb input.d { width: 52px; text-align: right; }
.tb input.msg { width: 170px; }
.tb input.desc { width: min(330px, 70vw); }
.tb tr.newline td { background: var(--row-alt); }
.tb tr.newline input.desc { border-style: dashed; }
.tb tr.focus td { background: var(--row-sel); }
#ig tbody tr[data-id]:not(.newline) { cursor: pointer; }
.dots { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 1px 6px; border-radius: 4px; }
.dots:hover { background: var(--surface-3); color: var(--fg); }
.desc-t { font-weight: 500; }
.desc-t .com { color: var(--muted); font-weight: 400; }

/* ── order window ── */
.otitle { display: flex; gap: 8px 14px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0 10px; }
.pbar { position: relative; height: 22px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.pbar i { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-right: 2px solid var(--accent); transition: width .25s; }
.pbar span { position: relative; display: block; text-align: center; line-height: 20px; font-size: 12px; font-weight: 600; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tools .sep { width: 1px; background: var(--line); margin: 2px 2px; }
.otabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.otab { padding: 6px 10px 8px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: none; white-space: nowrap; font-weight: 500; cursor: pointer; }
.otab:hover { color: var(--fg); }
.otab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.otab .dotp { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ribbon); margin-left: 5px; vertical-align: 1px; }
.banner { border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--fg); }

.totals { position: sticky; bottom: calc(var(--foot-h, 50px) + 2px); z-index: 5; margin-top: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.totals table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.totals th, .totals td { padding: 3px 12px; text-align: right; white-space: nowrap; }
.totals th { font-size: 11px; color: var(--muted); font-weight: 600; }
.totals td:first-child, .totals th:first-child { text-align: left; font-weight: 600; }
.totals tr.al td { color: var(--muted); }
.totals td.big { font-weight: 600; color: var(--accent); }

.items-l { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.side { position: sticky; top: 62px; }
.side .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 10px; }
.sidesup td, .sidesup th { white-space: normal; }
.sub2 { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.side .stat { background: var(--bg); border-radius: 6px; padding: 4px 6px; text-align: center; }
.side .stat b { display: block; font-size: 15px; }
.side .stat span { font-size: 11px; color: var(--muted); }
.gbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 6px; }
.help { font-size: 11.5px; color: var(--muted); }
.three { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .9fr); gap: 10px; align-items: start; }
.entry-l { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.loads-l { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px 12px; align-items: end; }
.fgrid .w2 { grid-column: span 2; }
.ticks { display: flex; flex-wrap: wrap; gap: 6px; }
details.more { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-bottom: 8px; }
.cat-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.cat-list li button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-soft); background: none; padding: 5px 8px; cursor: pointer; font-size: 12.5px; }
.cat-list li button:hover { background: var(--row-hover); }
.cat-list li button[aria-pressed="true"] { background: var(--row-sel); font-weight: 600; }
.cat-list .av { color: var(--muted); font-weight: 400; }
.addstrip { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: end; margin-top: 10px; }
.addstrip .lf input, .addstrip .lf select { width: auto; }
.addstrip .w-s input { width: 170px; }
.addstrip .w-c select { width: min(420px, 86vw); }
.addstrip .w-n input { width: 84px; text-align: right; }
.addstrip .w-m input { width: min(220px, 86vw); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 3px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
textarea { resize: vertical; }
.notes-l textarea { min-height: 160px; }
.contact-col h3 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.contact-col .acct { font-family: var(--display); font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.contact-col .fgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* list */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin-bottom: 10px; }
.filters .lf input[type=search] { width: min(280px, 86vw); }
.rng { display: flex; gap: 4px; align-items: center; }
.rng input { width: 84px !important; }
details.reps { position: relative; }
details.reps summary { list-style: none; cursor: pointer; padding: 5px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-weight: 400; color: var(--fg); font-size: 13px; }
details.reps summary::-webkit-details-marker { display: none; }
details.reps .pop { position: absolute; z-index: 30; top: calc(100% + 3px); left: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.pctcell { min-width: 70px; }
.mini { display: inline-block; width: 38px; height: 6px; border-radius: 3px; background: var(--surface-3); vertical-align: middle; margin-left: 6px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--accent); }

/* footer */
.foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 16; background: var(--surface); border-top: 1px solid var(--line); padding: 8px 16px; display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; box-shadow: var(--foot-shadow); }
.foot .state { color: var(--muted); font-size: 12.5px; }
.foot .state b { color: var(--ribbon); }

/* overlays */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; display: grid; place-items: start center; padding: 6vh 12px 12px; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); width: min(560px, 100%); max-width: 100%; }
.modal.wide { width: min(760px, 100%); }
.modal-h { padding: 12px 16px 8px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.modal-h h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0; }
.modal-b { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.modal-f { padding: 10px 16px 14px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line-soft); }
.x { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.dd { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; min-width: 280px; max-width: min(560px, 96vw); padding: 3px 0; }
.dd .it { padding: 5px 10px; cursor: pointer; display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }
.dd .it.hi, .dd .it:hover { background: var(--row-sel); }
.dd .it .r { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dd .empty { padding: 6px 10px; color: var(--muted); }
.menu { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px 0; min-width: 210px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 14px; cursor: pointer; }
.menu button:hover:not(:disabled), .menu button:focus { background: var(--row-sel); outline: none; }
.menu button:disabled { color: var(--faint); cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 0; }
.toast { position: fixed; left: 50%; bottom: 66px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 6px; z-index: 80; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 24px); }
.toast button { background: none; border: 0; color: var(--bg); text-decoration: underline; cursor: pointer; font-weight: 600; }
.rv { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow-y: auto; }
.rv li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 8px; border-radius: 6px; background: var(--bg); }
.rv li .tx { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.rv li .st { flex: none; font-size: 11.5px; }
.rv li .sub { display: block; color: var(--muted); font-size: 11.5px; }
.rv h4 { margin: 8px 0 2px; font-size: 12px; color: var(--accent); }
.st-wait { color: var(--muted); }
.st-send { color: var(--accent); font-weight: 600; }
.st-done { color: var(--good); font-weight: 600; }
.st-ref { color: var(--bad); font-weight: 600; }
.st-chk { color: var(--warn); font-weight: 600; }

@media (max-width: 1100px) {
  .items-l { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .three, .entry-l { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .three > :last-child, .entry-l > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .three, .entry-l, .two, .loads-l { grid-template-columns: minmax(0, 1fr); }
  .bars { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .fgrid .w2 { grid-column: auto; }
  .who { margin-left: 0; }
  .totals th, .totals td { padding: 2px 8px; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media (prefers-reduced-motion: reduce) { .pbar i { transition: none; } }

/* ── added for the real site (2026-12-01) ── */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.top-tools { gap: 6px; }
.practice { position: sticky; top: var(--top-h, 46px); z-index: 14; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); padding: 5px 16px; font-size: 12.5px; text-align: center; }
.gate { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.gate-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px 24px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }
.gate-box h1 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0 0 8px; color: var(--accent); }

/* GLaDOS: docked beside the page (the Bible's panel), floating when popped out, a bottom sheet on a phone */
:root { --chat-w: 380px; --sheet-h: 0px; }
.glados-btn { display: inline-flex; align-items: center; gap: 7px; }
.glados-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.eye { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: radial-gradient(circle at 50% 50%, var(--eye-hi) 0 18%, var(--eye) 30% 62%, var(--eye-lo) 64%); box-shadow: 0 0 5px var(--eye-glow); }
.chat.busy .chat-head .eye { animation: pulse 1.2s infinite; }
body.chat-open { padding-right: var(--chat-w); }
body.chat-open .foot { right: var(--chat-w); }
body.chat-open .toast { left: calc(50% - var(--chat-w) / 2); }
.chat { position: fixed; top: 0; right: 0; bottom: 0; width: var(--chat-w); z-index: 18; display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); }
.chat[hidden] { display: none; }
.chat-grab { display: none; }
.chat-size { display: none; }
.chat-g { position: absolute; z-index: 2; touch-action: none; }
.chat-g[data-g="w"] { top: 0; bottom: 0; left: -3px; width: 7px; cursor: ew-resize; }
.chat-g[data-g="w"]:hover, .chat-g[data-g="w"]:focus-visible, body.chat-dragging .chat-g[data-g="w"] { background: linear-gradient(90deg, transparent 2px, var(--accent) 2px 4px, transparent 4px); outline: 0; }
body:not(.chat-float) .chat-g:not([data-g="w"]) { display: none; }
body.chat-dragging { user-select: none; -webkit-user-select: none; }
body.chat-float { --chat-w: 0px; }
body.chat-float .chat { right: auto; bottom: auto; z-index: 55; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
body.chat-float .chat-head { cursor: move; touch-action: none; user-select: none; -webkit-user-select: none; }
body.chat-float .chat-head :is(button, a) { cursor: pointer; }
body.chat-float .chat-g[data-g="w"] { left: 0; background: none; }
.chat-g[data-g="e"] { top: 0; bottom: 0; right: 0; width: 7px; cursor: ew-resize; }
.chat-g[data-g="n"] { left: 0; right: 0; top: 0; height: 6px; cursor: ns-resize; }
.chat-g[data-g="s"] { left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.chat-g[data-g="nw"], .chat-g[data-g="ne"], .chat-g[data-g="sw"], .chat-g[data-g="se"] { width: 14px; height: 14px; z-index: 3; }
.chat-g[data-g="nw"] { left: 0; top: 0; cursor: nwse-resize; } .chat-g[data-g="ne"] { right: 0; top: 0; cursor: nesw-resize; }
.chat-g[data-g="sw"] { left: 0; bottom: 0; cursor: nesw-resize; } .chat-g[data-g="se"] { right: 0; bottom: 0; cursor: nwse-resize; }
.scrim, .menu, .dd, .toast { z-index: 60; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head b { font-family: var(--display); font-size: 17px; font-weight: 600; }
.chat-sees { color: var(--muted); font-size: 12px; }
.chat-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 4px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-form textarea { flex: 1; resize: none; min-height: 36px; max-height: 140px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); line-height: 1.4; overflow-y: hidden; }
.chat-form .btn { min-width: 64px; padding: 7px 12px; }
.chat-form .btn.stop { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.chat-foot { padding: 0 12px 8px; background: var(--surface); color: var(--faint); font-size: 11px; }
.chat-empty { color: var(--muted); } .chat-empty p { margin: 0 0 10px; } .chat-empty b { color: var(--fg); }
.starters { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.starter { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; cursor: pointer; color: var(--fg); }
.starter:hover { border-color: var(--accent); }
.chat-loading { margin: 0; }
.gm { max-width: 92%; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.gm.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.gm.g { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); padding: 10px 12px; border-radius: 14px 14px 14px 4px; display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: 100%; }
.gm.g.err { border-color: var(--bad); color: var(--bad); }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol { margin: 0 0 8px; } .md ul, .md ol { padding-left: 20px; }
.md h2, .md h3, .md h4, .md h5 { font-family: var(--display); font-weight: 600; margin: 10px 0 6px; font-size: 15px; }
.md code { font-size: 12.5px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 0 0 8px; } .md pre code { background: none; padding: 0; }
.md .gt { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; margin: 4px 0 8px; }
.md table { border-collapse: collapse; font-size: 12.5px; }
.md th { font-size: 11px; padding: 5px 8px; background: var(--surface-2); white-space: nowrap; text-align: left; }
.md td { padding: 4px 8px; white-space: nowrap; border-top: 1px solid var(--line-soft); }
.files .file { display: inline-block; margin: 2px 6px 0 0; }
.g-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--muted); }
.g-meta .st { display: inline-flex; gap: 6px; align-items: center; }
.g-meta .st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--eye); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .g-meta .st::before, .chat.busy .chat-head .eye { animation: none; } }
.g-meta .via { border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.g-stopped { color: var(--muted); font-style: italic; }
@media (max-width: 759px) {
  body.chat-open { padding-right: 0; padding-bottom: var(--sheet-h); }
  body.chat-open .foot { right: 0; bottom: var(--sheet-h); }
  body.chat-open .toast { left: 50%; bottom: calc(var(--sheet-h) + 66px); }
  .chat { top: auto; left: 0; width: 100vw; height: 55vh; height: 55dvh; z-index: 30; border-left: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; box-shadow: var(--shadow); }
  .chat[data-sheet="bar"] { height: auto; } .chat[data-sheet="bar"] :is(.chat-body, .chat-form, .chat-foot) { display: none; }
  .chat[data-sheet="full"] { top: 0; height: auto; border-radius: 0; }
  .chat-grab { display: grid; place-items: center; height: 18px; cursor: ns-resize; touch-action: none; flex: none; }
  .chat-grab i { width: 44px; height: 5px; border-radius: 3px; background: var(--faint); }
  .chat-size { display: inline-block; }
  .chat-sees, .chat-g, #chat-pop { display: none; }
}
