/* DKS Wissens-Assistent — design system
   Native-feeling, hairline-bordered, one accent colour, no gradients for show. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;

  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 20px;

  --rail-w: 272px;
  --reader-w: 424px;

  --dur: 160ms;
  --ease: cubic-bezier(.32, .72, 0, 1);
}

/* light */
:root,
:root[data-theme="light"] {
  --bg:            #f4f4f6;
  --bg-rail:       #eeeef1;
  --bg-elev:       #ffffff;
  --bg-sunken:     #e9e9ed;
  --bg-hover:      rgba(0, 0, 0, .045);
  --bg-active:     rgba(0, 0, 0, .075);

  --text:          #1b1b1f;
  --text-2:        #5c5c66;
  --text-3:        #66666f;  /* WCAG AA on every light surface (>=4.69:1) */

  --hairline:      rgba(0, 0, 0, .10);
  --hairline-2:    rgba(0, 0, 0, .16);

  --accent:        #0071e3;
  --accent-text:   #ffffff;
  --accent-soft:   rgba(0, 113, 227, .10);
  --accent-line:   rgba(0, 113, 227, .30);

  --green:         #1a8a45;
  --green-soft:    rgba(26, 138, 69, .10);
  --amber:         #a86400;
  --amber-soft:    rgba(168, 100, 0, .11);
  --red:           #c8102e;
  --red-soft:      rgba(200, 16, 46, .09);

  --shadow-1:      0 1px 2px rgba(0, 0, 0, .06);
  --shadow-2:      0 8px 28px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-3:      0 24px 60px rgba(0, 0, 0, .22);
  --scrim:         rgba(20, 20, 24, .38);
  --lightbox-bg:   rgba(18, 18, 22, .82);
  --shimmer:       rgba(0, 0, 0, .03);
}

/* dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #161618;
    --bg-rail:     #1c1c1f;
    --bg-elev:     #222225;
    --bg-sunken:   #101012;
    --bg-hover:    rgba(255, 255, 255, .06);
    --bg-active:   rgba(255, 255, 255, .10);

    --text:        #f2f2f5;
    --text-2:      #a6a6b0;
    --text-3:      #8d8d97;  /* WCAG AA on every dark surface (>=4.83:1) */

    --hairline:    rgba(255, 255, 255, .11);
    --hairline-2:  rgba(255, 255, 255, .18);

    --accent:      #0a84ff;
    --accent-text: #ffffff;
    --accent-soft: rgba(10, 132, 255, .16);
    --accent-line: rgba(10, 132, 255, .42);

    --green:       #37c979;
    --green-soft:  rgba(55, 201, 121, .14);
    --amber:       #ffb340;
    --amber-soft:  rgba(255, 179, 64, .14);
    --red:         #ff5a5f;
    --red-soft:    rgba(255, 90, 95, .14);

    --shadow-1:    0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2:    0 8px 28px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-3:    0 24px 60px rgba(0, 0, 0, .66);
    --scrim:       rgba(0, 0, 0, .55);
    --lightbox-bg: rgba(8, 8, 10, .88);
    --shimmer:     rgba(255, 255, 255, .045);
  }
}

:root[data-theme="dark"] {
  --bg:          #161618;
  --bg-rail:     #1c1c1f;
  --bg-elev:     #222225;
  --bg-sunken:   #101012;
  --bg-hover:    rgba(255, 255, 255, .06);
  --bg-active:   rgba(255, 255, 255, .10);

  --text:        #f2f2f5;
  --text-2:      #a6a6b0;
  --text-3:      #8d8d97;  /* WCAG AA on every dark surface (>=4.83:1) */

  --hairline:    rgba(255, 255, 255, .11);
  --hairline-2:  rgba(255, 255, 255, .18);

  --accent:      #0a84ff;
  --accent-text: #ffffff;
  --accent-soft: rgba(10, 132, 255, .16);
  --accent-line: rgba(10, 132, 255, .42);

  --green:       #37c979;
  --green-soft:  rgba(55, 201, 121, .14);
  --amber:       #ffb340;
  --amber-soft:  rgba(255, 179, 64, .14);
  --red:         #ff5a5f;
  --red-soft:    rgba(255, 90, 95, .14);

  --shadow-1:    0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2:    0 8px 28px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-3:    0 24px 60px rgba(0, 0, 0, .66);
  --scrim:       rgba(0, 0, 0, .55);
  --lightbox-bg: rgba(8, 8, 10, .88);
  --shimmer:     rgba(255, 255, 255, .045);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

h1, h2, h3, h4, p, figure, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

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

.icon { flex: none; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: var(--hairline-2);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ layout */
#app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) 0;
  height: 100dvh;
  transition: grid-template-columns var(--dur) var(--ease);
}
#app[data-reader="open"] { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--reader-w); }
#app[data-rail="off"]    { grid-template-columns: 0 minmax(0, 1fr) 0; }
#app[data-rail="off"][data-reader="open"] { grid-template-columns: 0 minmax(0, 1fr) var(--reader-w); }

/* --------------------------------------------------------------- left rail */
#rail {
  grid-column: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-rail);
  border-right: 1px solid var(--hairline);
  overflow: hidden;
}
#app[data-rail="off"] #rail { border-right-color: transparent; }

/* ------------------------------------------------- Comarch umbrella brand
 *
 * v7.1 (§2). DKS, Schilling and Suite are Comarch products: the corporate
 * logo is the umbrella brand, the product identity next to (or below) it is
 * never displaced.
 *
 * One inline copy of public/assets/comarch-logo.svg per page carries
 * fill="currentColor", so the appearance is a pure CSS decision — no second
 * asset, no filter that would falsify the brand blue:
 *   light  #152A94  the original Comarch blue
 *   dark   #F2F2F5  pure white glares on the near-black surfaces; this is the
 *                   same near-white the body text already uses (--text/dark)
 *
 * These rules live in styles.css because every one of the six pages loads it
 * (hub, three landings, auth, app). public/admin.html loads only admin.css —
 * Owner A carries an equivalent rule there.
 */

.comarch-brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  color: #152A94;
  text-decoration: none;
  border-radius: var(--r-xs);
  transition: opacity var(--dur) var(--ease);
}
.comarch-brand:hover { text-decoration: none; opacity: .72; }
.comarch-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 416 x 64 — the height drives, the viewBox keeps the 6.5:1 ratio. */
.comarch-logo { display: block; height: 22px; width: auto; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .comarch-brand { color: #F2F2F5; }
}
:root[data-theme="dark"] .comarch-brand { color: #F2F2F5; }

/* Narrow displays: smaller, never gone (§2). */
@media (max-width: 520px) {
  .comarch-logo { height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .comarch-brand { transition: none; }
}

/* App shell: the umbrella brand sits above the product brand in the rail head.
   Deliberately outside .rail-head — app.js prepends the knowledge-base switch
   bar into that element and would otherwise push the logo down. */
/* display:flex, not block — a block would add the inline line-box descender
   under the logo and push the whole rail down by another 6 px. */
.rail-comarch { display: flex; align-items: center; padding: 15px 16px 0; flex: none; }

/* The rail head loses the top padding the logo row now provides. */
.rail-comarch + .rail-head { padding-top: 11px; }

/* Below 900 px the rail turns into an off-canvas drawer, so the rail copy is
   only visible while the drawer is open — the topbar copy carries the brand
   there. Above 900 px the rail is always on screen and the topbar copy stays
   out of the way. */
.topbar-comarch { display: none; }

@media (max-width: 900px) {
  .topbar-comarch { display: inline-flex; }
}

.rail-head { padding: 18px 16px 10px; }

.brand { display: flex; gap: 11px; align-items: center; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-1);
}
.brand-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub   { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rail-search {
  margin: 4px 12px 12px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  color: var(--text-3);
  font-size: 13px;
  text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.rail-search:hover { border-color: var(--hairline-2); }
.rail-search span { flex: 1; }
kbd {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-sunken);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 1px 5px;
  white-space: nowrap;
}

.rail-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 8px 12px; }
.rail-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .045em; text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 8px 6px;
}

.manual { border-radius: var(--r-sm); }
.manual-btn {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  color: var(--text);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.manual-btn:hover { background: var(--bg-hover); }
.manual-btn .m-ic { color: var(--text-2); }
.manual-btn .m-name {
  flex: 1; min-width: 0;
  font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.manual-btn .m-id {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em;
  color: var(--text-3);
  background: var(--bg-sunken);
  border-radius: 4px; padding: 1px 4px;
}
.manual-btn .m-chev { color: var(--text-3); transition: transform var(--dur) var(--ease); }
.manual[data-open="1"] .m-chev { transform: rotate(90deg); }
.manual[data-open="1"] > .manual-btn { color: var(--accent); }
.manual[data-open="1"] > .manual-btn .m-ic { color: var(--accent); }

.chapters { display: none; padding: 2px 0 8px 14px; margin-left: 14px; border-left: 1px solid var(--hairline); }
.manual[data-open="1"] .chapters { display: block; }
.chapter {
  display: block; width: 100%;
  text-align: left;
  font-size: 12.5px; color: var(--text-2);
  padding: 4px 8px;
  border-radius: var(--r-xs);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chapter:hover { background: var(--bg-hover); color: var(--text); }
.chapter[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }

.rail-foot {
  border-top: 1px solid var(--hairline);
  padding: 9px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.rail-stats { font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: var(--r-xs);
  font-size: 12.5px; color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ghost-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ------------------------------------------------------------------- main */
/* min-height:0 — a grid/flex item's automatic minimum size is its content, so
   without this the 100dvh row stretches to the answer height and the composer
   is pushed off screen while #thread never becomes scrollable. */
#main { grid-column: 2; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
#rail, #reader { min-height: 0; }

#topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.topbar-title {
  flex: 1; min-width: 0;
  font-size: 13.5px; font-weight: 590; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-2);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-xs);
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  border-radius: 15px;
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  font-size: 12.5px; font-weight: 500; color: var(--text);
  box-shadow: var(--shadow-1);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.pill-btn:hover { border-color: var(--hairline-2); }
.pill-btn:active { transform: scale(.97); }
.pill-btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 34%, transparent); }
.pill-btn.accent { color: var(--accent-text); background: var(--accent); border-color: transparent; }

/* ----------------------------------------------------------------- thread */
#thread {
  flex: 1;
  min-height: 0;          /* flex item must be allowed to shrink, or it never scrolls */
  overflow-y: auto;
  overflow-x: hidden;
  /* NO scroll-behavior: smooth here. The stream calls scrollToBottom() on every
     delta; with smooth scrolling each call restarts an animation, so the
     container sits permanently mid-animation and swallows the user's wheel and
     any scrollTop assignment. Deliberate jumps opt into smoothness per call. */
  overscroll-behavior: contain;
  padding: 26px 24px 8px;
}
.thread-inner { max-width: 780px; margin: 0 auto; }

.turn { margin-bottom: 34px; }
.turn:last-child { margin-bottom: 12px; }

.q-row { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 16px; }
/* The question and its status line ease in like everything that follows them —
   without this the ask started with a hard pop and only the answer was soft. */
.q-row, .status-line { animation: rise 200ms var(--ease) both; }
.q-avatar {
  width: 26px; height: 26px; flex: none; margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  color: var(--text-2);
}
.q-text {
  font-size: 19px; font-weight: 600; letter-spacing: -.015em; line-height: 1.35;
  padding-top: 1px;
  overflow-wrap: anywhere;
}

/* live status line */
.status-line {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text-2);
  padding: 6px 2px 2px;
}
.spinner {
  width: 14px; height: 14px; flex: none;
  border-radius: 50%;
  border: 1.6px solid var(--hairline-2);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Soft breathing on the status text — only alive while an answer is pending;
   the whole line is removed the moment the card lands. */
.status-line > span:not(.spinner) { animation: status-pulse 1.6s ease-in-out infinite; }
@keyframes status-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }

/* ------------------------------------------------------------- answer card */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  animation: rise 200ms var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Skeleton shimmer while the answer JSON is still streaming (draft card only).
   The band is an oversized overlay moved purely via transform; .card clips it. */
.card.draft { position: relative; }
.card.draft::after {
  content: "";
  position: absolute;
  inset: 0 -60%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, var(--shimmer) 50%, transparent 60%);
  transform: translateX(-30%);
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { transform: translateX(30%); } }

.card-head {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 18px 12px;
}
.card-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.card-headings { flex: 1; min-width: 0; }
.card-title {
  font-size: 17px; font-weight: 640; letter-spacing: -.012em; line-height: 1.3;
  overflow-wrap: anywhere;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.card-actions { display: flex; gap: 2px; flex: none; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px;
  border-radius: 11px;
  border: 1px solid var(--hairline);
  font-size: 11.5px; font-weight: 500; color: var(--text-2);
  white-space: nowrap;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.conf-high    { color: var(--green); border-color: color-mix(in srgb, var(--green) 32%, transparent); background: var(--green-soft); }
.tag.conf-medium  { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 32%, transparent); background: var(--amber-soft); }
.tag.conf-low     { color: var(--red);   border-color: color-mix(in srgb, var(--red) 32%, transparent);   background: var(--red-soft); }
.tag.kind         { color: var(--text-2); background: var(--bg-sunken); border-color: transparent; }
.tag.manual       { font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; }

.card-summary {
  padding: 0 18px 4px;
  font-size: 15.5px; line-height: 1.6; color: var(--text);
  overflow-wrap: anywhere;
}

.card-section { padding: 16px 18px 0; }
.card-section:last-child { padding-bottom: 16px; }
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 9px;
  display: flex; align-items: center; gap: 6px;
}

/* steps: numbered vertical timeline with a connecting rail */
.steps { padding-top: 2px; }
.step { position: relative; padding: 0 0 18px 40px; }
.step:last-child { padding-bottom: 2px; }
.step::before {
  content: "";
  position: absolute;
  left: 13px; top: 30px; bottom: 2px;
  width: 1px;
  background: var(--hairline-2);
}
.step:last-child::before { display: none; }
.step-n {
  position: absolute; left: 0; top: 1px;
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--hairline-2);
  background: var(--bg-elev);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.step-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 14.5px; font-weight: 600; letter-spacing: -.005em;
  min-height: 29px;
  overflow-wrap: anywhere;
}
.step-title .icon { color: var(--accent); }
.step-detail { font-size: 14.5px; color: var(--text-2); margin-top: 3px; overflow-wrap: anywhere; }
.step-ui { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.step-src { margin-top: 9px; }

.ui-chip {
  font-family: var(--mono);
  font-size: 11.5px; letter-spacing: .01em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--hairline);
  color: var(--text);
  white-space: nowrap;
}

.step-figs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 11px; }

/* figures */
.fig {
  display: block;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  overflow: hidden;
  max-width: 100%;
  text-align: left;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.fig:hover { border-color: var(--accent-line); }
.fig:active { transform: scale(.995); }
.fig img { width: 100%; height: auto; background: #fff; }
.fig figcaption {
  font-size: 11.5px; color: var(--text-3);
  padding: 7px 9px;
  border-top: 1px solid var(--hairline);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.step-figs .fig { width: min(320px, 100%); }
.fig.loading { min-height: 92px; min-width: 150px; display: grid; place-items: center; color: var(--text-3); }

.fig-strip {
  display: flex; gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.fig-strip .fig { flex: none; width: 260px; scroll-snap-align: start; }

/* facts */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--hairline); border: 1px solid var(--hairline); border-radius: var(--r-md); overflow: hidden; }
.fact { background: var(--bg-elev); padding: 10px 12px; display: flex; gap: 9px; align-items: flex-start; min-width: 0; }
.fact .icon { color: var(--text-3); margin-top: 2px; }
.fact-body { min-width: 0; }
.fact-label { font-size: 11.5px; color: var(--text-3); letter-spacing: .01em; }
.fact-value { font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* warnings */
.callouts { display: flex; flex-direction: column; gap: 8px; }
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid;
  font-size: 14px; line-height: 1.5;
  overflow-wrap: anywhere;
}
.callout .icon { margin-top: 1px; flex: none; }
.callout.info     { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.callout.info .icon { color: var(--accent); }
.callout.warn     { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 34%, transparent); }
.callout.warn .icon { color: var(--amber); }
.callout.critical { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 36%, transparent); }
.callout.critical .icon { color: var(--red); }

/* related */
.related-row { display: flex; flex-wrap: wrap; gap: 7px; }
.related-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 9px;
  border-radius: 16px;
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  font-size: 13px; color: var(--text);
  text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.related-chip .icon { color: var(--accent); }
.related-chip:hover { border-color: var(--accent-line); background: var(--accent-soft); }

/* sources */
.card-foot {
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg-sunken) 55%, transparent);
  padding: 12px 18px;
}
.src-chip {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 100%;
  padding: 4px 10px 4px 5px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  font-size: 12.5px; color: var(--text-2);
  text-align: left;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.src-chip:hover { border-color: var(--accent-line); color: var(--text); }
.src-chip .src-n {
  width: 18px; height: 18px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-sunken);
  font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.src-chip .src-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-chip .src-manual { font-family: var(--mono); font-size: 10px; color: var(--text-3); }

/* the "sources arrived" preview row — each chip fades and rises on its own,
   30 ms apart, so the retrieval result reads as arriving rather than popping */
.src-preview { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.src-preview .src-chip { animation: rise 200ms var(--ease) both; }
.src-preview .src-chip:nth-child(2) { animation-delay: 30ms; }
.src-preview .src-chip:nth-child(3) { animation-delay: 60ms; }
.src-preview .src-chip:nth-child(4) { animation-delay: 90ms; }
.src-preview .src-chip:nth-child(5) { animation-delay: 120ms; }
.src-preview .src-chip:nth-child(n+6) { animation-delay: 150ms; }

/* the final card's source chips echo the same 30 ms cadence */
.card-foot .chips-row .src-chip { animation: rise 180ms var(--ease) both; }
.card-foot .chips-row .src-chip:nth-child(2) { animation-delay: 30ms; }
.card-foot .chips-row .src-chip:nth-child(3) { animation-delay: 60ms; }
.card-foot .chips-row .src-chip:nth-child(4) { animation-delay: 90ms; }
.card-foot .chips-row .src-chip:nth-child(5) { animation-delay: 120ms; }
.card-foot .chips-row .src-chip:nth-child(n+6) { animation-delay: 150ms; }

/* error card */
.card.error { border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.card.error .card-icon { background: var(--red-soft); color: var(--red); }
.err-detail {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  background: var(--bg-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  overflow-x: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* -------------------------------------------------------------- empty state */
.empty { max-width: 780px; margin: 0 auto; padding: 4px 0 20px; animation: rise 240ms var(--ease) both; }
.empty-hero { text-align: center; padding: 26px 0 26px; }
.empty-mark {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 15px;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  color: var(--accent);
  box-shadow: var(--shadow-1);
}
.empty-title { font-size: 25px; font-weight: 650; letter-spacing: -.022em; }
.empty-sub { font-size: 15px; color: var(--text-2); margin-top: 7px; }

.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.starter {
  display: flex; flex-direction: column; gap: 9px;
  padding: 13px 13px 12px;
  min-height: 116px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  text-align: left;
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
.starter:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.starter:active { transform: none; }
.starter-ic {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}
.starter-q { font-size: 13.5px; line-height: 1.42; font-weight: 500; flex: 1; }
.starter-m { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); letter-spacing: .02em; }

.empty-foot {
  margin-top: 18px;
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  font-size: 12.5px; color: var(--text-3);
}
.empty-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* --------------------------------------------------------------- composer */
#composer {
  flex: none;
  padding: 10px 24px 18px;
  background: linear-gradient(to bottom, transparent, var(--bg) 26%);
}
.composer-inner { max-width: 780px; margin: 0 auto; }

#voiceBar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 9px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  animation: rise var(--dur) var(--ease) both;
}
#voiceBar[hidden] { display: none; }
.voice-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--text-3); }
#voiceBar[data-state="listening"] .voice-dot { background: var(--green); animation: pulse 1.4s ease-in-out infinite; }
#voiceBar[data-state="speaking"]  .voice-dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
#voiceBar[data-state="connecting"] .voice-dot { background: var(--amber); animation: pulse .9s ease-in-out infinite; }
#voiceBar[data-state="error"] .voice-dot { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
#voiceState { font-weight: 550; white-space: nowrap; }
.voice-transcript {
  flex: 1; min-width: 0;
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  direction: rtl; text-align: left;
}
.voice-transcript > * { direction: ltr; unicode-bidi: bidi-override; }

.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 7px 7px 7px 14px;
  border-radius: var(--r-xl);
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  box-shadow: var(--shadow-2);
  transition: border-color var(--dur) var(--ease);
}
.composer-box:focus-within { border-color: var(--accent-line); }
#q {
  flex: 1; min-width: 0;
  border: 0; outline: 0; resize: none;
  background: transparent;
  font-size: 15px; line-height: 1.5;
  padding: 7px 0;
  max-height: 168px;
  overflow-y: auto;
}
#q::placeholder { color: var(--text-3); }
.composer-tools { display: flex; align-items: center; gap: 6px; flex: none; padding-bottom: 1px; }

.mic {
  height: 34px; width: 34px;
  display: grid; place-items: center;
  border-radius: 17px;
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  color: var(--text-2);
  overflow: hidden;
  transition: width var(--dur) var(--ease), background var(--dur) var(--ease),
              color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mic:hover { color: var(--text); border-color: var(--hairline-2); }
/* Der Canvas füllt den Knopf exakt — vorher war er hart 132×48 bei einem
   82×34-Knopf: die Grid-Zeile lief nach unten über und die Wellenform hing
   sichtbar unterhalb der Mitte. */
.mic canvas { display: none; width: 100%; height: 100%; }
.mic[data-state="connecting"] { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.mic[data-state="listening"], .mic[data-state="speaking"] { width: 82px; }
.mic[data-state="listening"] { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); background: var(--green-soft); }
.mic[data-state="speaking"]  { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.mic[data-state="listening"] canvas,
.mic[data-state="speaking"] canvas { display: block; }
.mic[data-state="listening"] .mic-glyph,
.mic[data-state="speaking"] .mic-glyph { display: none; }
.mic[data-muted="1"] { color: var(--text-3); background: var(--bg-sunken); }
.mic-glyph { display: grid; place-items: center; }

.send {
  height: 34px; width: 34px;
  display: grid; place-items: center;
  border-radius: 17px;
  background: var(--accent);
  color: var(--accent-text);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.send:disabled { opacity: .38; cursor: default; }
.send:not(:disabled):active { transform: scale(.94); }
/* One quiet pop when a stream has finished — app.js adds the class once and
   removes it on animationend. */
.send.pulse { animation: send-pop 240ms var(--ease); }
@keyframes send-pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }

.composer-hint {
  display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center;
  margin-top: 9px;
  font-size: 11.5px; color: var(--text-3);
}
.composer-hint span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------------------------------------------------------- reader */
#reader {
  grid-column: 3;
  min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--hairline);
  overflow: hidden;
}
#app:not([data-reader="open"]) #reader { display: none; }

.reader-head {
  flex: none;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px 12px 18px;
  border-bottom: 1px solid var(--hairline);
}
/* The pane itself slides via the grid transition; the content inside fades a
   touch behind it. Restarts on open because #reader toggles display; app.js
   re-arms .content-in when a new page lands in an already-open pane. */
.reader-head { animation: fade 200ms var(--ease) both; }
.reader-body { animation: fade 200ms var(--ease) both; }
.reader-body.content-in { animation: content-fade 180ms var(--ease) both; }
@keyframes content-fade { from { opacity: 0; } to { opacity: 1; } }
.reader-heads { flex: 1; min-width: 0; }
.reader-manual {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-3);
}
.reader-title { font-size: 14.5px; font-weight: 620; letter-spacing: -.01em; margin-top: 2px; overflow-wrap: anywhere; }
.reader-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 18px 18px 60px; font-size: 14.5px; }
.reader-body h1, .reader-body h2, .reader-body h3, .reader-body h4 {
  font-size: 15px; font-weight: 640; letter-spacing: -.01em;
  margin: 22px 0 7px;
  scroll-margin-top: 16px;
}
.reader-body h1:first-child, .reader-body h2:first-child { margin-top: 0; }
.reader-body p { margin: 0 0 11px; color: var(--text-2); }
.reader-body ul, .reader-body ol { margin: 0 0 12px; padding-left: 18px; color: var(--text-2); }
.reader-body ul li { list-style: disc; }
.reader-body ol li { list-style: decimal; }
.reader-body img { border: 1px solid var(--hairline); border-radius: var(--r-sm); margin: 8px 0 14px; background: #fff; cursor: zoom-in; }
.reader-body table { border-collapse: collapse; font-size: 13px; width: 100%; }
.reader-body td, .reader-body th { border: 1px solid var(--hairline); padding: 5px 8px; text-align: left; vertical-align: top; }
.reader-body .table-scroll { overflow-x: auto; margin: 0 0 14px; }
.reader-body code, .reader-body kbd { font-family: var(--mono); font-size: 12.5px; }
.reader-section { scroll-margin-top: 12px; border-radius: var(--r-sm); transition: background 400ms var(--ease); }
.reader-section.hit { background: var(--accent-soft); box-shadow: 0 0 0 8px var(--accent-soft); }
.reader-empty { color: var(--text-3); font-size: 13.5px; display: grid; place-items: center; height: 60%; text-align: center; gap: 8px; }

/* --------------------------------------------------------------- lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: grid; grid-template-rows: 1fr auto;
  background: var(--lightbox-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 46px 20px 20px;
  animation: fade var(--dur) var(--ease) both;
}
#lightbox[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lb-stage { display: grid; place-items: center; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow-3); }
/* content settles from 0.98 while the scrim fades — restarts on every open
   because #lightbox toggles display */
.lb-stage img, .lb-info { animation: lb-in 200ms var(--ease) both; }
@keyframes lb-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.lb-info {
  max-width: 760px; width: 100%; margin: 16px auto 0;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 13px 15px;
  color: var(--text);
}
.lb-cap { font-size: 14px; font-weight: 560; overflow-wrap: anywhere; }
.lb-ai { font-size: 13px; color: var(--text-2); margin-top: 6px; overflow-wrap: anywhere; }
.lb-ai b { font-weight: 600; color: var(--text-3); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.lb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; align-items: center; }
/* absolute, not fixed: #lightbox is inset:0 fixed, so the placement is
   identical — but a fixed child has offsetParent null and the focus trap's
   visibility check (offsetParent !== null) skipped the close button on Tab. */
.lb-close { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 17px; display: grid; place-items: center; background: var(--bg-elev); border: 1px solid var(--hairline); color: var(--text); box-shadow: var(--shadow-2); z-index: 2; }

/* ‹/› gallery navigation + counter (hidden for single images) */
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 20px;
  display: grid; place-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  color: var(--text);
  box-shadow: var(--shadow-2);
  z-index: 2;
  transition: background 120ms var(--ease), border-color 120ms var(--ease), transform 120ms var(--ease);
}
.lb-nav:hover { border-color: var(--hairline-2); background: var(--bg-hover); }
.lb-nav:active { transform: translateY(-50%) scale(.94); }
.lb-nav[hidden] { display: none; }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-count {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: 12px; font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-1);
  z-index: 2;
}
.lb-count[hidden] { display: none; }
@media (max-width: 620px) {
  .lb-nav { width: 34px; height: 34px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

/* --------------------------------------------------------------- palette */
#palette {
  position: fixed; inset: 0; z-index: 70;
  background: var(--scrim);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: 14vh 16px 16px;
  animation: fade 120ms var(--ease) both;
}
#palette[hidden] { display: none; }
.palette-panel {
  max-width: 580px; margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: drop var(--dur) var(--ease) both;
}
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--hairline); color: var(--text-3); }
.palette-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; }
.palette-results { max-height: min(52vh, 420px); overflow-y: auto; padding: 6px; }
.p-group { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 9px 10px 5px; }
.p-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--text);
}
.p-item .icon { color: var(--text-3); }
.p-item .p-label { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-item .p-hint { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.p-item[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.p-item[aria-selected="true"] .icon,
.p-item[aria-selected="true"] .p-hint { color: color-mix(in srgb, var(--accent-text) 78%, transparent); }
.p-empty { padding: 22px 12px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--hairline); font-size: 11px; color: var(--text-3); }
.palette-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* ------------------------------------------------------------------ scrim */
#scrim { display: none; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  #app[data-reader="open"] { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0; }
  #app[data-rail="off"][data-reader="open"] { grid-template-columns: 0 minmax(0, 1fr) 0; }
  #reader {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(440px, 100vw);
    z-index: 45;
    box-shadow: var(--shadow-3);
    animation: slideIn var(--dur) var(--ease) both;
  }
  @keyframes slideIn { from { transform: translateX(14px); opacity: .4; } to { transform: none; opacity: 1; } }
  #app[data-reader="open"] #scrim { display: block; position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fade var(--dur) var(--ease) both; }
}

@media (max-width: 900px) {
  #app, #app[data-reader="open"] { grid-template-columns: 0 minmax(0, 1fr) 0; }
  #rail {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(300px, 84vw);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow-3);
  }
  #app[data-rail="on"] #rail { transform: none; }
  #app[data-rail="on"] #scrim { display: block; position: fixed; inset: 0; z-index: 44; background: var(--scrim); }
  .starters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #thread { padding: 20px 16px 4px; }
  #composer { padding: 8px 16px 14px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .starters { grid-template-columns: 1fr; }
  .starter { min-height: 0; flex-direction: row; align-items: center; gap: 11px; }
  .starter-ic { flex: none; }
  .starter-m { display: none; }
  .facts { grid-template-columns: 1fr; }
  .empty-title { font-size: 21px; }
  .empty-hero { padding: 12px 0 20px; }
  .q-text { font-size: 17px; }
  .card-summary { font-size: 15px; }
  .composer-hint span:nth-child(n+3) { display: none; }
  #topbar { padding: 0 10px; }
  .fig-strip .fig { width: 210px; }
  #lightbox { padding: 44px 12px 12px; }
  .voice-transcript { display: none; }
}

@media (max-width: 420px) {
  #thread { padding: 16px 12px 4px; }
  #composer { padding: 8px 12px 12px; }
  .card-head, .card-summary, .card-section, .card-foot,
  .fb-row, .fb-thanks { padding-left: 14px; padding-right: 14px; }
  .step { padding-left: 34px; }
  .step-n { width: 24px; height: 24px; font-size: 11px; }
  .step::before { left: 11.5px; top: 27px; }
  .topbar-title { display: none; }
}

/* ------------------------------------------------------------------ motion */

/* Consistent press feel across every button-like control:
   120 ms for hover surfaces (background/border/colour), 80 ms into the press. */
.pill-btn, .icon-btn, .related-chip, .src-chip {
  transition: background 120ms var(--ease), border-color 120ms var(--ease),
              color 120ms var(--ease), box-shadow 120ms var(--ease),
              transform 120ms var(--ease);
}
.pill-btn:active, .icon-btn:active, .related-chip:active, .src-chip:active {
  transform: scale(.985);
  transition-duration: 80ms;
}

/* Theme toggle: the root containers cross-fade instead of snapping. Only
   colour properties — never layout. #rail keeps its mobile transform slide. */
body, #main, #topbar, #reader, .card, .card-foot, .composer-box, .reader-head {
  transition-property: background-color, color, border-color;
  transition-duration: 180ms;
  transition-timing-function: var(--ease);
}
#rail {
  transition: transform var(--dur) var(--ease), background-color 180ms var(--ease),
              color 180ms var(--ease), border-color 180ms var(--ease);
}

.stagger > * { animation: rise 220ms var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 20ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 140ms; }
.stagger > *:nth-child(5) { animation-delay: 180ms; }
.stagger > *:nth-child(6) { animation-delay: 220ms; }
.stagger > *:nth-child(7) { animation-delay: 260ms; }
.stagger > *:nth-child(n+8) { animation-delay: 300ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ *
 * Integration fixes (post-audit)
 * ------------------------------------------------------------------ */

/* The reader pane (server/server.mjs) emits these two classes; without rules
   the manual eyebrow and the 5250 screen dumps rendered as plain body text. */
.doc-manual {
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 2px;
}
.reader-body pre.mono,
pre.mono {
  font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--bg-sunken);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 10px 12px;
  overflow-x: auto;           /* 80-column masks scroll inside their own box */
  white-space: pre;
  tab-size: 4;
}

/* The 1px grid gap painted the hairline colour through as a solid block when a
   facts row was short or odd-numbered. Collapse to one column when there is no
   room for two, and let the cells carry their own separators. */
@media (max-width: 560px) {
  .facts { grid-template-columns: minmax(0, 1fr); }
}

/* Rail footer stats were clipped mid-word inside the 272px rail. */
.rail-stats {
  white-space: normal;
  line-height: 1.35;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Voice bar: the state label was unshrinkable and pushed the stop button out of
   the bar on narrow screens. */
@media (max-width: 520px) {
  #voiceState {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 0 1 auto;
  }
  .voice-transcript { display: none; }   /* transcript needs room we do not have */
  #voiceBar .pill-btn.danger { flex: none; white-space: nowrap; }
}

/* Below 420px the title was hidden outright, which removed the flex spacer and
   bunched the header controls to the left. Keep the element, drop only its text. */
@media (max-width: 420px) {
  .topbar-title { display: block; visibility: hidden; flex: 1; min-width: 0; }
}

/* --------------------------------------------- v7.1 (§2): room in the topbar
 *
 * The umbrella brand (~117 px at 18 px height) joins an already full narrow
 * topbar. Two concessions buy the space, neither of them a lost feature:
 *
 *   - the gap tightens to 8 px below 560 px;
 *   - below 420 px the title was invisible already and only held space as a
 *     flex spacer; the logo does that job now, and an auto margin keeps the
 *     controls flush right, which is what the spacer was for.
 *
 * The ⌘K palette button only has to go below 375 px. Measured with the widest
 * corpus badge („Schilling", 77 px): at 375 px the row still ends at 367 px of
 * 375 with the button in place, at 360 px it overruns by 2 px. So 375 px — the
 * width the acceptance bar names — keeps the button; narrower phones lose it
 * and reach the very same palette through the rail's „Suchen oder springen".
 */
@media (max-width: 560px) {
  #topbar { gap: 8px; }
}

@media (max-width: 374px) {
  #topbar #paletteBtn { display: none; }
}

@media (max-width: 420px) {
  #topbar { padding: 0 8px; }
  #topbar .topbar-title { display: none; }
  #topbar .topbar-actions { margin-left: auto; }
}

/* 375 px still fits „Neue Frage" spelled out; the common 360 px Android width
   does not. There the pill goes icon-only — its tooltip/accessible name
   („Alles zurücksetzen", re-set by app.js per language) stays. */
@media (max-width: 400px) {
  #topbar #newBtn > span:last-child { display: none; }
  #topbar #newBtn { padding-left: 8px; padding-right: 8px; }
}

/* app.js keeps #accountBtn `hidden` until GET /api/auth/me reports a session,
   but .icon-btn's `display: grid` outranks the UA rule `[hidden]{display:none}`
   — the button stayed as an empty 30 px slot. It now really is gone, which is
   also what makes the narrow topbar add up. */
.icon-btn[hidden] { display: none; }

/* Placeholder was sliced in half at 390px: the long corpus placeholder wrapped
   into a second line the one-row textarea clips. app.js now swaps in the short
   „Frage stellen…“ below 480px; the ellipsis here is the guard for widths where
   a long placeholder would still wrap (a clipped second line never shows). */
#q::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Shortcut hints are keyboard-only concepts — on touch devices ("/", ⌘K,
   Leertaste halten) they are noise and cost a full row of composer height. */
@media (pointer: coarse) {
  .composer-hint { display: none; }
}
/* Auch bei feinem Zeiger sind Tastatur-Hinweise unter 480px nur Ballast. */
@media (max-width: 479px) { .composer-hint { display: none; } }

/* Visually hidden but announced by assistive technology. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ *
 * Answer archive
 * ------------------------------------------------------------------ */

/* Slim divider above a thread restored from localStorage. */
.thread-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 22px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3);
  animation: fade 200ms var(--ease) both;
}
.thread-divider::before,
.thread-divider::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

/* ------------------------------------------------------------------ *
 * Draft card (visible from the `sources` event on)
 * ------------------------------------------------------------------ */

.draft-context { color: var(--text-2); }
.card .draft-sources { padding-top: 12px; }
/* the preview row keeps its own margins outside a card; inside the draft the
   section provides the spacing */
.src-preview.in-draft { margin: 0; }

/* ------------------------------------------------------------------ *
 * Card actions: rate (thumbs + optional comment), toast
 * ------------------------------------------------------------------ */

.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn:disabled:hover { background: none; color: var(--text-2); }
.icon-btn.fb-btn.voted, .icon-btn.fb-btn.voted:disabled { color: var(--accent); opacity: 1; }

.fb-row {
  display: flex; gap: 8px; align-items: center;
  padding: 2px 18px 0;
  animation: rise 160ms var(--ease) both;
}
.fb-row input {
  flex: 1; min-width: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--bg);
  padding: 5px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 120ms var(--ease);
}
.fb-row input:focus-visible { outline: none; border-color: var(--accent-line); }
.fb-row .pill-btn { flex: none; }
.fb-thanks {
  padding: 4px 18px 0;
  font-size: 12.5px; color: var(--text-3);
}

/* six header icon actions must fit beside the title on a phone */
@media (max-width: 480px) {
  .card-actions .icon-btn { width: 26px; height: 26px; }
}

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 80;
  max-width: min(86vw, 420px);
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  padding: 8px 16px;
  font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease); /* opacity only — never layout */
}
.toast.show { opacity: 1; }

/* ------------------------------------------------------------------ *
 * Print: exactly one answer card on white paper
 * app.js marks body.print-card, .turn.print-turn and .card.print-target,
 * calls window.print() and removes the marks on afterprint.
 * ------------------------------------------------------------------ */

@media print {
  body.print-card { overflow: visible !important; height: auto !important; background: #fff !important; }
  body.print-card #app { display: block !important; height: auto !important; }
  body.print-card #rail,
  body.print-card #topbar,
  body.print-card #composer,
  body.print-card #reader,
  body.print-card #scrim,
  body.print-card #lightbox,
  body.print-card #palette,
  body.print-card .toast { display: none !important; }
  body.print-card #main { display: block !important; height: auto !important; background: #fff !important; }
  /* scroll containers clip print output to one page — flatten them */
  body.print-card #thread { overflow: visible !important; height: auto !important; padding: 0 !important; }
  body.print-card .thread-inner { max-width: none !important; }
  body.print-card .thread-inner > :not(.print-turn) { display: none !important; }
  body.print-card .print-turn > :not(.print-target) { display: none !important; }

  body.print-card .card.print-target {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
    animation: none !important;
    overflow: visible !important;
  }
  body.print-card .card.print-target,
  body.print-card .card.print-target * { color: #000 !important; }
  body.print-card .card.print-target .card-icon,
  body.print-card .card.print-target .tag,
  body.print-card .card.print-target .ui-chip,
  body.print-card .card.print-target .callout,
  body.print-card .card.print-target .fact,
  body.print-card .card.print-target .facts,
  body.print-card .card.print-target .step-n,
  body.print-card .card.print-target .src-chip,
  body.print-card .card.print-target .src-chip .src-n,
  body.print-card .card.print-target .related-chip,
  body.print-card .card.print-target .card-foot { background: #fff !important; }
  /* on-screen affordances have no meaning on paper */
  body.print-card .card.print-target .card-actions,
  body.print-card .card.print-target .fb-row,
  body.print-card .card.print-target .fb-thanks { display: none !important; }

  body.print-card .card.print-target img {
    max-width: 12cm !important;
    max-height: 12cm !important;
    width: auto !important;
    height: auto !important;
  }
  body.print-card .card.print-target .fig-strip { flex-wrap: wrap; overflow: visible !important; }
  body.print-card .card.print-target .fig,
  body.print-card .card.print-target .step,
  body.print-card .card.print-target .callout { break-inside: avoid; }
}

/* ==================================================================== *
 * v5 (CONTRACT-V5, Owner B)
 *
 * 1. Language switcher (§2.7): globe button in the topbar + a small
 *    anchored menu. 2. Hotline block (§2.3) on notfound cards — quiet,
 *    matches the card design, nothing alarming. 3. EXT source chips
 *    (§2.4): non-interactive editorial extensions. 4. Starters note.
 * ==================================================================== */

/* ---- language menu ------------------------------------------------- */
.topbar-actions { position: relative; }

.lang-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  min-width: 200px;
  padding: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  animation: rise 140ms var(--ease) both;
}

.lang-menu-title {
  padding: 6px 10px 5px;
  font-size: 10.5px; font-weight: 590;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
}

.lang-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--r-xs);
  font-size: 13px; color: var(--text);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.lang-item:hover { background: var(--bg-hover); }
.lang-item .lang-item-label { flex: 1; min-width: 0; }
.lang-item .lang-item-hint {
  font-family: var(--mono); font-size: 10px;
  color: var(--text-3); letter-spacing: .05em;
}
.lang-item .lang-item-check {
  width: 15px; height: 15px; flex: none;
  display: grid; place-items: center;
  color: var(--accent);
}
.lang-item.active { color: var(--accent); font-weight: 550; }

/* ---- hotline block on notfound cards (§2.3) ------------------------ */
.card-section.support-block { padding-top: 14px; }

.support-lead {
  margin: 8px 0 10px;
  font-size: 13px; line-height: 1.55;
  color: var(--text-2);
}

.support-rows { display: flex; flex-wrap: wrap; gap: 8px; }

.support-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px;
  border-radius: 15px;
  border: 1px solid var(--hairline);
  background: var(--bg-elev);
  font-size: 12.5px; font-weight: 500; color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.support-chip:hover { border-color: var(--accent-line); color: var(--accent); text-decoration: none; }
.support-chip .icon { color: var(--text-3); flex: none; }
.support-chip:hover .icon { color: var(--accent); }
.support-chip .support-region {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .05em; color: var(--text-3);
}
.support-chip .support-number { font-variant-numeric: tabular-nums; }

.support-hours {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px;
  font-size: 12px; color: var(--text-3);
}
.support-hours .icon { flex: none; }

/* ---- EXT source chips (§2.4): editorial, not clickable ------------- */
span.src-chip.ext { cursor: default; border-style: dashed; }
span.src-chip.ext:hover { border-color: var(--hairline); color: var(--text-2); }
span.src-chip.ext .src-manual { color: var(--accent); }

/* ---- starters stay German — one quiet explanatory line (§2.7) ------ */
.starters-note {
  margin: 10px 2px 0;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: center;
}
