/* Claude Mobiel — een warme, rustige chat-UI in Claude-stijl.
   Terracotta-accent (#d97757), steenkleurige neutrals, automatisch licht bij
   systeemvoorkeur. Alle kleuren leven in CSS-var-tokens. */

:root {
  color-scheme: dark;
  --bg: #161210;
  --bg-soft: #1e1813;
  --bg-raised: #272019;
  --line: #362c23;
  --fg: #f3eae2;
  --fg-dim: #a9978a;
  --fg-dim-strong: #c3b3a5;
  --accent: #d97757;
  --accent-strong: #e69572;
  --accent-deep: #b6532f;
  --accent-soft: rgba(217, 119, 87, 0.16);
  --user-bubble: #3c2c21;
  --assistant-bubble: #241d16;
  --code-bg: #1a1410;
  --danger: #e0604f;
  --danger-soft: rgba(224, 96, 79, 0.14);
  --ok: #82ae7d;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --hl-bg: rgba(217, 119, 87, 0.34);
  --hl-fg: #ffe9dd;
  font-size: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #faf5ef;
    --bg-soft: #f2eae1;
    --bg-raised: #ffffff;
    --line: #e5d7c9;
    --fg: #2a2018;
    --fg-dim: #7d6a5a;
    --fg-dim-strong: #6b5a4b; /* 5,3:1 op --bg-soft; was 4,32:1 */
    --accent: #bb5a35;
    --accent-strong: #a84e2c;
    --accent-deep: #96411f;
    --accent-soft: rgba(187, 90, 53, 0.13);
    --user-bubble: #f3e0d0;
    --assistant-bubble: #ffffff;
    --code-bg: #f4ede4;
    --danger: #c0392b;
    --danger-soft: rgba(192, 57, 43, 0.10);
    --ok: #3f7d43;
    --shadow: 0 10px 30px rgba(90, 55, 25, 0.16);
    --hl-bg: rgba(217, 119, 87, 0.28);
    --hl-fg: #4a1f0a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  /* Zachte, warme gloed bovenin — sfeer zonder extra elementen */
  background-image: radial-gradient(
    1100px 520px at 50% -180px,
    color-mix(in srgb, var(--accent) 9%, transparent),
    transparent 70%
  );
}

.hidden { display: none !important; }

::selection { background: var(--accent); color: #fff; }

/* Subtiele scrollbars (desktop) */
#main::-webkit-scrollbar, #conv-list::-webkit-scrollbar { width: 8px; }
#main::-webkit-scrollbar-thumb, #conv-list::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px;
}

/* ── Kop ── */
#app-header {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  flex: 0 0 auto;
}

#app-header h1 {
  flex: 1;
  margin: 0;
  font-size: 0.97rem;
  font-weight: 650;
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  color: var(--fg);
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  line-height: 1;
  font-size: 1.2rem;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.send {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 12px -1px color-mix(in srgb, var(--accent) 55%, transparent),
    0 1px 3px rgba(0, 0, 0, 0.2);
}
.icon-btn.send:active { filter: brightness(1.08); }
.icon-btn.send:disabled { opacity: 0.4; box-shadow: none; }
.icon-btn.danger { color: var(--danger); }
#btn-new, #btn-menu { color: var(--fg); }

/* Iconen in de kop en de composer: één maat voor alle knoppen, zodat tekst-
   tekens (☰ ＋ ✕ ■ ➤) en SVG's niet meer door elkaar lopen. */
.icon-btn svg, .side-logo svg { width: 20px; height: 20px; display: block; }
.icon-btn.danger svg { width: 17px; height: 17px; }
#btn-down svg { width: 20px; height: 20px; display: block; }
#btn-cache-refresh svg { width: 15px; height: 15px; display: block; }

/* Icoon vóór een label, in knoppen en chips. */
.b-ico {
  display: inline-flex;
  flex: 0 0 auto;
  width: 16px; height: 16px;
  align-items: center;
  justify-content: center;
}
.b-ico svg { width: 100%; height: 100%; display: block; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
  margin-right: 2px;
}
@keyframes pulse { 0%,100% { opacity: .35; transform: scale(.8);} 50% { opacity: 1; transform: scale(1.1);} }

/* Verbindingsbanner (onder de kop) */
#conn-banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 7px 12px;
  background: color-mix(in srgb, var(--danger) 16%, var(--bg-soft));
  color: var(--fg);
  border-bottom: 1px solid var(--line);
  font-size: .8rem;
  text-align: center;
}
#conn-banner .sp {
  width: 10px; height: 10px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-top-color: var(--danger);
  animation: spin .8s linear infinite;
}

/* Offline-lezen: gesprek komt uit de lokale cache (geen serverfout) */
#cache-note {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 5px 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-soft));
  color: var(--fg-dim);
  border-bottom: 1px solid var(--line);
  font-size: .78rem;
  text-align: center;
}
#cache-note #cache-note-txt { flex: 1; }
#btn-cache-refresh {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-size: .95rem;
  line-height: 1;
  border-radius: 9px;
  padding: 4px 8px;
  cursor: pointer;
}
#btn-cache-refresh:active { background: var(--bg-raised); color: var(--fg); }

/* ── Zijpaneel ── */
#scrim {
  position: fixed; inset: 0;
  background: rgba(10, 6, 3, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 30;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(88vw, 360px);
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  z-index: 40;
  transform: translateX(-103%);
  transition: transform .24s cubic-bezier(.32,.72,.22,1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
#sidebar.open { transform: translateX(0); }

.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
.side-logo {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.side-title { flex: 1; font-weight: 700; font-size: .98rem; }
.side-search { padding: 0 12px 8px; }
#search-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  border-radius: 12px;
  padding: 9px 12px;
  font: inherit;
  font-size: 1rem; /* ≥16px: anders zoomt iOS Safari bij focus in */
  outline: none;
  transition: border-color .15s ease;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--fg-dim); }

#conv-list {
  list-style: none;
  margin: 0; padding: 4px 8px 6px;
  flex: 1;
  overflow-y: auto;
}
#conv-list li {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color .12s ease;
  -webkit-user-select: none;
  user-select: none;
}
#conv-list li:active { background: var(--bg-raised); }
#conv-list li.active { background: var(--accent-soft); }
#conv-list li .c-txt { flex: 1; min-width: 0; }
#conv-list li .c-head {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
}
#conv-list li .c-title {
  flex: 0 1 auto; min-width: 0;
  font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Rondje met de beginletter: herkenbaarder dan een rij gelijke regels. */
#conv-list li .c-av {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: .92rem; font-weight: 650;
  background: var(--bg-raised);
  color: var(--fg-dim);
  overflow: hidden;
  transition: background-color .12s ease, color .12s ease;
}
#conv-list li .c-av svg { width: 16px; height: 16px; display: block; }
#conv-list li .c-av[data-tint="0"] { background: color-mix(in srgb, var(--accent) 26%, var(--bg-raised)); color: var(--accent-strong); }
#conv-list li .c-av[data-tint="1"] { background: color-mix(in srgb, var(--accent) 13%, var(--bg-raised)); color: var(--fg); }
#conv-list li .c-av[data-tint="2"] { background: var(--bg-raised); color: var(--fg-dim); }
#conv-list li .c-av[data-tint="3"] { background: color-mix(in srgb, var(--ok) 20%, var(--bg-raised)); color: var(--ok); }
#conv-list li .c-av[data-tint="4"] { background: color-mix(in srgb, var(--accent) 6%, var(--bg-raised)); color: var(--fg-dim); }
#conv-list li.active .c-av { background: var(--accent); color: #fff; }
/* Loopt nog in de CLI: een zachte ring, zodat je ziet dat er iets beweegt. */
#conv-list li .c-av.loopt { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }

/* Toestand van een geïmporteerd gesprek: één rustig pilletje achter de titel. */
.c-pill {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .66rem;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--fg-dim);
  white-space: nowrap;
}
.c-pill svg { width: 11px; height: 11px; display: block; }
.c-pill:not(:has(span)) { padding: 3px; }
.c-pill.loopt {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent-strong);
}
#conv-list li .c-sub {
  font-size: .78rem; color: var(--fg-dim-strong); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
#conv-list .empty {
  color: var(--fg-dim); text-align: center; padding: 30px 12px;
  font-size: .88rem;
}
/* rij-actie (⋮ / kebab) — altijd zichtbaar, ook op touch */
.rowact {
  appearance: none; border: 0; background: transparent;
  color: var(--fg-dim); font-size: 1.1rem; line-height: 1;
  /* 44 px, net als alle andere knoppen: dit is de "⋯" in elke rij van de
     gesprekslijst en die is op een telefoon het meest gebruikte menu. */
  width: 44px; height: 44px; border-radius: 12px;
  flex: 0 0 auto; cursor: pointer;
  display: grid; place-items: center;
  opacity: 0; transition: opacity .12s ease;
}
#conv-list li:hover .rowact, #conv-list li:focus-within .rowact, #conv-list li .rowact:focus { opacity: 1; }
#conv-list li.active .rowact, #conv-list li .rowact:active { color: var(--fg); }
@media (pointer: coarse) {
  #conv-list li .rowact { opacity: .55; }
  #conv-list li.active .rowact { opacity: 1; color: var(--fg); }
}

.side-foot {
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* De twee hulpknoppen naast elkaar in plaats van twee volle regels: minder
   hoogte, en "nieuw gesprek" blijft als enige de grote knop. */
.foot-row { display: flex; gap: 8px; }
.foot-row button { flex: 1 1 0; min-width: 0; }

button.primary {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: .92rem;
  border-radius: 13px;
  padding: 11px 14px;
  cursor: pointer;
  transition: filter .12s ease, transform .08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button.primary.wide { width: 100%; }
button.primary:active { filter: brightness(1.08); transform: translateY(0.5px); }
button.primary:disabled { opacity: .55; }

button.ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-size: .78rem;
  border-radius: 11px;
  padding: 9px 10px;
  cursor: pointer;
  line-height: 1.3;
  transition: color .12s ease, background-color .12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  overflow: hidden;
}
button.ghost.wide { width: 100%; margin-bottom: 8px; }
button.ghost:active { background: var(--bg-raised); color: var(--fg); }
button.ghost:disabled { opacity: .55; }
/* notificatie-toggle: aan = subtiele accent-tint */
#btn-notify.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--fg);
  background: var(--accent-soft);
}

/* ── Berichten ── */
#main {
  flex: 1;
  overflow-y: auto;
  /* géén scroll-behavior: smooth — breekt programmatische scroll (zie scrollToMsg) */
  overscroll-behavior: contain;
}
#messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}

.msg { display: flex; flex-direction: column; align-items: flex-start; }
.msg.user { align-items: flex-end; }

/* Transiënte systeemregel (bijv. "context niet hervatbaar → verse sessie") */
.system-note {
  align-self: center;
  max-width: min(92%, 560px);
  margin: 6px 0;
  padding: 6px 12px;
  font-size: .78rem;
  line-height: 1.45;
  text-align: center;
  color: var(--fg-dim);
  background: color-mix(in srgb, var(--fg-dim) 9%, transparent);
  border: 1px dashed var(--line);
  border-radius: 999px;
  animation: enter .25s ease both;
}

.bubble {
  max-width: min(86%, 640px);
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: .95rem;
  line-height: 1.52;
  word-wrap: break-word;
}
.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 5px;
  white-space: pre-wrap;
}
.assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.msg.streaming .bubble::after,
.bubble.streaming::after {
  content: "▍";
  color: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Streamende bubble krijgt een zachte, warme "live"-gloed */
.bubble.streaming {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 1px var(--accent-soft),
    0 12px 28px -18px color-mix(in srgb, var(--accent) 75%, transparent);
}

/* Bijsturen & wachtrij — een gemarkeerd user-bericht.
   "gestuurd" = meegelift in de LOPENDE beurt (een vraag; de beurt loopt door).
   "wachtrij" = opgespaard; wordt pas een eigen beurt als deze klaar is. */
.stuurd-tag {
  display: inline-block;
  margin: 5px 0 1px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.5;
  vertical-align: middle;
  white-space: nowrap;
}
.msg.gestuurd .bubble,
.gestuurd .bubble {
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
}
.msg.gestuurd .stuurd-tag,
.gestuurd .stuurd-tag {
  background: var(--accent-soft);
  color: var(--accent);
}
.msg.wachtrij .bubble,
.wachtrij .bubble {
  border: 1px dashed color-mix(in srgb, var(--fg-dim) 55%, var(--line));
  opacity: .82;
}
.msg.wachtrij .stuurd-tag,
.wachtrij .stuurd-tag {
  background: color-mix(in srgb, var(--fg-dim) 16%, transparent);
  color: var(--fg-dim);
}

/* Meta-rij onder elke bubble: tijd (+ acties) */
.meta {
  display: flex; align-items: center; gap: 2px;
  margin-top: 3px; padding: 0 8px;
  min-height: 18px;
}
.msg.user .meta { flex-direction: row-reverse; }
.time { font-size: .68rem; color: var(--fg-dim); }
.copy-btn,
.share-btn,
.del-btn {
  appearance: none; border: 0; background: transparent;
  color: var(--fg-dim); cursor: pointer;
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  padding: 0; margin-left: 2px;
  opacity: 0; transition: opacity .12s ease, color .12s ease;
}
.copy-btn svg, .share-btn svg, .del-btn svg { width: 14px; height: 14px; }
.msg:hover .copy-btn, .msg:focus-within .copy-btn, .copy-btn:focus,
.msg:hover .share-btn, .msg:focus-within .share-btn, .share-btn:focus,
.msg:hover .del-btn, .msg:focus-within .del-btn, .del-btn:focus { opacity: 1; }
.copy-btn:active, .share-btn:active { color: var(--accent); }
.del-btn:active, .del-btn:focus { color: var(--danger); }
/* Telefoon/tablet: duimgrootte en goed zichtbaar, want selecteren is daar lastig
   (24px is te klein om te raken; de knop moet meteen opvallen). */
@media (pointer: coarse) {
  .copy-btn, .share-btn, .del-btn { opacity: .65; width: 34px; height: 34px; border-radius: 9px; margin-left: 4px; }
  .copy-btn svg, .share-btn svg, .del-btn svg { width: 17px; height: 17px; }
  .msg:active .copy-btn, .msg:active .share-btn, .msg:active .del-btn { opacity: 1; }
}
.copy-btn.done { color: var(--ok); opacity: 1; }

/* Datum-scheidingslijn */
.day-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 0;
  color: var(--fg-dim);
  font-size: .72rem;
}
.day-divider::before, .day-divider::after {
  content: ""; flex: 1; height: 1px;
  background: var(--line);
}
.day-divider span { padding: 2px 12px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); }

/* Gezochte term markeren */
mark {
  background: var(--hl-bg);
  color: var(--hl-fg);
  border-radius: 3px;
  padding: 0 1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Binnenkomst-animatie voor live berichten (niet bij bulk/chunks) */
.msg.enter { animation: enter .22s ease both; }
@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Markdown-inhoud netjes */
.bubble p { margin: 0 0 .6em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: .3em 0 .7em; padding-left: 1.35em; }
.bubble li { margin: .18em 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { margin: .75em 0 .35em; line-height: 1.3; }
.bubble h1 { font-size: 1.16rem; } .bubble h2 { font-size: 1.08rem; }
.bubble h3 { font-size: 1rem; } .bubble h4 { font-size: .95rem; }
.bubble code {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: .85em;
  background: color-mix(in srgb, var(--fg) 9%, transparent);
  padding: 1px 5px;
  border-radius: 6px;
}
.bubble pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  overflow-x: auto;
  margin: .5em 0;
  position: relative;
}
.bubble pre code { background: none; padding: 0; font-size: .84em; }
.bubble blockquote {
  margin: .5em 0;
  padding: 2px 12px;
  border-left: 3px solid var(--accent);
  color: var(--fg-dim);
}
.bubble a { color: var(--accent); text-decoration: none; }
.bubble a:hover { text-decoration: underline; }
.bubble table { border-collapse: collapse; margin: .5em 0; font-size: .86em; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 4px 10px; }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: .9em 0; }
.bubble img { max-width: 100%; border-radius: 10px; }

/* Syntax-highlighting (highlight.js tokens, thema via tokens) */
.bubble pre code .hljs-comment,
.bubble pre code .hljs-quote { color: var(--fg-dim); font-style: italic; }
.bubble pre code .hljs-keyword,
.bubble pre code .hljs-selector-tag,
.bubble pre code .hljs-literal,
.bubble pre code .hljs-doctag { color: #d98b63; }
.bubble pre code .hljs-string,
.bubble pre code .hljs-regexp,
.bubble pre code .hljs-addition,
.bubble pre code .hljs-attr { color: #a8c78a; }
.bubble pre code .hljs-number,
.bubble pre code .hljs-symbol,
.bubble pre code .hljs-bullet { color: #d9ab6a; }
.bubble pre code .hljs-title,
.bubble pre code .hljs-title.function_,
.bubble pre code .hljs-section,
.bubble pre code .hljs-name { color: #e8a67e; }
.bubble pre code .hljs-built_in,
.bubble pre code .hljs-type { color: #8fb9c4; }
.bubble pre code .hljs-variable,
.bubble pre code .hljs-template-variable,
.bubble pre code .hljs-params { color: var(--fg); }
.bubble pre code .hljs-meta { color: #b49fd6; }
.bubble pre code .hljs-deletion { color: var(--danger); }
.bubble pre code .hljs-emphasis { font-style: italic; }
.bubble pre code .hljs-strong { font-weight: 700; }
@media (prefers-color-scheme: light) {
  .bubble pre code .hljs-keyword,
  .bubble pre code .hljs-selector-tag,
  .bubble pre code .hljs-literal,
  .bubble pre code .hljs-doctag { color: #a2471c; }
  .bubble pre code .hljs-string,
  .bubble pre code .hljs-regexp,
  .bubble pre code .hljs-addition,
  .bubble pre code .hljs-attr { color: #4d6e2e; }
  .bubble pre code .hljs-number,
  .bubble pre code .hljs-symbol,
  .bubble pre code .hljs-bullet { color: #9a6518; }
  .bubble pre code .hljs-title,
  .bubble pre code .hljs-title.function_,
  .bubble pre code .hljs-section,
  .bubble pre code .hljs-name { color: #b2571f; }
  .bubble pre code .hljs-built_in,
  .bubble pre code .hljs-type { color: #1f6e7a; }
  .bubble pre code .hljs-meta { color: #6d54a3; }
}

/* ── Activiteit (tools) ── */
#activity {
  max-width: 780px;
  margin: 0 auto;
  padding: 2px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#activity .tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .73rem;
  color: var(--fg-dim);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}
/* Lopende subagent in de activiteitenbalk, los van het blok in het antwoord:
   zie je ook als je weggescrold bent. Verdwijnt bij agent_end. */
#activity .agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .74rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}
#activity .agent-chip .a-ico { display: inline-flex; color: var(--accent-strong); }
#activity .agent-chip .a-ico svg { width: 13px; height: 13px; }
#activity .agent-chip .a-name { font-weight: 600; }
#activity .agent-chip .a-meta { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
#activity .agent-chip .a-meta:empty { display: none; }
.tool-chip .sp {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tool-blokken in een antwoord ── */
/* Leeg = geen marge, zodat een tekst-only antwoord er niets van merkt. */
.tools:empty { display: none; }
.tools { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }

/* In een beurt wisselen tekst en blokken elkaar af: elk deel na het eerste
   krijgt lucht, in welke volgorde dan ook. */
.bubble > .md + .md,
.bubble > .tools + .md,
.bubble > .md + .tools,
.bubble > .tools + .tools { margin-top: 8px; }

/* Regel tussen de delen, bijv. "38 latere tool-calls niet bewaard". */
.part-note {
  margin-top: 8px;
  font-size: .76rem;
  color: var(--fg-dim);
  font-style: italic;
}

details.tool {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: .84rem;
}
details.tool.err { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
details.tool.loopt { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

details.tool > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  list-style: none;
}
details.tool > summary::-webkit-details-marker { display: none; }
details.tool[open] > summary { border-bottom: 1px solid var(--line); }

.t-chev {
  display: inline-flex;
  flex: 0 0 auto;
  width: 14px; height: 14px;
  color: var(--fg-dim);
  transition: transform .16s ease;
}
.t-chev svg { width: 100%; height: 100%; }
details.tool[open] .t-chev { transform: rotate(90deg); }

.t-icon {
  display: inline-flex;
  flex: 0 0 auto;
  width: 15px; height: 15px;
  color: var(--accent);
}
.t-icon svg { width: 100%; height: 100%; }
.t-icon .sp {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}

.t-name { flex: 0 0 auto; font-weight: 600; }
.t-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: .74rem;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Bij een subagent is de hint geen commando maar een omschrijving ("Tel
   .md-bestanden") — die hoort in het gewone lettertype, niet in monospace. */
details.tool.agent .t-hint { font-family: inherit; font-size: .78rem; }
/* Voortgang in de dichtgeklapte balk: "3 tools" terwijl de subagent werkt. */
.t-live {
  flex: 0 0 auto;
  font-size: .72rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.t-ms { flex: 0 0 auto; font-size: .72rem; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.t-status { flex: 0 0 auto; display: inline-flex; align-items: center; color: var(--ok); }
.t-status svg { width: 13px; height: 13px; }
details.tool.err .t-status { color: var(--danger); }

/* Binnenkant: input, uitvoer en de afkap-melding */
details.tool .tool-in,
details.tool .tool-out,
details.tool .tool-trunc { margin: 0 10px; }
details.tool .tool-in { margin-top: 9px; }
details.tool .tool-trunc { margin-bottom: 8px; }

.tool-cmd, .tool-json, .tool-out {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: .76rem;
  line-height: 1.45;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.tool-cmd { color: var(--accent); }
.tool-json { color: var(--fg-dim); }
.tool-out { margin-bottom: 10px; }
.tool-trunc { font-size: .72rem; color: var(--fg-dim); font-style: italic; }

/* Tijdens het draaien: nog geen uitvoer, dus geen leeg vlak tonen. */
details.tool.loopt .tool-out:empty { display: none; }

/* ── Subagent-blok ── */
/* Een agent is meer dan een tool: eigen accent, een metaregel en de calls die
   hij zelf doet zichtbaar eronder. Zo zie je in één oogopslag dát er een agent
   werkt en wát hij uitvoert. */
details.tool.agent {
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-soft));
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}
details.tool.agent > summary { font-size: .88rem; }
details.tool.agent .t-icon { color: var(--accent-strong); }
details.tool.agent .t-name { color: var(--accent-strong); }

/* De opdracht en de cijfers van de agent. */
details.tool .agent-meta,
details.tool .agent-prompt,
details.tool .tool-kids { margin: 0 10px; }
details.tool .agent-meta {
  margin-top: 7px;
  font-size: .72rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
details.tool .agent-meta:empty { display: none; }
details.tool .agent-prompt {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: .74rem;
  line-height: 1.45;
  color: var(--fg-dim);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  margin-top: 7px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

/* Wat de agent zelf deed: ingesprongen onder een lichte lijn, zodat de
   hiërarchie klopt zonder extra ruimte te vreten. */
details.tool .tool-kids {
  margin-top: 7px;
  padding-left: 9px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  display: flex;
  flex-direction: column;
  gap: 5px;
}
details.tool .tool-kids:empty { display: none; }
details.tool .tool-kids details.tool {
  background: var(--bg-soft);
  border-color: color-mix(in srgb, var(--line) 80%, transparent);
}

/* Denk-indicator: mini-ster + oplichtende bolletjes zolang er nog geen tekst stroomt */
#activity .think {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .74rem;
  color: var(--fg-dim);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
}
#activity .think .t-s { width: 14px; height: 14px; display: grid; place-items: center; color: var(--accent); }
#activity .think .t-s svg { width: 13px; height: 13px; }
#activity .think .t-b { display: inline-flex; gap: 3px; align-items: center; margin-top: 1px; }
#activity .think .t-b i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--fg-dim);
  animation: tthink 1.2s ease-in-out infinite;
}
#activity .think .t-b i:nth-child(2) { animation-delay: .15s; }
#activity .think .t-b i:nth-child(3) { animation-delay: .3s; }
@keyframes tthink {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-2.5px); opacity: 1; background: var(--accent); }
}

/* ── Welkom / lege staat ── */
.welcome {
  margin: auto;
  max-width: 420px;
  text-align: center;
  padding: 24px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.welcome .wlogo {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 6px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent),
    0 12px 36px -8px color-mix(in srgb, var(--accent) 60%, transparent);
}
.welcome .wlogo svg { width: 32px; height: 32px; }
.welcome h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.welcome p { margin: 0 0 14px; color: var(--fg-dim); font-size: .92rem; line-height: 1.5; }
.wchip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg);
  font: inherit;
  font-size: .85rem;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.wchip:active { background: var(--bg-raised); border-color: var(--accent); }
.wchip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }

/* ── Laad-skeletons ── */
.skeleton { display: flex; flex-direction: column; gap: 10px; width: min(86%, 640px); margin: 8px auto; }
.sk-line {
  height: 13px; border-radius: 7px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--bg-raised) 45%, var(--bg-soft) 65%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease infinite;
}
.sk-bubble {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-bottom-left-radius: 5px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  align-self: flex-start;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading-hint {
  text-align: center; color: var(--fg-dim); font-size: .8rem;
  padding: 4px 0 8px; display: flex; align-items: center; justify-content: center; gap: 8px;
}

/* ── "Laad oudere berichten" ── */
.load-older { display: flex; justify-content: center; margin: 0 0 4px; }
.load-older button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.load-older button:active { background: var(--bg-raised); color: var(--fg); border-color: var(--accent); }

/* ── "Nieuwere berichten" (na een sprong in de historie) ── */
.load-newer { display: flex; justify-content: center; margin: 6px 0 2px; }
.load-newer button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.load-newer button:active { background: var(--bg-raised); color: var(--fg); border-color: var(--accent); }

/* Kopje boven zoekresultaten in de gesprekslijst */
.search-head {
  padding: 10px 16px 6px;
  font-size: .78rem;
  letter-spacing: .01em;
  color: var(--accent);
}

/* Spinner binnen de laad-hint */
.loading-hint .sp {
  width: 12px; height: 12px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}

/* ── Alleen-lezen-melding ── */
/* Zoeken binnen het gesprek: een dunne balk tussen berichten en composer. */
#find-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom) * 0);
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
}
#find-bar.hidden { display: none; }
#find-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1rem; /* 16px: geen iOS/Android-zoom bij focus */
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
}
#find-input:focus { outline: none; border-color: var(--accent); }
.find-count {
  font-size: .78rem;
  color: var(--fg-dim-strong);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}
#find-bar .icon-btn { width: 40px; height: 40px; }
mark.hit-on {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#readonly-note {
  flex: 0 0 auto;
  padding: 8px 16px;
  background: var(--bg-soft);
  color: var(--fg-dim);
  border-top: 1px solid var(--line);
  font-size: .8rem;
  text-align: center;
  line-height: 1.4;
}
#readonly-note svg {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
  margin-right: 1px;
}
#readonly-note .takeover-btn {
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: .75rem;
  line-height: 1.5;
  cursor: pointer;
  white-space: nowrap;
}
#readonly-note .takeover-btn:hover { background: var(--accent); color: var(--bg-soft); }
#readonly-note .takeover-btn:disabled { opacity: .6; cursor: default; }
@media (max-width: 420px) {
  #readonly-note .takeover-btn { display: block; margin: 6px auto 0; }
}
#input:disabled { opacity: .5; }

/* ── Composer ── */
#composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
/* Gereedschapsrij — locatie & screenshot. ⚠️ Deze twee stonden éérst ín de
   invoerrij; dan vechten vijf knoppen om de breedte en houdt de textarea er
   ~229 px van over (gemeten 8 okt 2026, viewport 390). Apart gezet, zodat de
   invoerrij alleen input + stop + queue + send draagt. */
.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Locatie en schermafbeelding: dezelfde 44 px als alle andere knoppen. Ze
   stonden op 36 px — gemeten op een telefoon van 390 px breed, en dat is onder
   de minimum-maat voor een vinger. Het icoon blijft 20 px, dus het ziet er
   hetzelfde uit; alleen het raakvlak groeit. */
.composer-tools .icon-btn { width: 44px; height: 44px; border-radius: 12px; }

/* De invoerrij. ⚠️ Hier zaten twee fouten verstopt (gemeten 8 okt 2026):
   1. #input had `min-width: auto` → een textarea met flex:1 krimpt dan níet
      onder zijn intrinsieke breedte (~229 px). De rij liep over zodra stop én
      queue verschenen, en de send-knop verdween van het scherm. Dát was "de
      lay-out gesloopt".
   2. de knoppen hadden geen `flex: 0 0 auto` → díe krompen wél, ongelijk
      (42 → 35/28/25), wat scheef oogt.
   Nu: de knoppen houden hun maat, de textarea geeft mee. */
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.composer-row > .icon-btn { flex: 0 0 auto; }
#btn-attach { color: var(--fg-dim); flex: 0 0 auto; }
#btn-attach svg { display: block; }
#btn-attach:disabled { opacity: .4; }
#btn-attach:active { color: var(--accent); }

#btn-loc { color: var(--fg-dim); flex: 0 0 auto; }
#btn-loc svg { display: block; }
#btn-loc:disabled { opacity: .4; }
#btn-loc:active { color: var(--accent); }
#btn-loc.has-loc { color: var(--accent); }
#btn-loc.locating { opacity: .55; animation: pulse 1.1s ease-in-out infinite; }

/* Geselecteerde screenshots boven de composer */
#attach-tray {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 2px 2px;
}
#attach-tray .attach-chip {
  position: relative;
  flex: 0 0 auto;
  width: 76px; height: 76px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-raised);
}
#attach-tray .attach-chip img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* Voortgang per foto: zonder dit lijkt een upload die nog loopt op niets. */
#attach-tray .attach-chip .chip-status {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 0;
  font-size: .62rem; text-align: center;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
}
#attach-tray .attach-chip.is-bezig img { opacity: .55; }
#attach-tray .attach-chip.is-mislukt { border-color: var(--danger); }
#attach-tray .attach-chip.is-mislukt .chip-status { background: var(--danger); }
#attach-tray .attach-chip .chip-rm {
  position: absolute; top: 3px; right: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: .78rem; line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
}
#attach-tray .attach-chip .chip-rm:active { background: var(--danger); }
#attach-tray .attach-chip .chip-count {
  position: absolute; left: 3px; bottom: 3px;
  background: rgba(0, 0, 0, 0.62); color: #fff;
  font-size: .62rem; padding: 1px 6px; border-radius: 999px;
}

/* 📍 Locatie-chip in de tray (klaar om mee te sturen) */
#attach-tray .loc-chip {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  max-width: 100%;
  background: var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 999px;
  padding: 6px 8px 6px 10px;
  font-size: .82rem;
  color: var(--fg);
}
#attach-tray .loc-chip .loc-coords { font-variant-numeric: tabular-nums; white-space: nowrap; }
#attach-tray .loc-chip .loc-acc { color: var(--fg-dim); white-space: nowrap; }
#attach-tray .loc-chip .loc-map { color: var(--accent); font-weight: 650; text-decoration: none; white-space: nowrap; }
#attach-tray .loc-chip .loc-map:active { text-decoration: underline; }
#attach-tray .loc-chip .chip-rm {
  width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: .7rem; line-height: 1; display: grid; place-items: center;
  cursor: pointer; margin-left: 2px; flex: 0 0 auto;
}
#attach-tray .loc-chip .chip-rm:active { background: var(--danger); }

/* 📍 Locatie-chip binnen een bericht */
.bubble .loc-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px;
  margin: 6px 0;
  font-size: .82rem;
  color: var(--fg);
  background: color-mix(in srgb, var(--bg-soft) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 10px;
}
.bubble .loc-row .loc-coords { font-variant-numeric: tabular-nums; font-weight: 600; }
.bubble .loc-row .loc-acc { color: var(--fg-dim); }
.bubble .loc-row .loc-map { color: var(--accent); font-weight: 650; text-decoration: none; margin-left: auto; }
.bubble .loc-row .loc-map:active { text-decoration: underline; }

/* Geüploade afbeeldingen binnen een bericht-bubble */
.bubble .attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.bubble .attach-row:last-child { margin-bottom: 0; }
.bubble .attach-item { display: block; line-height: 0; }
.bubble .attach-item img {
  max-width: min(100%, 280px);
  max-height: 260px;
  border-radius: 10px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: var(--bg);
}
#input {
  flex: 1 1 auto;
  min-width: 0; /* ⚠️ essentiëel: zonder dit krimpt een textarea niet (min-width:auto) */
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-raised);
  color: var(--fg);
  font: inherit;
  font-size: 1rem; /* ≥16px voorkomt iOS-zoom */
  line-height: 1.45;
  padding: 10px 15px;
  max-height: 150px;
  min-height: 44px;
  outline: none;
  transition: border-color .15s ease;
}
#input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#input::placeholder { color: var(--fg-dim); }

/* Floating "naar nieuwste"-knop (boven de composer, rechts) */
#btn-down {
  position: fixed;
  right: 14px;
  bottom: calc(118px + env(safe-area-inset-bottom)); /* JS meet de echte composerhoogte */
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--fg-dim);
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 25;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px) scale(.88);
  pointer-events: none;
  transition: opacity .18s ease, transform .2s cubic-bezier(.32,.72,.22,1),
    color .12s ease, border-color .12s ease;
}
#btn-down.show { opacity: 1; transform: none; pointer-events: auto; }
#btn-down:active { background: var(--bg-soft); color: var(--accent); border-color: var(--accent); }

/* ── Modals / actiesheet ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 6, 3, 0.55);
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .15s ease;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  animation: slideUp .22s cubic-bezier(.32,.72,.22,1);
  display: flex;
  flex-direction: column;
  /* Het verbruiksvenster is langer dan een berichtenvenster; zonder dit valt
     de onderkant (en de Sluiten-knop) buiten beeld op een telefoon. */
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } }
.modal .m-title { font-weight: 700; font-size: 1rem; margin: 6px 0 2px; text-align: center; }
.modal .m-sub { color: var(--fg-dim); font-size: .84rem; text-align: center; margin: 0 0 10px; line-height: 1.45; }
.modal input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  border-radius: 12px;
  padding: 11px 13px;
  font: inherit;
  font-size: .95rem;
  outline: none;
  margin-bottom: 10px;
}
.modal input[type="text"]:focus { border-color: var(--accent); }
.modal .m-actions { display: flex; flex-direction: column; gap: 8px; }
.modal .m-actions button {
  appearance: none; border: 0;
  font: inherit; font-size: .95rem;
  border-radius: 13px;
  padding: 13px;
  cursor: pointer;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.modal .m-actions button:active { background: var(--bg-raised); }
.modal .m-actions button.m-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.modal .m-actions button.m-primary { background: var(--accent); color: #fff; border: 0; }
.modal .m-actions button.m-muted { color: var(--fg-dim); border-color: transparent; background: transparent; }

/* ── Verbruik: regel onder een antwoord + het venster ── */
.usage-line {
  font-size: .68rem; color: var(--fg-dim);
  margin-left: 6px; font-variant-numeric: tabular-nums;
}
.modal .v-head {
  font-size: .72rem; font-weight: 700; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: .05em;
  margin: 14px 0 2px;
}
.modal .v-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  font-size: .9rem;
}
.modal .v-row.v-strong {
  font-weight: 700; font-size: 1rem; border-bottom: 0; padding-top: 8px;
}
.modal .v-key { color: var(--fg-dim); }
.modal .v-row.v-strong .v-key { color: var(--fg); }
.modal .v-val { font-variant-numeric: tabular-nums; text-align: right; }
.modal .v-note {
  font-size: .74rem; color: var(--fg-dim); line-height: 1.45; margin: 2px 0;
}
.modal .v-bar {
  height: 8px; border-radius: 4px; overflow: hidden; margin: 6px 0 4px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
}
.modal .v-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.modal .v-fill.v-vol { background: var(--danger); }
.modal .v-warn {
  margin: 12px 0 0; padding: 9px 11px; border-radius: 11px;
  font-size: .8rem; line-height: 1.45;
  background: color-mix(in srgb, var(--danger) 13%, transparent);
}

/* ── Toast ── */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--bg-raised);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: .88rem;
  max-width: 88vw;
  z-index: 80;
  text-align: center;
  animation: toastIn .18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Grote afbeeldingsweergave (tik op een bijlage in de chat) */
.img-backdrop {
  align-items: center;
  background: rgba(8, 5, 3, 0.88);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  cursor: zoom-out;
}
.img-backdrop img {
  max-width: 100%;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: var(--bg);
}
.img-backdrop .img-cap {
  color: var(--fg-dim);
  font-size: .82rem;
  text-align: center;
  margin-top: 12px;
  padding: 0 8px;
  word-break: break-word;
}

/* Fijne beweging uitzetten voor wie dat vraagt (toegankelijkheid) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Verder op de pc: het sessie-commando + de "van de pc"-markering ── */
.pc-cmd { display: flex; gap: 8px; align-items: stretch; margin: 4px 0 8px; }
.pc-cmd code {
  flex: 1 1 auto; min-width: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.5;
  padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft);
  overflow-wrap: anywhere;
}
.pc-copy {
  flex: 0 0 auto; appearance: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-raised);
  color: var(--fg); border-radius: 10px; padding: 0 14px;
  font-size: .82rem; font-weight: 600;
  min-width: 44px; min-height: 44px;
}
.pc-copy:active { background: var(--accent-soft); color: var(--accent); }
.van-pc {
  font-size: .64rem; color: var(--fg-dim);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 0 5px; margin-left: 6px; white-space: nowrap;
}
