/* Figtree (SIL Open Font License, web/fonts/OFL.txt): latin subset, all weights in one variable file */
@font-face {
  font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url("/fonts/figtree-latin.woff2") format("woff2");
}

:root {
  /* "Salbei": warm paper tones, a sage accent that picks up Lyra's eyes */
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #eeede6;
  --text: #1f2427;
  --muted: #5c6469;
  --border: #e2e0d7;
  --accent: #2f7d6d;
  --accent-text: #ffffff;
  --accent-soft: #ddefe9;
  --user-bubble: #2f7d6d;
  --user-text: #ffffff;
  --danger: #b4372e;
  --ok: #2e7d4f;
  --warn: #9a5b08;
  --on-danger: #ffffff;
  --act-soft: #f7e4dc; --act: #a5412c;
  --info-soft: #e3eaee; --info: #3a5f73;
  --done-soft: #dff0e5;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(31, 36, 39, .06), 0 4px 16px rgba(31, 36, 39, .05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 58px;
  color-scheme: light;
}

/* Dark follows the system unless this device chose a theme (data-theme on <html>, see the head of index.html). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141819;
    --surface: #1b2022;
    --surface-2: #252b2e;
    --text: #e9edeb;
    --muted: #9aa5a7;
    --border: #30383b;
    --accent: #6cc4af;
    --accent-text: #0f201c;
    --accent-soft: #1e3832;
    --user-bubble: #2b6357;
    --user-text: #f0faf7;
    --danger: #f08a80;
    --ok: #6ccb8f;
    --warn: #e8b05a;
    --on-danger: #2a0f0c;
  --act-soft: #3a2420; --act: #f2a28f;
  --info-soft: #1f2c33; --info: #9fc2d4;
  --done-soft: #1c3226;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141819;
  --surface: #1b2022;
  --surface-2: #252b2e;
  --text: #e9edeb;
  --muted: #9aa5a7;
  --border: #30383b;
  --accent: #6cc4af;
  --accent-text: #0f201c;
  --accent-soft: #1e3832;
  --user-bubble: #2b6357;
  --user-text: #f0faf7;
  --danger: #f08a80;
  --ok: #6ccb8f;
  --warn: #e8b05a;
  --on-danger: #2a0f0c;
  --act-soft: #3a2420; --act: #f2a28f;
  --info-soft: #1f2c33; --info: #9fc2d4;
  --done-soft: #1c3226;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
#app { height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.02rem; margin-top: .2em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1.4em; }

/* buttons & inputs */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .6em 1em; border-radius: 12px; font: inherit; font-weight: 550; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: .35em .7em; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn.icon { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%; flex: none; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: .6em .8em; width: 100%; min-width: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { display: block; margin: .6em 0; text-align: left; }
.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2em; }
.row { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; margin-top: .6em; }
.row input { flex: 1; }
.stack { display: flex; flex-direction: column; gap: .5em; margin-top: .5em; }

/* topbar & tabbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1em;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5em; font-weight: 700; font-size: 1.1rem; }
.topbar-sub { color: var(--muted); font-size: .85rem; text-align: right; }
.topbar-right { display: flex; align-items: center; gap: .6em; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; }
.page { overflow-y: auto; padding: 20px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px); max-width: 720px; width: 100%; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom); height: calc(var(--tabbar-h) + var(--safe-bottom));
}
.tabbar button {
  position: relative; flex: 1; border: 0; background: none; color: var(--muted); font: inherit; font-size: .72rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--accent); }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); background: var(--danger); color: var(--on-danger);
  font-size: .68rem; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; line-height: 18px;
}

/* chat */
.chat { display: flex; flex-direction: column; }
.messages {
  flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px;
  max-width: 760px; width: 100%; margin: 0 auto;
}
/* nothing in a stream may shrink when it fills up: a one-line note (overflow hidden) would collapse to a sliver */
.messages > *, .fold-body > * { flex-shrink: 0; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: var(--radius); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user-bubble); color: var(--user-text); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.msg.assistant p { margin: 0 0 .6em; }
.msg.assistant[data-done] { cursor: pointer; }
.msg-actions { display: flex; gap: .4em; margin-top: .6em; padding-top: .5em; border-top: 1px solid var(--border); }
.msg.assistant p:last-child, .msg.assistant ul:last-child, .msg.assistant ol:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 .6em; padding-left: 1.3em; }
.msg.assistant code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; font-size: .9em; }
.msg.assistant pre { background: var(--surface-2); padding: .7em; border-radius: 10px; overflow-x: auto; }
.msg.assistant pre code { background: none; padding: 0; }
.code-block { position: relative; margin: 0 0 .6em; }
.code-block:last-child { margin-bottom: 0; }
.code-block pre, .msg.assistant .code-block pre {
  margin: 0; padding: 2.4em .7em .7em; background: var(--surface-2); border-radius: 10px; overflow-x: auto; }
.code-copy {
  position: absolute; top: .4em; right: .4em; font: inherit; font-size: .75rem; line-height: 1;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .45em .7em; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.code-copy:hover { color: var(--accent); border-color: var(--accent); }
.copying .code-copy { display: none; }
.msg.assistant a { color: var(--accent); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { font-size: .75rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }
.chip.live::after { content: " …"; }
.note { align-self: center; font-size: .8rem; color: var(--muted); background: var(--surface-2); padding: 4px 12px; border-radius: 999px; text-align: center; max-width: 90%; }
.sysline { max-width: min(90%, 560px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sysline.expandable { cursor: pointer; }
.sysline:has(.sysline-more:not([hidden])) { white-space: normal; border-radius: 12px; text-align: left; }
.sysline-label { font-weight: 600; }
.sysline-label .ic { width: 15px; height: 15px; vertical-align: -.2em; margin-right: 4px; }
.sysline-time { font-variant-numeric: tabular-nums; }
.sysline:has(.sysline-more:not([hidden])) .sysline-gist.cut { display: none; } /* the full text replaces its start */
.sysline.approved .sysline-label { color: var(--ok); }
.sysline.failed .sysline-label { color: var(--danger); }
.sysline.routine .sysline-label, .sysline.overview-note .sysline-label { color: var(--accent); }
.sysline-more { margin-top: 4px; display: grid; gap: 2px; white-space: pre-wrap; }
.day-empty { margin: auto; text-align: center; color: var(--muted); max-width: 320px; }
.day-empty img { opacity: .9; margin-bottom: .6em; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.inline-approval { border: 1px dashed var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 8px 10px; margin-top: 8px; font-size: .9rem; }
.inline-approval a { color: var(--accent); font-weight: 600; }
.msg-error { align-self: center; color: var(--danger); font-size: .88rem; }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  max-width: 760px; width: 100%; margin: 0 auto;
}
.composer textarea { overflow-y: hidden; resize: none; max-height: 40vh; border-radius: 22px; padding: .65em 1em; line-height: 1.4; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.item { display: flex; gap: .6em; align-items: flex-start; justify-content: space-between; padding: .5em 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.pre { white-space: pre-wrap; }
.approval { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.approval.focus { outline: 2px solid var(--accent); }
.approval .meta { font-size: .8rem; color: var(--muted); margin-bottom: .3em; }
.approval pre { white-space: pre-wrap; font-size: .82rem; background: var(--surface-2); padding: .6em; border-radius: 10px; margin: .5em 0 0; max-height: 240px; overflow: auto; }
.status { font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); }
.status.ok { color: var(--ok); } .status.error { color: var(--danger); } .status.running { color: var(--warn); }

/* login */
.login { display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-logo { margin-bottom: .4em; }
.login-card details { margin-top: 1.4em; text-align: left; }
.login-card summary { cursor: pointer; color: var(--muted); text-align: center; }

/* ---------- Lyra avatar & header ---------- */
/* Lyra stays a small portrait in the header; the caption beside it says what she is doing. */
.stage {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface); width: 100%;
}
.stage-text { display: flex; flex-direction: column; min-width: 0; }
.stage-name { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.caption { color: var(--accent); font-size: .85rem; min-height: 1.3em; transition: opacity .2s; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caption:empty::before { content: attr(data-idle); color: var(--muted); }

.avatar { width: 44px; height: 44px; flex: none; cursor: pointer; }
.lyra-svg { width: 100%; height: 100%; overflow: visible; display: block; }
.lyra-svg * { transform-box: fill-box; transform-origin: center; }
.lyra-svg .halo { animation: lyra-breathe 4.5s ease-in-out infinite; opacity: .75; transition: opacity .4s; }
.lyra-svg .body { animation: lyra-float 6s ease-in-out infinite; }
.lyra-svg .orbit { opacity: 0; transform-origin: 100px 100px; transform-box: view-box; transition: opacity .4s; }
.lyra-svg .eyes { transition: transform .45s cubic-bezier(.3,.7,.4,1); }
.lyra-svg .eye { transition: transform .12s ease; }
.lyra-svg .smile { transition: opacity .2s, transform .3s; }
.lyra-svg .mouth { opacity: 0; transition: opacity .15s; }
.lyra-svg .stars { transition: opacity .6s; }
.lyra-svg .vega { animation: lyra-twinkle 3.2s ease-in-out infinite; }
.avatar.blink .eye { transform: scaleY(.08); }

.avatar[data-state="listening"] .halo { opacity: 1; animation-duration: 2.4s; }
.avatar[data-state="listening"] .eye { transform: scale(1.12); }
.avatar[data-state="thinking"] .orbit { opacity: 1; animation: lyra-spin 5s linear infinite; }
.avatar[data-state="thinking"] .stars { opacity: .85; }
.avatar[data-state="working"] .orbit { opacity: 1; animation: lyra-spin 1.8s linear infinite; }
.avatar[data-state="working"] .halo { animation-duration: 1.6s; opacity: 1; }
.avatar[data-state="speaking"] .smile { opacity: 0; }
.avatar[data-state="speaking"] .mouth { opacity: 1; }
.avatar[data-state="speaking"] .halo { opacity: calc(.7 + var(--talk, 0) * .3); }
.avatar[data-state="waiting"] .halo { filter: hue-rotate(175deg) saturate(1.6); animation-duration: 1.8s; opacity: 1; }
.avatar[data-state="sad"] .eye { transform: scaleY(.55) translateY(3px); }
.avatar[data-state="sad"] .smile { transform: translateY(6px) scaleY(-1); }

@keyframes lyra-breathe { 0%, 100% { transform: scale(.9); } 50% { transform: scale(1.03); } }
@keyframes lyra-float { 0%, 100% { transform: translateY(1.5px); } 50% { transform: translateY(-2.5px); } }
@keyframes lyra-spin { to { transform: rotate(360deg); } }
@keyframes lyra-twinkle { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .lyra-svg .halo, .lyra-svg .body, .lyra-svg .vega, .avatar .orbit { animation: none !important; }
}
.avatar-hi { animation: lyra-hop .6s ease; }
@keyframes lyra-hop { 30% { transform: translateY(-6px) rotate(-4deg); } 60% { transform: translateY(0) rotate(3deg); } }

/* photorealistic avatar */
.avatar.photo { border-radius: 50%; padding: 3px; transition: width .35s ease, height .35s ease, box-shadow .4s ease; box-shadow: 0 0 0 2px var(--border); }
.photo-frame { position: relative; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.photo-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .6s ease; }
.photo-frame img.on { opacity: 1; }
.avatar.photo[data-state="listening"] { box-shadow: 0 0 0 3px var(--accent); }
.avatar.photo[data-state="thinking"],
.avatar.photo[data-state="working"] { box-shadow: 0 0 0 3px var(--accent); animation: photo-ring 1.8s ease-in-out infinite; }
.avatar.photo[data-state="speaking"] { box-shadow: 0 0 0 3px var(--accent), 0 0 22px 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.avatar.photo[data-state="waiting"] { box-shadow: 0 0 0 3px var(--warn); }
.avatar.photo[data-state="sad"] { box-shadow: 0 0 0 3px var(--danger); }
@keyframes photo-ring { 50% { box-shadow: 0 0 0 3px var(--accent), 0 0 18px 3px color-mix(in srgb, var(--accent) 40%, transparent); } }
@media (prefers-reduced-motion: reduce) { .avatar.photo { animation: none !important; } }

/* ---------- threads (lyra/threads.py) ---------- */
.msg { position: relative; }
.reply-btn {
  display: grid; place-items: center; position: absolute; top: 50%; right: -38px; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; padding: 0;
  border: 1px solid var(--border); background: var(--surface); color: var(--accent); font: inherit; font-weight: 700;
  cursor: pointer; opacity: 0; transition: opacity .15s; box-shadow: var(--shadow);
}
.msg.user .reply-btn { right: auto; left: -38px; }
.reply-btn:hover { background: var(--accent-soft); }
@media (hover: hover) and (pointer: fine) { .msg:hover .reply-btn, .reply-btn:focus-visible { opacity: 1; } }
@media (pointer: coarse) { .reply-btn { display: none; } }
.thread-link { display: block; margin-top: 6px; font-size: .82rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.msg.user .thread-link { color: var(--user-text); opacity: .9; }
.thread-link:hover { text-decoration: underline; }
/* an exchange that moved into a thread: one line in the main stream, the arrow shows it here again */
.fold-wrap { display: flex; flex-direction: column; gap: 10px; }
.fold {
  display: flex; align-items: center; gap: 4px; align-self: stretch; padding: 2px 4px 2px 12px; border-radius: 12px;
  border: 1px dashed var(--border); background: var(--surface); font-size: .85rem;
}
.fold-line { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; padding: 6px 0; color: var(--accent);
  font-weight: 600; text-decoration: none; }
.fold-line:hover .fold-text { text-decoration: underline; }
.fold-icon { flex: none; }
.fold-text { min-width: 0; display: flex; flex-direction: column; }
.fold-question, .fold-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fold-meta { font-size: .78rem; font-weight: 500; color: var(--muted); }
@media (min-width: 600px) {  /* room enough: the whole line in one */
  .fold-text { flex-direction: row; }
  .fold-question { flex: 0 1 auto; }
  .fold-meta { flex: none; font-size: inherit; }
}
.fold.done { background: transparent; }
.fold.done .fold-line { color: var(--muted); font-weight: 500; }
.fold-toggle {
  flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted);
  font: inherit; font-size: 1rem; cursor: pointer; transition: transform .15s; display: grid; place-items: center;
}
.fold-toggle:hover { background: var(--accent-soft); }
.fold-toggle[aria-expanded="true"] { transform: rotate(90deg); }
.fold-body { display: flex; flex-direction: column; gap: inherit; padding-left: 10px; border-left: 2px solid var(--border); }
.fold-body[hidden] { display: none; }
.thread-anchor {
  margin: 0 0 4px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2);
  border-radius: 0 12px 12px 0; font-size: .85rem; color: var(--muted); max-height: 9.5em; overflow: auto; overflow-wrap: anywhere;
}
.incoming { margin: 0 0 6px; padding: 10px 14px 12px; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 0 14px 14px 0; background: var(--surface-2); overflow-wrap: anywhere; }
.incoming-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.incoming-head .kind { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.incoming-head .kind .ic { width: 15px; height: 15px; }
.incoming-meta { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.incoming-ref { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.incoming-text { white-space: pre-wrap; font-size: .95rem; line-height: 1.45; }
.incoming .msg-photos { margin: 8px 0 0; }
.incoming .msg-photos img.photo { max-width: 240px; max-height: 240px; }
@media (max-width: 600px) { .incoming .msg-photos img.photo { max-width: 96px; max-height: 96px; } }
.thread-anchor p { margin: 0 0 .4em; } .thread-anchor p:last-child { margin: 0; }
.stage-tools .chat-toggle { display: none; }  /* narrow screens: the chat is the home view */
.threads-toggle .count, .chat-toggle .count { background: var(--accent); color: var(--accent-text); border-radius: 9px; min-width: 18px; padding: 0 5px; font-size: .7rem; line-height: 18px; text-align: center; }

.thread-list { display: none; flex-direction: column; gap: 6px; padding: 12px; min-height: 0; }
.thread-list-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 4px; }
.thread-list-head b { flex: 1; font-size: .95rem; }
.threads { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.thread-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 12px; color: var(--text); text-decoration: none; }
.thread-item:hover { background: var(--surface-2); }
.thread-item.active { background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.thread-kind { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; }
.thread-kind .ic { width: 18px; height: 18px; }
.thread-item.has-approval .thread-kind, .thread-item.unread .thread-kind { background: var(--accent-soft); color: var(--accent); }
.thread-item.waiting .thread-kind { color: var(--muted); }
.thread-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.thread-group { display: flex; justify-content: space-between; margin: 12px 8px 4px; font-size: .72rem; font-weight: 650;
  letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.thread-group:first-child { margin-top: 2px; }
.thread-group span { font-weight: 700; }
.thread-group.needs { color: var(--accent); }
.thread-item-title { font-size: .9rem; font-weight: 550; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thread-item-meta { font-size: .74rem; color: var(--muted); }
.thread-item.unread .thread-item-title { font-weight: 750; }
.thread-item.unread .thread-item-title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.thread-empty { padding: 4px; }
#btn-thread-archived { align-self: flex-start; color: var(--muted); }

.thread-panel { display: none; flex-direction: column; min-height: 0; background: var(--bg); }
.thread-head { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; border-bottom: 1px solid var(--border); }
.thread-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.thread-panel .messages { max-width: none; }
.thread-panel .msg { max-width: 92%; }

/* phones and narrow windows: the list and an open thread cover the chat */
.chat.list-open .thread-list {
  display: flex; position: fixed; inset: 0; z-index: 10; background: var(--bg);
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px); padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
}
.chat.thread-open .thread-panel { display: flex; position: fixed; inset: 0; z-index: 11; }
.chat.thread-open .thread-panel .composer { padding-bottom: calc(var(--safe-bottom) + 8px); }

/* wide screens (keep in sync with SIDE_BY_SIDE in app.js): the header with Lyra across the top, the threads on the
   left, the open thread (or what is running) in the middle, the main stream on the right once the speech bubble opens it. */
@media (min-width: 900px) and (min-height: 520px) and (min-aspect-ratio: 5/4) {
  .chat {
    display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: 100%;
  }
  .chat .overview-panel { display: flex; grid-column: 2; grid-row: 2 / -1; }
  .chat .overview-panel > * { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
  .chat.thread-open .overview-panel { display: none; }
  .chat .stage { grid-column: 1 / -1; grid-row: 1; padding: 10px 16px 10px 20px; }
  .chat .threads-toggle { display: none; }
  .chat .thread-list, .chat.list-open .thread-list {
    display: flex; position: static; grid-column: 1; grid-row: 2 / -1; z-index: auto; background: var(--bg);
    border-right: 1px solid var(--border); padding: 14px 10px 12px;
  }
  .only-narrow { display: none !important; }
  .chat .messages { grid-column: 2; grid-row: 2; padding-top: 20px; }
  .chat .above-composer { grid-column: 2; grid-row: 3; }
  .chat .composer { grid-column: 2; grid-row: 4; }
  .chat .thread-panel, .chat.thread-open .thread-panel {
    position: static; grid-column: 2; grid-row: 2 / -1; z-index: auto; background: var(--surface);
  }
  /* the main stream waits behind the speech bubble; opened, it takes the right column */
  .chat .stage-tools .chat-toggle { display: inline-flex; }
  .chat .chat-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
  .chat:not(.chat-open) #messages, .chat:not(.chat-open) > .above-composer, .chat:not(.chat-open) #composer { display: none; }
  .chat.chat-open, .chat.chat-open.thread-open { grid-template-columns: 300px minmax(0, 1fr) minmax(360px, 440px); }
  .chat #messages, .chat > .above-composer, .chat #composer { grid-column: 3; border-left: 1px solid var(--border); }
  .chat #messages { padding-left: 16px; padding-right: 16px; }
  .chat.thread-open .thread-panel .composer { padding-bottom: calc(var(--safe-bottom) + 8px); }
  .thread-head { padding-top: 12px; }
}

.msg.assistant.reminder { border-color: var(--accent); background: var(--accent-soft); }

/* voice mode */
.mic.recording { background: var(--danger); color: var(--on-danger); border-color: transparent; animation: mic-pulse 1.2s ease-in-out infinite; }
.mic.busy { opacity: .6; }
.mic.talking:not(.recording) { background: var(--accent); color: var(--accent-text); border-color: transparent; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 25%, transparent); } }
.voice-toggle {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .82rem; cursor: pointer;
}
.voice-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
@media (prefers-reduced-motion: reduce) { .mic.recording { animation: none; } }

/* memory: profiles Lyra keeps */
.profile { border-top: 1px solid var(--border); padding: .45em 0; }
.profile summary { cursor: pointer; list-style: none; }
.profile summary::-webkit-details-marker { display: none; }
.profile[open] summary { margin-bottom: .4em; }
.profile-kind { margin-top: .8em; text-transform: uppercase; letter-spacing: .04em; }
.profile-edit { width: 100%; font: inherit; font-size: .9rem; padding: .5em; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: inherit; }

/* photos */
.attach { flex: none; }
/* receipt stack: photographed receipts wait above the composer until Ralph sends them */
.receipt-tray { padding: 8px 12px 0; max-width: 760px; width: 100%; margin: 0 auto; }
.receipt-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.receipt-more { flex: none; width: 64px; height: 64px; border-radius: 10px; border: 1px dashed var(--border); background: none;
  color: inherit; display: grid; place-items: center; cursor: pointer; }
.receipt-pdf { width: 100%; height: 100%; display: grid; place-items: center; }
.receipt-actions { display: flex; gap: 8px; align-items: center; }
.approval-summary { white-space: pre-line; }
.receipt-choices { display: flex; flex-direction: column; gap: 2px; }
.receipt-head { font-weight: 600; margin-bottom: 4px; }
.receipt-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.receipt-row.unklar { background: var(--accent-soft); }
.receipt-who { flex: none; width: auto; min-width: 92px; margin: 0; font: inherit; padding: .3em .5em; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: inherit; }
.receipt-who-done { flex: none; font-weight: 600; }
@media (max-width: 480px) {  /* phone: photo and receipt buttons side by side leave the text box its width */
  .composer .attach { width: 36px; margin-right: -4px; }
}
.attachments { display: flex; gap: 8px; padding: 8px 12px 0; max-width: 760px; width: 100%; margin: 0 auto; overflow-x: auto; }
.attachment { position: relative; flex: none; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.attachment img { width: 100%; height: 100%; object-fit: cover; }
.attachment.uploading img { opacity: .45; }
.attachment.uploading::after { content: "…"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; }
.attachment-remove { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 20px; padding: 0; cursor: pointer; }
.msg-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.msg-photos + div { margin-top: 2px; }
img.photo { display: block; max-width: min(260px, 100%); max-height: 260px; border-radius: 12px; object-fit: cover; }
.msg-photos img.photo { max-width: 160px; max-height: 160px; }
.photo-link { display: inline-block; margin: 4px 0; }

.composer.dragging { outline: 2px dashed var(--accent, #7c8cff); outline-offset: 4px; }

.reading .row { margin-top: .5em; }
.info-lines { margin: 0; padding-left: 1.1em; }
.info-lines li { margin: .25em 0; }
.info-lines a { color: inherit; }
.highlights { margin: .2em 0 .5em; padding-left: 1.1em; font-weight: 600; }
.reading details { margin-top: .4em; }

/* Results of the specialist managers on Ralph's Mac (#fach/<id>) */
.fach-dialog { width: min(760px, calc(100vw - 24px)); max-height: 86vh; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 16px; box-shadow: var(--shadow); }
.fach-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.fach-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.fach-md { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.report-frame { width: 100%; height: min(78vh, 900px); border: 0; border-radius: 10px; background: var(--bg, #fff); }

/* Tables of the managers: scroll sideways inside their own box on a phone, figures right-aligned and aligned digits */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5em 0; border: 1px solid var(--border);
  border-radius: 10px; max-width: 100%; }
.table-wrap table { border-collapse: collapse; font-size: 13px; width: 100%; overflow-wrap: normal; }
.table-wrap th, .table-wrap td { border-bottom: 1px solid var(--border); padding: 6px 10px; text-align: left;
  vertical-align: top; white-space: nowrap; }
.table-wrap th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td:first-child, .table-wrap th:first-child { position: sticky; left: 0; background: var(--surface); }
.table-wrap th:first-child { background: var(--surface-2); }
.table-wrap .num { text-align: right; font-variant-numeric: tabular-nums; }
.md-h { font-weight: 650; margin: .9em 0 .2em; }
.md-h:first-child { margin-top: 0; }

/* A finding in the fixed outline (lyra/befund.py): grade, key statement, figures, to-dos; details fold away */
.grade { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 650; letter-spacing: .01em;
  padding: 3px 10px 3px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.grade .ic { width: 14px; height: 14px; }
.grade-act { background: var(--act-soft); color: var(--act); }
.grade-info { background: var(--info-soft); color: var(--info); }
.grade-quiet { background: var(--surface-2); color: var(--muted); }
.grade-done { background: var(--done-soft); color: var(--ok); }
.befund { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.befund-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.befund-title { font-size: .82rem; color: var(--muted); font-weight: 500; min-width: 0; }
.befund-kern { font-size: 1.02rem; line-height: 1.45; font-weight: 500; }
.befund-kern p { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.tile-v { font-size: 1.3rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-l { font-size: .78rem; font-weight: 600; margin-top: 3px; line-height: 1.25; }
.tile-h { font-size: .74rem; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.befund-act .tile-v { color: var(--act); }
.befund-label { display: flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.befund-todo ul, .befund-todo ol { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.befund-todo li { position: relative; padding-left: 18px; }
.befund-todo li::before { content: ""; position: absolute; left: 3px; top: .55em; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); }
.befund-act .befund-todo li::before { background: var(--act); }
.befund-todo p { margin: 0; }
.befund-details { border-top: 1px solid var(--border); }
.bf-fold { border-bottom: 1px solid var(--border); }
.bf-fold:last-child { border-bottom: 0; }
.bf-fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 2px;
  font-size: .86rem; font-weight: 600; color: var(--muted); }
.bf-fold > summary::-webkit-details-marker { display: none; }
.bf-fold > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 2px; }
.bf-fold[open] > summary::before { transform: rotate(45deg); }
.bf-fold[open] > summary { color: var(--text); }
.bf-fold-body { padding: 0 2px 10px; font-size: .92rem; min-width: 0; }
.bf-fold-body > :first-child { margin-top: 0; }
.verdict { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; }
.verdict .grade { align-self: center; }
.cc-grade { display: flex; }
.befund-foot { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: .9rem; }
.befund-foot p { margin: 0; }
.fach-task, .fach-file { border-top: 1px solid var(--border); padding: 8px 0; font-size: 14px; }
.fach-task summary, .fach-file summary { cursor: pointer; color: var(--muted); }
.fach-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 10px 0; }
.fach-media img, .fach-media video { width: 100%; border-radius: 10px; background: var(--surface-2); }
.msg .fach-video { max-width: 100%; border-radius: 12px; }
.fach-media .photo-link { display: block; margin: 0; }
.photo-link.video { position: relative; }
.photo-link.video::after { content: "▶"; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; padding-left: 3px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 18px; pointer-events: none; }

/* Media lightbox: one message's or one order's photos and videos as a gallery */
.lightbox { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: rgba(0, 0, 0, .92); color: #fff; outline: none; overscroll-behavior: contain; }
.lightbox::backdrop { background: transparent; }
.lb-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.lb-stage img, .lb-stage video { max-width: calc(100vw - 128px); max-height: calc(100dvh - 112px); object-fit: contain; border-radius: 6px; }
.lb-btn { position: absolute; border: 0; border-radius: 50%; width: 44px; height: 44px; background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 26px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.lb-btn:hover, .lb-btn:focus-visible { background: rgba(255, 255, 255, .28); }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; font-size: 20px; }
.lb-count { position: absolute; top: calc(22px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  font-size: 14px; font-variant-numeric: tabular-nums; opacity: .85; }
.lightbox.single .lb-prev, .lightbox.single .lb-next, .lightbox.single .lb-count { display: none; }
@media (max-width: 600px) {  /* phone: swiping replaces most of the arrows' work, the medium gets the width */
  .lb-stage img, .lb-stage video { max-width: 100vw; max-height: calc(100dvh - 140px); border-radius: 0; }
  .lb-prev, .lb-next { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); transform: none; }
}

/* Ads-Lage (lyra/ads_lage.py): every shop at a glance */
.lage-card .lage-sum { margin: .4em 0; font-size: .92rem; }
.lage-needs h4 { margin: .8em 0 .3em; font-size: .9rem; }
.lage-need { border-left: 3px solid var(--warn); padding: 4px 10px; margin: 6px 0; font-size: .9rem; }
.lage-need .msg-body { margin-top: 3px; color: var(--text); }
.lage-scroll { overflow-x: auto; margin: 10px -4px 6px; }
table.lage { border-collapse: collapse; font-size: .84rem; width: 100%; white-space: nowrap; }
table.lage th { text-align: left; font-weight: 600; color: var(--muted); font-size: .74rem; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.lage td { padding: 5px 6px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; vertical-align: middle; }
table.lage td.shop { font-weight: 600; position: sticky; left: 0; background: var(--surface); }
table.lage tr.ampel-rot td.shop { color: var(--danger); }
table.lage td.below { color: var(--warn); font-weight: 600; }
.delta { font-size: .76rem; color: var(--muted); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
svg.spark { width: 96px; height: 26px; display: block; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark-target { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 2; opacity: .7; }
.lage-need.ampel-rot { border-left-color: var(--danger); }
#view-lesen { max-width: 1060px; } /* room for the Ads-Lage table with its curves */
@media (max-width: 700px) {  /* phone: one compact tile per shop instead of a wide table */
  .lage-scroll { overflow: visible; margin: 8px 0; }
  table.lage, table.lage tbody { display: block; }
  table.lage thead { display: none; }
  table.lage tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.lage td { display: block; border: 0; padding: 0; white-space: normal; }
  table.lage td.shop { position: static; grid-column: 1 / 3; grid-row: 1; align-self: center; }
  table.lage td.curve { grid-column: 3; grid-row: 1; justify-self: end; }
  table.lage td:nth-child(6) { grid-column: 2 / 4; } /* revenue of the 7 days next to their ROAS */
  table.lage td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .7rem; font-weight: 500; }
}

/* one page (no tab bar): threads are the tasks; settings behind the icon in the header */
:root { --tabbar-h: 0px; }
#tabbar { display: none !important; }
.brand #btn-back { margin-right: 4px; }
.thread-filter { display: flex; gap: 4px; padding: 0 4px 6px; }
.thread-filter button { flex: 1; border: 1px solid var(--border); background: transparent; color: var(--muted); border-radius: 999px;
  padding: 4px 10px; font: inherit; font-size: .82rem; cursor: pointer; }
.thread-filter button.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.thread-filter b { font-weight: 700; }
.thread-item.waiting .thread-item-title { color: var(--muted); }
.thread-item.status-erledigt .thread-item-title, .thread-item.status-abgelehnt .thread-item-title { color: var(--muted); }
.status-pill { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.status-pill[data-status="erledigt"] { color: var(--ok); }
.status-pill[data-status="abgelehnt"] { color: var(--danger); }
.thread-karte .btn-read { display: none; } /* in a thread, "Erledigt" on the thread marks it read */
.thread-karte .approval, .thread-panel .approval { margin: 4px 0; }

/* ---------- icons (web/icons.js) & theme ---------- */
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.25em; }
.ic.sm, .small .ic, .reply-btn .ic, .fold .ic, .thread-link .ic, .note .ic, .status-pill .ic { width: 16px; height: 16px; }
[data-icon] { display: inline-flex; }
.with-icon { display: inline-flex; align-items: center; gap: 6px; }
/* the round buttons on the stage: icon only, the name sits in the tooltip */
.voice-toggle.icon-only { padding: 0; width: 38px; height: 38px; justify-content: center; position: relative; }
.voice-toggle.icon-only .count { position: absolute; top: -4px; right: -4px; }
.stage-tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.stage-tools .voice-toggle { margin: 0; }
.thread-item-meta .ic { width: 13px; height: 13px; vertical-align: -.15em; margin-right: 2px; }
.fold-icon { display: inline-flex; align-self: center; }
.ampel { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: .05em; }
.ampel.gruen { background: var(--ok); } .ampel.gelb { background: var(--warn); } .ampel.rot { background: var(--danger); }
.theme-switch { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; width: fit-content; }
.theme-switch button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 6px 12px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.btn.icon-btn { padding: .4em; display: inline-grid; place-items: center; line-height: 0; }
.btn.with-icon, .thread-filter .with-icon { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.lb-btn .ic { width: 24px; height: 24px; }

/* settings in three areas; the bar on top jumps to one */
.settings-nav { position: sticky; top: -20px; z-index: 2; display: flex; gap: 4px; padding: 6px 0 10px; background: var(--bg); flex-wrap: wrap; }
.settings-nav button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.settings-nav button:hover { border-color: var(--accent); color: var(--accent); }
.settings-group { scroll-margin-top: 56px; margin-top: 18px; }
.settings-group-title { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; margin: 0; }
.settings-group-title .ic { color: var(--accent); }
.settings-group > .muted { margin: .3em 0 0; }

/* ---------- context of a thread and "Läuft gerade" (lyra/kontext.py) ---------- */
.ctx { display: flex; flex-direction: column; gap: 6px; flex: none; max-height: 30%; overflow-y: auto; padding: 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg); font-size: .85rem; }
.ctx .ov-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.ctx .wait-row { align-items: center; }
.ctx .wait-row .grow { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx .kind { width: 24px; height: 24px; }
.approval.ask { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* a thread as one timeline: days, who wrote (others left, Ralph right), agents as lines, the draft at the end */
.day-sep { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; color: var(--muted); font-size: .75rem; font-weight: 650;
  letter-spacing: .04em; text-transform: uppercase; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.clamp.open { display: block; -webkit-line-clamp: unset; }
.more-btn { align-self: flex-start; border: 0; background: none; padding: 2px 0 0; font: inherit; font-size: .8rem; font-weight: 600;
  color: var(--accent); cursor: pointer; }
.msg.user .more-btn { color: var(--user-text); opacity: .85; }
.thread-panel .incoming { align-self: flex-start; max-width: 86%; display: flex; flex-direction: column; }
.msg.sent { display: flex; flex-direction: column; gap: 4px; white-space: normal; }
.sent-head { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 650; opacity: .9; }
.sent-meta { margin-left: auto; padding-left: 10px; font-weight: 500; font-size: .75rem; opacity: .8; white-space: nowrap; }
.sent-text { white-space: pre-wrap; }
.msg.sent.rejected { background: transparent; color: var(--muted); border: 1px dashed var(--border); }
.agent-entry { align-self: flex-start; max-width: 92%; display: flex; flex-direction: column; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); padding: 8px 14px 10px; }
.agent-head { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.agent-entry .kind { width: 24px; height: 24px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.agent-entry .sent-meta { color: var(--muted); }
.agent-entry.failed .kind { color: var(--danger); }
.agent-body { padding-top: 6px; overflow-wrap: anywhere; }
.agent-body p { margin: .5em 0; } .agent-body > :first-child { margin-top: 0; } .agent-body > :last-child { margin-bottom: 0; }
.clamp-h { max-height: 18em; overflow: hidden; }
.clamp-h.cut { -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.clamp-h.open { max-height: none; -webkit-mask-image: none; mask-image: none; }
.approval.draft { border: 1.5px dashed var(--accent); box-shadow: none; }
.draft-label { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 650; color: var(--accent); }
.cc { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px; font-size: .9rem; overflow-wrap: anywhere; }
.cc-h { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.cc .kind, .ov-row .kind { width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; flex: none; }
.grow { flex: 1; min-width: 0; }
.pill { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.run { color: var(--warn); } .pill.bad { color: var(--danger); }
.pill.ask { background: var(--accent-soft); color: var(--accent); }
.cc-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cc-thumbs .photo-link { margin: 0; }
.cc-thumbs img, .cc-thumbs video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
.cc-line { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.ctx a, .overview-panel a { color: var(--accent); font-weight: 600; text-decoration: none; }
.overview-panel { display: none; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 16px; background: var(--bg); }
.ov-title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.overview-panel .ov-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; color: var(--text); font-weight: 500; }
.ov-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ov-row:hover { background: var(--surface-2); }

/* a short note at the bottom with one action ("Erledigt · Rückgängig") */
.toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 84px);
  display: flex; align-items: center; gap: 14px; max-width: min(92vw, 520px); padding: 10px 12px 10px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); font-size: .92rem; }
.toast-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { flex: none; border: 0; border-radius: 9px; padding: 6px 12px; background: var(--accent-soft); color: var(--accent);
  font: inherit; font-weight: 700; cursor: pointer; }

/* approval cards: what goes out, in plain words (app.js approvalCard) */
.approval-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.approval-head .kind { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.approval-preview { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: .92rem; }
.approval-preview dt { color: var(--muted); font-size: .82rem; padding-top: .1em; }
.approval-preview dd { margin: 0; overflow-wrap: anywhere; }
.approval-preview dd.files { white-space: pre-line; }
.approval-warn { display: flex; color: var(--warn); font-weight: 600; margin: 8px 0 0; }
.approval-preview dd.long { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; max-height: 260px; overflow-y: auto; }
.approval-edit { width: 100%; box-sizing: border-box; font: inherit; color: inherit; background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 6px 10px; }
.approval-edit.long { white-space: pre-wrap; padding: 8px 10px; min-height: 120px; resize: vertical; line-height: 1.45; }
.approval-edit:hover { border-color: var(--border); }
.approval-edit:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.approval-tech { margin-top: 6px; }
.approval-tech pre { margin-top: 6px; }
.approval-status:empty { display: none; }
.approval-status { margin-top: 8px; font-size: .88rem; font-weight: 600; display: flex; align-items: center; gap: 2px; }
.approval-status.approved { color: var(--ok); }
.approval-status.failed { color: var(--danger); }
.approval-status.rejected, .approval-status.working { color: var(--muted); }
.approval-result { margin: 4px 0 0; }
.approval-change { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.approval-change textarea { resize: vertical; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
  display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* waiting list rows (lyra/wartet.py) */
.overview-panel .wait-row { align-items: flex-start; }
.wait-row .grow { display: flex; flex-direction: column; white-space: normal; }
.wait-row .grow > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-row b { font-weight: 600; }
.tick { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; }
.tick:hover { color: var(--ok); border-color: var(--ok); }

/* focus time (lyra/fokus.py) */
.focus-card.on { border-color: var(--accent); background: var(--accent-soft); }
.focus-card.on .kind { background: var(--surface); color: var(--accent); }
