/* Karteikarten – Stylesheet. Farben als Variablen, automatisch hell/dunkel. */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1d2433;
  --muted: #667085;
  --border: #e3e6ee;
  --primary: #3b5bdb;
  --primary-text: #ffffff;
  --danger: #d92d20;
  --success: #12805c;
  --warn: #b54708;
  --new: #1c7ed6;
  --learn: #e8590c;
  --due: #2b8a3e;
  --again: #e03131;
  --hard: #f08c00;
  --good: #2f9e44;
  --easy: #1971c2;
  --radius: 12px;
  --tabbar-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  /* Textfarben im Editor (feste Palette, im Dunkelmodus aufgehellt) */
  --tc-red: #c92a2a; --tc-orange: #d9480f; --tc-green: #2b8a3e; --tc-blue: #1864ab; --tc-purple: #7048e8; --tc-gray: #667085;
  color-scheme: light dark;
}

/* Dunkles Design: automatisch nach Systemeinstellung – außer jemand hat oben rechts „Hell“ gewählt –
   oder fest, wenn „Dunkel“ gewählt wurde (Attribut data-theme an <html>, gesetzt von theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #12151c; --surface: #1b1f29; --text: #e6e8ee; --muted: #98a2b3; --border: #2c3240;
  --primary: #5c7cfa; --shadow: none;
  --tc-red: #ff8787; --tc-orange: #ffa94d; --tc-green: #69db7c; --tc-blue: #74c0fc; --tc-purple: #b197fc; --tc-gray: #adb5bd;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151c; --surface: #1b1f29; --text: #e6e8ee; --muted: #98a2b3; --border: #2c3240;
  --primary: #5c7cfa; --shadow: none;
  --tc-red: #ff8787; --tc-orange: #ffa94d; --tc-green: #69db7c; --tc-blue: #74c0fc; --tc-purple: #b197fc; --tc-gray: #adb5bd;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
kbd {
  font: .7rem ui-monospace, monospace; padding: 1px 5px; margin-left: .35rem;
  border: 1px solid currentColor; border-radius: 4px; opacity: .6;
}
[hidden] { display: none !important; }

/* ---------- Symbole ---------- */
.icon { width: 1.35em; height: 1.35em; flex: none; vertical-align: -.25em; }
.icon-sm { width: 1.1em; height: 1.1em; }
.icon-xl { width: 2.6rem; height: 2.6rem; }

/* ---------- Kopfzeile (Desktop-Navigation) ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); font-size: 1.1rem; margin-right: auto; }
.nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.nav a { color: var(--text); padding: .2rem 0; border-bottom: 2px solid transparent; }
.nav a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.nav a:hover { text-decoration: none; color: var(--primary); }
/* Hell/Dunkel-Knopf ganz rechts: zeigt den Mond im hellen und die Sonne im dunklen Design */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -4px -6px -4px 0;
  border: 1px solid transparent; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; padding: 0;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--border); }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-toggle .icon { width: 22px; height: 22px; }
.theme-icon-sun { display: none; }
:root[data-theme-active="dark"] .theme-icon-sun { display: inline; }
:root[data-theme-active="dark"] .theme-icon-moon { display: none; }
@media (max-width: 640px) { .theme-toggle { width: 44px; height: 44px; margin: -8px -10px -8px 0; } }

/* Auswahl als Knopfreihe (z. B. Darstellung im Konto) */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: .6rem; }
.form .segmented label { margin: 0; font-weight: 500; }
.segmented label { position: relative; padding: .45rem .9rem; cursor: pointer; border-left: 1px solid var(--border); }
.segmented label:first-child { border-left: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }

/* ---------- Untere Tab-Leiste (Handy und installierte App) ---------- */
.tabbar { display: none; }
@media (max-width: 640px) {
  .desktop-nav { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(16, 24, 40, .06);
  }
  .tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: .72rem; font-weight: 600; text-decoration: none !important; min-height: 44px;
  }
  .tab .icon { width: 24px; height: 24px; }
  .tab.active { color: var(--primary); }
  .tab.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
  .tab-dot { position: absolute; top: 8px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
  body.has-tabbar .container { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 1.5rem); }
  body.has-tabbar .sticky-actions { bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
  .topbar-inner { padding: .5rem .9rem; }
}
.mobile-only { display: none; }
@media (max-width: 640px) { .mobile-only { display: block; } }
.inline { display: inline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font: inherit; }
.link-btn:hover { color: var(--danger); }

.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; }
.card + .card, .card + form, form + .card { margin-top: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.breadcrumb { margin: 0 0 .25rem; color: var(--muted); font-size: .9rem; }
.notice { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: 8px; padding: .5rem .75rem; font-size: .9rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none !important; line-height: 1.2;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: .35rem .7rem; font-size: .875rem; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; color: var(--muted); padding: .1rem .45rem; font: inherit; }
.icon-btn:hover { border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.flash-error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.flash-info { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }

.pill { display: inline-block; min-width: 1.8em; text-align: center; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--border); color: var(--text); }
.pill.new, .pill.state-new { background: color-mix(in srgb, var(--new) 15%, transparent); color: var(--new); }
.pill.learn, .pill.state-learning, .pill.state-relearning { background: color-mix(in srgb, var(--learn) 15%, transparent); color: var(--learn); }
.pill.due, .pill.state-review { background: color-mix(in srgb, var(--due) 15%, transparent); color: var(--due); }
.pill.status-disabled { color: var(--danger); }
.pill.status-pending { color: var(--warn); }
.badge.warn { background: var(--warn); color: #fff; border-radius: 999px; padding: .05rem .6rem; font-size: .8rem; }

/* ---------- Formulare ---------- */
.form label { display: block; margin-bottom: .9rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { resize: vertical; }
label.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.auth-box { max-width: 420px; margin: 2rem auto; }

/* ---------- Übersicht ---------- */
.stats-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; min-width: 110px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat.chart { flex: 1; min-width: 180px; flex-direction: row; align-items: flex-end; gap: 3px; height: 72px; }
.stat.chart .bar { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; opacity: .75; }

.deck-list { display: flex; flex-direction: column; gap: .6rem; }
.deck-row { display: flex; align-items: center; gap: .9rem; padding: .75rem 1rem; }
.deck-row + .deck-row { margin-top: 0; }
.deck-main { flex: 1; display: flex; flex-direction: column; color: var(--text); min-width: 0; }
.deck-main strong { overflow: hidden; text-overflow: ellipsis; }
.deck-counts { display: flex; gap: .3rem; }
.export-bar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: .5rem 0; }
.legend { margin-top: .5rem; }
.empty { text-align: center; padding: 2rem 1rem; }
.deck-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; margin: 1rem 0; }
.deck-tile { display: flex; flex-direction: column; gap: .25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--text); }

/* ---------- Stapel / Tabellen ---------- */
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar input { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.cards-table td:nth-child(2), .cards-table td:nth-child(3) { max-width: 320px; overflow-wrap: anywhere; }
.kv th { width: 200px; }
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin: 1rem 0; }
.pagination a { padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 6px; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.deck-tools { margin-top: 2rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.tool { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .5rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.checklist { list-style: none; padding: 0; }
.checklist .ok { color: var(--success); }
.checklist .fail { color: var(--danger); font-weight: 600; }

/* ---------- Karteneditor ---------- */
.editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.editor-grid .card { margin-top: 0; }
.block-edit { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem .6rem; margin-bottom: .6rem; background: var(--bg); }
.block-head { display: flex; align-items: center; gap: .2rem; margin-bottom: .3rem; }
.block-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: auto; }
.block-edit textarea, .block-edit input { margin-top: 0; background: var(--surface); }
.block-edit input[type=text] { margin-top: .4rem; }
.formula-preview { min-height: 1.5rem; overflow-x: auto; }
.block-head .drag-handle {
  touch-action: none; cursor: grab; background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); font-size: 1.1rem; line-height: 1; padding: .35rem .45rem; min-width: 36px; min-height: 36px;
}
.block-head .drag-handle:hover, .block-head .drag-handle:focus-visible { border-color: var(--border); color: var(--text); }
.block-edit.dragging { opacity: .35; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; opacity: .92; box-shadow: 0 10px 30px rgba(0,0,0,.25); margin: 0; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.drop-marker { height: 4px; border-radius: 2px; background: var(--primary); margin: .2rem 0 .5rem; }
.editor-side.drop-target { outline: 2px dashed var(--primary); outline-offset: 2px; }
/* Formatierter Text */
.rt-bar { display: flex; gap: .2rem; flex-wrap: wrap; margin-bottom: .3rem; }
.rt-btn { min-width: 36px; min-height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.rt-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 18%, var(--surface)); border-color: var(--primary); }
.rt-b { font-weight: 800; } .rt-i { font-style: italic; font-family: Georgia, serif; } .rt-u { text-decoration: underline; }
.rt-color { font-weight: 700; text-decoration: underline 3px var(--again); }
.rt-colors { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .3rem; padding: .3rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.rt-swatch { font-weight: 800; }
.rt-input {
  min-height: 3.2rem; padding: .55rem .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: text;
}
.rt-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.rt-input:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.f-b { font-weight: 700; } .f-i { font-style: italic; } .f-u { text-decoration: underline; }
/* Formel-Editor */
.fpad { margin-bottom: .4rem; }
.fpad-tabs { display: flex; gap: .2rem; overflow-x: auto; margin-bottom: .3rem; scrollbar-width: thin; }
.fpad-tab { flex: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: .82rem; padding: .3rem .55rem; border-radius: 999px; cursor: pointer; }
.fpad-tab[aria-selected="true"] { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); font-weight: 600; }
.fpad-keys { display: flex; gap: .25rem; flex-wrap: wrap; }
.fpad-key { min-width: 40px; min-height: 38px; padding: .15rem .45rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-size: .9rem; }
.fpad-key:hover { border-color: var(--primary); }
.formula-dialog textarea { margin: .4rem 0; }
.image-pick { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Textfarben (Variablen oben bei :root) */
.tc-red { color: var(--tc-red); } .tc-orange { color: var(--tc-orange); } .tc-green { color: var(--tc-green); }
.tc-blue { color: var(--tc-blue); } .tc-purple { color: var(--tc-purple); } .tc-gray { color: var(--tc-gray); }
.rt-swatch.none { color: var(--text); }
/* Eigene Dialoge */
.kk-dialog { border: 0; padding: 0; background: transparent; max-width: min(92vw, 460px); width: 100%; color: var(--text); }
.kk-dialog.wide { max-width: min(96vw, 640px); }
.kk-dialog::backdrop { background: rgba(10, 14, 22, .55); }
.kk-dialog-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.25rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.kk-dialog-title { margin: 0 0 .5rem; }
.kk-dialog-text { margin: 0 0 1rem; white-space: pre-line; }
.kk-dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (hover: none) { .hint-desktop { display: none; } }
.image-edit { display: flex; flex-direction: column; gap: .4rem; }
.thumb { max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px; align-self: flex-start; }
.add-bar { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.preview-label { margin-top: 1rem; border-top: 1px dashed var(--border); padding-top: .5rem; }
.preview { min-height: 2rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; margin-top: 1rem; border-top: 1px solid var(--border); }
.card-tools { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

/* ---------- Karteninhalte ---------- */
.face { font-size: 1.15rem; }
.blk + .blk { margin-top: .75rem; }
.blk-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.blk-formula { overflow-x: auto; overflow-y: hidden; }
.blk-image { margin: 0; text-align: center; }
.blk-image img { max-width: 100%; max-height: 60vh; border-radius: 8px; }
.blk-image-missing, .blk-unknown { color: var(--muted); font-style: italic; }

/* ---------- Lernmodus ---------- */
.learn { max-width: 760px; margin: 0 auto; }
.learn-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.learn-counts { display: flex; gap: .3rem; }
.learn-status { text-align: center; color: var(--muted); padding: 2rem 0; }
.learn-status.error { color: var(--danger); }
.learn .notice { margin: 0 0 .75rem; }
.flashcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  padding: 2rem 1.5rem; min-height: 240px; text-align: center; cursor: pointer;
  animation: card-in .2s ease-out;
}
.flashcard.revealed { cursor: default; }
.flashcard .face.back { animation: flip-in .3s ease-out; }
.flashcard .divider { border: 0; border-top: 1px dashed var(--border); margin: 1.5rem 0; }
.flashcard .blk-text { text-align: left; display: inline-block; max-width: 100%; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes flip-in { from { opacity: 0; transform: perspective(800px) rotateX(-25deg); } to { opacity: 1; transform: none; } }
.learn-actions { margin-top: 1rem; }
.show-answer { padding: .9rem; font-size: 1.05rem; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.rate {
  display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .7rem .3rem;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.rate .ivl { font-size: .8rem; font-weight: 400; color: var(--muted); }
.rate.again { border-bottom: 4px solid var(--again); }
.rate.hard { border-bottom: 4px solid var(--hard); }
.rate.good { border-bottom: 4px solid var(--good); }
.rate.easy { border-bottom: 4px solid var(--easy); }
.rate:hover { background: var(--bg); }
.learn-done { text-align: center; padding: 2rem 1rem; }

/* ---------- Mobil ---------- */
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .container { padding: 1rem .75rem 4rem; }
  .card { padding: .9rem; }
  .deck-row { flex-wrap: wrap; }
  .deck-main { flex-basis: calc(100% - 3rem); }
  .flashcard { padding: 1.25rem 1rem; min-height: 200px; }
  .rate kbd, .show-answer kbd, .sticky-actions kbd { display: none; }
  .cards-table th:nth-child(5), .cards-table td:nth-child(5) { display: none; }
  .nav { gap: .75rem; font-size: .95rem; }
}

/* =====================================================================
   Version 1.1 – Design-Entscheidungen vom 26.11.2026
   ===================================================================== */

.center { justify-content: center; }
.section { margin-top: 1.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .6rem; }
.section-head h2 { margin: 0; }

/* ---------- "Heute lernen": großer Startknopf ---------- */
.hero { display: block; margin-bottom: 1rem; border-radius: 18px; }
.hero-start {
  display: flex; align-items: center; gap: 1rem; padding: 1.25rem 1.4rem; min-height: 96px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #7048e8));
  color: var(--primary-text); text-decoration: none !important; box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 35%, transparent);
  transition: transform .12s ease, box-shadow .12s ease;
}
.hero-start:hover { transform: translateY(-1px); box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 40%, transparent); }
.hero-start:active { transform: scale(.99); }
.hero-start:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.hero-play { display: flex; }
.hero-text { display: flex; flex-direction: column; }
.hero-title { font-size: 1.6rem; font-weight: 800; line-height: 1.15; margin: 0; }
.hero-sub { opacity: .92; font-size: 1rem; }
.hero-done, .hero-empty { text-align: center; padding: 1.5rem 1rem; }
.hero-done .hero-title, .hero-empty .hero-title { font-size: 1.35rem; margin-bottom: .35rem; }
.hero-empty .actions { margin-top: .75rem; }

/* ---------- Werkzeugzeile über Listen: Anzahl · Ansicht · Auswählen ---------- */
.list-tools { display: flex; align-items: center; gap: .35rem; margin-bottom: .5rem; }
.list-tools > .muted { margin-right: auto; }
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tool-btn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 0; }
.list-tools > .tool-btn { border: 1px solid var(--border); border-radius: 8px; }
.tool-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--primary) 15%, var(--surface)); color: var(--primary); }
.select-box { display: none; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; cursor: pointer; }
.select-box input { width: 20px; height: 20px; margin: 0; }
.selecting .select-box { display: inline-flex; }
.selection-bar {
  position: sticky; bottom: .5rem; z-index: 5; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-top: .75rem; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, .15);
}
.selection-count { margin-right: auto; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 640px) { body.has-tabbar .selection-bar { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + .5rem); } }

/* ---------- Kartenliste: Liste (Desktop als Tabelle) oder Kacheln ---------- */
.card-items { display: grid; gap: .5rem; }
.card-item { display: grid; align-items: center; gap: .25rem .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; }
.ci-main { display: contents; color: var(--text); text-decoration: none !important; }
.ci-front, .ci-back { overflow-wrap: anywhere; min-width: 0; }
.ci-front { font-weight: 600; }
.ci-back { color: var(--muted); }
.ci-due { white-space: nowrap; }
.card-item:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.card-items-head { display: none; }

/* Liste – Desktop: Tabellenraster */
.view-list .card-item, .view-list .card-items-head { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 8.5rem 6.5rem; }
.view-list .card-items-head > span:first-child { display: none; }
.selecting .view-list .card-items-head > span:first-child { display: block; }
.selecting .view-list .card-item, .selecting .view-list .card-items-head { grid-template-columns: 32px minmax(0, 1.2fr) minmax(0, 1fr) 8.5rem 6.5rem; }
.view-list .card-items-head { display: grid; gap: .75rem; padding: 0 .75rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.view-list { gap: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.view-list .card-items-head { padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.view-list .card-item { border: 0; border-radius: 0; border-bottom: 1px solid var(--border); padding: .6rem .75rem; }
.view-list .card-item:last-child { border-bottom: 0; }
.view-list .ci-front, .view-list .ci-back { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.view-list .ci-main { cursor: pointer; }

/* Kacheln */
.view-tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.view-tiles .card-item { grid-template-columns: 1fr auto; grid-template-areas: "front front" "back back" "state due"; align-content: start; padding: .8rem; min-height: 140px; position: relative; }
.view-tiles .select-box { position: absolute; top: .3rem; right: .3rem; z-index: 1; }
.view-tiles .ci-front { grid-area: front; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.view-tiles .ci-back { grid-area: back; font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.view-tiles .ci-state { grid-area: state; align-self: end; }
.view-tiles .ci-due { grid-area: due; align-self: end; text-align: right; }

@media (max-width: 640px) {
  /* Liste am Handy: eine Zeile je Karte, Status + Datum rechts */
  .view-list .card-items-head { display: none; }
  .view-list .card-item, .selecting .view-list .card-item {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "front state" "back due"; gap: .15rem .6rem;
  }
  .selecting .view-list .card-item { grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-areas: "check front state" "check back due"; }
  .view-list .select-box { grid-area: check; }
  .view-list .ci-front { grid-area: front; }
  .view-list .ci-back { grid-area: back; -webkit-line-clamp: 1; font-size: .9rem; }
  .view-list .ci-state { grid-area: state; justify-self: end; }
  .view-list .ci-due { grid-area: due; justify-self: end; }
  .view-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .view-tiles .card-item { min-height: 120px; padding: .65rem; }
}

/* ---------- Gefahrenzone ---------- */
.danger-title { color: var(--danger); margin-top: 1.25rem; }
.tool.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* ---------- Konto (Handy) ---------- */
.account-links { display: flex; flex-direction: column; gap: 0; padding: .25rem 1rem; margin-bottom: 1rem; }
.account-links a, .account-links .link-btn { display: flex; align-items: center; gap: .6rem; padding: .8rem 0; color: var(--text); font-size: 1rem; width: 100%; }
.account-links > * + * { border-top: 1px solid var(--border); }
.account-links .link-btn { color: var(--danger); }

/* ---------- Teilen-Dialog ---------- */
.share-summary { font-weight: 600; margin: 0 0 .75rem; }
.share-options { display: grid; gap: .5rem; }
.share-option { display: flex; gap: .7rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-weight: 400; margin: 0; }
.share-option input { margin-top: .25rem; width: 18px; height: 18px; flex: none; }
.share-option span { display: flex; flex-direction: column; }
.share-option:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.share-status { min-height: 1.2em; margin: .6rem 0 0; color: var(--muted); }
.share-status.error { color: var(--danger); }
.share-import { margin: .4rem 0 0; }

/* ---------- Lernmodus ---------- */
.learn-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.learn-top .deck-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learn-close { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; }
.learn-progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: .9rem; }
.learn-progress span { display: block; height: 100%; width: 0; background: var(--good); transition: width .3s ease; }
.card-deck { margin: -0.75rem 0 1rem; text-align: center; }
.done-icon { font-size: 2rem; margin: 0; color: var(--good); font-weight: 800; }

/* "Gut" betont: doppelt so breit, grün gefüllt */
.ratings { grid-template-columns: 1fr 1fr 2fr 1fr; }
.rate.good { background: var(--good); border-color: var(--good); color: #fff; }
.rate.good .ivl { color: rgba(255, 255, 255, .9); }
.rate.good:hover { background: color-mix(in srgb, var(--good) 88%, #000); }
.rate:active { transform: scale(.98); }
.rate { min-height: 56px; justify-content: center; }

@media (max-width: 640px) {
  /* Antwort-Knopf und Bewertungen unten in der Daumenzone */
  body.focus-mode .topbar { display: none; }
  body.focus-mode .container { padding-top: .6rem; padding-bottom: calc(150px + var(--safe-bottom)); }
  .learn .learn-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0;
    padding: .6rem .6rem calc(.6rem + var(--safe-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-top: 1px solid var(--border);
  }
  .show-answer { min-height: 56px; }
  .ratings { gap: .35rem; }
  .rate { padding: .5rem .2rem; font-size: .92rem; }
}

/* ---------- Registrierung, Einführung, Rechtliches (v1.2) ---------- */
.hint { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.auth-box .form { margin-top: .5rem; }
.auth-links { margin-top: .75rem; }
.captcha-box { margin: .25rem 0 1rem; min-height: 1px; }
.greeting { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; }
.verify-banner a { font-weight: 600; margin-left: .25rem; }
.notice-card { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.notice ul.compact { margin: .4rem 0; padding-left: 1.2rem; }
.notice { margin-bottom: 1rem; }
.invite-link { display: block; margin-top: .35rem; font-size: .75rem; padding: .25rem .4rem; min-width: 220px; }
.codes-table td { vertical-align: middle; }
.codes-table form.inline + form.inline { margin-left: .25rem; }
.site-footer { text-align: center; font-size: .82rem; color: var(--muted); padding: 0 1rem 1.5rem; }
.site-footer a { color: var(--muted); }
@media (max-width: 640px) { body.has-tabbar .site-footer { display: none; } }
.legal-links { text-align: center; margin-top: 1.5rem; }
.legal { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.legal h2 { margin-top: 1.5rem; }
.legal h3 { margin-top: 1rem; }
mark.placeholder { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--text); padding: 0 .25rem; border-radius: 4px; }
.tour { text-align: center; }
.tour-icon { font-size: 2.6rem; line-height: 1; margin: .25rem 0 .75rem; }
.tour-text { margin: 0 0 1rem; line-height: 1.55; }
.tour-dots { display: flex; justify-content: center; gap: .4rem; margin-bottom: .25rem; }
.tour-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.tour-dots span.active { background: var(--primary); width: 20px; border-radius: 4px; }
.pill.status-active { color: var(--success); }
