:root {
  --trail: 16px; /* the distance of every trailing chevron from the right edge of its card, panel or page: ONE value */
  /* black theme with a yellow accent (the colours of Brain); one theme only */
  --bg: #000000; --surface: #0b0b0c; --surface-2: #151516; --surface-3: #1d1d20; --line: #2a2a2e;
  --fg: #ededed; --muted: #9b9ba1; --accent: #f5c518;
  --line-strong: #62626a; --ring: var(--accent); /* focus frames stay yellow (the owner likes them); --line-strong: frames you can see on black */
  --accent-soft: color-mix(in oklch, #f5c518 11%, #121214); --accent-fg: #0a0800;
  --add: #5fcf8a; --del: #f08a82; --del-bg: #2b1514; --mod: #f0a35e; --mod-bg: #2b1d0e;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --side: 288px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 16px; }
.err { color: var(--del); font-size: 13px; }

body:not([data-ready]) #shell { visibility: hidden; } /* the shell is public: stay blank until the server has confirmed the session, so a logged-out visitor never sees it */
#shell { display: flex; height: 100vh; height: 100dvh; }

/* ---------- sidebar */
#side { width: var(--side); flex: none; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-right: 1px solid var(--line); padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 10px; min-height: 0;  overflow-y: auto; overscroll-behavior: contain;}
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 4px 8px 8px; font-size: 17px; font-weight: 650; }
.brand span { flex: 1; }
.brand .icon { width: 34px; height: 34px; }
.brand svg { color: var(--accent); width: 24px; height: 24px; }
#side a { color: var(--fg); text-decoration: none; }
.newchat, #side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-weight: 550; }
.newchat:hover, #side nav a:hover { background: var(--surface-3); }
#side nav a.on, .newchat.on { background: var(--surface-3); }
#side nav a.on { background: var(--surface-3); }
.search input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--fg); font: inherit; font-size: 14px; padding: 8px 12px; }
.clist { flex: none; margin: 4px -4px 0; padding: 0 4px calc(8px + env(safe-area-inset-bottom, 0px)); } /* the whole sidebar scrolls as one (on a phone the part above the list took half of the screen), see #side */
/* the headings of the groups: the text starts where the titles below it start; the fold chevron sits at the right edge, the same on every group */
.grp h3 { margin: 0; padding: 14px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.grp:first-child h3 { padding-top: 6px; }
.citem { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 10px; border-radius: 9px; font-size: 14px; }
.citem:hover { background: var(--surface-3); }
.citem.on { background: var(--accent-soft); }
.citem .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .st svg { width: 13px; height: 13px; color: var(--accent); fill: var(--accent); stroke: none; }
.citem .run { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.citem small { flex-basis: 100%; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .25; } }
#scrim { display: none; }
@media (min-width: 821px) { body:not(.side-collapsed) .top .menubtn { display: none; } } /* wide screen: the header button only shows while the sidebar is folded away */
body.side-collapsed #side { display: none; } /* desktop: the sidebar can be folded away (the choice is remembered) */

/* ---------- main */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; flex: none; min-height: calc(60px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 16px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
/* the title sits at the height of the buttons; the small line below it (project, parent page) hangs under the title and does not push it up */
.ttl { position: relative; align-self: stretch; flex: 1; min-width: 0; display: flex; align-items: center; line-height: 1.25; }
.title { background: none; border: 0; padding: 4px 6px; margin: 0 -6px; text-align: left; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 8px; }
.title:not(.static):not(:disabled):hover { background: var(--surface-3); }
.title:disabled { cursor: default; }
.ttl .sub { position: absolute; left: 0; right: 0; top: calc(50% + 11px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); text-decoration: none; padding: 0; }
.ttl .sub:hover { color: var(--accent); }
.icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: none; border: 0; color: var(--muted); text-decoration: none; flex: none; }
.icon:hover { background: var(--surface-3); color: var(--fg); }
.icon.sm { width: 32px; height: 32px; }
.icon.sm svg { width: 17px; height: 17px; }
.icon.sm { width: 38px; height: 38px; } /* a touch target of at least 36 px (the UI audit test checks it) */
.menubtn { color: var(--fg); }
.badge { font-size: 11px; font-weight: 650; letter-spacing: .04em; padding: 3px 9px; border-radius: 999px; color: var(--muted); background: var(--surface-3); }
.badge.api { background: var(--mod-bg); color: var(--mod); }
.badge.bedrock { background: var(--surface-3); color: var(--muted); }
.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.dock { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }

.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 14px; font-weight: 550; text-decoration: none; color: var(--fg); }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary.danger { background: var(--del); border-color: var(--del); }
.btn svg { width: 17px; height: 17px; }

/* ---------- chat log */
.log { max-width: 780px; margin: 0 auto; padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 22px; min-height: 100%; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 40px 0; }
.empty svg { width: 48px; height: 48px; color: var(--accent); stroke-width: 2.3; }
.empty h1 { margin: 12px 0 4px; font-size: 26px; font-weight: 600; color: var(--fg); }
.empty p { margin: 0; }
.msg { position: relative; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble { max-width: min(88%, 640px); background: var(--surface-3); border: 1px solid var(--line); border-radius: 18px 18px 6px 18px; padding: 10px 14px; overflow-wrap: anywhere; }
.bubble .txt { white-space: pre-wrap; }
.bubble textarea.edit { width: min(78vw, 600px); max-width: 100%; border: 0; background: transparent; color: var(--fg); font: inherit; resize: vertical; outline: none; min-height: 60px; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.att { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--fg); text-decoration: none; font-size: 13px; max-width: 100%; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--muted); }
.att.expired { color: var(--muted); border-style: dashed; }
.att.img { padding: 0; border: 0; background: none; }
.att.img img { display: block; max-width: min(100%, 300px); max-height: 240px; border-radius: 12px; border: 1px solid var(--line); }
.acts { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; margin-top: 2px; }
.msg:hover .acts, .msg:focus-within .acts, .msg.last .acts { opacity: 1; }
@media (hover: none) { .acts { opacity: 1; } }
.msg.assistant:not(.lastassistant) [data-act="redo"] { display: none; }
.msg.user.editing .acts { display: none; }
.assistant .tools:not(:empty) { margin-bottom: 8px; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; }
.toolsum > summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; color: var(--muted); list-style: none; padding: 2px 0; }
.toolsum > summary::-webkit-details-marker { display: none; }
.toolsum > summary svg { width: 13px; height: 13px; }
.toolsum > summary::after { content: '›'; font-size: 15px; transition: transform .15s; }
.toolsum[open] > summary::after { transform: rotate(90deg); }
.toolsum > .steps { margin-top: 6px; }
.tool { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool svg { width: 13px; height: 13px; }
.assistant .err { margin-top: 8px; padding: 8px 12px; background: var(--del-bg); border-radius: 10px; }
.assistant.stopped .err { background: var(--surface-2); color: var(--muted); }
.working { display: inline-flex; gap: 5px; padding: 10px 0 2px; }
.working i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.working i:nth-child(2) { animation-delay: .2s; } .working i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- rendered markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .5em; line-height: 1.3; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.5em; }
.md li { margin: .2em 0; }
.md li > p { margin: 0 0 .4em; }
.md blockquote { margin: 0 0 .85em; padding: 2px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md code { font: .88em var(--mono); background: var(--surface-3); border-radius: 5px; padding: .12em .38em; }
.md pre code { background: none; padding: 0; border-radius: 0; font-size: 13px; }
.codeblock { margin: 0 0 .9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.codehead { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font: 12px var(--mono); color: var(--muted); background: var(--surface-3); }
.codehead .copy { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 8px; }
.codehead .copy:hover { color: var(--fg); background: var(--surface-2); }
.codehead svg { width: 16px; height: 16px; }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.codeblock pre code.hljs { background: none; padding: 0; }
.tbl { overflow-x: auto; margin: 0 0 .9em; border: 1px solid var(--line); border-radius: 10px; }
.tbl table { border-collapse: collapse; width: 100%; font-size: 14px; }
.tbl th, .tbl td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: var(--surface-3); font-weight: 650; white-space: nowrap; }
/* a word is not torn apart inside a table (the text around it wraps at spaces, a wide table scrolls sideways); numbers and dates never wrap */
.tbl th, .tbl td { overflow-wrap: normal; word-break: normal; }
.tbl td.nw { white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.md .chk { color: var(--muted); }
.md .chk.on { color: var(--accent); }
.md li:has(> .chk), .md li:has(> p > .chk) { list-style: none; margin-left: -1.2em; }
.md-img { max-width: 100%; border-radius: 10px; }
.math.block { display: block; margin: .6em 0 1em; overflow-x: auto; overflow-y: hidden; text-align: center; padding: 2px 0; }
.math-err { color: var(--mod); font-family: var(--mono); }
.mathml-out { margin: .6em 0 1em; overflow-x: auto; text-align: center; }
.mathml-out math { font-size: 1.15em; }
.md math { font-size: 1.05em; }
.svgblock { margin: .4em 0 .6em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.svgblock img { width: 100%; max-width: 560px; max-height: 520px; height: auto; } /* an SVG with only a viewBox fills the width: not wider than 560px, or a small drawing becomes huge */
.svgblock.broken { color: var(--mod); font-size: 13px; }
details.svgsrc { margin: 0 0 .9em; }
details.svgsrc > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 2px 0; }
details.svgsrc .codeblock { margin-top: 6px; }
.diagram { position: relative; margin: .4em 0 1em; cursor: zoom-in; }
.diagram > svg { display: block; margin: 0 auto; width: 100%; height: auto; max-height: 75vh; max-width: none; stroke-width: initial; fill: initial; } /* always the width of the chat; a tap opens the viewer (zoom.js) */
.diagram .dzoom { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--muted); opacity: 0; transition: opacity .15s; pointer-events: none; }
.diagram:hover .dzoom, .diagram:focus-visible .dzoom { opacity: 1; }
@media (pointer: coarse) { .diagram .dzoom { opacity: .85; } }
.diagram .dzoom svg { width: 16px; height: 16px; }
.diagram:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 8px; }
/* the diagram viewer */
.viewer { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: var(--bg); }
.vbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.vbar .vlabel { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar button { min-width: 40px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); font-size: 18px; cursor: pointer; }
.vbar button[data-z="fit"] { font-size: 14px; }
.vbar .vz { min-width: 52px; text-align: right; color: var(--muted); font-size: 13px; }
.vstage { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.vstage.drag { cursor: grabbing; }
.vcanvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.vcanvas svg { display: block; }
.sketch, .htmlprev { margin: .4em 0 .6em; }
.sketch-wrap { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.sketch-frame { display: block; width: 100%; height: 300px; border: 0; background: var(--surface-2); }
.sketch-frame.html { background: #fff; }
.sketch-pp { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--fg); }
.sketch-pp svg { width: 16px; height: 16px; }
.sketch-err { margin-top: 6px; font-size: 13px; color: var(--del); }

/* ---------- composer */
.composer { max-width: 780px; margin: 0 auto; width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 8px 10px 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.composer:focus-within { border-color: var(--ring); }
.composer.drop { border-color: var(--accent); background: var(--accent-soft); }
.composer textarea { width: 100%; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 16px; resize: none; outline: none; padding: 6px 2px; max-height: 240px; }
.crow { display: flex; align-items: center; gap: 2px; }
.crow .spacer { flex: 1; }
.composer .more { width: 36px; height: 36px; }
.send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; flex: none; }
.send:disabled { background: var(--surface-3); color: var(--muted); cursor: default; }
.send svg { width: 20px; height: 20px; stroke-width: 2.2; }
.send.stop { background: var(--fg); color: var(--bg); }
.icon-btn { width: 36px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: 50%; display: inline-grid; place-items: center; flex: none; } /* the info button and the microphone */
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }
.icon-btn.info.warn { color: var(--del); } /* the chat has become expensive */
.icon-btn.mic.rec { background: var(--accent-soft); color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.chip.file { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 8px; font-size: 13px; max-width: 100%; }
.chip.file img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.chip.file svg { width: 15px; height: 15px; }
.chip.file .nm { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.file small { color: var(--muted); }
.chip.file .x { border: 0; background: none; color: var(--muted); padding: 2px; display: grid; }
.chip.file .x svg { width: 13px; height: 13px; }

/* ---------- pages (projects, settings) */
.page { max-width: 780px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 28px; }
.page .lead { margin: 0; color: var(--muted); }
.page h2 { margin: 0 0 12px; font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.page h2 small, .page h2 select { text-transform: none; letter-spacing: 0; font-weight: 400; }
.page h2 select { margin-left: auto; }
.page section textarea, .page select, .dlg input, .dlg textarea, .dlg select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--fg); font: inherit; font-size: 15px; padding: 10px 12px; }
.page h2 select { width: auto; padding: 10px 10px; font-size: 13px; }
.page section textarea:focus, .dlg input:focus, .dlg textarea:focus { outline: none; border-color: var(--ring); }
.page section textarea { resize: vertical; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--fg); text-decoration: none; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card > svg { color: var(--accent); margin-top: 2px; }
.card b { display: block; }
.card small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere; }
.card small.count { margin-top: 6px; }
.phead h1 { margin: 0; font-size: 24px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.frow, .plink { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 8px; color: var(--fg); text-decoration: none; }
.frow .nm, .plink .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow small, .plink small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.frow > svg, .plink > svg { color: var(--muted); }
.plink:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card-plain { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card-plain p { margin: 0 0 8px; }
.card-plain p:last-child { margin-bottom: 0; }
.card-plain code, .page code { font: .88em var(--mono); background: var(--surface-3); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
.facts { margin: 8px 0 0; padding-left: 18px; }
.facts .warn { color: var(--mod); }
.copyline { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.copyline code { flex: 1; min-width: 0; padding: 8px 10px; }

/* ---------- dialog, menu, toast, banner */
.dlg { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--fg); padding: 0; width: min(440px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .65); }
.dlg form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg h2 { margin: 0; font-size: 17px; }
.dlg p { margin: 0; color: var(--muted); font-size: 14px; }
.dlg label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dlg textarea { min-height: 200px; font-family: var(--mono); font-size: 13px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.menu { position: fixed; z-index: 60; min-width: 220px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--del); }
.menu svg { width: 17px; height: 17px; color: var(--muted); }
.menu button.danger svg { color: var(--del); }
#toast { position: fixed; z-index: 70; left: 50%; width: max-content; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px; padding: 9px 16px; font-size: 14px; max-width: calc(100vw - 32px); transition: opacity .15s, transform .15s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--del-bg); color: var(--del); border-color: transparent; }
.update-banner { position: fixed; z-index: 80; top: env(safe-area-inset-top, 0px); left: 0; right: 0; border: 0; padding: 10px 16px; background: var(--accent); color: var(--accent-fg); font-size: 15px; cursor: pointer; }

/* ---------- phone: the sidebar becomes a drawer */
@media (max-width: 820px) {
  #side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .7); }
  body.nav-open #side { transform: none; }
  body.nav-open #scrim { display: block; position: fixed; z-index: 30; inset: 0; background: rgba(0, 0, 0, .6); }
  .log { padding-top: 14px; }
  .bubble { max-width: 94%; }
}
.top .btn { min-height: 38px; padding: 6px 14px; }

/* the info panel of a chat (model, tokens, price) */
.info-pop { padding: 12px 14px; min-width: 230px; max-width: min(340px, calc(100vw - 16px)); font-size: 13.5px; }
.info-pop dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.info-pop dt { color: var(--muted); }
.info-pop dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.info-pop dd.hot { color: var(--del); }
.info-pop p { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.info-pop p.hot { color: var(--del); }

/* a file Claude wrote for the project (```datei:name): a folded card */
.filecard { margin: 0 0 .9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.filecard > summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; }
.filecard > summary::-webkit-details-marker { display: none; }
.filecard > summary svg { width: 18px; height: 18px; color: var(--accent); }
.filecard > summary small { margin-left: auto; color: var(--muted); }
.filecard > summary::after { content: '›'; color: var(--muted); font-size: 15px; transition: transform .15s; }
.filecard[open] > summary::after { transform: rotate(90deg); }
.filecard > .codeblock { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }

/* meters: context window and subscription limits */
.meters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.meter .mhead { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.meter .mhead b { font-weight: 500; color: var(--fg); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.hot .bar i { background: var(--del); }
.meter.hot .mhead b { color: var(--del); }
.card-plain .meters { margin-top: 12px; }

.menu .mh { padding: 8px 10px 3px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu .mh:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.flux { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.flux svg { width: 13px; height: 13px; }

.citem .ghost { color: var(--muted); display: inline-flex; }
.citem .ghost svg { width: 15px; height: 15px; }
.archivebtn { display: flex; align-items: center; gap: 8px; margin: 0 -2px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border: 0; border-top: 1px solid var(--line); background: none; color: var(--muted); font-size: 13.5px; text-align: left; }
.archivebtn:hover { color: var(--fg); background: var(--surface-3); }
.archivebtn svg { width: 17px; height: 17px; }

.codehead .dl { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 8px; margin-left: auto; margin-right: 2px; }
.codehead .dl:hover { color: var(--fg); background: var(--surface-2); }
.codehead .dl svg { width: 16px; height: 16px; }
.msg.speaking [data-act="speak"] { color: var(--accent); }

/* the shopping list / checklists */
.list { gap: 18px; }
.lgroup h2 { margin-bottom: 8px; }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tasks .task { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); text-align: left; font-size: 16px; }
.tasks .task:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tasks .box { flex: none; width: 22px; height: 22px; border: 1.5px solid var(--muted); border-radius: 6px; display: grid; place-items: center; color: var(--accent-fg); }
.tasks .box svg { width: 16px; height: 16px; stroke-width: 2.6; }
.tasks .task.done .box { background: var(--accent); border-color: var(--accent); }
.tasks .task.done .tx { text-decoration: line-through; color: var(--muted); }
.ladd, .lnew { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.ladd input, .lnew input { flex: 1; min-width: 0; border: 1px dashed var(--line); border-radius: 12px; background: transparent; color: var(--fg); font: inherit; font-size: 15px; padding: 10px 12px; }
.ladd input:focus, .lnew input:focus { outline: none; border-style: solid; border-color: var(--ring); }
.btn:disabled { opacity: .45; cursor: default; }
.card-plain .row + p { margin-top: 14px; }

/* favourite knowledge files in the sidebar and the star on files */
.citem.file { display: flex; align-items: center; gap: 8px; }
.citem .fi { flex: none; width: 16px; display: inline-grid; place-items: center; }
.citem .fi svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.citem { gap: 8px; }
.citem.file .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem .cnt { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3, var(--line)); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; line-height: 20px; }
.icon.star.on svg, #fstar.on svg { color: var(--accent); fill: var(--accent); }
.frow a.nm { color: inherit; text-decoration: none; }
.frow a.nm:hover { text-decoration: underline; }
.filebody { padding-bottom: 40px; }

/* the button next to selected text: take it over into a chat as a quote */
.quotebtn { position: fixed; z-index: 60; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-3, var(--surface)); color: var(--fg); font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .45); cursor: pointer; }
.quotebtn[hidden] { display: none; }
.quotebtn svg { width: 16px; height: 16px; color: var(--accent); }

/* answers to pick (```auswahl / ```mehrfach) */
.choices { display: flex; flex-direction: column; align-items: stretch; gap: 2px; margin: 10px 0 4px; max-width: 34rem; }
/* one answer per line, with a marker in front instead of a frame: a yellow triangle for "tap one", a round tick box for "pick several" */
.choice { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--fg); font: inherit; font-size: 15.5px; text-align: left; cursor: pointer; }
.choice:hover, .choice:active { background: var(--surface-2); }
.choice::before { content: ''; flex: none; width: 0; height: 0; margin: 0 4px 0 2px; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent var(--accent); }
.choices.many .choice::before { width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--line-strong); border-radius: 50%; background: transparent; }
.choices.many .choice.on::before { border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M5 9.5l2.7 2.7L13 6.5' fill='none' stroke='%230a0800' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; }
.choice.send { width: auto; height: auto; justify-content: center; margin-top: 8px; background: var(--accent); color: var(--accent-fg); font-weight: 600; align-self: flex-start; padding: 9px 20px; border-radius: 999px; }
.choice.send::before { display: none; }
.choice.send:disabled { opacity: .4; cursor: default; background: var(--accent); color: var(--accent-fg); }
/* an old question is history: the answers stay visible but cannot be tapped any more */
.msg.assistant:not(.lastassistant) .choices { opacity: .45; pointer-events: none; }

/* the project list: one project per line, newest change on top */
.prows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.prow { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--fg); text-decoration: none; border-top: 1px solid var(--line); }
.prow:first-child { border-top: 0; }
.prow:hover { background: var(--surface-3, var(--surface)); }
.prow > svg { flex: none; width: 18px; height: 18px; color: var(--muted); }
.prow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.prow small { flex: none; color: var(--muted); font-size: 13px; }
.prow .when { min-width: 62px; text-align: right; }
@media (max-width: 560px) { .prow { flex-wrap: wrap; row-gap: 2px; } .prow .nm { flex-basis: calc(100% - 100px); } .prow .cnts { order: 3; margin-left: 30px; flex-basis: 100%; } }

/* recent projects, indented under "Projekte"; the favourites fold */
#recentprojects { display: flex; flex-direction: column; margin: -2px 0 4px; }
#recentprojects .rp { display: block; padding: 6px 10px 6px 38px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#recentprojects .rp:hover { background: var(--surface-3, var(--surface)); color: var(--fg); }
#recentprojects .rp.on { color: var(--fg); background: var(--surface-3, var(--surface)); }
.grp h3.fold { display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer; user-select: none; }
.grp h3.fold:hover { color: var(--fg); }
.grp.folded h3.fold { padding-bottom: 8px; }
.grp.folded > :not(h3) { display: none; }

.filelink { color: var(--accent); text-decoration: none; border-bottom: 1px dotted color-mix(in srgb, var(--accent) 60%, transparent); }
.filelink code { color: inherit; }

.subh { margin: 16px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.devices li.muted { border: 0; padding-left: 0; }
.devices .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.devices small { color: var(--muted); white-space: nowrap; }

/* the Drive picker */
.drivepick { width: min(520px, calc(100vw - 24px)); }
.drivepick input[type=search] { width: 100%; margin-bottom: 10px; }
.dfiles { list-style: none; margin: 0 0 10px; padding: 0; max-height: 52vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.dfiles .muted { padding: 8px 2px; }
.dfile { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); text-align: left; cursor: pointer; }
.dfile:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.dfile.loading { opacity: .6; }
.dfile > svg { flex: none; color: var(--muted); }
.dfile .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dfile small { color: var(--muted); white-space: nowrap; font-size: 12px; }

/* groups of knowledge files: a panel per group, the header folds it */
.fgroup { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fgroup h3 { margin: 0; padding: 12px var(--trail); font-size: 16px; font-weight: 650; color: var(--fg); }
.fgroup h3 small { margin-left: auto; min-width: 22px; padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 22px; text-align: center; }
.fgroup h3.fold { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.fgroup h3.fold:hover { background: var(--surface-3); }
.fgroup.folded .fbody { display: none; }
.fgroup .fbody { border-top: 1px solid var(--line); }
.fgroup .frow { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.fgroup .frow:first-child { border-top: 0; }
.fgroup.recent { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.fgroup.recent h3 .chev { color: var(--accent); }
.linkbtn { margin-left: 10px; padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; }
.linkbtn[hidden] { display: none; }
.frow small { overflow: hidden; text-overflow: ellipsis; max-width: 50%; }

/* a row of a knowledge file: the title (up to two lines) with file name and size below it, the buttons on the right: the title is never squeezed to a letter */
.frow .ftxt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.frow .ftxt .nm { flex: none; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; line-height: 1.3; }
.frow .ftxt small { max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the full-screen editor for knowledge files */
.editor { position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); }
.ebar { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.ebar .etitle { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ebar .btn { min-height: 40px; display: inline-flex; align-items: center; gap: 8px; }
.ebar .btn svg { width: 20px; height: 20px; }
.ebar .btn.busy { opacity: .6; }
@media (max-width: 560px) { .ebar .btn { min-width: 44px; justify-content: center; padding: 0 10px; } .ebar .btn .lbl { display: none; } } /* narrow: only the symbols */
.editor .ename { box-sizing: border-box; width: calc(100% - 24px); flex: none; margin: 10px 12px 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); font: inherit; font-size: 16px; font-weight: 600; }
.editor .etext { flex: 1; min-height: 0; width: 100%; margin: 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); border: 0; border-radius: 0; outline: none; resize: none; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--mono); tab-size: 2; }
@media (min-width: 900px) { .editor .etext, .editor .ename { max-width: 900px; width: 100%; margin-left: auto; margin-right: auto; } .editor .ename { box-sizing: border-box; } }

/* the project behind the title of a chat in the sidebar */
.citem .pj { flex: 0 1 auto; max-width: 42%; margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.citem .t { flex: 1 1 0; } /* the title gives way (…) so that the line never breaks and the project stays at the right edge */
.citem .st, .citem .run, .citem .fi, .citem .ghost, .citem .cnt { flex: none; }

/* viewer for pictures and PDFs of the knowledge base */
.imgview { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: zoom-in; overflow: hidden; }
.imgview img { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.pdfview { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.filebody:not(.md) .row { margin-top: 14px; }

/* Import */
#side nav a .cnt { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 650; text-align: center; line-height: 20px; }
#side nav a .cnt.wait ~ .cnt.alert { margin-left: 4px; }
#side nav a .cnt.alert { background: #e5484d; color: #fff; } /* red: something waits for an answer */
#importlink.sorting svg { animation: pulse 1.2s ease-in-out infinite; }
.importpage .frow .thumb { flex: none; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-3); }
.importpage #sort { margin-left: auto; }
.importpage #sort.busy { opacity: .6; }
.importpage #rules { width: 100%; font: 14px/1.5 var(--mono); }

/* messages waiting for the end of the answer */
.queue { padding: 0 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.queue:empty { display: none; }
.qmsg { display: flex; align-items: center; gap: 8px; max-width: 85%; opacity: .6; }
.qmsg .txt { padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--surface-3); white-space: pre-wrap; overflow-wrap: anywhere; }
.qmsg .txt small { display: block; margin-top: 4px; color: var(--muted); }
.qmsg .wait { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* a long message of the user: five lines, then a small button for the rest */
.msg.user .txt.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.msg.user .more-msg { align-self: flex-end; margin: 2px 4px 0; padding: 0 8px; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.msg.user .bubble { display: flex; flex-direction: column; }

/* undo of the file changes of an answer */
.msg .undo { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.msg .undo small { color: var(--muted); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13.5px; }

/* a message with a button (Rückgängig) can be tapped */
#toast.act { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toastbtn { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 650; cursor: pointer; padding: 4px 2px; }

/* "‹ 2/3 ›": the other versions of an edited question or of an answer */
.msg .branch { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; margin: 2px 0; }
.msg.user .branch { justify-content: flex-end; }
.msg .branch[hidden] { display: none; }
.msg .branch .icon { width: 26px; height: 26px; font-size: 18px; line-height: 1; color: var(--muted); }
.msg .branch .icon:disabled { opacity: .3; }
.msg .branch .bcount { min-width: 30px; text-align: center; }

/* the folded settings of the Import page */
.ibody { padding: 0; } /* the rows run edge to edge inside the panel, their text starts where the heading text starts */

/* no tap flash: a tap shows itself by what it does (folding, opening) */
* { -webkit-tap-highlight-color: transparent; }

/* skills */
.skillrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 8px; }
.skillrow .stxt { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; color: var(--fg); text-decoration: none; }
.skillrow .stxt b { font-weight: 650; }
.skillrow .stxt small { flex-basis: 100%; color: var(--muted); font-size: 13px; line-height: 1.35; }
.skillrow.flags { flex-wrap: wrap; }
.tag { padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11.5px; line-height: 20px; }

/* the Wissen panel folds as a whole */
h2.kfold { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 10px 0; margin: -10px 0 2px; } /* 40 px to touch, the rhythm of the page stays */
/* a folded section is only its heading: no gap below it, a short one to the next section */
section.kfolded h2.kfold { margin-bottom: -10px; }
.page section.kfolded { margin-bottom: -14px; }
section.kfolded .kbody, section.kfolded #foldall { display: none; }
h2.kfold #foldall { margin-left: auto; }
h2.kfold .chev { margin-left: auto; margin-right: var(--trail); }
h2.kfold #foldall:not([hidden]) + .chev { margin-left: 8px; }
section.kfolded h2.kfold #foldall + .chev { margin-left: auto; } /* (folded: the button is not shown, the chevron goes to the right edge) */
.fgroup h3.fold .chev { margin-left: 8px; margin-right: 0; }
.fgroup h3.fold:not(:has(small)) .chev { margin-left: auto; } /* (a heading with a count: the count is pushed right, the chevron follows it) */
/* a chat row: the title on the left, the date at the right edge (before the menu), no icon */
.chatrow .nm { flex: 1; min-width: 0; font-weight: 500; }
.chatrow .when { flex: none; color: var(--muted); font-size: 13px; white-space: nowrap; text-align: right; }


/* a settings row: the name on the left, the value on the right, a chevron; one thin divider between rows (Import settings) */
.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fgroup .srow, .panel .srow { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; margin: 0; padding: 0 var(--trail); border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--fg); font: inherit; font-size: 15.5px; text-align: left; cursor: pointer; }
.fgroup .srow:first-child, .panel .srow:first-child { border-top: 0; }
.fgroup .srow:hover, .panel .srow:hover { background: var(--surface-2); }
.srow .k small { display: block; margin-top: 1px; color: var(--muted); font-size: 13px; line-height: 1.3; }
.panel .srow { text-decoration: none; }
.srow .k { flex: 1; min-width: 0; }
.srow .v { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
/* a row that leads somewhere (another page, an editor, a choice) ends with a chevron pointing right: ONE rule for all of them */
.srow::after, .instrrow::after { content: ''; flex: none; width: 7px; height: 7px; margin-left: 2px; border-right: 1.6px solid var(--muted); border-top: 1.6px solid var(--muted); transform: rotate(45deg); }
.srow select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }

/* ---- chess (ported from Brain): the viewer for ```pgn blocks (public/chess/) and the analysis screen */
:root { --btn: 44px; } @media (hover: hover) and (pointer: fine) { :root { --btn: 38px; } }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: var(--btn); height: var(--btn); }
.dbtn { flex: none; width: 42px; height: 42px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 999px; background: transparent; color: #e8e8ee; cursor: pointer; transition: background .12s, transform .12s; }
.dbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dbtn:hover { background: #2a2a30; }
.dbtn:active { transform: scale(.92); }
.dbtn:disabled { opacity: .4; }
.dbtn.danger { color: #b4b4be; } .dbtn.danger:hover, .dbtn.danger:active { color: #ff8a8a; }
/* chess viewer (public/chess/): a ```pgn block in a page */
.chessv { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 16px; outline: none; max-width: 560px; }
.cv-meta { color: var(--muted); font-size: 13px; }
.cv-error { border: 1px solid color-mix(in srgb, var(--del) 45%, transparent); background: var(--del-bg); color: var(--del); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.cv-boardrow { display: flex; gap: 8px; align-items: stretch; }
.cv-board { flex: 1; min-width: 0; touch-action: manipulation; }
.cv-board .cb { display: block; width: 100%; height: auto; border-radius: 6px; user-select: none; }
.cv-evbar { flex: none; width: 22px; border-radius: 4px; overflow: hidden; background: var(--ev-light, #eff1e7); position: relative; }
.cv-evbar i { position: absolute; left: 0; right: 0; top: 0; background: var(--ev-dark, #2b2b2e); transition: height .25s; }
.cv-evbar.flip i { top: auto; bottom: 0; }
.cv-ctl { display: flex; align-items: center; gap: 8px; }
@media (max-width: 340px) { .cv-ctl { gap: 4px; } } /* six round buttons must fit a 320 px phone */
.cv-ctl .icon-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cv-now { min-height: 22px; font-size: 14px; }
.cv-now .cv-evl { color: var(--muted); font-size: 13px; margin-left: 6px; }
.cv-c { margin-top: 4px; color: var(--fg); font-size: 14px; line-height: 1.45; }
.cv-moves { max-height: 190px; overflow-y: auto; font-size: 14px; line-height: 1.9; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 8px 12px; }
.cv-mv { cursor: pointer; padding: 2px 3px; border-radius: 6px; white-space: nowrap; }
.cv-mv:hover { background: var(--surface); }
.cv-mv.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.cv-mv.has-c::after { content: '•'; color: var(--accent); margin-left: 2px; font-size: 11px; }
.cv-var { color: var(--muted); font-size: 13px; }
.cv-q { font-weight: 700; margin-left: 2px; }
.cv-q.ungenau { color: #d9a400; }
.cv-q.fehler, .cv-q.patzer { color: var(--del); }
.cv-curvebox { cursor: pointer; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; line-height: 0; }
.cv-curve { width: 100%; height: 70px; display: block; }
.cv-curve-bg { fill: var(--surface-2); }
.cv-curve-w, .cv-curve-b { fill: #9a9da3; opacity: .8; } /* one grey for both sides, as on Lichess: the position above or below the middle line says who leads */
.cv-curve-line { fill: none; stroke: #b4b7bc; stroke-width: 1; vector-effect: non-scaling-stroke; }
.cv-curve-mid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cv-curve-cur { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.cv-actions { margin-top: 2px; }
.chess:not([data-done]) pre { max-height: 160px; overflow: auto; }

/* chess analysis screen (public/chess/analyze.js): full screen over the app, like the drawing surface */
.chessa { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.ca-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.ca-bar .dbtn[aria-pressed="false"] { opacity: .45; }
.ca-bar .dbtn[aria-pressed="true"] { color: var(--accent); } /* engine running: yellow with a filled chip, as on Lichess */
.ca-bar .dbtn[aria-pressed="true"] svg rect { fill: color-mix(in srgb, var(--accent) 40%, transparent); }
.ca-title { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px 12px 20px; }
.ca-body .cv-boardrow { width: 100%; max-width: 560px; align-self: center; }
.ca-side { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 560px; align-self: center; }
.ca-status { color: var(--muted); font-size: 12px; min-height: 16px; }
.ca-lines { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.ca-line { display: flex; gap: 12px; align-items: baseline; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--fg); font: inherit; font-size: 14px; padding: 10px 12px; min-height: var(--btn); cursor: pointer; }
.ca-line:first-child { border-top: 0; }
.ca-line b { flex: none; min-width: 52px; font-variant-numeric: tabular-nums; }
.ca-line span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ca-lines .muted { padding: 10px 12px; }
.ca-lines { min-height: calc(3 * var(--btn) + 2px); }
.ca-line.stale { opacity: .45; cursor: default; }
.ca-now { min-height: 24px; font-size: 14px; }
.ca-var { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ca-curve { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; line-height: 0; }
@media (min-width: 900px) {
  .ca-body { flex-direction: row; align-items: flex-start; justify-content: center; gap: 24px; padding: 20px; }
  .ca-body .cv-boardrow { flex: 0 1 min(70vh, 640px); min-width: 0; align-self: flex-start; }
  .ca-side { flex: 0 1 360px; min-width: 0; align-self: flex-start; }
}

/* the board by hand (analyze.js): drag layer, as on lichess.org */
.chessa .cv-board { position: relative; touch-action: none; }
.chessa .cv-board [data-sq] { cursor: grab; }
.chessa .cv-board.dragging, .chessa .cv-board.dragging [data-sq] { cursor: grabbing; }
.cb-ghost { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; filter: drop-shadow(0 3px 6px rgba(0,0,0,.45)); }
.cb-ghost svg { width: 100%; height: 100%; display: block; }
.cb-hover { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; background: color-mix(in srgb, var(--accent) 38%, transparent); }
.cb-promo { position: absolute; z-index: 6; width: 12.5%; display: flex; flex-direction: column; background: var(--surface-2); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.55); overflow: hidden; }
.cb-promo button { width: 100%; aspect-ratio: 1; padding: 0; border: 0; background: transparent; cursor: pointer; }
.cb-promo button:hover { background: var(--accent-soft); }
.cb-promo svg { width: 100%; height: 100%; display: block; }
.cv-pl { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 22px; }
.cv-pl[hidden] { display: none; }
.cv-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--muted); }
.cv-dot.w { background: #eff1e7; }
.cv-dot.b { background: #2b2b2e; }
.cv-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cv-elo { color: var(--muted); font-size: 13px; }
.cv-evbar .cv-evl { position: absolute; left: 0; right: 0; text-align: center; font-size: 9.5px; font-weight: 700; line-height: 1; padding: 3px 0; font-variant-numeric: tabular-nums; pointer-events: none; }
.cv-evbar .cv-evl.at-top { top: 0; } .cv-evbar .cv-evl.at-bottom { bottom: 0; }
.cv-evbar .cv-evl.on-light { color: #1d1d1f; } .cv-evbar .cv-evl.on-dark { color: #f2f2f2; }

/* the budget of the always-loaded skills */
.budget { margin: 4px 2px 0; font-size: 13px; color: var(--muted); }
.budget.warn { color: var(--mod); }
.budget.full { color: var(--del); }

/* the chess board is a picture of its own: the general icon rule for svg (fill none, thin stroke, 20 px) must not reach into the pieces (black ones rely on the default fill) */
svg.cb { width: 100%; height: auto; fill: initial; stroke: initial; stroke-width: initial; stroke-linecap: initial; stroke-linejoin: initial; flex: initial; }
/* the list of games: every row is one box of the same height, long names are cut (the frames do not jump with the text) */
#games .game { width: 100%; height: 62px; align-items: center; cursor: pointer; font: inherit; text-align: left; }
#games .game .ftxt { min-width: 0; flex: 1; }
#games .game .nm, #games .game small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#games .gmore { text-align: center; padding: 14px 0 24px; color: var(--muted); font-size: 13px; }

/* the settings of one skill: a row per switch, its meaning in the row */
.setpanel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; margin-bottom: 14px; }
.setrow { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border-top: 1px solid var(--line); }
.setrow:first-child { border-top: 0; }
.setrow .k { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.setrow .k b { font-weight: 600; font-size: 15.5px; }
.setrow .k small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.setrow .v { flex: none; color: var(--muted); }

.instrrow { display: flex; align-items: center; gap: 10px; min-height: 48px; width: 100%; padding: 12px var(--trail); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.instrrow:hover { background: var(--surface-2); }
.instrrow .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.instrrow.empty .nm { color: var(--muted); }


/* the choice of one skill: three states in one pill */
.setrow.col { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
.setrow.col b { font-weight: 600; font-size: 15.5px; }
.setrow.col small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); }
.segbtn { flex: 1; min-height: 40px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.segbtn.on { background: var(--accent); color: var(--accent-fg); }

/* ONE fold chevron for every foldable heading (sidebar groups, file groups, Import settings, project sections): pointing down when open, right when folded */
.chev { flex: none; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; }
.grp.folded .chev, .fgroup.folded .chev, section.kfolded .chev { transform: rotate(-45deg); }
.grp h3.fold .chev { margin-right: 4px; } /* (the sidebar has its own, smaller inset) */

.gapt { margin-top: 10px; }
