/* Chat Normaliza — tokens in DESIGN.md. Paper, ink, one green, a highlighter yellow reserved for cited text. */
:root {
  --paper: #fbf9f4; --surface: #fff; --soft: #f2efe7; --line: #e3ded2;
  --ink: #1c2521; --muted: #5a645f; --accent: #0e5a4a; --accent-hi: #0a463a; --accent-soft: #e1efe9;
  --mark: #ffe08a; --field: #7d8882; --err: #b42318; --ok: #17663a;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { font: 16px/1.55 var(--sans); color: var(--ink); background: var(--paper); }
::selection { background: var(--mark); color: var(--ink); }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
input, textarea { font: inherit; padding: .65rem .8rem; border: 1px solid var(--field); border-radius: 8px; width: 100%; background: var(--surface); color: var(--ink); caret-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
:is(input, textarea, button, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
form > button, .composer > button { padding: .65rem 1.1rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
form > button:hover:not(:disabled), .composer > button:hover:not(:disabled) { background: var(--accent-hi); }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; margin-top: 30vh; }
.ok { color: var(--ok); } .err { color: var(--err); }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.mark { display: inline-flex; flex: none; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font: 1.1rem/1 var(--serif); color: var(--ink); }
.brand strong { font-weight: 700; }
.btn { padding: .55rem 1rem; min-height: 40px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
.btn:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.big { min-height: 48px; padding: .7rem 1.4rem; }

/* auth form (inside the landing, and the reset screen) */
.auth { max-width: 24rem; width: 100%; }
.auth.reset { margin: 12vh auto; padding: 0 1rem; }
.auth h1, .auth h2 { margin: 0 0 .25rem; font: 700 1.35rem/1.2 var(--serif); }
.auth form { display: grid; gap: .6rem; margin-top: 1rem; }
.links { display: grid; gap: .4rem; justify-items: start; margin-top: 1rem; font-size: .92rem; }
.links .link { min-height: 24px; }

/* landing */
.landing { min-height: 100%; overflow-y: auto; height: 100%; }
.land-top, .hero, .feats, .doc { max-width: 68rem; margin-inline: auto; padding-inline: 1.25rem; }
.land-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1rem; }
.land-top nav { display: flex; gap: .5rem; }
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 3rem; align-items: start; padding-block: 3rem 4rem; }
.hero h1 { font: 700 clamp(2rem, 5.5vw, 3.4rem)/1.08 var(--serif); letter-spacing: -.01em; margin: 0 0 1rem; text-wrap: balance; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 34rem; margin: 0 0 1.5rem; }
.cta { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero .auth { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; box-shadow: 0 1px 2px rgba(28,37,33,.06), 0 12px 32px -12px rgba(28,37,33,.18); scroll-margin-top: 1rem; }
.anatomy { margin: 2.5rem 0 0; padding: 1.1rem 1.25rem; max-width: 26rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: grid; gap: .55rem; }
.ln { display: block; height: .55rem; border-radius: 3px; background: var(--line); }
.ln.hl { background: var(--mark); height: .8rem; margin-inline: -.35rem; }
.w90 { width: 90%; } .w80 { width: 80%; } .w70 { width: 70%; } .w60 { width: 60%; }
.chip { justify-self: start; margin-top: .25rem; font-size: .8rem; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: .1rem .4rem; }
.feats, .doc { padding-block: 2.5rem; border-top: 1px solid var(--line); }
.feats h2, .doc h2 { font: 700 1.5rem/1.2 var(--serif); margin: 0 0 1.5rem; }
.feats ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem 3rem; }
.feats h3 { font: 600 1.05rem/1.3 var(--sans); margin: 0 0 .25rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.feats p { margin: 0; color: var(--muted); max-width: 32rem; }
.soon { font-size: .75rem; font-weight: 600; color: var(--ink); background: var(--mark); border-radius: 4px; padding: .05rem .4rem; }
.doc p { max-width: 40rem; }
.doc { padding-bottom: 4rem; }

/* chat */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; }
.layout.with-panel { grid-template-columns: 1fr minmax(20rem, 32rem); }
.chat { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); }
.scroll-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.msgs { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; max-width: 52rem; width: 100%; margin: 0 auto; container-type: size; overscroll-behavior: contain; }
@media (prefers-reduced-motion: no-preference) { .msgs { scroll-behavior: smooth; } }
/* The last turn is at least one viewport tall, so the question can sit at the top while the answer is still short. */
.turn { display: flex; flex-direction: column; gap: 1rem; scroll-margin-top: 1.25rem; }
.turn:last-child { min-height: calc(100cqh - 2.5rem); }
.to-end { position: absolute; left: 50%; bottom: .75rem; transform: translateX(-50%); display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: .35rem .85rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .88rem; box-shadow: 0 2px 8px rgba(28,37,33,.15); }
.to-end:hover { background: var(--accent-soft); }
.msg.user { align-self: flex-end; background: var(--soft); padding: .6rem .9rem; border-radius: 12px; max-width: 80%; white-space: pre-wrap; }
.msg.assistant .body { white-space: pre-wrap; }
.cite { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 .3rem; margin-left: .15rem; font-size: .75rem; vertical-align: super; line-height: 1.2; font-weight: 600; }
.cite:hover { background: var(--mark); color: var(--ink); }
.sources { margin: .6rem 0 0; padding-left: 1.25rem; font-size: .9rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.empty { display: grid; gap: .5rem; justify-items: start; margin-top: 8vh; }
.example { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .4rem .9rem; text-align: left; color: var(--ink); }
.example:hover { border-color: var(--accent); }
.composer { display: grid; grid-template-columns: 1fr auto; gap: .5rem; padding: .75rem 1.25rem 1.25rem; max-width: 52rem; width: 100%; margin: 0 auto; }
.composer textarea { resize: none; grid-column: 1 / -1; }
.composer > button { grid-column: 2; }

/* voice control: segmented, more text to the right; only the active stop shows its name */
.voz { grid-column: 1; justify-self: start; display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; }
.voz button { min-width: 32px; height: 32px; padding: 0 8px; border: 0; background: none; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; color: var(--muted); font-size: .85rem; font-weight: 600; transition: background-color .15s, color .15s; }
.voz button:hover { color: var(--ink); background: var(--line); }
.voz button[aria-checked="true"] { background: var(--accent); color: #fff; padding: 0 12px 0 10px; }

.panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--soft); }
.panel header { display: flex; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.panel .pdf { padding: .6rem 1rem; }
.panel pre { flex: 1; overflow: auto; margin: 0; padding: 0 1rem 1rem; white-space: pre-wrap; font: .85rem/1.5 ui-monospace, monospace; }
mark { background: var(--mark); color: var(--ink); }

@media (max-width: 760px) {
  .layout.with-panel { grid-template-columns: 1fr; }
  .panel { position: fixed; inset: 20% 0 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,.15); }
  .hero { grid-template-columns: 1fr; gap: 2rem; padding-block: 1.5rem 3rem; }
  .feats ul { grid-template-columns: 1fr; }
  .top { padding-inline: 1rem; } .top .muted { font-size: .8rem; text-align: right; }
}
@media (max-width: 760px) {
  .brand, .land-top .btn { white-space: nowrap; }
  .land-top .btn { padding-inline: .8rem; }
}

/* attachments: chips above the textarea, clip button, drop overlay, notes */
.composer .fchips { grid-column: 1 / -1; }
.composer .tools { grid-column: 1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.composer .notes { grid-column: 1 / -1; margin: 0; font-size: .8rem; line-height: 1.4; }
.clip { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; background: var(--surface); color: var(--accent); border: 1px solid var(--line); border-radius: 999px; }
.clip:hover { border-color: var(--accent); background: var(--accent-soft); }
.fchips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.fchip { position: relative; display: inline-flex; align-items: center; gap: .45rem; max-width: 100%; min-height: 32px; padding: 0 .3rem 0 .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: .88rem; overflow: hidden; }
.fchip .ico { flex: none; font: 700 .65rem/1 var(--sans); letter-spacing: .03em; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: .22rem .3rem; }
.fchip .nm { min-width: 0; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fchip .st { flex: none; color: var(--muted); font-size: .8rem; }
.fchip.erro { border-color: var(--err); }
.fchip.erro .st { color: var(--err); white-space: normal; max-width: 18rem; }
.fchip .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.fchip .bar i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.fchip .x { flex: none; width: 28px; height: 28px; padding: 0; border: 0; background: none; border-radius: 6px; color: var(--muted); font-size: 1.15rem; line-height: 1; }
.fchip .x:hover { background: var(--soft); color: var(--ink); }
.fchips.sent { margin-bottom: .45rem; }
.fchips.sent .fchip { min-height: 28px; padding-right: .5rem; background: var(--paper); }
.drop { position: absolute; inset: .5rem; z-index: 5; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--paper) 88%, transparent); pointer-events: none; }
.drop span { font: 600 1.15rem var(--serif); color: var(--accent); }
.chat { position: relative; }
/* the user's own document: dashed, never the highlighter yellow (that stays for the cited passage itself) */
.cite.own { background: var(--surface); border: 1px dashed var(--accent); }
.cite.own:hover { background: var(--accent-soft); color: var(--accent); }
.link.own { font-style: italic; }
@media (max-width: 760px) { .fchip .nm { max-width: 9rem; } .fchip.erro .st { max-width: 12rem; } }

/* narrow screens: nothing may be wider than the viewport (320, 375, 1280) */
.chat, .msgs, .composer, .turn, .msg { min-width: 0; }
.top { min-width: 0; }
.top .muted { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.top .email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .link { flex: none; }
.msg { overflow-wrap: anywhere; }
.land-top { flex-wrap: wrap; }
.land-top nav { flex-wrap: wrap; }
@media (max-width: 400px) { .land-top { padding-inline: .75rem; } .land-top .btn { padding-inline: .65rem; min-height: 36px; font-size: .9rem; } }

.doc-card { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .6rem; padding: .55rem .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; max-width: 100%; }
.doc-card .doc-title { font-family: var(--serif); flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.doc-card .err { flex-basis: 100%; margin: 0; }
