
/* ============================================================
   KAITEIKARTEN - Aussehen

   Abgeleitet aus design/entwurf-5.html. Das Layout haengt per Container
   Query an der Breite von .app (700 px, 1100 px, 1300 px) - dieselben
   Umbrueche wie im Mock. Tastatur-Hinweise erscheinen nur mit Maus und
   Tastatur (hover: hover, pointer: fine).

   Alle Farben sind Tokens, geschrieben als light-dark(hell, dunkel);
   die App folgt hell/dunkel des Systems.
   ============================================================ */

:root { color-scheme: light dark; }

:root {
  --bg: light-dark(#f3f1ec, #111316);
  --surface: light-dark(#ffffff, #1a1d22);
  --surface-2: light-dark(#ebe8e1, #24282f);
  --line: light-dark(#ddd8cd, #2d323a);
  --line-strong: light-dark(#c5beb0, #434a55);
  --text: light-dark(#1e1d1a, #e9eaed);
  --dim: light-dark(#6d695f, #9aa1ad);
  --dim-2: light-dark(#98938a, #6b727d);
  --accent: light-dark(#2d5bd0, #7ea3ff);
  --accent-soft: light-dark(#e2e9fb, #1d2943);
  --on-accent: light-dark(#ffffff, #0b1326);
  --ok: light-dark(#1d7f4c, #52d18e);
  --ok-soft: light-dark(#dcf1e5, #15301f);
  --on-ok: light-dark(#ffffff, #06210f);
  --bad: light-dark(#bf3a2c, #ff7d6d);
  --bad-soft: light-dark(#f8e2de, #3a1e1b);
  --warn: light-dark(#8f5c00, #f0b54a);
  --warn-soft: light-dark(#f8ecd2, #33270f);
  --rule: light-dark(#e0675a, #b0564d);
  --shadow-c: light-dark(rgba(46, 36, 16, .10), rgba(0, 0, 0, .5));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }

/* Die ganze App ist ein Container; ihre Breite bestimmt das Layout. */
/* Unten bleibt Platz fuer den Home-Indikator (iPhone, iPad). Auf Android
   zeichnet die Seite nicht unter die Navigationsleiste (kein viewport-fit=cover,
   siehe index.html), der Wert ist dort 0. Falls doch: Chrome meldet
   env(safe-area-inset-bottom) erst nach dem ersten Scrollen, diese Seite scrollt
   nie - safe-area-max-inset-bottom steht sofort fest; Safari kennt es nicht und
   nimmt den Ersatzwert. Der Abstand sitzt einmal an #app, nicht an jeder Leiste. */
:root { --unten: env(safe-area-max-inset-bottom, env(safe-area-inset-bottom, 0px)); }
/* 100svh statt 100dvh: als installierte App auf Android zaehlt Chrome die
   Navigationsleiste offenbar zum "grossen" Viewport (wie eine ausblendbare
   Leiste) - dvh war dort genau um ihre Hoehe zu hoch. Die Seite scrollt nie,
   Leisten blenden sich also nie aus; im Browser ist svh daher dasselbe. */
#app { height: 100vh; height: 100svh; padding-bottom: var(--unten); }

/* ============================================================
   APP
   ============================================================ */

.app { container: app / inline-size; position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
:where(.app) :where(button, input, textarea) { font: inherit; color: inherit; margin: 0; }
:where(.app) button { cursor: pointer; }
:where(.app) :where(h2, p) { margin: 0; }
/* Im Entwurf trugen diese Bereiche eine Index-Marke und waren dadurch
   position: relative - darauf verlassen sich z. B. der Vote auf der
   Abfragekarte (absolut in .qcard) und die Stapelung der Ebenen. Ohne
   Spezifitaet, damit jede eigene Angabe gewinnt. */
:where(.app) :where(.decks, .side-empty, .deck-add, .side-foot .link, .welcome, .deck-head .btn, .bottom-bar .btn, .back,
  .title-wrap, .new-btn, .deck-end .link, .tagbar, .tagbar .chip, .tile, .tile-tags, .tile-pic, .vote, .field, .field-tools,
  .field-tools .tool, .ta, .preview-text, .thumb, .ed-head, .ed-note, .ed-foot .link, .score-field, .tag-box, .tag-sugg,
  .check-row, .rail, .icon-btn, .qz-deck, .qz-prog, .qcard, .qc-content, .qz-hint, .qz-keys, .qz-foot, .stats,
  .end-actions .btn, .bulk-head, .bulk-tools, .selall, .row, .tagpanel, .tp-del, .tp-foot .btn, .bulk-bar, .ask) { position: relative; }

.shell { height: 100%; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.shell > * { grid-area: 1 / 1; min-width: 0; min-height: 0; }
.side, .deck, .editor { display: none; }
.shell[data-screen="start"] > .side, .shell[data-screen="leer"] > .side { display: flex; }
.shell[data-screen="stapel"] > .deck { display: flex; }
.shell[data-screen="karte"] > .editor { display: flex; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 15px; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--line-strong); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: none; border-color: transparent; color: var(--accent); font-weight: 500; padding: 0 10px; }
.btn .n { font: 600 12px/1 var(--mono); padding: 4px 7px; border-radius: 99px; background: color-mix(in srgb, currentColor 18%, transparent); }
.btn svg { flex: none; }
.link { background: none; border: 0; padding: 10px 0; min-height: 44px; font-size: 14px; color: var(--dim); }
.link:hover { color: var(--text); }
.link.danger { color: var(--bad); }
.link.confirm { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
kbd { display: inline-block; min-width: 1.7em; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface); font: 600 11.5px/1.3 var(--mono); color: var(--text); text-align: center; }

/* ---- Seitenleiste / Startseite ---- */
.side { flex-direction: column; background: var(--bg); overflow-y: auto; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 26px 20px 2px; }
.logo { flex: none; width: 26px; height: 19px; border-radius: 3px; border: 1.5px solid var(--text); background: linear-gradient(var(--rule), var(--rule)) 0 5px / 100% 1.5px no-repeat, var(--surface); }
.brand { font-size: 30px; font-weight: 780; letter-spacing: -.02em; }
.side-meta { padding: 0 20px 16px 56px; color: var(--dim); font-size: 14px; }
.side-label { display: none; }
.decks { list-style: none; margin: 0 16px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.deck-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 14px 0 16px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.decks li:last-child .deck-row { border-bottom: 0; }
.deck-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 560; }
.deck-n { font: 13px var(--mono); color: var(--dim); }
.chev { color: var(--dim-2); font-size: 22px; line-height: 1; margin-top: -2px; }
.deck-add { margin: 12px 16px 0; }
.add-btn { width: 100%; justify-content: flex-start; border-style: dashed; background: transparent; color: var(--dim); font-weight: 550; }
.add-form { display: flex; flex-direction: column; gap: 5px; }
.add-form input { width: 100%; min-height: 46px; padding: 0 14px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); font-size: 16px; outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.add-hint { font-size: 12px; color: var(--dim); padding-left: 4px; }
.side-empty { display: flex; flex-direction: column; gap: 4px; margin: 8px 16px 0; padding: 18px 16px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--dim); font-size: 14px; }
.side-empty b { color: var(--text); font-size: 15px; }
.side-foot { margin-top: auto; padding: 18px 20px 16px; }

/* ---- Stapel / Kartenliste ---- */
.deck { flex-direction: column; background: var(--bg); }
.deck-head { padding: 6px 16px 2px; }
.deck-nav { display: flex; align-items: center; justify-content: space-between; }
/* Lupe [S6]: blendet das Suchfeld ein; auf dem Handy rechts neben "‹ Stapel". */
.such-btn { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -8px; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--accent); }
.such-btn svg { width: 22px; height: 22px; }
.such-btn.on { background: var(--accent-soft); }
/* Ohne eingeblendetes Suchfeld folgt die Tag-Reihe direkt auf den Kopf. */
.deck-head + .tagbar { margin-top: 10px; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 10px 0 0; margin-left: -4px; background: none; border: 0; color: var(--accent); font-size: 16px; font-weight: 500; }
.back b { font-size: 26px; font-weight: 400; line-height: 1; margin-top: -3px; }
.tt { min-width: 0; }
.title-in { display: block; width: 100%; padding: 2px 0 3px; border: 0; border-bottom: 1.5px solid transparent; border-radius: 0; background: transparent; outline: none; font-size: 28px; font-weight: 760; letter-spacing: -.015em; text-overflow: ellipsis; }
.title-in:hover { border-bottom-color: var(--line); }
.title-in:focus { border-bottom-color: var(--accent); }
.quiz-btn, .new-btn { display: none !important; }
.deck-tools { display: flex; gap: 10px; padding: 12px 16px 10px; }
.search { position: relative; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim-2); }
.search input { width: 100%; min-height: 44px; padding: 0 14px 0 38px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 16px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 16px 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; min-height: 132px; padding: 14px 16px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; box-shadow: 0 1px 2px var(--shadow-c); overflow: hidden; }
.tile:hover { border-color: var(--line-strong); }
.tile-row { display: flex; gap: 10px; align-items: flex-start; }
.tile-front, .tile-back { flex: 1; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.tile-front { -webkit-line-clamp: 3; font-size: 15px; font-weight: 620; line-height: 1.35; }
.tile-rule { flex: none; height: 1px; margin: 10px -16px 9px; background: var(--rule); opacity: .75; }
.tile-back { -webkit-line-clamp: 3; font-size: 13.5px; line-height: 1.42; color: var(--dim); }
.tile-pic { flex: none; width: 58px; }
.tile.is-editing { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 16px; color: var(--dim); text-align: center; }
.deck-end { display: flex; justify-content: center; padding-top: 18px; }
.bottom-bar { display: flex; gap: 10px; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); }
.bottom-bar .btn { min-height: 52px; font-size: 16px; }
.bottom-bar .btn.primary { flex: 1; }
.deck-welcome { align-items: center; justify-content: center; padding: 24px; }
.welcome { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 360px; padding: 24px; text-align: center; color: var(--dim); }
.welcome h2 { color: var(--text); font-size: 20px; }
.pile { position: relative; width: 132px; height: 92px; margin-bottom: 18px; }
.pile i { position: absolute; inset: 0; border-radius: 8px; border: 1px solid var(--line-strong); background: linear-gradient(var(--rule), var(--rule)) 0 22px / 100% 1.5px no-repeat, var(--surface); box-shadow: 0 2px 6px var(--shadow-c); }
.pile i:nth-child(1) { transform: rotate(-8deg) translate(-10px, 4px); }
.pile i:nth-child(2) { transform: rotate(5deg) translate(8px, 2px); }

/* ---- Bilder: immer auf weissem Grund, auch dunkel ---- */
.pic { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pic img { display: block; width: 100%; height: auto; }

/* ---- Formeln ---- */
.app .katex { font-size: 1.08em; }
.app .katex-display { margin: .45em 0; padding: 2px 0; overflow-x: auto; overflow-y: hidden; }

/* Formatierung auf den Karten (rich.js): Ueberschriften, Listen, Groessen.
   Jede Zeile ist ein eigener Block; Abstaende nur zwischen Bloecken. */
.md-h1, .md-h2, .md-h3 { font-weight: 760; line-height: 1.22; letter-spacing: -.01em; }
.md-h1 { font-size: 1.5em; }
.md-h2 { font-size: 1.25em; }
.md-h3 { font-size: 1.07em; }
:is(.md-z, .md-ul, .md-ol, .md-h1, .md-h2, .md-h3) + :is(.md-h1, .md-h2, .md-h3) { margin-top: .45em; }
:is(.md-h1, .md-h2, .md-h3) + :is(.md-z, .md-ul, .md-ol, .md-h2, .md-h3) { margin-top: .15em; }
.md-ul, .md-ol { margin: .1em 0; padding-left: 1.35em; }
:is(.md-ul, .md-ol) :is(.md-ul, .md-ol) { margin: 0; }
.md-ul { list-style: disc; }
.md-ul .md-ul { list-style: circle; }
.md-ul .md-ul .md-ul { list-style: square; }
.md-ul li, .md-ol li { margin: .08em 0; }
.md-ul li::marker, .md-ol li::marker { color: var(--dim); }
.gr { font-size: 1.3em; }
.kl { font-size: .8em; }
code.tex { font: .88em/1.5 var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--surface-2); color: var(--accent); white-space: pre-wrap; }
code.tex.disp { display: block; margin: .4em 0; text-align: center; }
.mx { border-radius: 6px; cursor: pointer; }
.mx-d { display: block; }
.mx:hover { background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- Editor ---- */
.editor { position: relative; flex-direction: column; background: var(--surface); }
.ed-head { display: flex; align-items: center; gap: 6px; min-height: 58px; padding: 6px 10px 6px 4px; border-bottom: 1px solid var(--line); }
.ed-title { flex: 1; min-width: 0; text-align: center; font-weight: 650; line-height: 1.2; }
.ed-title small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 400; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-head .btn.primary { min-height: 40px; padding: 0 14px; }
.ed-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; padding: 14px 16px 16px; overflow-y: auto; }
.field { display: flex; flex-direction: column; gap: 7px; flex: 1 0 auto; }
.field-top { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.field-top > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.field-top i { display: none; font-style: normal; }
.field-tools { flex: none; display: flex; gap: 4px; }
.tool { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tool b { font-size: 15px; font-weight: 700; color: var(--accent); }
.tool:hover { border-color: var(--line-strong); }
.tool.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ta { display: flex; flex: 1; }
.field textarea { flex: 1; min-height: 76px; width: 100%; resize: none; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); outline: none; font-size: 16px; line-height: 1.45; }
.field textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Formatleiste ueber dem Textfeld: Ueberschrift 1-3, Liste, nummerierte Liste,
   kleiner/groesser. Auf schmalen Bildschirmen eine Zeile zum Wischen. */
.fmt-bar { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.fmt-bar::-webkit-scrollbar { display: none; }
.fmt { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 1px; min-width: 38px; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 700; touch-action: manipulation; }
.fmt:hover { border-color: var(--line-strong); }
.fmt.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.fmt b { font-weight: 780; }
.fmt .h1 { font-size: 14px; }
.fmt .h2 { font-size: 12.5px; }
.fmt .h3 { font-size: 11px; }
.fmt .a-kl { font-size: 11px; }
.fmt .a-gr { font-size: 16px; }
.fmt-sep { flex: none; width: 1px; height: 18px; margin: 0 3px; background: var(--line); }
.snips { display: flex; flex-wrap: wrap; gap: 4px; }
.snips button { min-width: 40px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 15px; }
.snips button:hover { border-color: var(--line-strong); }
.preview-slot:empty { display: none; }
.preview { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--bg); }
.preview-text { flex: 1; min-width: 0; max-height: 150px; overflow: auto; white-space: pre-line; font-size: 15px; line-height: 1.45; }
.preview-cap { display: block; margin-bottom: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--dim-2); white-space: normal; }
.thumb { flex: none; width: 116px; }
.thumb-tools { display: flex; gap: 4px; margin-top: 5px; }
.thumb-tools button { flex: 1; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.thumb-tools button:hover { border-color: var(--line-strong); }
.ed-note { font-size: 13px; color: var(--dim); padding: 2px 2px; }
.ed-note.ok { color: var(--ok); font-weight: 600; }
.ed-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ed-kbd { display: none; font-size: 12.5px; color: var(--dim); }

/* ---- Formelfeld (liegt ueber dem Editor) ---- */
/* z-index ueber den Index-Marken (40), sonst scheinen die Marken der
   verdeckten Elemente durch */
.sheet { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--surface); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 20px 18px; }
.mf-wrap { display: block; }
math-field.mf { display: block; width: 100%; min-height: 72px; padding: 14px 16px; font-size: 26px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }
.tex-in { width: 100%; min-height: 84px; resize: vertical; padding: 12px 14px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); font: 16px/1.5 var(--mono); outline: none; }
.tex-prev { min-height: 60px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--bg); font-size: 20px; }
.sheet-hint { font-size: 13.5px; color: var(--dim); }
.sheet-hint.warn { color: var(--warn); }
.check-row { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Bausteine im Formelfeld: je Gruppe eine Reihe. Mit Touch eine Reihe zum
   Wischen (bleibt flach, auch wenn die Bildschirmtastatur die halbe Hoehe
   nimmt), mit Maus umbrechend. */
.bausteine { display: flex; flex-direction: column; gap: 10px; }
.bs-lbl { margin: 0 0 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.bs-reihe { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.bs-reihe::-webkit-scrollbar { display: none; }
.bs { flex: none; min-width: 46px; height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: 19px/1 KaTeX_Main, "Times New Roman", serif; white-space: nowrap; touch-action: manipulation; }
.bs:hover { border-color: var(--line-strong); background: var(--surface); }
.bs:active { background: var(--accent-soft); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .bs-reihe { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .bs { min-width: 40px; height: 38px; font-size: 17px; }
}

/* ---- Skizze (liegt ueber der ganzen App) ---- */
.shell > .draw { grid-column: 1 / -1; grid-row: 1 / -1; }
.draw { position: relative; z-index: 70; display: flex; flex-direction: column; background: var(--bg); }
.draw-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.draw-head .btn.primary { margin-left: auto; min-height: 40px; }
.draw-tools { order: 3; width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.pen { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 2px solid transparent; background: var(--surface-2); }
.pen i { width: 18px; height: 18px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.pen.on { border-color: var(--accent); background: var(--accent-soft); }
.pen.eraser { width: auto; padding: 0 12px; border-radius: 21px; font-size: 13px; font-weight: 600; }
.draw-sep { display: none; width: 1px; height: 26px; margin: 0 4px; background: var(--line); }
.draw-tools { gap: 3px; }
.draw-tools .pen { width: 36px; height: 36px; }
.draw-tools .pen.eraser { width: auto; padding: 0 9px; }
.draw-tools .tool { padding: 0 8px; }
.draw-stage { container-type: size; flex: 1; min-height: 0; display: grid; place-items: center; padding: 14px; }
.draw-stage canvas { display: block; width: min(100cqw, 100cqh * 4 / 3); height: auto; aspect-ratio: 4 / 3; background: #fff; border-radius: 12px; border: 1px solid var(--line-strong); box-shadow: 0 10px 30px -14px var(--shadow-c); touch-action: none; cursor: crosshair; }
.draw-hint { padding: 0 16px 12px; text-align: center; font-size: 13px; color: var(--dim); }

/* ---- Abfrage ---- */
.quiz { display: flex; flex-direction: column; background: var(--bg); }
.qz-head { display: flex; align-items: center; gap: 8px; min-height: 54px; padding: 4px 8px 0 4px; }
.icon-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--dim); font-size: 19px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.qz-deck { flex: 1; min-width: 0; text-align: center; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qz-count { flex: none; min-width: 44px; padding-right: 8px; text-align: right; font: 600 13px var(--mono); color: var(--dim); }
.qz-prog { padding: 2px 18px 0; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .3s ease; }
.qz-prog-label { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12.5px; color: var(--dim); }
.qz-main { flex: 1; min-height: 0; display: flex; gap: 16px; padding: 14px 16px 6px; }
.rail { display: none; }
.qz-center { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qcard { flex: 1; min-height: 0; width: 100%; max-width: 760px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); cursor: pointer; user-select: none; -webkit-user-select: none; box-shadow: 0 1px 2px var(--shadow-c), 0 16px 36px -16px var(--shadow-c); overflow: hidden; }
.qc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px 11px; font-size: 12px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
.qc-rule { flex: none; height: 1.5px; background: var(--rule); }
.qc-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: safe center; gap: 14px; padding: 20px 22px 26px; }
.qc-q { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 14px; border-bottom: 1px dashed var(--line); font-size: 15px; line-height: 1.4; color: var(--dim); }
.qc-q-text { flex: 1; min-width: 0; white-space: pre-line; }
.qc-q-pic { flex: none; width: 96px; }
.qc-content { display: flex; flex-direction: column; gap: 16px; }
.qc-text { font-size: 23px; line-height: 1.35; font-weight: 620; white-space: pre-line; text-wrap: pretty; }
[data-side="back"] .qc-text { font-weight: 480; }
.qcard[data-len="long"] .qc-text { font-size: 18px; }
.qc-pic { width: 100%; max-width: 440px; align-self: center; }
.chip-again { padding: 3px 8px; border-radius: 99px; letter-spacing: .03em; background: var(--warn-soft); color: var(--warn); font-size: 11px; }
.qz-hint { font-size: 13px; color: var(--dim); text-align: center; padding: 0 8px; }
.qz-keys { display: none; }
.qz-foot { display: flex; gap: 10px; padding: 8px 16px 14px; }
.qz-foot .btn { flex: 1; min-height: 58px; font-size: 16.5px; border-radius: 15px; }
.btn.no { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.yes { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.anim-flip { animation: flip .34s cubic-bezier(.2, .7, .3, 1); }
.anim-next { animation: next .28s ease-out; }
@keyframes flip { from { transform: perspective(1400px) rotateY(-80deg); opacity: .3; } }
@keyframes next { from { transform: translateX(28px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .anim-flip, .anim-next { animation: none; } }

/* ---- Runde fertig ---- */
.end { display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); overflow-y: auto; }
.end-box { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.end-check { display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: 12px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 36px; font-weight: 700; }
.end h2 { font-size: 27px; letter-spacing: -.01em; }
.end-sub { color: var(--dim); margin-bottom: 16px !important; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-bottom: 20px; }
.stats div { padding: 14px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stats b { display: block; font-size: 30px; line-height: 1.15; }
.stats span { font-size: 13px; color: var(--dim); }
.end-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.end-actions .btn { min-height: 52px; font-size: 16px; }

/* ============================================================
   >= 700 px
   ============================================================ */
@container app (min-width: 700px) {
  .shell { grid-template-columns: 264px minmax(0, 1fr); }
  .shell > .side { grid-area: 1 / 1; display: flex; background: var(--surface); border-right: 1px solid var(--line); }
  .shell > .deck { grid-area: 1 / 2; display: flex; }
  .shell[data-screen="karte"] > .deck { display: none; }
  .shell > .editor { grid-area: 1 / 2; }
  .shell > .quiz, .shell > .end { grid-column: 1 / -1; }

  .side-head { padding: 20px 18px 16px; }
  .brand { font-size: 17px; font-weight: 720; letter-spacing: 0; }
  .side-meta { display: none; }
  .side-label { display: block; padding: 4px 20px 6px; font-size: 11.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--dim-2); }
  .decks { margin: 0 10px; background: none; border: 0; border-radius: 0; }
  .deck-row { min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; }
  .deck-row:hover { background: var(--surface-2); }
  .deck-row.is-active { background: var(--accent-soft); color: var(--accent); }
  .deck-row.is-active .deck-n { color: var(--accent); }
  .chev { display: none; }
  .deck-add { margin: 8px 10px 0; }
  .add-btn { min-height: 40px; font-size: 14px; }
  .side-empty { margin: 4px 10px 0; }
  .side-foot { padding: 14px 20px 16px; }

  .back, .bottom-bar { display: none; }
  .deck-head { display: flex; align-items: flex-end; gap: 16px; padding: 24px 28px 4px; }
  .tt { flex: 1; }
  .quiz-btn, .new-btn { display: inline-flex !important; }
  .quiz-btn { min-height: 48px; padding: 0 20px; font-size: 16px; }
  /* Neben der Liste: Lupe im Kopf links neben "Abfragen". */
  .deck-nav { display: contents; }
  .tt { order: 0; }
  .such-btn { order: 1; width: 48px; height: 48px; margin: 0; border: 1px solid var(--line); background: var(--surface); }
  .such-btn.on { border-color: var(--accent); background: var(--accent-soft); }
  .deck-head .new-btn { order: 2; min-height: 48px; }
  .deck-head .quiz-btn { order: 3; }
  .deck-tools { padding: 14px 28px 12px; }
  .search { max-width: 520px; margin-right: auto; }
  .grid-wrap { padding: 4px 28px 28px; }

  .ed-head { padding: 8px 14px 8px 8px; }
  .ed-body { padding: 16px 20px 18px; }
  .field-top i { display: inline; }
  .sheet-body { padding: 24px 22px; }

  .draw-tools { order: 0; width: auto; flex: 1; gap: 6px; }
  .draw-tools .pen { width: 42px; height: 42px; }
  .draw-sep { display: block; }
  .draw-head .btn.primary { margin-left: 0; }

  .qz-head { padding: 12px 22px 0 14px; }
  .qz-prog { width: 100%; max-width: 760px; margin: 0 auto; padding: 2px 0 0; }
  .qz-main { padding: 20px 20px 22px; gap: 20px; }
  .rail { display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 128px; padding: 18% 8px 0; border: 1px solid var(--line); border-radius: 24px; background: var(--surface-2); color: var(--dim); font-size: 15px; font-weight: 650; text-align: center; }
  .rail .ico { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface); font-size: 25px; font-weight: 700; }
  [data-side="back"] .rail-l { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
  [data-side="back"] .rail-r { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
  [data-side="back"] .rail-r .ico { background: var(--ok); color: var(--on-ok); }
  .qz-center { justify-content: center; }
  .qcard { max-height: 560px; }
  .qc-top { padding: 18px 28px 13px; }
  .qc-body { padding: 24px 32px 30px; }
  .qc-text { font-size: 27px; }
  .qcard[data-len="long"] .qc-text { font-size: 20px; }
  .qc-q { font-size: 16px; }
  /* "neben dem Text": ab Tablet steht das Bild rechts */
  .qc-content.has-pic { flex-direction: row; align-items: center; gap: 28px; }
  .qc-content.has-pic > .qc-text { flex: 1 1 0; min-width: 0; }
  .qc-content.has-pic > .qc-pic { flex: 0 0 46%; max-width: none; }
  .qz-foot { display: none; }
}

@container app (min-width: 1100px) {
  .shell[data-screen="karte"] { grid-template-columns: 264px minmax(0, 1fr) 440px; }
  .shell[data-screen="karte"] > .deck { display: flex; }
  .shell > .editor { grid-area: 1 / 3; border-left: 1px solid var(--line); box-shadow: -10px 0 30px -24px var(--shadow-c); }
  .rail { width: 140px; }
}

@media (hover: hover) and (pointer: fine) {
  .qz-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13px; color: var(--dim); }
  .ed-kbd { display: block; }
}

@container app (min-width: 1300px) {
  .rail { width: 160px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
}

/* ---- Tags ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 14px; font-weight: 560; white-space: nowrap; }
.chip:hover { border-color: var(--line-strong); }
.chip .c { font: 12px var(--mono); color: var(--dim); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.on .c { color: inherit; opacity: .8; }
/* Smartphone: eine Reihe zum Wischen statt mehrerer Zeilen ueber der Liste */
.tagbar { display: flex; gap: 6px; padding: 0 16px 12px; overflow-x: auto; scrollbar-width: none; }
.tagbar::-webkit-scrollbar { display: none; }
.tile-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 10px; }
.tile-tag { padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--dim); font-size: 11.5px; font-weight: 550; }
.tags-field { display: flex; flex-direction: column; gap: 7px; }
.tag-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 52px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.tag-box:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-box .chip { height: 34px; padding: 0 10px 0 12px; border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.tag-box .chip .x { font-size: 12px; opacity: .7; }
.tag-in { flex: 1; min-width: 150px; height: 34px; padding: 0 6px; border: 0; background: transparent; outline: none; font-size: 16px; }
.tag-sugg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-sugg .lbl { margin-right: 2px; font-size: 12.5px; color: var(--dim); }
.chip.dashed { height: 34px; border-style: dashed; background: transparent; color: var(--dim); font-weight: 500; }
.qz-deck small { display: block; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 500; color: var(--dim); }
@container app (min-width: 700px) {
  .tagbar { flex-wrap: wrap; overflow: visible; padding: 0 28px 14px; }
}

/* ---- Alle Stapel ---- */
.decks-all { margin-bottom: 18px; }
.decks-all .deck-row svg { flex: none; color: var(--accent); }
.title-static { padding: 2px 0 3px; font-size: 28px; font-weight: 760; letter-spacing: -.015em; }
.tile-deck { margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 650; color: var(--accent); }
.qc-top > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qc-deck { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); }
.tagbar .chip.dashed { height: 36px; color: var(--accent); font-weight: 600; }
.tb-sep { flex: none; align-self: stretch; width: 1px; margin: 4px 2px; background: var(--line); }

/* ---- Tags bearbeiten ---- */
.bulk { display: none; position: relative; flex-direction: column; background: var(--bg); }
.shell[data-screen="tags"] > .bulk { display: flex; }
.bulk-head { display: flex; align-items: center; min-height: 50px; padding: 4px 16px 0; }
.bulk-back { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-height: 44px; margin-left: -4px; padding: 0 8px 0 0; overflow: hidden; border: 0; background: none; color: var(--accent); font-size: 16px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.bulk-back b { font-size: 26px; font-weight: 400; line-height: 1; margin-top: -3px; }
.bulk-title { padding: 0 16px 2px; font-size: 28px; font-weight: 760; letter-spacing: -.015em; }
.bulk-body { flex: 1; min-height: 0; display: flex; }
.bulk-list { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bulk-tools { padding: 10px 16px 0; }
.bulk-tools .tagbar { padding: 10px 0 0; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.bulk-dyn { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.selbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.selall { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0; border: 0; background: none; font-size: 15px; font-weight: 600; }
.selcount { font-size: 13.5px; color: var(--dim); text-align: right; }
.cb { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: transparent; font-size: 14px; font-weight: 800; line-height: 1; }
.row[aria-pressed="true"] .cb, .cb.full, .cb.part { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.rows { flex: 1; min-height: 0; margin: 0; padding: 0 0 24px; overflow-y: auto; list-style: none; }
.row { width: 100%; display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.row:hover { background: var(--surface-2); }
.row[aria-pressed="true"] { background: var(--accent-soft); }
.row .cb { margin-top: 1px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.row-front { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.row-tags .none { font-size: 12px; color: var(--dim-2); }
.row-tags .tile-deck { margin: 0 4px 0 0; }

.tagpanel { display: none; flex-direction: column; background: var(--surface); }
.tp-head { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 10px 0 18px; }
.tp-head h3 { flex: 1; margin: 0; font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.tp-hint { padding: 0 18px 10px; font-size: 13.5px; line-height: 1.45; color: var(--dim); }
.tp-hint b { color: var(--text); }
.tp-list { flex: 1; min-height: 0; margin: 0; padding: 0 8px; overflow-y: auto; list-style: none; }
.tp-row { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 4px 6px 4px 10px; border-bottom: 1px solid var(--line); }
.tp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tp-n { min-width: 22px; margin-right: 4px; text-align: right; font: 12px var(--mono); color: var(--dim); }
.tp-btn { min-width: 56px; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tp-btn.add:not(:disabled) { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); color: var(--ok); }
.tp-btn.rm:not(:disabled) { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-soft); color: var(--bad); }
.tp-btn:disabled { opacity: .35; cursor: default; }
.tp-del { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--dim); }
.tp-del:hover { background: var(--bad-soft); color: var(--bad); }
.tp-empty { padding: 16px 10px; color: var(--dim); font-size: 14px; }
.tp-foot { padding: 12px 18px 14px; }
.tp-foot .add-btn { color: var(--accent); }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); }
.bulk-bar span { flex: 1; font-size: 14px; color: var(--dim); }
.bulk-bar .btn { min-height: 50px; }
/* Smartphone und Tablet hoch: die Tag-Liste kommt als Blatt von unten */
.sheet-back { position: absolute; inset: 0; z-index: 50; background: rgba(10, 12, 16, .45); }
.tagpanel.open { display: flex; position: absolute; left: 0; right: 0; bottom: 0; z-index: 55; max-height: 80%; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, .35); }

/* ---- Sicherheitsabfrage ---- */
.shell > .ask-layer { grid-column: 1 / -1; grid-row: 1 / -1; }
.ask-layer { position: relative; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(10, 12, 16, .5); }
.ask { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); padding: 22px 22px 18px; border-radius: 18px; background: var(--surface); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5); }
.ask h3 { margin: 0; font-size: 19px; }
.ask p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--dim); }
.ask p b { color: var(--text); }
.ask input[type="text"] { min-height: 46px; padding: 0 14px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); outline: none; font-size: 16px; }
.ask-check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }
.ask-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.ask .ask-err { color: var(--bad); font-size: 13.5px; }
.ask-actions { display: flex; gap: 10px; margin-top: 8px; }
.ask-actions .btn { flex: 1; min-height: 48px; }
.ask-wahl { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ask-wahl .btn { justify-content: flex-start; gap: 10px; min-height: 52px; padding: 0 16px; font-size: 16px; }

/* ---- Bild im Vollbild (Abfrage) ---- */
.zoombar { position: relative; cursor: zoom-in; }
.zoom-badge { position: absolute; right: 6px; bottom: 6px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(12, 14, 18, .55); color: #fff; font-size: 15px; font-style: normal; pointer-events: none; }
.qc-q-pic .zoom-badge { width: 22px; height: 22px; right: 4px; bottom: 4px; font-size: 12px; }
.zoom { position: fixed; inset: 0; z-index: 150; background: #0b0c0e; }
.zoom-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 56px 12px calc(44px + var(--unten)); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.zoom-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; transform-origin: center; -webkit-user-drag: none; pointer-events: auto; }
.zoom-zu { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 19px; }
.zoom-zu:hover { background: rgba(255, 255, 255, .26); }
.zoom-hint { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--unten)); margin: 0; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .6); pointer-events: none; }
.btn.danger-fill { border-color: var(--bad); background: var(--bad); color: #fff; }

@container app (min-width: 700px) {
  .decks-all { margin: 0 10px 14px; }
  .shell > .bulk { grid-area: 1 / 2; }
  .bulk-head { padding: 12px 28px 0; }
  .bulk-title { padding: 0 28px 4px; }
  .bulk-tools { padding: 12px 28px 0; }
  .bulk-tools .search { max-width: 520px; }
  .bulk-tools .tagbar { margin: 0; padding: 12px 0 2px; }
  .selbar { padding: 10px 28px; }
  .row { padding: 12px 28px; }
}
/* Ab 1100 px steht die Tag-Liste fest rechts neben der Kartenliste */
@container app (min-width: 1100px) {
  .tagpanel, .tagpanel.open { display: flex; position: relative; flex: none; width: 340px; max-height: none; border-left: 1px solid var(--line); border-radius: 0; box-shadow: none; }
  .bulk-bar, .sheet-back, .tp-close { display: none; }
}

/* ---- Votes (wie bei Jodel: Pfeil, Zahl, Pfeil) ---- */
.vote { flex: none; display: flex; flex-direction: column; align-items: center; width: 44px; color: var(--dim); }
.vote button { display: grid; place-items: center; width: 44px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--dim-2); }
.vote button:hover { background: var(--surface-2); color: var(--text); }
.vote .vote-up:active { color: var(--ok); }
.vote .vote-down:active { color: var(--bad); }
.vote .vote-down svg { transform: rotate(180deg); }
.vote-n { min-width: 2.2ch; text-align: center; font: 700 15px/1.25 var(--font); font-variant-numeric: tabular-nums; color: var(--dim); }
.vote.pos .vote-n { color: var(--ok); }
.vote.neg .vote-n { color: var(--bad); }
.vote.bump-up .vote-n { animation: vup .28s ease-out; }
.vote.bump-down .vote-n { animation: vdown .28s ease-out; }
@keyframes vup { from { transform: translateY(7px); opacity: .2; } }
@keyframes vdown { from { transform: translateY(-7px); opacity: .2; } }
.vote.h { flex-direction: row; width: auto; gap: 2px; }
.vote.h button { height: 40px; border: 1px solid var(--line); }
.vote.h .vote-n { min-width: 3ch; font-size: 17px; }

/* Kachel: Inhalt links (bearbeiten), Vote rechts */
.tile { flex-direction: row; padding: 0; }
.tile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 14px 2px 14px 16px; border: 0; background: none; text-align: left; }
.tile-main .tile-rule { margin: 10px -2px 9px -16px; }
.tile > .vote { padding: 8px 0 8px; }
/* Massenliste: Zeile waehlt aus, Vote daneben */
.row-wrap { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.row-wrap.on { background: var(--accent-soft); }
/* min-width: 0 - sonst schiebt ein langer Kartentext den Vote aus dem Bild
   (im Entwurf 5 noch so: dort fehlte der Vote bei langen Zeilen). */
.row-wrap .row { flex: 1; min-width: 0; border-bottom: 0; }
.row-wrap .row[aria-pressed="true"] { background: transparent; }
.row-wrap > .vote { margin-right: 8px; }
/* Abfrage: Vote am rechten Rand der Karte, dreht sie nicht um */
.qc-vote { position: absolute; top: 50px; right: 8px; z-index: 2; }
.qc-body { padding-right: 58px; }
/* Editor */
.score-field { display: flex; flex-direction: column; gap: 7px; }
.score-row { display: flex; align-items: center; gap: 14px; }
.score-hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--dim); }
@container app (min-width: 700px) {
  .qc-vote { top: 60px; right: 14px; }
  .qc-body { padding-right: 78px; }
  .row-wrap > .vote { margin-right: 20px; }
}

/* ---- Laden, Meldungen ---- */
.laden { display: grid; place-items: center; height: 100%; color: var(--dim); font-size: 15px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--unten)); z-index: 200;
  max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border-radius: 14px;
  transform: translateX(-50%); background: var(--text); color: var(--bg);
  font-size: 14.5px; font-weight: 550; box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .45);
  animation: toast-in .2s ease-out;
}
.toast.fehler { background: var(--bad); color: #fff; }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }
.lade-bild { opacity: .6; pointer-events: none; }

/* ---- Installierte App: Systemleisten freihalten ---- */
@media (display-mode: standalone), (display-mode: fullscreen) {
  #app { padding-top: env(safe-area-inset-top); padding-right: env(safe-area-inset-right); padding-left: env(safe-area-inset-left); }
}

/* ---- Anmeldung ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px 24px calc(24px + var(--unten)); }
.login-card { width: min(360px, 100%); padding: 26px 24px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 16px 40px -20px var(--shadow-c); }
.login-card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-card .brand-row b { font-size: 22px; font-weight: 760; letter-spacing: -.01em; }
.login-hint { margin: 0 0 18px; color: var(--dim); font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 8px; }
.login-card label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.login-card input { min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font: 16px var(--font); outline: none; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { margin-top: 8px; min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font: 600 16px var(--font); cursor: pointer; }
.login-card button:disabled { opacity: .6; }
.login-error { margin: 6px 0 0; color: var(--bad); font-size: 14px; }

/* ---- Messwerte (diagnose.js) ---- */
.diagnose { position: fixed; left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top)); z-index: 300; max-height: 80%; overflow: auto; padding: 10px 12px; border-radius: 12px; background: #000; color: #e9eaed; font: 12px/1.4 var(--mono); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.diagnose-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.diagnose-kopf button { margin-left: 6px; padding: 6px 10px; border: 1px solid #444; border-radius: 8px; background: #222; color: #fff; font: inherit; }
.diagnose table { width: 100%; border-collapse: collapse; }
.diagnose th { padding: 3px 8px 3px 0; text-align: left; font-weight: 600; color: #9aa1ad; white-space: nowrap; vertical-align: top; }
.diagnose td { padding: 3px 0; word-break: break-word; }
.diagnose p { margin: 8px 0 0; color: #9aa1ad; }
