/* Farben und Schrift aus dem Sagosys-Theme (wie ScreenShare). Hell/Dunkel folgt der Systemeinstellung. */
@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url(../fonts/plex-400.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; font-display: swap; src: url(../fonts/plex-500.woff2) format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-display: swap; src: url(../fonts/plex-600.woff2) format('woff2'); }

:root {
  --bg: #F2F8F7; --surface: #FFFFFF; --surface-2: #E6F1EF;
  --text: #0B1F22; --text-2: #3E5C5A; --text-3: #557270;
  --border: #D2E3E0; --accent: #0A7D6B; --accent-hover: #076556; --on-accent: #FFFFFF; --accent-soft: #D6F5EE;
  --danger: #C62020; --danger-soft: #FBD9D6; --ok: #0A7D6B; --ok-soft: #D6F5EE; --warn: #B45309;
  --ring: #0A7D6B; --shadow: 0 1px 2px rgba(11,31,34,.06), 0 8px 24px rgba(11,31,34,.08);
  --font: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --r: 10px; --r-lg: 16px; --tabbar: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314; --surface: #1A1B1D; --surface-2: #242527;
    --text: #ECEEEF; --text-2: #A7ABB0; --text-3: #8F949A;
    --border: #2B2D30; --accent: #1FF3CD; --accent-hover: #5CF7DC; --on-accent: #03251E; --accent-soft: rgba(31,243,205,.13);
    --danger: #F87171; --danger-soft: rgba(248,113,113,.18); --ok: #1FF3CD; --ok-soft: rgba(31,243,205,.13); --warn: #FBBF24;
    --ring: #5CF7DC; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font); }
h1 { font-size: 1.6rem; font-weight: 600; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0; }
h3 { font-size: 1rem; font-weight: 600; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
[hidden] { display: none !important; }

.page { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)); }
body.in-study .page { padding-bottom: 24px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.tight { gap: 2px; flex-wrap: nowrap; }
.spacer { flex: 1; }
.center { text-align: center; }
.pad { padding: 24px; }
.muted { color: var(--text-2); font-size: .92rem; }
.hint { color: var(--text-2); font-size: .9rem; }
.error { color: var(--danger); }
.empty { color: var(--text-2); text-align: center; padding: 24px 8px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-lg); }
.page-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.page-head h1 { flex: 1; }
.badge { display: inline-block; background: var(--accent-soft); color: var(--accent); padding: 1px 10px; border-radius: 99px; font-size: .82rem; font-weight: 500; margin-left: 8px; }
.ico { display: inline-flex; vertical-align: middle; }

/* Knöpfe und Felder */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 1rem var(--font); cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.big { min-height: 54px; font-size: 1.1rem; padding: 0 26px; }
.btn.wide { width: 100%; }
.btn.right { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }
.btn.wrong { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.wrong { color: #1c0606; } }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: transparent; color: var(--text-2); border-radius: var(--r); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.star.on { color: #E3A008; }
.icon-btn.star.on svg { fill: currentColor; }
.icon-btn.speak { color: var(--accent); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input[type=number] { width: 80px; text-align: center; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
input[type=file] { padding: 10px; border: 1px dashed var(--border); border-radius: var(--r); background: var(--surface); width: 100%; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .88rem; color: var(--text-2); font-weight: 500; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; }
.choice { display: flex; flex-direction: column; gap: 8px; }
.choice-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); cursor: pointer; }
.choice-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Anmeldung */
.login { max-width: 420px; margin: 0 auto; padding: 48px 20px; display: flex; flex-direction: column; gap: 16px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r); }
.tab { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font: 500 .95rem var(--font); cursor: pointer; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Untere Navigation */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--surface); border-top: 1px solid var(--border); z-index: 5; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-2); text-decoration: none; font-size: .75rem; font-weight: 500; }
.tabbar a.on { color: var(--accent); }

/* Stapel */
.deck { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 4px 8px 4px 10px; }
.deck-main { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: none; border: 0; color: inherit; font: inherit; padding: 10px 4px; cursor: pointer; min-width: 0; }
.deck-main strong { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.deck-main .badge { margin-left: 0; }
.pick-gap { width: 20px; flex: none; }
.bar { display: block; width: 100%; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.bar.wide { margin: 0 0 12px; }
.sticky-bar { position: sticky; bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r-lg); box-shadow: var(--shadow); }

/* Lernansicht */
.study { display: flex; flex-direction: column; gap: 4px; min-height: calc(100dvh - 40px); }
.study-head { display: flex; align-items: center; gap: 8px; }
.study-title { display: flex; flex-direction: column; min-width: 0; }
.card-body { margin: auto 0; display: flex; flex-direction: column; gap: 14px; }
.flashcard { flex: 1; display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 12px 18px 24px; min-height: 340px; }
.card-tools { display: flex; align-items: center; gap: 2px; }
.side { display: flex; flex-direction: column; gap: 6px; }
.side-lang { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }
.word-row { display: flex; align-items: center; gap: 8px; }
.word { flex: 1; font-size: clamp(1.7rem, 7vw, 2.4rem); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.side.back .word { color: var(--accent); }
.note-row { display: flex; align-items: flex-start; gap: 4px; }
.note { flex: 1; white-space: pre-wrap; color: var(--text-2); background: var(--surface-2); border-radius: var(--r); padding: 8px 12px; font-size: 1.1rem; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--border); }
.tap-hint { text-align: center; }
.answer-bar { display: flex; gap: 12px; padding: 12px 0 0; }
.answer-bar .btn { flex: 1; }
.finish { margin: auto; display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; padding: 32px 8px; }

/* Kartenverwaltung */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input { flex: 2 1 160px; }
.toolbar select { flex: 1 1 140px; width: auto; }
.bulk { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-lg); }
.bulk select { width: auto; min-width: 120px; }
.cardlist { display: flex; flex-direction: column; gap: 6px; }
.crow { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 6px 6px 12px; }
.ctext { flex: 1; min-width: 0; }
.cline { display: flex; flex-wrap: wrap; gap: 4px 10px; font-weight: 500; overflow-wrap: anywhere; }
.cnote, .cstat { font-size: .82rem; overflow-wrap: anywhere; }
.cnote { font-size: .9rem; }

/* Import */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 36px 16px; text-align: center; border: 2px dashed var(--border); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.preview { overflow-x: auto; }
.preview table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.preview th, .preview td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.preview th { color: var(--text-2); font-weight: 500; }

/* Einstellungen */
.rules { display: flex; flex-direction: column; gap: 6px; }
.rule { display: flex; align-items: center; gap: 10px; }
.rule > span:first-child { flex: 1; }
.voice { padding-top: 6px; border-top: 1px solid var(--border); }

/* Dialoge, Hinweise */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; overflow-y: auto; }
.modal { width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Importverlauf */
.imp { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 6px 8px 14px; }
.imp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.imp-main strong { overflow-wrap: anywhere; }
a.icon-btn { text-decoration: none; }
.pos { flex: none; min-width: 2.2em; text-align: right; font-size: .82rem; font-variant-numeric: tabular-nums; }
.range { align-items: flex-end; }
.range .field { width: 110px; }
