/* Library — the Hasselrot Hem theme, "Nordisk grön".
 *
 * The tokens are the design system's own: a green-tinted ground, white cards,
 * the wall green from Teddy's room for the one highlighted box, moss for the
 * accent. Its rules are the rules here:
 *
 *   - No gradients and no shadows. Depth is a card on a ground, nothing else.
 *   - No icons and no emoji. Every control says what it does in words.
 *   - Wall green carries ink text only. White text on it cannot be read.
 *   - Moss is the accent: the big numerals, the top row, the small labels.
 *   - Radius 16 on cards and boxes, 10 on photographs and controls.
 *   - Never smaller than 16 px in text that is meant to be followed, never
 *     smaller than 12 px anywhere.
 *
 * THE DARK THEME IS NOT IN THE DESIGN SYSTEM, which defines one light theme.
 * It is derived here in the same spirit — the same greens, turned down — and
 * is this app's own addition. Moss as an accent would vanish on a dark ground,
 * so the accent lightens to a sage and the primary button turns light with
 * dark text on it. Change it freely; nothing upstream depends on it.
 *
 * Every colour is a token. No rule below names a literal colour, and
 * tests/security.test.py also keeps the document free of style attributes,
 * which is what lets the CSP go without 'unsafe-inline'.
 */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/Manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/Manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* colour — Hasselrot Hem, light */
  --ground: #F0F3EA;
  --surface: #FFFFFF;
  --wall-green: #B7C9A0;
  --moss: #3F5A2E;
  --ink: #1F2A1A;
  --ink-soft: #3A4733;
  --ink-muted: #4F5C45;
  --on-moss: #FFFFFF;
  /* this app's additions, kept to the same family */
  --accent: #3F5A2E;          /* moss as text: numerals, labels, links */
  --rule: #D9E0CE;            /* a hairline between rows on a card */
  --field: #F7F9F3;           /* the inside of an input */
  --danger: #8A2B1E;
  --danger-ground: #F6E4DF;
  --veil: rgba(240, 243, 234, .92);

  /* type */
  --font-sans: "Manrope", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* space and radius */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 22px;
  --space-4: 56px;
  --radius-sm: 10px;
  --radius-md: 16px;

  --page: 760px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #12170F;
    --surface: #1B2217;
    --wall-green: #2F3F26;
    --moss: #B7CF9B;
    --ink: #E9EFE2;
    --ink-soft: #C9D3BF;
    --ink-muted: #A3B098;
    --on-moss: #12170F;
    --accent: #B7CF9B;
    --rule: #2A3324;
    --field: #141A11;
    --danger: #F2A796;
    --danger-ground: #3A1E18;
    --veil: rgba(18, 23, 15, .92);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #12170F;
  --surface: #1B2217;
  --wall-green: #2F3F26;
  --moss: #B7CF9B;
  --ink: #E9EFE2;
  --ink-soft: #C9D3BF;
  --ink-muted: #A3B098;
  --on-moss: #12170F;
  --accent: #B7CF9B;
  --rule: #2A3324;
  --field: #141A11;
  --danger: #F2A796;
  --danger-ground: #3A1E18;
  --veil: rgba(18, 23, 15, .92);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base -- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  /* break-word, not anywhere: a long word moves to its own line first and is
     only broken if it still does not fit. `anywhere` also shrinks the
     narrowest a column may become, and broke titles mid-word beside a
     thumbnail. */
  overflow-wrap: break-word;
}

h1, h2, h3, p, dl, dd, ul, ol, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
[hidden], .hidden { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------------ type -- */

.title {
  font-size: 34px; line-height: 38px; font-weight: 800; letter-spacing: -.02em;
  text-wrap: balance;
}
.lead { color: var(--ink-soft); margin-top: var(--space-2); max-width: 60ch; }
.step-title { font-size: 21px; line-height: 26px; font-weight: 800; text-wrap: balance; }
/* Swedish compounds are long. Where one has to break, it breaks at a syllable
   with a hyphen, which the document's lang attribute makes possible. */
.title, .step-title, .box-title, .source-title, .doc-title { hyphens: auto; -webkit-hyphens: auto; }
.step-number {
  font-size: 44px; line-height: 44px; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums; min-width: 34px;
}
.box-title { font-size: 16px; line-height: 22px; font-weight: 800; }
.label {
  font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--ink-muted);
}
.label.accent { color: var(--accent); }
.brand { text-decoration: none; }
.hint { color: var(--ink-muted); font-size: 14px; line-height: 20px; }
.mono { font-family: var(--font-mono); font-size: 15px; letter-spacing: .04em; }

@media (min-width: 720px) {
  .title { font-size: 42px; line-height: 46px; }
}

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

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding-block: var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: var(--space-3);
}
.page > .lead { margin-top: calc(var(--space-2) - var(--space-3)); }
@media (min-width: 720px) {
  .page { padding-block: var(--space-4) var(--space-4); }
}
.view { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
@media (min-width: 520px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.desktop-only { display: none; }
@media (hover: hover) and (pointer: fine) { .desktop-only { display: block; } }

.masthead { display: flex; justify-content: space-between; gap: var(--space-2); }
.footline {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: var(--space-2); color: var(--ink-muted); font-size: 13px; line-height: 18px; font-weight: 600;
}
.footline.top { justify-content: flex-start; }

.card { background: var(--surface); border-radius: var(--radius-md); padding: var(--space-3); }
.box { background: var(--wall-green); color: var(--ink); border-radius: var(--radius-md); padding: var(--space-3); }
.step { display: flex; gap: var(--space-2); align-items: flex-start; }

.notice {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); font-weight: 600;
}
.notice.danger { background: var(--danger-ground); color: var(--danger); }
/* The highlighted line on a card: wall green, ink text. */
.notice.wall { background: var(--wall-green); color: var(--ink); }
.card > .notice:not(.wall):not(.danger) { background: var(--ground); }

.login { max-width: 520px; }

/* -------------------------------------------------------------- controls -- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
select, textarea {
  width: 100%; min-width: 0;
  font: inherit; color: var(--ink);
  background: var(--field);
  border: 2px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  appearance: none; -webkit-appearance: none;
}
textarea { resize: vertical; min-height: 52px; }
select { padding-right: 34px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--ink-muted); opacity: 1; }
input.code { font-family: var(--font-mono); font-size: 22px; letter-spacing: .3em; max-width: 220px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.btn {
  font: inherit; font-weight: 800; line-height: 22px;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px;
  /* A label breaks between words, never inside one. */
  overflow-wrap: normal; word-break: keep-all; text-align: center;
}
.ask-form .btn { flex: none; }
.btn.primary { background: var(--moss); color: var(--on-moss); border-color: var(--moss); }
.btn.wide { width: 100%; }
.btn.small { min-height: 40px; padding: 7px 14px; font-size: 14px; }
.btn.link {
  border: 0; padding: 6px 2px; min-height: 36px; background: none;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip {
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 600;
  color: var(--ink); background: var(--surface);
  border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 14px; cursor: pointer; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--moss); color: var(--on-moss); }
.box .chip { background: var(--surface); }

/* ---------------------------------------------------------------- topbar -- */

.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--ground);
  border-bottom: 2px solid var(--rule);
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 30; background: var(--ground);
}
.topbar-inner {
  max-width: var(--page); margin: 0 auto;
  padding-block: var(--space-2);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
}

/* On a phone the three destinations sit at the thumb, as words. */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 2px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tab {
  display: flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 6px 4px;
  font-size: 14px; line-height: 18px; font-weight: 800; text-align: center;
  color: var(--ink-muted); text-decoration: none;
  border-top: 4px solid transparent; margin-top: -2px;
}
.tab[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }

@media (min-width: 720px) {
  .tabs {
    position: static; display: flex; gap: var(--space-1);
    background: none; border: 0; padding: 0;
  }
  .tabs { margin-left: auto; }
  .tab { min-height: 40px; padding: 6px 12px; font-size: 15px; border-top: 0; margin: 0; border-bottom: 4px solid transparent; }
  .tab[aria-current="page"] { border-bottom-color: var(--accent); }
  .view { padding-bottom: var(--space-4); }
}

/* The one small word in the corner: settings, help, sign out. */
.top-link {
  font-size: 14px; line-height: 18px; font-weight: 800; color: var(--ink-muted);
  text-decoration: none; padding: 10px 4px; margin: -10px 0;
}
.top-link[aria-current="page"] { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }

.update-bar {
  max-width: var(--page); margin: var(--space-2) auto 0; padding: var(--space-1) var(--space-3);
  background: var(--wall-green); color: var(--ink); border-radius: var(--radius-sm);
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); font-weight: 600;
}
.update-bar .btn.link { color: var(--ink); }

/* ------------------------------------------------------------------- ask -- */

.conversation { display: flex; flex-direction: column; gap: var(--space-3); }
.turn { display: flex; flex-direction: column; gap: var(--space-2); }
.question { align-self: flex-end; max-width: 88%; font-weight: 600; }
.answer p + p { margin-top: var(--space-2); }
.answer .cite {
  font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums;
  font-size: 13px; vertical-align: super; line-height: 0; margin-left: 1px;
  background: none; border: 0; padding: 0 1px; cursor: pointer; font-family: inherit;
}
.sources { border-top: 2px solid var(--rule); margin-top: var(--space-3); padding-top: var(--space-2); }
.sources > .label { margin-bottom: var(--space-1); }
.own-answer {
  border-top: 2px solid var(--rule); margin-top: var(--space-3); padding-top: var(--space-2);
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1);
}
.own-answer textarea, .own-answer .notice { align-self: stretch; }
.sources + .sources, .sources + .own-answer { margin-top: var(--space-2); }
.source {
  display: flex; gap: var(--space-2); align-items: flex-start; width: 100%;
  padding: var(--space-1) 0; background: none; border: 0; color: inherit; font: inherit;
  text-align: left; cursor: pointer; text-decoration: none;
}
.source .step-number { font-size: 30px; line-height: 32px; min-width: 26px; }
.source-title { font-weight: 800; }
.thinking { color: var(--ink-muted); font-weight: 600; }
/* Over an answer kept from before: when it was written, and "ask again". */
.saved-answer {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1);
  border-bottom: 2px solid var(--rule); margin-bottom: var(--space-2); padding-bottom: var(--space-1);
}
/* Earlier questions: plain rows under the question box, one rule between. */
.earlier-block { display: flex; flex-direction: column; gap: var(--space-1); }
.earlier-list { display: flex; flex-direction: column; border-top: 2px solid var(--rule); }
.earlier {
  font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0;
  border-bottom: 2px solid var(--rule); padding: 12px 0; text-align: left; cursor: pointer;
}
.earlier:hover { color: var(--accent); }
/* A long question is shown by its first two lines. */
.earlier span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

.ask-form {
  position: sticky; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  display: flex; gap: var(--space-1); align-items: flex-end;
  background: var(--ground); padding-block: var(--space-1);
}
.ask-form textarea { resize: none; max-height: 160px; }
@media (min-width: 720px) { .ask-form { bottom: 0; } }

/* --------------------------------------------------------------- library -- */


.entry-list { display: flex; flex-direction: column; gap: var(--space-2); }
.entry {
  display: flex; gap: var(--space-2); align-items: flex-start; justify-content: space-between;
  background: var(--surface); border-radius: var(--radius-md); padding: var(--space-3);
  color: inherit; text-decoration: none;
}
.entry.old { opacity: .6; }
.entry-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.entry-main .label .state::before { content: " · "; color: var(--ink-muted); white-space: pre; }
.entry-snippet { color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry-thumb { width: 84px; height: 84px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--ground); }
/* Documents as sheets in a grid: two across on a phone, more where there is room. */
.entry-list.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); align-items: start; }
.doc {
  min-width: 0; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border-radius: var(--radius-md); padding: var(--space-2);
}
.doc.old { opacity: .6; }
.doc-open { min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); color: inherit; text-decoration: none; }
.doc-sheet {
  aspect-ratio: 3 / 4; overflow: hidden; display: flex; flex-direction: column; gap: 6px;
  background: var(--ground); border-radius: var(--radius-sm); padding: var(--space-2);
}
/* A drawn page is white on a white card: the rule is what makes it a sheet. */
.doc-sheet.pictured { padding: 0; border: 2px solid var(--rule); }
/* From the top: a page is recognised by its letterhead, not by its middle. */
.doc-image { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.doc-words { font-size: 12px; line-height: 16px; color: var(--ink-muted); overflow-wrap: anywhere; }
.doc-title {
  font-size: 16px; line-height: 21px; font-weight: 800; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-meta { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.doc-meta .state::before { content: " · "; color: var(--ink-muted); white-space: pre; }
.doc-file { overflow-wrap: anywhere; }
.doc .tag { padding: 4px 8px; }
.doc .tag[aria-pressed="true"] { background: var(--moss); color: var(--on-moss); }
.state { color: var(--accent); }
.state.failed { color: var(--danger); }
.empty { text-align: left; }

/* ------------------------------------------------------------------- add -- */

/* The drop box. Only where there is a mouse to drag with: on a phone it would
 * be a large box that does nothing a thumb can do. */
.drop-zone { display: none; }
@media (hover: hover) and (pointer: fine) {
  .drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    width: 100%; min-height: 176px; padding: var(--space-3); margin-bottom: var(--space-2);
    background: none; color: var(--ink); font: inherit; text-align: center; cursor: pointer;
    border: 3px dashed var(--wall-green); border-radius: var(--radius-md);
  }
  .drop-zone:hover { background: var(--surface); border-color: var(--accent); }
  .drop-zone .hint { max-width: 60ch; }
}

/* Two buttons a thumb cannot miss. */
.capture { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.capture .btn { min-height: 72px; font-size: 18px; }

/* Save stays within reach while the keyboard and the list push the page. */
.save-bar {
  position: sticky; bottom: calc(58px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  background: var(--ground); padding-block: var(--space-1);
}
@media (min-width: 720px) { .save-bar { position: static; padding: 0; } }

/* A folded row: closed it is one line, open it is a card. */
.fold { background: var(--surface); border-radius: var(--radius-md); }
.fold > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: 16px var(--space-3); min-height: 56px;
  font-size: 16px; line-height: 22px; font-weight: 800;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "+"; font-size: 22px; line-height: 22px; font-weight: 600; color: var(--accent); }
.fold[open] > summary::after { content: "\2212"; }
.fold[open] > summary { margin-bottom: 0; }
.fold > :not(summary) { padding: 0 var(--space-3) var(--space-3); }

/* ----------------------------------------------------------------- entry -- */

.photos { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }
.photos img { width: 100%; border-radius: var(--radius-sm); background: var(--ground); }
.prose { display: flex; flex-direction: column; gap: var(--space-2); max-width: 68ch; }
.prose h3 { font-size: 16px; line-height: 22px; font-weight: 800; margin-top: var(--space-1); }
.prose ul { list-style: disc; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.prewrap { white-space: pre-wrap; }
.facts { display: grid; grid-template-columns: 1fr; gap: var(--space-1) var(--space-3); }
.facts > div { display: flex; flex-direction: column; gap: 2px; padding-bottom: var(--space-1); border-bottom: 2px solid var(--rule); }
.facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts dd { font-weight: 600; }
@media (min-width: 520px) { .facts.two { grid-template-columns: 1fr 1fr; } .facts.two > div { border-bottom: 0; } }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font: inherit; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink);
  background: var(--ground); border: 0; border-radius: 6px; padding: 6px 10px; cursor: pointer;
}
.tag:hover { text-decoration: underline; }
.tag-filter { display: flex; flex-direction: column; gap: 6px; }
/* On a card the chips need the ground behind them to be seen at all. */
.tag-picker { display: flex; flex-direction: column; gap: var(--space-1); }
.tag-picker .chip { background: var(--ground); }
.tag-picker .chip[aria-pressed="true"] { background: var(--moss); color: var(--on-moss); }
.tag-manager { display: flex; flex-direction: column; }
.tag-row { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-1) 0; border-bottom: 2px solid var(--rule); }
.tag-row.plain { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tag-row:last-child { border-bottom: 0; }
/* Room for the bars at the top and bottom when a row is scrolled into view. */
.tag-row { scroll-margin: 96px 0; }
.tag-name { font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
#tagAddForm input { flex: 1; min-width: 0; }
.tag-filter .chips { align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tag-filter .chips::-webkit-scrollbar { display: none; }
.tag-filter .chip { flex: none; }
@media (hover: hover) and (pointer: fine) { .tag-filter .chips { flex-wrap: wrap; overflow-x: visible; } }
.file-list { display: flex; flex-direction: column; gap: var(--space-1); }
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-1) 0; border-bottom: 2px solid var(--rule);
}
.file-row:last-child { border-bottom: 0; }
.file-row img { width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; flex: none; }
.file-name { min-width: 0; flex: 1; font-weight: 600; }
details > summary { cursor: pointer; font-weight: 800; }
details[open] > summary { margin-bottom: var(--space-2); }
.qr svg { width: 208px; height: 208px; border-radius: var(--radius-sm); }

/* ---------------------------------------------------------- drop, upload -- */

.drop-veil {
  position: fixed; inset: 0; z-index: 60; background: var(--veil);
  display: flex; align-items: center; justify-content: center; padding: var(--space-3);
  pointer-events: none;
}
.drop-veil .box { max-width: 420px; width: 100%; border: 4px dashed var(--ink); }

.upload-panel {
  position: fixed; z-index: 50;
  left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  max-width: 460px; margin-left: auto;
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3); max-height: 50vh; overflow: auto;
}
@media (min-width: 720px) { .upload-panel { bottom: var(--space-3); left: auto; width: 460px; } }
.upload-list { display: flex; flex-direction: column; }
.upload-list li { display: flex; justify-content: space-between; gap: var(--space-2); padding: 6px 0; border-bottom: 2px solid var(--rule); }
.upload-list li:last-child { border-bottom: 0; }
.upload-list .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .what { flex: none; font-weight: 800; font-size: 13px; color: var(--accent); }
.upload-list .what.failed { color: var(--danger); }

.toast {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  max-width: min(520px, calc(100vw - 32px));
  background: var(--ink); color: var(--ground);
  border-radius: var(--radius-sm); padding: 12px 18px; font-weight: 600;
}

.boot-error {
  max-width: 560px; margin: var(--space-4) auto; padding: var(--space-3);
  background: var(--surface); border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.boot-error pre { white-space: pre-wrap; font-family: var(--font-mono); font-size: 13px; line-height: 18px; }

@media (prefers-reduced-motion: no-preference) {
  .thinking::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
  @keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
}

@media print {
  .topbar, .tabs, .ask-form, .upload-panel, .toast, .footline .btn { display: none !important; }
  body { background: none; }
  .card, .box { break-inside: avoid; }
}
