/* ==========================================================================
   SyncBrain — Gestaltung: Messinstrument
   Das Programm misst dein Gedächtnis und terminiert Wiederholungen.
   Also sieht es aus wie ein Gerät: Gehäuse, Schilder, Gravuren, eine
   Signalfarbe für das, was Aufmerksamkeit fordert. Keine Verläufe,
   keine weichen Ecken, keine Dekoration ohne Funktion.
   ========================================================================== */

/* --------------------------------- Schrift -------------------------------- */

@font-face {
  font-family: 'Plex Sans';
  src: url('/vendor/font/sans/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Sans';
  src: url('/vendor/font/sans/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Sans';
  src: url('/vendor/font/sans/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Sans';
  src: url('/vendor/font/sans/ibm-plex-sans-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/vendor/font/mono/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/vendor/font/mono/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
  font-weight: 500; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/vendor/font/mono/ibm-plex-mono-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Cond';
  src: url('/vendor/font/cond/ibm-plex-sans-condensed-latin-600-normal.woff2') format('woff2');
  font-weight: 600; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Plex Cond';
  src: url('/vendor/font/cond/ibm-plex-sans-condensed-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-display: swap; font-style: normal;
}

/* --------------------------------- Token ---------------------------------- */

:root {
  /* Tagbetrieb: helles Gerätegehäuse mit Schildern */
  --housing:  #d9d7cf;
  --plate:    #f3f2ed;
  --recess:   #e6e4dc;
  --ink:      #191a16;
  --ink-2:    #55564e;
  --ink-3:    #85867c;
  --rule:     #c0beb4;
  --rule-2:   #d6d4cb;
  --signal:   #cf4320;
  --go:       #2c6a4c;
  --cool:     #33556c;
  --amber:    #a8760e;

  --r: 2px;
  --fs: 'Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fc: 'Plex Cond', 'Plex Sans', sans-serif;
  --fm: 'Plex Mono', ui-monospace, Menlo, monospace;

  --nav-h: 58px;
  --head-h: 52px;
  --rail-w: 208px;
}

:root[data-theme="night"] {
  /* Nachtbetrieb: unbeleuchtetes Gehäuse, hinterleuchtete Schilder */
  --housing:  #14150f;
  --plate:    #1e201a;
  --recess:   #191b15;
  --ink:      #e8e7dd;
  --ink-2:    #9fa094;
  --ink-3:    #74766a;
  --rule:     #33362c;
  --rule-2:   #282b22;
  --signal:   #ef643c;
  --go:       #4f9a73;
  --cool:     #6f9ec0;
  --amber:    #d9a53a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior-y: none; }

body {
  background: var(--housing);
  color: var(--ink);
  font-family: var(--fs);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'kern' 1;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.22; letter-spacing: -.008em; }
h1 { font-size: 19px; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }
p { margin: 0 0 10px; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--signal); }
button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--rule); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Gravur — die Beschriftung auf einem Gerät */
.engraved, .label, .section-title, .stat .l, .gbtn .lab, .hero .label, .chart-labels, .tabs button {
  font-family: var(--fm);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
}

/* Messwert — jede Zahl steht im Anzeigeschnitt */
.readout, .stat .n, .hero .count, .box-cell .n, .gbtn .num, .grade-bars .val, .study-top .n {
  font-family: var(--fm);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* --------------------------------- Aufbau --------------------------------- */

#app { min-height: 100%; }
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--head-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; padding-top: env(safe-area-inset-top);
  background: var(--housing);
  border-bottom: 1px solid var(--rule);
}
.topbar h1 {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  font-family: var(--fm);
}

.page { padding: 16px 14px 30px; max-width: 900px; width: 100%; margin: 0 auto; flex: 1; }
.page.wide { max-width: 1120px; }

/* Untere Leiste: flach, Aktivmarkierung als Balken oben */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--plate);
  border-top: 1px solid var(--rule);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--ink-3); position: relative;
  font-family: var(--fm); font-size: 9px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
}
.tabbar a svg { width: 19px; height: 19px; }
.tabbar a::before {
  content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 2px;
  background: transparent;
}
.tabbar a.active { color: var(--ink); }
.tabbar a.active::before { background: var(--signal); }
.tabbar a .badge {
  position: absolute; top: 5px; left: 50%; margin-left: 7px;
  background: var(--signal); color: #fff; font-size: 9px; font-weight: 600;
  min-width: 15px; height: 15px; padding: 0 3px;
  display: grid; place-items: center; letter-spacing: 0;
}

/* -------------------------------- Bauteile -------------------------------- */

/* Schild — der einzige Container. Ersetzt die abgerundete Kachel. */
.card, .plate {
  background: var(--plate);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 15px 16px;
}
.card + .card { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--ink); border-radius: var(--r);
  background: transparent; color: var(--ink);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .1s linear, color .1s linear, border-color .1s linear;
  user-select: none;
}
.btn:hover { background: var(--ink); color: var(--plate); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; color: var(--ink); }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--plate); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

/* Der eine Signalknopf: Tagespensum starten. Sonst nirgends. */
.btn.signal { background: var(--signal); border-color: var(--signal); color: #fff; font-weight: 600; }
.btn.signal:hover { background: var(--ink); border-color: var(--ink); color: var(--plate); }

.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--recess); color: var(--ink); border-color: transparent; }
.btn.danger { border-color: transparent; color: var(--signal); }
.btn.danger:hover { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 12.5px; }
.btn.icon { padding: 0; width: 38px; min-height: 38px; }
.btn.block { width: 100%; }
.btn.big { min-height: 46px; font-size: 15px; font-weight: 600; }

.input, textarea.input, select.input {
  width: 100%; min-height: 40px; padding: 9px 11px;
  background: var(--housing);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  outline: none;
  transition: border-color .1s linear;
}
:root[data-theme="night"] .input { background: var(--recess); }
.input:focus { border-color: var(--ink); }
.input::placeholder { color: var(--ink-3); }
textarea.input { min-height: 104px; resize: vertical; line-height: 1.55; }
textarea.mono, .mono { font-family: var(--fm); font-size: 13px; }
select.input {
  appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2385867c' stroke-width='1.6'%3E%3Cpath d='M3 5.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.field { margin-bottom: 13px; }
.field label {
  display: block; margin-bottom: 5px; color: var(--ink-2);
  font-family: var(--fm); font-size: 10px; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase;
}
.field .hint { margin-top: 5px; font-size: 12px; color: var(--ink-3); line-height: 1.45; }

.row { display: flex; gap: 9px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-title {
  color: var(--ink-3); margin: 24px 0 9px;
  display: flex; align-items: center; gap: 9px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

/* Kennzeichnung — aufgedruckt, nicht als Bonbon */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border: 1px solid var(--rule); border-radius: var(--r);
  background: transparent; color: var(--ink-2);
  font-family: var(--fm); font-size: 9.5px; font-weight: 500;
  letter-spacing: .09em; text-transform: uppercase; white-space: nowrap;
}
.pill.accent { border-color: var(--ink); color: var(--ink); }
.pill.green  { border-color: var(--go); color: var(--go); }
.pill.amber  { border-color: var(--amber); color: var(--amber); }
.pill.red    { border-color: var(--signal); color: var(--signal); }
.pill.blue   { border-color: var(--cool); color: var(--cool); }

/* Kippschalter — rechteckig, mit Rastung */
.switch { position: relative; width: 44px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--recess); transition: border-color .1s linear, background .1s linear;
  pointer-events: none;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 17px; height: 18px;
  background: var(--ink-3); border-radius: 1px;
  transition: transform .12s cubic-bezier(.3,.7,.4,1), background .12s linear;
  pointer-events: none;
}
.switch input:checked ~ .track { border-color: var(--ink); background: var(--plate); }
.switch input:checked ~ .thumb { transform: translateX(21px); background: var(--signal); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--signal); outline-offset: 2px; }

.empty { text-align: center; padding: 44px 18px; color: var(--ink-2); }
.empty .icon { font-family: var(--fm); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }
.empty h3 { margin-bottom: 6px; color: var(--ink); font-size: 16px; }

.divider { height: 1px; background: var(--rule); margin: 15px 0; border: 0; }

.spinner {
  width: 16px; height: 16px; border: 1.5px solid var(--rule);
  border-top-color: var(--ink); animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 56px 0; }

/* Meldung — Statusstreifen, kein schwebendes Bonbon */
#toasts {
  position: fixed; z-index: 200; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--plate);
  padding: 10px 14px; font-size: 13px;
  display: flex; gap: 9px; align-items: baseline;
  animation: toast-in .12s linear;
  border-left: 3px solid var(--ink-3);
}
.toast .dot { font-family: var(--fm); font-size: 10px; letter-spacing: .1em; opacity: .7; }
.toast .dot::before { content: 'INFO'; }
.toast.error { border-left-color: var(--signal); }
.toast.error .dot::before { content: 'FEHLER'; }
.toast.success { border-left-color: var(--go); }
.toast.success .dot::before { content: 'OK'; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* Beim Lernen sitzen die Bewertungsziffern unten — Meldungen wandern nach oben. */
body.studying #toasts { bottom: auto; top: calc(env(safe-area-inset-top) + 42px); }
body.studying .toast { animation: none; }

/* Klappe / Dialog */
.overlay {
  position: fixed; inset: 0; z-index: 150;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .1s linear;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: var(--plate); width: 100%; max-width: 540px;
  border: 1px solid var(--rule); border-bottom: 0; border-radius: var(--r) var(--r) 0 0;
  max-height: 92dvh; overflow-y: auto;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  animation: sheet-up .16s cubic-bezier(.3,.7,.4,1);
}
@keyframes sheet-up { from { transform: translateY(20px); } }
.sheet .grabber { width: 34px; height: 3px; background: var(--rule); margin: 0 auto 14px; }
.sheet h2 { margin-bottom: 3px; }
.sheet .sub { color: var(--ink-2); font-size: 13px; margin-bottom: 15px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

/* ------------------------- Anzeige: Pensum + Fächer ------------------------ */

.hero {
  background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 0; overflow: hidden;
}
.hero .readout-top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  padding: 14px 16px 10px;
}
.hero .label { color: var(--ink-3); display: block; margin-bottom: 2px; }
.hero .count {
  font-family: var(--fc); font-size: 76px; font-weight: 700;
  line-height: .84; letter-spacing: -.02em; color: var(--ink);
  display: block;
}
.hero .count small {
  font-family: var(--fm); font-size: 11px; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); margin-left: 8px; vertical-align: 12px;
}
.hero.clear .count { color: var(--go); }
.hero .breakdown {
  text-align: right; font-family: var(--fm); font-size: 11px;
  color: var(--ink-2); line-height: 1.7; white-space: nowrap;
}
.hero .breakdown b { font-weight: 600; color: var(--ink); }
.hero .progress { height: 3px; background: var(--recess); margin: 0 16px 12px; }
.hero .progress i { display: block; height: 100%; background: var(--signal); transition: width .3s linear; }
.hero .action { padding: 0 16px 16px; }

/* Signature: der Leitner-Kasten. Zeigt, in welchem Fach deine Karten stecken. */
.box-strip { border-top: 1px solid var(--rule); background: var(--recess); }
.box-strip .box-head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px 0; color: var(--ink-3);
}
.box-strip .box-head::after { content: ''; flex: 1; height: 1px; background: var(--rule-2); }
.box-cells { display: grid; grid-template-columns: repeat(5, 1fr); }
.box-cell {
  padding: 8px 4px 9px; text-align: center;
  border-right: 1px solid var(--rule-2);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.box-cell:last-child { border-right: 0; }
.box-cell .n { font-size: 16px; color: var(--ink); line-height: 1; }
.box-cell.zero .n { color: var(--ink-3); }
.box-cell .fill { width: 100%; height: 3px; background: var(--rule-2); position: relative; }
.box-cell .fill i { position: absolute; inset: 0 auto 0 0; background: var(--ink-2); }
.box-cell.due .n { color: var(--signal); }
.box-cell.due .fill i { background: var(--signal); }
.box-cell .l {
  font-family: var(--fm); font-size: 8.5px; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); line-height: 1.2;
}

/* Registrierstreifen — 14 Tage Lernleistung, heute rechts */
.trace {
  display: flex; align-items: flex-end; gap: 3px; height: 44px;
  border-bottom: 1px solid var(--rule);
}
.trace-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; }
.trace-bar { width: 100%; background: var(--ink-2); }
.trace-bar.zero { background: var(--rule); }
.trace-bar.now { background: var(--signal); }
.trace-foot { display: flex; justify-content: space-between; margin-top: 6px; color: var(--ink-3); }

/* Messwertzeile */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px;
  border: 1px solid var(--rule); background: var(--plate); }
.stat { padding: 11px 8px; text-align: center; border-right: 1px solid var(--rule-2); }
.stat:last-child { border-right: 0; }
.stat .n { font-size: 19px; line-height: 1.1; display: block; }
.stat .l { color: var(--ink-3); margin-top: 3px; display: block; }

/* Zeile im Verzeichnis */
.deck-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r);
  text-decoration: none; color: inherit;
  transition: border-color .1s linear;
}
.deck-row:hover { border-color: var(--ink); color: inherit; }
.deck-row .dot { width: 3px; height: 26px; flex: none; }
.deck-row .body { flex: 1; min-width: 0; }
.deck-row .name { font-weight: 600; font-size: 14.5px; }
.deck-row .meta {
  margin-top: 2px; display: flex; gap: 7px; flex-wrap: wrap;
  font-family: var(--fm); font-size: 10.5px; color: var(--ink-3);
}
.deck-row .chev, .deck-row svg { color: var(--ink-3); flex: none; }

.list > * + * { margin-top: 7px; }

/* ---------------------------------- Lernen -------------------------------- */

.study-root {
  position: fixed; inset: 0; z-index: 100; background: var(--housing);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.study-top {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; flex: none;
  border-bottom: 1px solid var(--rule);
}
.study-top .bar { flex: 1; height: 2px; background: var(--rule); }
.study-top .bar i { display: block; height: 100%; background: var(--signal); transition: width .2s linear; }
.study-top .n { font-size: 11px; color: var(--ink-2); letter-spacing: .06em; }

.study-stage {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 14px; min-height: 0; position: relative;
}

/* Die Karte: ein Schild im Gerät, oben graviert */
.flashcard {
  position: relative; justify-content: center; padding-top: 32px;
  background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r);
  max-width: 620px; width: 100%; margin: 0 auto;
  min-height: min(58vh, 460px); max-height: 100%; overflow-y: auto;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column;
  transition: transform .14s linear, opacity .14s linear;
}
.flashcard.swipe-active { transition: none; }
.flashcard .origin {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 7px; flex: none;
  padding: 8px 16px; border-bottom: 1px solid var(--rule-2); background: var(--recess);
  font-family: var(--fm); font-size: 9.5px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}
.flashcard .origin .dot { width: 6px; height: 6px; flex: none; }
.flashcard .side {
  padding: 26px 20px; font-size: 19px; line-height: 1.45; font-weight: 500;
  word-break: break-word; overflow-wrap: anywhere;
}
.flashcard .side.answer { font-size: 17px; font-weight: 400; color: var(--ink-2); }
.flashcard .sep { height: 1px; background: var(--rule); margin: 0 20px; flex: none; }
.flashcard .tap-hint {
  padding: 0 20px 18px; display: flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--fm); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}
.flashcard .tap-hint .key { border: 1px solid var(--rule); padding: 1px 5px; }

.swipe-hint {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-family: var(--fm); font-size: 10px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; padding: 6px 9px; opacity: 0;
  transition: opacity .08s linear; pointer-events: none; border: 1px solid;
}
.swipe-hint.left { left: 14px; color: var(--signal); border-color: var(--signal); }
.swipe-hint.right { right: 14px; color: var(--go); border-color: var(--go); }

/* Bewertung: ein gerasteter Wahlschalter, keine fünf Bonbons */
.grades { padding: 0 14px 16px; flex: none; }
.grades .glabel {
  text-align: center; color: var(--ink-3); padding: 10px 0 8px;
  font-family: var(--fm); font-size: 10px; letter-spacing: .13em; text-transform: uppercase;
}
.grades .buttons {
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 620px; margin: 0 auto;
  border: 1px solid var(--ink); background: var(--plate);
}
.gbtn {
  border: 0; border-right: 1px solid var(--rule); background: transparent;
  padding: 10px 2px 9px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 68px; justify-content: center;
  transition: background .08s linear, color .08s linear;
}
.gbtn:last-child { border-right: 0; }
.gbtn .num { font-size: 17px; line-height: 1; color: var(--ink); }
.gbtn .lab { color: var(--ink-3); font-size: 8.5px; letter-spacing: .06em; line-height: 1.15; }
.gbtn .ivl { font-family: var(--fm); font-size: 9px; color: var(--ink-3); }
.gbtn:hover { background: var(--recess); }
.gbtn[data-g="1"]:hover, .gbtn[data-g="2"]:hover { background: var(--signal); }
.gbtn[data-g="4"]:hover, .gbtn[data-g="5"]:hover { background: var(--go); }
.gbtn[data-g="3"]:hover { background: var(--ink); }
.gbtn:hover .num, .gbtn:hover .lab, .gbtn:hover .ivl { color: #fff; }
.gbtn:active { transform: translateY(1px); }

.study-done { text-align: center; padding: 36px 20px; max-width: 420px; margin: auto; }
.study-done .big {
  font-family: var(--fm); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px;
}
.study-done h2 { font-family: var(--fc); font-size: 30px; font-weight: 700; margin-bottom: 8px; }

/* --------------------------------- Inhalt --------------------------------- */

.content p { margin: 0 0 9px; }
.content p:last-child { margin-bottom: 0; }
.content ul, .content ol { margin: 7px 0; padding-left: 20px; }
.content li { margin: 2px 0; }
.content code {
  font-family: var(--fm); font-size: .875em;
  background: var(--recess); border: 1px solid var(--rule-2); padding: 1px 4px;
}
.content pre {
  background: var(--recess); border: 1px solid var(--rule-2);
  padding: 11px 13px; overflow-x: auto; margin: 9px 0; font-size: 13px; line-height: 1.5;
}
.content pre code { background: none; border: 0; padding: 0; }
.content img { max-width: 100%; }
.content blockquote { margin: 8px 0; padding-left: 11px; border-left: 2px solid var(--rule); color: var(--ink-2); }
.content table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0; }
.content th, .content td { border: 1px solid var(--rule); padding: 5px 8px; text-align: left; }
.content strong { font-weight: 600; }
.katex-display { margin: 11px 0; overflow-x: auto; overflow-y: hidden; }

/* ------------------------------ Deck-Ansicht ------------------------------ */

/* Reiter: Unterstrich statt Segmentschalter */
.tabs {
  display: flex; gap: 0; margin-bottom: 14px;
  border-bottom: 1px solid var(--rule); overflow-x: auto;
}
.tabs button {
  border: 0; background: transparent; color: var(--ink-3);
  padding: 9px 13px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .1s linear, border-color .1s linear;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--signal); }

.folder-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r);
}
.folder-item.off { background: var(--recess); color: var(--ink-3); }
.folder-item.off .fname { color: var(--ink-3); }
.folder-item .fname { font-weight: 500; flex: 1; min-width: 0; }
.folder-item .fcount { font-family: var(--fm); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.folder-item svg { color: var(--ink-3); }

.card-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  background: var(--plate); border: 1px solid var(--rule); border-radius: var(--r);
  cursor: pointer; transition: border-color .1s linear;
}
.card-item:hover { border-color: var(--ink); }
.card-item.selected { border-color: var(--signal); }
.card-item .cbody { flex: 1; min-width: 0; }
.card-item .cfront { font-weight: 500; font-size: 14px; line-height: 1.4; }
.card-item .cback { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; line-height: 1.4; }
.card-item .cmeta { display: flex; gap: 7px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.card-item .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-item .check {
  width: 17px; height: 17px; border: 1px solid var(--rule); flex: none; margin-top: 3px;
  display: grid; place-items: center; transition: background .1s linear, border-color .1s linear;
}
.card-item.selected .check { background: var(--signal); border-color: var(--signal); }
.card-item .check svg { width: 11px; height: 11px; color: #fff; opacity: 0; }
.card-item.selected .check svg { opacity: 1; }

.strength-bar { width: 30px; height: 3px; background: var(--rule); flex: none; }
.strength-bar i { display: block; height: 100%; }

.presence { display: flex; align-items: center; }
.avatar {
  width: 22px; height: 22px; display: grid; place-items: center;
  font-family: var(--fm); font-size: 9px; font-weight: 600; color: var(--plate);
  border: 1px solid var(--plate); margin-left: -5px; flex: none;
}
.avatar:first-child { margin-left: 0; }

.live-dot { width: 6px; height: 6px; background: var(--go); flex: none; }
.live-dot.off { background: var(--ink-3); }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 15px; height: 15px; pointer-events: none; }
.search-wrap .input { padding-left: 32px; }

.fab {
  position: fixed; right: 14px; z-index: 45;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  width: 48px; height: 48px; border-radius: var(--r);
  background: var(--ink); color: var(--plate); border: 0;
  display: grid; place-items: center; cursor: pointer;
}
.fab:active { transform: translateY(1px); }
.fab svg { width: 22px; height: 22px; }

.preview-card { border: 1px solid var(--rule); padding: 9px 11px; background: var(--recess); font-size: 13px; }
.preview-card .q { font-weight: 500; }
.preview-card .a { color: var(--ink-2); margin-top: 2px; }

.dropzone {
  border: 1px dashed var(--rule); padding: 24px 14px; text-align: center;
  color: var(--ink-2); transition: border-color .1s linear, background .1s linear; cursor: pointer;
}
.dropzone svg { color: var(--ink-3); }
.dropzone.over { border-color: var(--signal); background: var(--recess); }

/* ------------------------------- Diagramme -------------------------------- */

.chart { display: flex; align-items: flex-end; gap: 2px; height: 92px; margin: 12px 0 5px;
  border-bottom: 1px solid var(--rule); }
.chart .bar { flex: 1 1 0; min-width: 0; background: var(--ink-2); min-height: 1px; }
.chart .bar.zero { background: var(--rule); min-height: 1px; padding: 0; }
.chart-labels { display: flex; justify-content: space-between; color: var(--ink-3); }

.grade-bars { display: flex; flex-direction: column; gap: 6px; }
.grade-bars .gb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.grade-bars .gb .lbl { width: 14px; text-align: center; font-family: var(--fm); font-weight: 600; }
.grade-bars .gb .track { flex: 1; height: 6px; background: var(--recess); border: 1px solid var(--rule-2); }
.grade-bars .gb .track i { display: block; height: 100%; transition: width .3s linear; }
.grade-bars .gb .val { width: 38px; text-align: right; color: var(--ink-3); font-size: 11px; }

/* ------------------------------- Anmeldung -------------------------------- */

.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.auth-box { width: 100%; max-width: 372px; }
.brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.brand .logo {
  width: 30px; height: 30px; flex: none;
  background: var(--signal); color: #fff;
  display: grid; place-items: center;
  font-family: var(--fc); font-weight: 700; font-size: 17px;
}
.brand .name {
  font-family: var(--fm); font-size: 14px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
}

.link-btn { background: none; border: 0; color: var(--ink); cursor: pointer; padding: 2px;
  text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.link-btn:hover { color: var(--signal); }

.copy-field { display: flex; gap: 6px; }
.copy-field .input { font-family: var(--fm); font-size: 11.5px; }

/* --------------------------------- Desktop -------------------------------- */

@media (min-width: 880px) {
  .tabbar { display: none; }
  .main { padding-bottom: 0; }
  .fab { display: none; }
  #toasts { left: auto; right: 0; bottom: 0; width: 340px; }

  /* Bedienspalte des Geräts */
  .sidebar {
    display: flex; flex-direction: column;
    width: var(--rail-w); flex: none; padding: 18px 0 14px;
    background: var(--plate); border-right: 1px solid var(--rule);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .sidebar .brand { margin: 0 16px 26px; }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; color: var(--ink-3); text-decoration: none;
    border-left: 2px solid transparent;
    font-family: var(--fm); font-size: 10.5px; font-weight: 500;
    letter-spacing: .12em; text-transform: uppercase;
    transition: color .1s linear, border-color .1s linear;
  }
  .sidebar a.nav:hover { color: var(--ink); }
  .sidebar a.nav.active { color: var(--ink); border-left-color: var(--signal); }
  .sidebar a.nav svg { width: 16px; height: 16px; flex: none; }
  .sidebar a.nav .badge {
    margin-left: auto; background: var(--signal); color: #fff;
    font-size: 9.5px; font-weight: 600; padding: 1px 5px; letter-spacing: 0;
  }
  .sidebar .foot { margin-top: auto; padding: 12px 16px 0; border-top: 1px solid var(--rule-2); }

  .topbar { min-height: 56px; padding: 0 22px; }
  .page { padding: 22px 22px 40px; }

  .overlay { align-items: center; }
  .sheet { border: 1px solid var(--rule); border-radius: var(--r); max-height: 86vh; padding: 20px; }
  .sheet .grabber { display: none; }

  /* Gerätefront: Messwert links, Ablesung mittig, Bedienknopf rechts —
     alles auf einer Linie, darunter der Kasten über die volle Breite. */
  .hero {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "top action" "prog prog" "box box";
    align-items: center;
  }
  .hero .readout-top { grid-area: top; padding: 20px 0 20px 22px; align-items: center; }
  .hero .count { font-size: 108px; }
  .hero .count small { vertical-align: 18px; }
  .hero .breakdown { padding-left: 32px; }
  .hero .action { grid-area: action; padding: 20px 22px; }
  .hero .action .btn { width: 250px; }
  .hero .progress { grid-area: prog; margin: 0 22px 14px; }
  .box-strip { grid-area: box; }
  .box-strip .box-head { padding: 10px 22px 0; }
  .box-cell { padding: 10px 4px 11px; }
  .box-cell .n { font-size: 18px; }

  .flashcard .side { padding: 40px 34px; font-size: 22px; }
  .flashcard .side.answer { font-size: 19px; }
  .gbtn { min-height: 76px; }
  .gbtn .lab { font-size: 9.5px; }

  .deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
  .deck-grid .list > * + * { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .tabbar, .sidebar, .fab, .topbar, #toasts { display: none !important; }
}
