/* Designs (0.3.0), modelled on the RP-Management-Board V1–V4:
   classic      – sidebar, solid surfaces (the original Compain look)
   glass        – sidebar, glass panels over a background picture with sliders for blur, opacity and dimming
   modern       – navigation on top as pills, calm flat surfaces
   modern-glass – navigation on top, glass panels over the background
   Everything hangs on <html data-design data-bg> and the CSS variables --g-blur, --g-alpha, --g-dim. */

/* ---------- Mono and other palettes: readable hero text ---------- */
:root[data-palette="mono"] :is(.hero h1, .hero p, .hero .caps) { color: inherit; opacity: .92; }
:root[data-palette="mono"] .hero { color: var(--accent-fg); }

/* ---------- Top bar (all designs): Changelog and Impressum, in modern designs also brand and navigation ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; position: relative; z-index: 30; }
.topbar .brand, .topbar .topnav { display: none; }
.topbar .spacer { flex: 1; }
.topbar .tb-btn {
  position: relative; height: 40px; padding: 0 14px; border-radius: 999px; gap: 8px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); box-shadow: none;
}
.topbar .tb-btn:hover { color: var(--fg); }
.topbar .tb-btn[aria-expanded="true"] { color: var(--fg); border-color: var(--accent); }
.tb-dot { position: absolute; top: 6px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.tb-dot[hidden] { display: none; }

/* ---------- Popover (like the notification popover in the RP-Management-Board) ---------- */
.popover {
  position: absolute; z-index: 60; top: calc(100% + 10px); right: 0; width: min(440px, calc(100vw - 32px));
  max-height: min(70vh, 600px); overflow: auto; padding: 14px 18px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); animation: pop .16s ease-out both;
}
.popover.floating { position: fixed; top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%); animation: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.popover-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); position: sticky; top: -14px; background: inherit; z-index: 1; }
.popover-head h2 { font-size: 17px; }
.popover .md h1 { font-size: 20px; margin: 10px 0 6px; }
.popover .md h2 { font-size: 15px; margin: 16px 0 6px; display: flex; align-items: center; gap: 8px; }
.popover .md p { margin: 3px 0; line-height: 1.55; font-size: 14px; }
.popover .md ul { margin: 4px 0 4px 18px; padding: 0; font-size: 14px; line-height: 1.55; }
.popover .md li { margin: 3px 0; }
.popover .md code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.popover-backdrop { position: fixed; inset: 0; z-index: 55; background: rgb(0 0 0 / .35); }

/* ---------- Background layer for the glass designs ---------- */
#bg-layer { display: none; }
:root:is([data-design="glass"], [data-design="modern-glass"]) #bg-layer {
  display: block; position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: var(--sky, var(--bg)); background-size: cover;
}
#bg-layer i { position: absolute; inset: 0; display: block; }
#bg-layer .bg-sun {
  inset: auto; left: 69%; top: 55%; width: 46vmin; height: 46vmin; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, var(--sun) 0 16%, color-mix(in srgb, var(--sun) 45%, transparent) 26%, transparent 68%);
}
#bg-layer .bg-m1 { background: var(--m1); clip-path: polygon(0 64%, 12.5% 55%, 22% 59.5%, 36% 48%, 48.5% 58%, 60% 51%, 72% 59.5%, 85% 49%, 100% 58.5%, 100% 100%, 0 100%); }
#bg-layer .bg-m2 { background: var(--m2); clip-path: polygon(0 72.5%, 10% 65.5%, 21% 70.5%, 33% 62.5%, 44.5% 69.5%, 57% 64%, 69.5% 72.5%, 82% 65%, 100% 72%, 100% 100%, 0 100%); }
#bg-layer .bg-m3 { background: var(--m3); clip-path: polygon(0 82%, 15% 76.5%, 29% 83%, 43% 77.5%, 60% 84.5%, 75% 78%, 89% 83.5%, 100% 79.5%, 100% 100%, 0 100%); }
#bg-layer .bg-dim { background: #000; opacity: var(--g-dim, .2); }
:root[data-bg="dusk"]   { --sky: linear-gradient(180deg, #1b1640 0%, #5b2a86 52%, #f08a4b 80%); --sun: #ffd29a; --m1: #3a2559; --m2: #24173d; --m3: #120c22; }
:root[data-bg="forest"] { --sky: linear-gradient(180deg, #0f2a2a 0%, #2f6f62 52%, #c9e3b5 82%); --sun: #fff3c4; --m1: #2b5a4a; --m2: #1b3d33; --m3: #0c1f1a; }
:root[data-bg="night"] {
  --sky: radial-gradient(1.5px 1.5px at 9% 8%, #fff 99%, transparent), radial-gradient(1px 1px at 18% 19%, #fff 99%, transparent),
    radial-gradient(1.4px 1.4px at 29% 5%, #fff 99%, transparent), radial-gradient(1px 1px at 39% 15%, #fff 99%, transparent),
    radial-gradient(1.7px 1.7px at 48% 7%, #fff 99%, transparent), radial-gradient(1.2px 1.2px at 57% 21%, #fff 99%, transparent),
    radial-gradient(1.5px 1.5px at 67% 10%, #fff 99%, transparent), radial-gradient(1px 1px at 77% 5%, #fff 99%, transparent),
    radial-gradient(1.6px 1.6px at 86% 17%, #fff 99%, transparent), radial-gradient(1.2px 1.2px at 94% 8%, #fff 99%, transparent),
    linear-gradient(180deg, #050816 0%, #0f1d45 55%, #2b4c7e 82%);
  --sun: #dbe7ff; --m1: #14213d; --m2: #0c1529; --m3: #060b17;
}
:root[data-bg="none"] { --sky: radial-gradient(900px 420px at 80% -10%, var(--glow), transparent 65%), var(--bg); }
:root[data-bg="none"] #bg-layer :is(.bg-sun, .bg-m1, .bg-m2, .bg-m3) { display: none; }

/* ---------- Glass (glass and modern-glass) ---------- */
:root:is([data-design="glass"], [data-design="modern-glass"]) {
  --g-surface: rgb(255 255 255 / calc(var(--g-alpha, .52) + .22));
  --g-line: rgb(255 255 255 / .7);
  --g-hi: rgb(255 255 255 / .8);
  --g-solid: #ffffff;
  --on-image: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]):is([data-design="glass"], [data-design="modern-glass"]) {
    --g-surface: rgb(16 16 28 / var(--g-alpha, .52)); --g-line: rgb(255 255 255 / .13); --g-hi: rgb(255 255 255 / .09); --g-solid: #16161f;
    --fg: #f4f4f8; --muted: #c3c3d2; --surface-2: rgb(255 255 255 / .07);
  }
}
:root[data-mode="dark"]:is([data-design="glass"], [data-design="modern-glass"]) {
  --g-surface: rgb(16 16 28 / var(--g-alpha, .52)); --g-line: rgb(255 255 255 / .13); --g-hi: rgb(255 255 255 / .09); --g-solid: #16161f;
  --fg: #f4f4f8; --muted: #c3c3d2; --surface-2: rgb(255 255 255 / .07);
}
:root:is([data-design="glass"], [data-design="modern-glass"]) body { background: transparent; }
:root:is([data-design="glass"], [data-design="modern-glass"]) :is(.card, .sidebar, .chats-shell, .featured, .topbar .tb-btn, .topnav-pills, .bottombar, .subtabs) {
  background: var(--g-surface); border-color: var(--g-line);
  -webkit-backdrop-filter: blur(var(--g-blur, 22px)) saturate(160%); backdrop-filter: blur(var(--g-blur, 22px)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--g-hi), 0 24px 48px -24px rgb(0 0 0 / .45);
}
/* Panels inside panels: no second blur */
:root:is([data-design="glass"], [data-design="modern-glass"]) :is(.card, .chats-shell) :is(.card, .list-pane, .conv-head) {
  -webkit-backdrop-filter: none; backdrop-filter: none; background: transparent; box-shadow: none;
}
:root:is([data-design="glass"], [data-design="modern-glass"]) .chats-shell .list-pane { background: rgb(255 255 255 / .04); }
:root:is([data-design="glass"], [data-design="modern-glass"]) :is(.popover, .toast) { background: color-mix(in srgb, var(--g-solid) 90%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
:root:is([data-design="glass"], [data-design="modern-glass"]) select option { background: var(--g-solid); color: var(--fg); }
:root:is([data-design="glass"], [data-design="modern-glass"]) .subtabs { border: 1px solid var(--g-line); border-radius: 16px; padding: 6px; width: fit-content; max-width: 100%; }
/* Text right on the picture */
:root:is([data-design="glass"], [data-design="modern-glass"]) .page-head :is(h1, p, .caps) { color: var(--on-image); text-shadow: 0 1px 2px rgb(0 0 0 / .35), 0 2px 18px rgb(0 0 0 / .45); }
:root:is([data-design="glass"], [data-design="modern-glass"]) .page-head p { opacity: .92; }
:root:is([data-design="glass"], [data-design="modern-glass"]) .login .muted { color: var(--muted); }
/* Glass sidebar floats with a margin */
:root[data-design="glass"] .app { gap: 16px; padding: 16px 16px 0 0; }
:root[data-design="glass"] .sidebar { top: 16px; height: calc(100vh - 32px); border-radius: 22px; border: 1px solid var(--g-line); }

/* ---------- Modern (modern and modern-glass): navigation on top ---------- */
:root:is([data-design="modern"], [data-design="modern-glass"]) .app { grid-template-columns: minmax(0, 1fr); }
:root:is([data-design="modern"], [data-design="modern-glass"]) .sidebar { display: none; }
:root:is([data-design="modern"], [data-design="modern-glass"]) main.content { margin: 0 auto; padding-top: 18px; }
:root:is([data-design="modern"], [data-design="modern-glass"]) .topbar { flex-wrap: wrap; margin-bottom: 22px; }
:root:is([data-design="modern"], [data-design="modern-glass"]) .topbar .brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 19px; color: var(--fg); text-transform: lowercase; letter-spacing: -.02em; }
:root:is([data-design="modern"], [data-design="modern-glass"]) .topbar .brand i { width: 30px; height: 30px; border-radius: 8px; background: url(/static/icons/icon.svg) center / contain no-repeat; display: inline-block; box-shadow: 0 4px 14px rgb(232 100 44 / .28); }
:root[data-design="modern-glass"] .topbar .brand { color: var(--on-image); text-shadow: 0 1px 12px rgb(0 0 0 / .45); }
:root:is([data-design="modern"], [data-design="modern-glass"]) .topbar .topnav { display: block; order: 3; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.topnav::-webkit-scrollbar { display: none; }
.topnav-pills { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.topnav-pills button {
  border: 0; box-shadow: none; background: transparent; color: var(--muted); padding: 10px 18px; border-radius: 999px;
  font-weight: 550; white-space: nowrap; gap: 8px; transition: background .18s, color .18s;
}
.topnav-pills button:hover { color: var(--fg); background: var(--surface-2); }
.topnav-pills button[aria-current="page"] { background: var(--accent); color: var(--accent-fg); }
/* Modern without glass: calm, flat surfaces with a soft glow */
:root[data-design="modern"] { --radius: 18px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"])[data-design="modern"] { --surface: rgb(255 255 255 / .045); --surface-2: rgb(255 255 255 / .08); --line: rgb(255 255 255 / .09); }
}
:root[data-mode="dark"][data-design="modern"] { --surface: rgb(255 255 255 / .045); --surface-2: rgb(255 255 255 / .08); --line: rgb(255 255 255 / .09); }
:root[data-design="modern"] body { background: radial-gradient(900px 380px at 18% -10%, var(--glow), transparent 70%), radial-gradient(700px 320px at 88% -6%, rgb(45 212 191 / .08), transparent 70%), var(--bg); background-attachment: fixed; }
:root[data-design="modern"] :is(.popover, .toast) { background: var(--bg); }
:root[data-design="modern"] .chats-shell .list-pane { background: transparent; }

/* ---------- Design picker in Settings ---------- */
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 12px; }
.design-card { display: grid; gap: 10px; text-align: left; justify-content: stretch; align-items: stretch; padding: 12px; border-radius: 18px; background: var(--surface-2); border: 2px solid transparent; box-shadow: none; }
.design-card[aria-checked="true"] { border-color: var(--accent); background: var(--surface); }
.design-card .mini { position: relative; height: 92px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.design-card .mini.glassy { background: linear-gradient(180deg, #1b1640 0%, #5b2a86 52%, #f08a4b 80%); }
.design-card .mini .side { position: absolute; left: 6px; top: 6px; bottom: 6px; width: 22%; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.design-card .mini .bar { position: absolute; left: 6px; right: 6px; top: 6px; height: 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.design-card .mini .bar b { position: absolute; left: 4px; top: 3px; width: 26%; height: 6px; border-radius: 99px; background: var(--accent); }
.design-card .mini .panel { position: absolute; right: 6px; bottom: 6px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.design-card .mini.glassy :is(.side, .bar, .panel) { background: rgb(255 255 255 / .22); border-color: rgb(255 255 255 / .35); }
.design-card .name { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.design-card .sub { font-size: 12.5px; color: var(--muted); }
.slider-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 56px; align-items: center; gap: 12px; }
.slider-row input[type="range"] { padding: 0; background: transparent; accent-color: var(--accent); }
.slider-row output { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; text-align: right; }

/* ---------- Phones ---------- */
@media (max-width: 900px) {
  :root:is([data-design="modern"], [data-design="modern-glass"]) .topbar .topnav { display: none; } /* bottom bar instead */
  :root[data-design="glass"] .app { padding: 0; }
  .topbar .tb-btn span { display: none; }
  .topbar .tb-btn { width: 40px; padding: 0; }
  .popover { position: fixed; top: 64px; left: 12px; right: 12px; width: auto; max-height: calc(100dvh - 170px); }
  .slider-row { grid-template-columns: 1fr 52px; }
  .slider-row label { grid-column: 1 / -1; margin: 0; }
  /* Glass on phones: no blur (battery and smooth scrolling), stronger panels */
  :root:is([data-design="glass"], [data-design="modern-glass"]) :is(.card, .chats-shell, .featured, .topbar .tb-btn, .bottombar, .subtabs) {
    -webkit-backdrop-filter: none; backdrop-filter: none; background: color-mix(in srgb, var(--g-solid) 86%, transparent);
  }
}
@media (prefers-reduced-transparency: reduce) {
  :root:is([data-design="glass"], [data-design="modern-glass"]) :is(.card, .sidebar, .chats-shell, .bottombar) { background: color-mix(in srgb, var(--g-solid) 94%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .popover { animation: none; } }

/* Fixes after the first screenshots */
.design-card, .palette-card { white-space: normal; min-width: 0; }
.design-grid { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
#view-home .grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }

/* ---------- Messages: Markdown, actions, search, stop (0.4.0) ---------- */
.bubble p { margin: 0; }
.bubble p + p, .bubble p + ul, .bubble ul + p, .bubble p + ol, .bubble ol + p, .bubble blockquote + p, .bubble p + blockquote { margin-top: .7em; }
.bubble ul, .bubble ol { margin: .3em 0 .3em 1.2em; padding: 0; }
.bubble blockquote { margin: .4em 0; padding-left: .8em; border-left: 3px solid color-mix(in srgb, currentColor 35%, transparent); opacity: .9; }
.bubble code { font-size: .9em; padding: 1px 5px; border-radius: 6px; background: color-mix(in srgb, currentColor 12%, transparent); }
.bubble .md-h { font-weight: 700; }
/* Actions in *asterisks* read like stage directions */
.msg.char .bubble em { font-style: italic; color: color-mix(in srgb, var(--fg) 68%, var(--accent)); }
.msg.user .bubble em { font-style: italic; opacity: .88; }
.msg .meta-line { flex-wrap: wrap; row-gap: 2px; }
.msg .meta-line .mark { opacity: .75; }
.msg:hover .meta-line .mark, .msg .meta-line .mark:focus-visible { opacity: 1; }
.variants { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.edit-box textarea { min-height: 90px; border-radius: 16px; }
.chat-search { display: flex; align-items: center; gap: 8px; padding: 8px 20px; border-bottom: 1px solid var(--line); }
.chat-search input { border-radius: 999px; padding: 8px 14px; }
.msg.hit .bubble { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.msg.hit-now .bubble { box-shadow: 0 0 0 3px var(--accent); }
.quick .accent-chip { color: var(--accent-text, var(--accent)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }
.send.stopping { background: var(--fg); border-color: var(--fg); }
.stop-square { width: 14px; height: 14px; border-radius: 3px; background: var(--bg); display: block; }

/* ---------- 0.4.0: own background, likes, security cards ---------- */
:root[data-bg="custom"] { --sky: var(--user-bg) center / cover no-repeat, var(--bg); }
:root[data-bg="custom"] #bg-layer :is(.bg-sun, .bg-m1, .bg-m2, .bg-m3) { display: none; }
.like { border: 0; background: transparent; box-shadow: none; padding: 4px 8px; color: var(--muted); font-size: 14px; }
.like.on { color: #e0517e; }
.like:hover { color: #e0517e; background: var(--surface-2); }
.qr { width: 190px; height: 190px; border-radius: 12px; background: #fff; flex: none; }
code.secret { display: inline-block; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13px; word-break: break-all; }
pre.codes { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; line-height: 1.7; user-select: all; }
.card.danger { border-color: color-mix(in srgb, #dc2626 40%, var(--line)); }
.danger-btn { background: #dc2626; border-color: #dc2626; color: #fff; }
.danger-btn:hover { filter: brightness(1.08); border-color: #dc2626; }

/* ---------- Help: FAQ, guide, Markdown reference, tickets (1.1.0) ---------- */
.md p { margin: 0; }
.md p + p, .md p + ul, .md ul + p, .md p + ol, .md ol + p, .md blockquote + p, .md p + blockquote { margin-top: .7em; }
.md ul, .md ol { margin: .3em 0 .3em 1.2em; padding: 0; }
.md li + li { margin-top: .25em; }
.md blockquote { margin: .4em 0; padding-left: .8em; border-left: 3px solid color-mix(in srgb, currentColor 35%, transparent); opacity: .9; }
.md code { font-size: .9em; padding: 1px 5px; border-radius: 6px; background: color-mix(in srgb, currentColor 12%, transparent); }
.md .md-h { font-weight: 700; }
.md { line-height: 1.6; }

.nav-badge { margin-left: auto; font-style: normal; }
.nav-badge[hidden] { display: none; }
.topnav-pills .nav-badge, .subtabs .nav-badge { margin-left: 6px; min-width: 18px; height: 18px; font-size: 10px; }
.bottombar button { position: relative; }
.bottombar .nav-badge { position: absolute; top: 2px; right: calc(50% - 20px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }

.faq-list { display: grid; gap: 10px; }
.card.faq { padding: 0; }
.faq summary { cursor: pointer; padding: 16px 20px; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text, var(--accent)); font-weight: 700; }
.faq[open] summary::before { content: "–"; }
.faq > .md { padding: 0 20px 18px 52px; color: var(--muted); }
.faq[open] > .md { color: var(--fg); }
.guide-card .md { margin-top: 10px; }
.guide-card { scroll-margin-top: 90px; }

.md-table td { vertical-align: top; }
.md-src { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: pre-wrap; background: var(--surface-2); padding: 6px 9px; border-radius: 9px; }
.md-try-out { margin: 0; align-self: start; }
.md-try-out .bubble { width: 100%; }
#md-try { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }

.ticket-list { display: grid; gap: 10px; }
.ticket-row { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; white-space: normal; }
.ticket-row:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ticket-row.unread { border-color: var(--accent); }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.t-status.t-in_progress { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.t-status.t-closed { opacity: .75; }
.ticket-head h2 { margin: 0; overflow-wrap: anywhere; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; }
.inline-field select { width: auto; }
.ticket-thread { display: grid; gap: 12px; margin: 16px 0; }
.t-msg { display: grid; gap: 6px; max-width: min(760px, 92%); }
.t-msg.admin { justify-self: start; }
.t-msg.user { justify-self: end; }
.t-msg .bubble { padding: 12px 16px; border-radius: 18px; background: var(--surface-2); white-space: pre-wrap; line-height: 1.6; overflow-wrap: anywhere; }
.t-msg.user .bubble { background: var(--accent-soft); }
.t-msg.internal .bubble { background: transparent; border: 1.5px dashed color-mix(in srgb, var(--warn) 60%, var(--line)); }
.ticket-controls .danger { color: #dc2626; }
@media (max-width: 720px) {
  .t-msg { max-width: 100%; }
  .faq > .md { padding-left: 20px; }
}

/* ---------- 1.3.0: export menu, bookmarks, search hits, model status ---------- */
.pop-wrap { position: relative; display: inline-flex; }
.pop-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: flex; flex-direction: column; gap: 2px; min-width: 210px;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.pop-menu .btn { justify-content: flex-start; text-align: left; white-space: nowrap; }
.mini-count { font-size: 10px; font-weight: 700; margin-left: 2px; color: var(--accent-text, var(--accent)); }
.bookmark-box { display: flex; flex-direction: column; align-items: stretch; gap: 2px; max-height: 220px; overflow: auto;
  padding: 10px 20px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.bm-row { display: flex; gap: 8px; align-items: center; border: 0; background: transparent; box-shadow: none; padding: 6px 8px; border-radius: 10px; text-align: left; color: var(--fg); min-width: 0; }
.bm-row:hover { background: var(--surface-2); }
.bm-row .ic { color: var(--accent-text, var(--accent)); flex: none; }
.msg .mark.bm[aria-pressed="true"] { color: var(--accent-text, var(--accent)); }
.msg.bookmarked .bubble { border-left: 3px solid var(--accent); }
.msg.flash .bubble { animation: msg-flash 2.2s ease-out; }
@keyframes msg-flash { 0%, 40% { box-shadow: 0 0 0 4px var(--accent-ring); } 100% { box-shadow: 0 0 0 0 transparent; } }
.typing-status { font-size: 12px; color: var(--muted); margin: 4px 0 0 4px; min-height: 1em; }
.model-state { color: var(--warn); }
.hit-row .preview { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hit-row mark { background: var(--accent-soft); color: var(--fg); border-radius: 4px; padding: 0 2px; }
#view-characters.dropping { outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: var(--radius); }
@media (prefers-reduced-motion: reduce) { .msg.flash .bubble { animation: none; box-shadow: 0 0 0 3px var(--accent-ring); } }

/* ---------- 1.3.3: large character pictures ---------- */
.char-cover { display: block; width: 100%; aspect-ratio: 4 / 5; max-height: 460px; padding: 0; border: 0; border-radius: calc(var(--radius) - 4px); overflow: hidden; background: var(--surface-2); cursor: zoom-in; box-shadow: none; }
.char-cover img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; transition: transform .3s ease; }
.char-cover:hover img { transform: scale(1.03); }
.char-cover.featured-pic { width: clamp(140px, 18vw, 240px); aspect-ratio: 4 / 5; }
.avatar-btn { padding: 0; border: 0; background: none; box-shadow: none; border-radius: 15px; cursor: zoom-in; flex: none; }
.picture-edit { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.picture-preview { width: 200px; aspect-ratio: 4 / 5; border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.picture-preview img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; gap: 10px; align-content: center; padding: 24px; background: rgb(0 0 0 / .82); cursor: zoom-out; animation: lb-in .15s ease; }
.lightbox img { max-width: min(100%, 1100px); max-height: calc(100vh - 90px); object-fit: contain; border-radius: 14px; box-shadow: 0 20px 60px rgb(0 0 0 / .5); }
.lightbox-name { color: #fff; font-family: var(--display); font-weight: 600; font-size: 17px; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lightbox { animation: none; } .char-cover img { transition: none; } }
@media (max-width: 900px) { .char-cover.featured-pic { width: 120px; } .picture-preview { width: 150px; } }

/* 1.5.0: relationship panel in the chat header */
.relation-box { display: flex; flex-direction: column; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.relation-box.hidden { display: none; }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 24px; }
.rel-meter .row { margin-bottom: 4px; }
.rel-note { margin: 0; line-height: 1.5; }
.relation-box input[type=range] { width: 100%; }
/* character assistant in the editor */
.assist-box { border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.assist-box textarea { min-height: 64px; }

/* ---------- 1.6.1: phone layout ---------- */
/* Choice rows (glass background, appearance) wrap instead of pushing the card wider than the screen. */
.segmented { flex-wrap: wrap; max-width: 100%; }
@media (max-width: 900px) {
  .segmented { border-radius: 16px; }
  /* An open chat fills the screen between the top edge and the bottom bar, so the input field is always visible.
     --bottombar-h is measured by app.js (syncBottombar). */
  body[data-chat="1"] .topbar { display: none; }
  :root[data-design] body[data-chat="1"] main.content { padding-top: env(safe-area-inset-top, 0px); }
  body[data-chat="1"] .chats-shell {
    height: calc(100vh - var(--bottombar-h, 70px) - env(safe-area-inset-top, 0px));
    height: calc(100dvh - var(--bottombar-h, 70px) - env(safe-area-inset-top, 0px));
  }
  /* Header: back, picture, name and ⋮. The tools open as a menu under ⋮ (app.js, chat-more). */
  body[data-chat="1"] .conv-head { gap: 10px; padding: 10px 12px; position: relative; }
  body[data-chat="1"] .conv-head .grow { flex: 1 1 0; }
  .conv-head .more-btn { display: inline-flex; }
  .conv-head .tools-wrap { position: relative; margin-left: auto; }
  .conv-head .tools-wrap .tools { display: none; }
  .conv-head .tools-wrap.open .tools {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px; position: absolute; right: 0; top: calc(100% + 8px); z-index: 35;
    min-width: 230px; max-width: calc(100vw - 32px); padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  }
  .conv-head .tools-wrap.open .tools > button, .conv-head .tools-wrap.open .tools .pop-wrap > button {
    width: 100%; justify-content: flex-start; gap: 12px; padding: 10px 12px; height: auto; border-radius: 12px; position: relative;
  }
  .conv-head .tools-wrap.open .tools .pop-wrap { display: flex; width: 100%; }
  /* The label of each tool is its (translated) aria-label. */
  .conv-head .tools-wrap.open .tools > button::after, .conv-head .tools-wrap.open .tools .pop-wrap > button::after {
    content: attr(aria-label); font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px;
  }
  .conv-head .tools-wrap.open .tools .mini-count { position: static; order: 2; margin-left: auto; }
  .conv-head .tools-wrap.open .tools .pop-menu { right: 8px; top: calc(100% + 2px); }
  /* Chat facts in one row that scrolls sideways instead of three rows. */
  body[data-chat="1"] .conv-stats:not(.hidden) { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
  body[data-chat="1"] .conv-stats .model-select { width: auto; }
}
/* Lists in cards (recent chats): rows may shrink, so long titles end with … inside the card. */
.feed { grid-template-columns: minmax(0, 1fr); }
.feed > li { min-width: 0; }

/* Documents in Markdown (Changelog, Impressum, Datenschutz): app.js mdDoc */
.md-doc h1, .md-doc h2, .md-doc h3, .md-doc h4, .md-doc h5, .md-doc h6 { line-height: 1.3; }
.popover .md-doc h3 { font-size: 14px; margin: 12px 0 4px; }
.popover .md-doc :is(h4, h5, h6) { font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
.md-doc p + p { margin-top: .6em; }
.md-doc :is(ul, ol) { margin: 4px 0 4px 20px; padding: 0; }
.md-doc li > :is(ul, ol) { margin-top: 2px; }
.md-doc li.task { list-style: none; margin-left: -20px; }
.md-doc li.task input { margin: 0 6px 0 0; vertical-align: -1px; }
.md-doc a { color: var(--accent-text, var(--accent)); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.md-doc pre { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
.md-doc pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
.md-doc hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md-doc blockquote { margin: 8px 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md-doc .md-table { overflow-x: auto; margin: 8px 0; }
.md-doc table { border-collapse: collapse; font-size: 13px; }
.md-doc :is(th, td) { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.md-doc th { background: var(--surface-2); font-weight: 600; }
.md-doc del { opacity: .7; }
.delete-menu { min-width: 250px; max-width: min(300px, calc(100vw - 32px)); padding: 12px; gap: 10px; }
.delete-menu p { margin: 0; line-height: 1.45; white-space: normal; }

/* Desktop: the tools stay in the header, no ⋮. */
@media (min-width: 901px) {
  .conv-head .more-btn { display: none; }
  .conv-head .tools-wrap { display: contents; }
}

/* Android app (mobile_app/): "Full-screen chats" hides the bottom bar in an open chat. */
@media (max-width: 900px) {
  body[data-chat="1"][data-chat-full="1"] .bottombar { display: none; }
  body[data-chat="1"][data-chat-full="1"] { padding: 0; }
  body[data-chat="1"][data-chat-full="1"] main.content { padding: 0; }
  body[data-chat="1"][data-chat-full="1"] .chats-shell {
    height: calc(100vh - env(safe-area-inset-top, 0px)); height: calc(100dvh - env(safe-area-inset-top, 0px));
    border-radius: 0; border: 0; min-height: 0;
  }
}

/* Help: FAQ and guide use the document renderer (mdDoc); keep the compact look of the help cards. */
.help-doc p { margin: 0; }
.help-doc p + p, .help-doc p + ul, .help-doc ul + p, .help-doc p + ol, .help-doc ol + p, .help-doc pre + p, .help-doc p + pre { margin-top: .7em; }
.help-doc pre { font-size: 13px; }
