/* Toser side panel design system. "Annotated fine print": ink, paper, marker. Built for 320 to 520px wide. */
@import url("../fonts/fonts.css");

:root {
  --bg: #0D0D0F; --bg-2: #111113; --surface: #151517; --surface-2: #1B1B1E; --surface-3: #232327;
  --line: rgba(238,232,221,.09); --line-2: rgba(238,232,221,.16);
  --text: #EEE8DD; --text-2: #B3AC9F; --muted: #8B8579;
  --marker: #FF9029; --marker-ink: #1A0E03; --marker-soft: rgba(255,144,41,.12); --marker-line: rgba(255,144,41,.38);
  --redline: #FF7A59; --redline-soft: rgba(255,122,89,.1); --sage: #8BD3A5; --sage-soft: rgba(139,211,165,.1);
  --internal: #F0C070; --internal-soft: rgba(240,192,112,.10); --internal-line: rgba(240,192,112,.34);
  --paper: #EEE8DD; --paper-ink: #2A2620; --paper-muted: #8A8172;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --hand: "Caveat", "Segoe Print", cursive;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --pad: 16px;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
body svg { width: 18px; height: 18px; flex: none; }
.logo-xl { display: block; margin-bottom: 26px; }
.logo-xl .wm { font-size: 44px; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: var(--marker); color: var(--marker-ink); }
:focus-visible { outline: 2px solid var(--marker); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-thumb { background: var(--surface-3); border: 3px solid var(--bg); border-radius: 10px; }

/* ---------- App frame ---------- */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.app.no-tabs { grid-template-rows: auto 1fr; }
.app-main { overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.screen { padding: 18px var(--pad) 28px; animation: enter .28s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px var(--pad); border-bottom: 1px solid var(--line); min-height: 52px; background: var(--bg); }
.logo { display: inline-flex; align-items: center; line-height: 1; flex: none; }
.wm { display: inline-flex; align-items: baseline; font-family: var(--serif); font-style: italic; font-weight: 400; line-height: 1;
  letter-spacing: 0; color: #FFFFFF; white-space: nowrap; font-size: 22px; }
.wm .sym { color: var(--marker); }
.sym-tile { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #0D0D0F;
  border: 1px solid var(--line-2); color: var(--marker); font-family: var(--serif); font-style: italic; font-size: 21px; line-height: 1; padding-top: 3px; }
/* The mark beside the team name is just the mark: no tile, no border, no background. */
.topbar .sym-tile { background: none; border: 0; padding-top: 0; padding-bottom: 3px; }
.ws { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.ws-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-plan { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.ws-plan.warn { color: var(--marker); } .ws-plan.bad { color: var(--redline); }
.topbar .spacer { flex: 1; }
.pill-demo { font-family: var(--mono); font-size: 10.5px; padding: 2px 7px; border-radius: 5px; border: 1px dashed var(--marker-line); color: var(--marker); }

.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--line); background: var(--bg); padding: 4px 4px max(4px, env(safe-area-inset-bottom)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; font-size: 10.5px; line-height: 1.15; text-align: center; letter-spacing: .02em; position: relative; }
.tab svg { width: 19px; height: 19px; }
.tab:hover { color: var(--text-2); }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::after { content: ""; position: absolute; top: -5px; left: 30%; right: 30%; height: 2px; border-radius: 2px; background: var(--marker); }

/* ---------- Type ---------- */
.title { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.12; letter-spacing: -.015em; margin: 0; }
.title em { font-style: italic; }
.title-xl { font-size: 40px; }
.sub { color: var(--text-2); margin: 8px 0 0; }
.eyebrow { font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.eyebrow::before { content: "§"; font-family: var(--serif); font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--marker); }
.label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); } .t2 { color: var(--text-2); }
.small { font-size: 12.5px; } .mono { font-family: var(--mono); }
.hand { font-family: var(--hand); font-size: 20px; color: var(--marker); line-height: 1; }
.mark { background: linear-gradient(100deg, transparent 0, rgba(255,144,41,.9) 3%, rgba(255,144,41,.75) 50%, rgba(255,144,41,.88) 97%, transparent 100%) 0 72% / 100% 74% no-repeat; color: var(--marker-ink); padding: 0 .1em; margin: 0 -.05em; border-radius: .2em .45em .25em .4em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.section-gap { margin-top: 22px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: transparent; color: var(--text); font-weight: 550; font-size: 13.5px; white-space: nowrap; transition: background .15s, border-color .15s, transform .15s, opacity .15s; }
.btn:hover { background: rgba(238,232,221,.05); border-color: rgba(238,232,221,.28); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--marker); color: var(--marker-ink); border-color: transparent; box-shadow: 0 1px 0 rgba(255,255,255,.35) inset; }
.btn-primary:hover { background: #FFA54D; border-color: transparent; }
.btn-danger { color: var(--redline); border-color: transparent; }
.btn-danger:hover { border-color: rgba(255,122,89,.35); }
.btn-danger:hover { background: var(--redline-soft); border-color: rgba(255,122,89,.45); }
.btn-ghost { border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); background: rgba(238,232,221,.05); border-color: transparent; }
.btn-lg { min-height: 46px; font-size: 15px; padding: 0 18px; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn .kbd { margin-left: 2px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-2); flex: none; }
.icon-btn:hover { background: rgba(238,232,221,.06); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-decoration-color: var(--marker-line); text-underline-offset: 3px; font-size: inherit; }
.link:hover { text-decoration-color: var(--marker); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }
.kbd { font-family: var(--mono); font-size: 10.5px; padding: 0 5px; border-radius: 4px; border: 1px solid currentColor; border-bottom-width: 2px; opacity: .7; line-height: 1.5; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span, .field > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--redline); }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line-2); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.textarea { resize: none; line-height: 1.5; min-height: 88px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--marker); box-shadow: 0 0 0 3px rgba(255,144,41,.15); }
.input[aria-invalid="true"] { border-color: var(--redline); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; border: 1px solid var(--line-2); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; font-size: 12.5px; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 550; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 20px; background: var(--surface-3); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform .2s var(--ease), background .2s; }
.switch input:checked { background: var(--marker); }
.switch input:checked::after { transform: translateX(16px); background: var(--marker-ink); }
.tabs-mini { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs-mini button { border: 0; background: transparent; padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-mini button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--marker); }
.dropzone { display: grid; place-items: center; gap: 6px; text-align: center; padding: 22px 14px; border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--marker-line); background: var(--marker-soft); }
.dropzone svg { width: 22px; height: 22px; color: var(--marker); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.card + .card { margin-top: 10px; }
.card-title { font-size: 13.5px; font-weight: 600; margin: 0; }
.list { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.click { cursor: pointer; } .row.click:hover .row-title { text-decoration: underline; text-decoration-color: var(--marker-line); text-underline-offset: 3px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 600; flex: none; }
.tag { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 5px; border: 1px solid var(--line-2); font-size: 11px; color: var(--text-2); white-space: nowrap; }
.tag.marker { border-color: var(--marker-line); color: var(--marker); }
.chip-clause { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--marker); background: var(--marker-soft); border: 1px solid var(--marker-line); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.high { color: var(--sage); } .badge.medium { color: var(--marker); } .badge.low { color: var(--redline); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.kpi { background: var(--bg); padding: 12px; }
.kpi b { display: block; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1; margin-top: 6px; }
.kpi span { font-size: 11.5px; color: var(--muted); }
.meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--marker); border-radius: inherit; transition: width .5s var(--ease); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 72px; }
.bars i { flex: 1; background: var(--marker); opacity: .85; border-radius: 2px 2px 0 0; min-height: 2px; }
.bars i.zero { background: var(--surface-3); opacity: 1; }

/* Paper sheet: clause text rendered like a page of the policy */
.paper { background: var(--paper); color: var(--paper-ink); border-radius: 6px; padding: 12px 14px; font-family: var(--serif); font-size: 15.5px; line-height: 1.45; box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 12px 30px -16px #000; }
.paper .ref { font-family: var(--mono); font-size: 10.5px; color: var(--paper-muted); display: block; margin-bottom: 4px; }
.paper mark { background: linear-gradient(100deg, transparent 0, rgba(255,144,41,.95) 2%, rgba(255,144,41,.8) 50%, rgba(255,144,41,.95) 98%, transparent 100%); color: #14110C; padding: 0 2px; margin: 0 -2px; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

/* ---------- Banners, empty states, skeletons ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.banner strong { color: var(--text); font-weight: 600; }
.banner .btn { margin-left: auto; flex: none; }
.banner.warn { border-color: var(--marker-line); background: var(--marker-soft); }
.banner.bad { border-color: rgba(255,122,89,.4); background: var(--redline-soft); }
.banner.ok { border-color: rgba(139,211,165,.35); background: var(--sage-soft); }
.empty { text-align: center; padding: 28px 10px; color: var(--text-2); }
.empty .hand { display: block; margin-bottom: 8px; font-size: 22px; }
.empty .title { font-family: var(--serif); font-weight: 400; font-size: 24px; letter-spacing: -.01em; color: var(--text); }
.empty p { margin: 8px auto 16px; max-width: 30ch; }
.skel { display: grid; gap: 8px; }
.skel i { height: 11px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel i:nth-child(2) { width: 90%; } .skel i:nth-child(3) { width: 66%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast & sheet ---------- */
.toasts { position: fixed; left: 12px; right: 12px; bottom: 70px; display: grid; gap: 8px; z-index: 50; pointer-events: none; }
.toast { justify-self: center; max-width: 100%; padding: 9px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 550; box-shadow: 0 12px 30px -10px #000; animation: toast .25s var(--ease) both; pointer-events: auto; }
.toast.bad { background: var(--redline); color: #1A0A05; }
@keyframes toast { from { opacity: 0; transform: translateY(8px); } }
.scrim { position: fixed; inset: 0; background: rgba(5,5,6,.6); z-index: 40; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88%; overflow: auto; background: var(--bg-2); border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0; padding: 8px var(--pad) 20px; animation: up .28s var(--ease) both; }
.sheet::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--surface-3); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet .title { font-size: 26px; margin-bottom: 12px; }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: flex; flex-direction: column; padding: 28px var(--pad) 20px; }
.auth-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px 0 28px; }
.auth-hero .title { font-size: 46px; }
.auth-hero .sub { font-size: 15px; max-width: 32ch; margin-top: 14px; }
.auth-sheet { margin-top: 18px; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--text-2); padding: 0; font-size: 13px; margin-bottom: 18px; }
.back:hover { color: var(--text); }
.stepper { display: flex; gap: 6px; margin-bottom: 18px; }
.stepper i { flex: 1; height: 3px; border-radius: 3px; background: var(--surface-3); }
.stepper i.on { background: var(--marker); }

/* ---------- Ask ---------- */
.ask-intro { padding-top: 6px; }
.ask-intro .title { font-size: 32px; }
.examples { display: grid; gap: 6px; margin-top: 16px; }
.example { text-align: left; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: transparent; color: var(--text-2); font-size: 13.5px; line-height: 1.35; transition: border-color .15s, color .15s, background .15s; }
.example:hover { border-color: var(--marker-line); color: var(--text); background: var(--marker-soft); }
.example::before { content: "“"; font-family: var(--serif); color: var(--marker); margin-right: 3px; font-size: 16px; }
.composer { border-top: 1px solid var(--line); background: var(--bg); padding: 10px var(--pad) 12px; }
.composer .textarea { min-height: 76px; max-height: 40vh; background: var(--bg-2); }
.composer.compact .textarea { min-height: 40px; height: 40px !important; overflow: hidden !important; }
.composer.compact .composer-extra { display: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.composer-bar .btn-primary { margin-left: auto; }
.composer-extra { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.question-echo { font-size: 13px; color: var(--text-2); padding: 9px 12px; border-left: 2px solid var(--marker); background: var(--bg-2); border-radius: 0 8px 8px 0; margin-bottom: 12px; white-space: pre-line; max-height: 7.5em; overflow: hidden; }
.answer-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.verified { font-family: var(--mono); font-size: 10.5px; color: var(--sage); }
.reply { width: 100%; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: 12px; font-size: 14.5px; line-height: 1.55; resize: none; overflow: hidden; min-height: 120px; }
.reply:focus { outline: none; border-color: var(--marker-line); }
.answer-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 10px; }
.escalate { padding: 10px 12px; border-radius: var(--r); border: 1px solid rgba(255,122,89,.4); background: var(--redline-soft); margin-bottom: 10px; font-size: 13px; color: #FFC6B6; }
.escalate b { display: block; color: var(--redline); font-weight: 600; margin-bottom: 2px; }
.sources { margin-top: 16px; display: grid; gap: 8px; }
.source { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.source > button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 0; background: transparent; text-align: left; }
.source > button .doc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.source > button .chev { color: var(--muted); transition: transform .2s; }
.source[data-open="true"] > button .chev { transform: rotate(180deg); }
.source .paper { margin: 0 10px 10px; }
.followups { margin-top: 16px; display: grid; gap: 6px; }
.followup { text-align: left; border: 1px dashed var(--line-2); background: transparent; border-radius: 9px; padding: 7px 10px; font-size: 13px; color: var(--text-2); }
.followup:hover { border-color: var(--marker-line); color: var(--text); }
.feedback { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.feedback .icon-btn[aria-pressed="true"] { color: var(--marker); background: var(--marker-soft); }
.thinking { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.thinking .dots { display: inline-flex; gap: 3px; }
.thinking .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--marker); animation: blink 1s infinite; }
.thinking .dots i:nth-child(2) { animation-delay: .15s; } .thinking .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .2; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* Text that must paint above a highlighted line below it (descenders over the marker). */
.ink-over { position: relative; z-index: 1; }

/* Headings are focused programmatically on route change (for screen readers); no ring for that. */
[tabindex="-1"]:focus { outline: none; }

/* ---------- Answer: clause first ---------- */
.clauses { display: grid; gap: 10px; margin-bottom: 18px; }
.clause-card { background: var(--paper); color: var(--paper-ink); border-radius: 8px; padding: 12px 14px 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 14px 30px -18px #000; }
.clause-card.rise { animation: clause-in .45s var(--ease) both; }
@keyframes clause-in { from { opacity: 0; transform: translateY(8px) rotate(-.4deg); } }
.clause-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 8px; min-width: 0; }
.clauses, .clause-card { min-width: 0; }
.clause-head .chip-clause { max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: #8A4A00; background: rgba(255,144,41,.16); border-color: rgba(178,92,10,.35); }
.clause-doc { font-size: 11.5px; color: var(--paper-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }
.clause-text { margin: 0; font-family: var(--serif); font-size: 16px; line-height: 1.5; color: var(--paper-ink); }
.clause-text mark.hl { color: #14110C; padding: 0 2px; margin: 0 -2px; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone;
  background: linear-gradient(100deg, transparent 0, rgba(255,144,41,.95) 2%, rgba(255,144,41,.8) 50%, rgba(255,144,41,.95) 98%, transparent 100%) 0 0 / 0% 100% no-repeat;
  transition: background-size .65s var(--ease); }
.clause-text mark.hl.on { background-size: 100% 100%; }
.clause-more { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 4px 10px 4px 8px; border-radius: 999px;
  border: 1px solid rgba(42,38,32,.22); background: rgba(42,38,32,.05); color: var(--paper-ink); font-size: 12px; font-weight: 550; }
.clause-more:hover { background: rgba(42,38,32,.1); }
.clause-more svg { width: 14px; height: 14px; transition: transform .2s; }
.clause-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.reply-block { opacity: 0; transform: translateY(8px); transition: opacity .35s var(--ease), transform .35s var(--ease); }
.reply-block.show { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reply-block { opacity: 1; transform: none; } .clause-text mark.hl { background-size: 100% 100%; } }

/* ---------- First run: agent or admin ---------- */
.role-list { display: grid; gap: 10px; }
.role-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 14px 16px 16px; text-align: left; color: inherit;
  border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease); }
.role-card:hover { border-color: var(--marker-line); background: var(--surface-2); }
.role-card:active { transform: scale(.99); }
.role-n { font-family: var(--serif); font-style: italic; font-size: 36px; line-height: .8; color: var(--marker); width: 22px; flex: none; }
.role-copy { display: grid; gap: 3px; flex: 1; min-width: 0; }
.role-title { font-size: 15px; font-weight: 600; color: var(--text); }
.role-text { font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.role-go { display: inline-flex; color: var(--muted); transition: transform .2s var(--ease), color .2s var(--ease); }
.role-card:hover .role-go { color: var(--marker); transform: translateX(3px); }

/* Keep me signed in */
.keep { position: relative; display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 2px 0; }
.keep input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.keep-box { flex: none; width: 18px; height: 18px; margin-top: 1px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 5px; color: transparent; transition: background .15s, border-color .15s, color .15s; }
.keep-box svg { width: 13px; height: 13px; }
.keep input:checked + .keep-box { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.keep input:focus-visible + .keep-box { outline: 2px solid var(--marker); outline-offset: 2px; }
.keep-text { display: grid; gap: 2px; font-size: 13px; color: var(--text); }
.keep-text .hint { font-size: 11.5px; color: var(--muted); }

/* Startup failure: show the reason instead of a blank panel */
.fatal-detail { font-family: var(--mono); font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; max-width: 34ch; margin: 0 auto 16px; word-break: break-word; }
.btn-row.center { justify-content: center; }

/* ---------- Policies style: clean (default) or classic paper ---------- */
.policy-text { margin: 0 0 12px; }
.policy-text .pl { display: block; }
[data-policy-style="clean"] .policy-text + .policy-text { margin-top:12px; }
.policy-text .pl + .pl { margin-top: 6px; }
.policy-text .sub-ref { font-family: var(--mono); font-size: 10.5px; color: var(--paper-muted); margin-right: 6px; }
[data-policy-style="clean"] .policy-text { background: none; box-shadow: none; border-radius: 0; padding: 0 0 6px; color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.62; }
[data-policy-style="clean"] .policy-text .sub-ref { color: var(--marker); font-size: 11.5px; font-weight: 500; }
[data-policy-style="clean"] .policy-text mark { background: var(--marker); color: var(--marker-ink); }

/* ---------- Ask: reply in another language ---------- */
.reply-en { margin: 0; padding: 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); font-size: 14.5px; line-height: 1.55; color: var(--text); }
.orig-label { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0 2px; padding-top: 10px; border-top: 1px solid rgba(255,144,41,.22);
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,144,41,.62); transition: color .25s var(--ease); }
.reply.reply-orig { border: 0; background: transparent; padding: 2px 0; font-size: 12.5px; line-height: 1.5; color: var(--marker); opacity: .55; resize: none;
  border-radius: var(--r-sm); transition: opacity .25s var(--ease), text-shadow .25s var(--ease), background .25s var(--ease); }
.reply.reply-orig:focus { opacity: 1; }
.reply-block.copy-hot .reply-orig { opacity: 1; text-shadow: 0 0 12px rgba(255,144,41,.38); background: radial-gradient(120% 140% at 50% 50%, rgba(255,144,41,.07), transparent 70%); }
.reply-block.copy-hot .orig-label { color: var(--marker); }
.copy-wrap { position: relative; display: inline-flex; }
.copy-wrap > .btn { width: 100%; }
.copy-bubble { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 5; white-space: nowrap; pointer-events: none;
  padding: 5px 11px; border-radius: 999px; background: var(--marker); color: var(--marker-ink); font-size: 12px; font-weight: 600;
  box-shadow: 0 8px 22px -8px rgba(255,144,41,.7); animation: copy-float 2s var(--ease) forwards; }
@keyframes copy-float {
  0% { opacity: 0; transform: translateY(6px) scale(.96); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-10px); }
  100% { opacity: 0; transform: translateY(-24px); }
}
@media (prefers-reduced-motion: reduce) { .copy-bubble { animation: copy-fade 2s linear forwards; } }
@keyframes copy-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* Language switch on the sign-in screens (the same control lives in Settings) */
.auth-lang { display: flex; justify-content: center; margin-top: 16px; }
.auth-lang .seg { width: auto; }

/* ---------- Related clauses: the clauses to check, best first ---------- */
.related { margin-top: 18px; }
.related-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.rel-list { display: grid; gap: 6px; }
.rel { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); overflow: hidden; min-width: 0; }
.rel[hidden] { display: none; }
.rel-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; color: inherit; cursor: pointer; }
.rel-row:hover { background: var(--surface-2); }
.rel-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted); }
.rel-dot.high { background: var(--sage); } .rel-dot.medium { background: var(--marker); }
.rel-main { display: grid; gap: 3px; min-width: 0; }
.rel-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.rel-why { font-size: 12.5px; line-height: 1.4; color: var(--text-2); }
.rel-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.rel-chev { display: inline-flex; color: var(--muted); margin-top: 3px; }
.rel-chev svg { width: 14px; height: 14px; transition: transform .2s; }
.rel-row[aria-expanded="true"] .rel-chev svg { transform: rotate(180deg); }
.rel-paper { margin: 0 10px 10px; padding: 10px 12px; border-radius: 6px; }
.rel-paper .clause-text { font-size: 14px; }
.rel-paper[hidden] { display: none; }
.rel-more { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.rel-more:hover { border-color: var(--marker-line); color: var(--text); }
.rel-more svg { width: 14px; height: 14px; transition: transform .2s; }
.rel-more[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Brand colour: a row of pastel circles instead of a colour wheel. */
.swatches { display:flex;flex-wrap:wrap;gap:8px;margin-top:4px; }
.swatch { width:26px;height:26px;border-radius:50%;border:2px solid transparent;cursor:pointer;box-shadow:0 0 0 1px var(--line-2) inset;transition:transform .12s ease; }
.swatch:hover { transform:scale(1.08); }
.swatch[aria-checked="true"] { border-color:var(--text); }

/* ---------- Headline glow: the brand's accent as a dithered lamp behind every screen title (lib/glow.js) ---------- */
.glow-host { position: relative; isolation: isolate; }
.title-glow { position: absolute; z-index: -1; pointer-events: none; image-rendering: pixelated; opacity: 0; animation: glow-in 1.1s var(--ease) .1s forwards, glow-breathe 7s ease-in-out 1.2s infinite; }
@keyframes glow-in { to { opacity: 1; } }
@keyframes glow-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }
@media (prefers-reduced-motion: reduce) { .title-glow { animation: none; opacity: 1; } }

/* ---------- First open: the three screen tour ---------- */
.intro-top { display: flex; align-items: center; justify-content: space-between; min-height: 28px; }
.intro-logo .wm { font-size: 22px; }
.intro-skip { font-size: 13px; color: var(--muted); }
.intro-stage { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 0; }
.intro-slide { animation: intro-in .45s var(--ease) both; }
.intro-slide .title { font-size: 42px; margin-top: 10px; }
.intro-slide .sub { font-size: 15px; max-width: 32ch; margin-top: 14px; }
.intro-ico { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-bottom: 22px;
  border-radius: 14px; border: 1px solid var(--marker-line); background: var(--marker-soft); color: var(--marker); }
.intro-ico svg { width: 26px; height: 26px; }
.intro-foot { display: grid; gap: 16px; }
.intro-dots { margin: 0; }
@keyframes intro-in { from { opacity: 0; transform: translateX(14px); } }

/* ---------- Continue with Google ---------- */
.google-block { display: grid; gap: 8px; }
.btn-google { gap: 10px; background: #fff; color: #1f1f1f; border-color: #fff; }
.btn-google:hover { background: #f1f1f1; border-color: #f1f1f1; }
.g-logo { display: inline-flex; }
.g-logo svg { width: 18px; height: 18px; }
.or { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; font-size: 12px; color: var(--muted); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Answer: quieter and tighter ----------
   The clause still leads, on paper, but at reading size; the quote is marked, not floodlit; the way back to the
   policy is a small control on the card instead of a faint full button. */
.clauses { gap: 8px; margin-bottom: 14px; }
.clause-card { padding: 10px 12px 10px; border-radius: 9px; box-shadow: 0 1px 0 rgba(255,255,255,.45) inset, 0 10px 24px -18px #000; }
.clause-head { margin-bottom: 6px; }
.clause-text { font-size: 14.5px; line-height: 1.55; }
.clause-text mark.hl { background: linear-gradient(100deg, transparent 0, rgba(255,144,41,.42) 2%, rgba(255,144,41,.34) 50%, rgba(255,144,41,.42) 98%, transparent 100%) 0 0 / 0% 100% no-repeat; box-shadow: inset 0 -1.5px 0 rgba(178,92,10,.55); transition: background-size .65s var(--ease); }
.clause-text mark.hl.on { background-size: 100% 100%; }
.clause-card .clause-actions { margin-top: 8px; }
.clause-card .clause-actions .btn { min-height: 26px; padding: 0 9px; font-size: 11.5px; color: var(--paper-ink); background: transparent; border: 1px solid rgba(42,38,32,.22); }
.clause-card .clause-actions .btn:hover { background: rgba(42,38,32,.07); }
.answer-meta { margin-bottom: 6px; }
.question-echo { padding: 7px 11px; margin-bottom: 10px; font-size: 12.5px; }
.reply { padding: 10px 12px; font-size: 14px; line-height: 1.5; min-height: 96px; }
