/* TÜV SÜD Akademie – Karteikarten Web-App. Optik wie die Android-App (Farben sind Platzhalter). */
:root {
  --blue: #005CA9;
  --blue-dark: #003F75;
  --bg: #FFFFFF;
  --text: #1A1A1A;
  --muted: #5F6368;
  --line: #E3E6EA;
  --row-hover: #F1F4F8;
  --c-new: #3F51B5;
  --c-learn: #D32F2F;
  --c-review: #2E7D32;
  --again: #D32F2F;
  --hard: #455A64;
  --good: #4CAF50;
  --easy: #005CA9;
  --bar-top: env(safe-area-inset-top, 0px);
  --bar-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--bar-top) + 10px) 8px 10px 16px;
  background: var(--blue); color: #fff;
}
.titles { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 21px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 14px; opacity: .9; }
.subtitle:empty { display: none; }
.sync-btn { position: relative; opacity: .6; }
.sync-btn.on { opacity: 1; }
.sync-btn .sync-dot { display: none; position: absolute; top: 9px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #4CAF50; border: 2px solid var(--blue); }
.sync-btn.on .sync-dot { display: block; }
.sync-btn.busy svg { animation: sync-spin 1s linear infinite; }
@keyframes sync-spin { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) { .sync-btn.busy svg { animation: none; } }
.top-logo { width: 36px; height: 36px; flex-shrink: 0; filter: brightness(0) invert(1); opacity: .95; }
.icon-btn {
  background: none; border: 0; color: inherit; width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 50%;
}
.icon-btn:active { background: #fff3; }

.menu {
  position: fixed; right: 8px; top: calc(var(--bar-top) + 58px); z-index: 20;
  background: #fff; border-radius: 6px; box-shadow: 0 4px 16px #0003;
  display: flex; flex-direction: column; min-width: 220px; overflow: hidden;
}
.menu button { background: none; border: 0; text-align: left; padding: 14px 16px; color: var(--text); }
.menu button:active { background: var(--row-hover); }

/* TÜV-SÜD-Logo als dezentes Wasserzeichen hinter Übersicht und "Geschafft" */
.watermark {
  position: fixed; left: 50%; top: 55%; z-index: 0; pointer-events: none;
  width: min(70vw, 420px); aspect-ratio: 1; transform: translate(-50%, -50%);
  background: url("icons/tuev-sued-logo.svg") center / contain no-repeat;
  opacity: .07;
}
.view { position: relative; z-index: 1; }
.total {
  position: fixed; left: 0; right: 0; bottom: calc(var(--bar-bottom) + 10px); z-index: 2;
  margin: 0; text-align: center; font-size: 13px; color: var(--muted); pointer-events: none;
}
.about-logo { display: block; width: 72px; height: 72px; margin: 0 auto 8px; }
.about h3 { font-size: 15px; margin: 16px 0 4px; }
.about ul { margin: 0; padding-left: 18px; }
.about li { margin: 2px 0; }
.about .meta { color: var(--muted); font-size: 13px; }
.dialog-box { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* Deckliste */
.view { padding-bottom: calc(var(--bar-bottom) + 48px); }
.deck-list { list-style: none; margin: 0; padding: 0; }
.deck {
  display: flex; align-items: center; min-height: 56px;
  padding: 8px 12px 8px calc(16px + var(--level, 0) * 24px);
  border-bottom: 1px solid var(--line);
}
.deck:active { background: var(--row-hover); }
.deck .toggle {
  width: 32px; height: 32px; margin-left: -8px; margin-right: 4px;
  background: none; border: 0; color: var(--text); display: grid; place-items: center;
  transition: transform .15s;
}
.deck .toggle.collapsed { transform: rotate(-90deg); }
.deck .toggle.none { visibility: hidden; }
.deck .name { flex: 1; font-size: 19px; font-weight: 700; min-width: 0; padding-right: 10px; overflow-wrap: anywhere; hyphens: auto; }
.deck .counts { display: flex; gap: 10px; flex-shrink: 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.c-total { color: var(--text); font-weight: 600; }
.c-new { color: var(--c-new); }
.c-learn { color: var(--c-learn); }
.c-review { color: var(--c-review); }
.counts .zero { color: #C4C7CC; }
.today { text-align: center; color: var(--muted); margin: 24px 16px; }
.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty img { border-radius: 20px; }

/* Eintrag "Zahlen & Daten" */
.deck.virtual .name { color: var(--blue); }
.deck.virtual .name::before {
  content: "123"; display: inline-block; margin-right: 8px; padding: 1px 5px; border-radius: 4px;
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 3px;
}

/* Statistik */
.stats { padding: 8px 16px calc(var(--bar-bottom) + 48px); max-width: 720px; margin: 0 auto; }
.stats h2 { font-size: 16px; margin: 22px 0 8px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.kpi { background: #F3F6FA; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi b { font-size: 26px; font-weight: 600; color: var(--blue); font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.prow { margin: 8px 0; }
.plabel { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 3px; }
.pnum { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.pbar, .abar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #EEF1F4; }
.pbar span, .abar span { display: block; height: 100%; }
.arow { display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
.arow .pnum { text-align: right; }
.stats svg { width: 100%; height: auto; display: block; }
.stats svg .axis { font-size: 10px; fill: var(--muted); }
.stats svg .base { stroke: #C4C7CC; stroke-width: 1; }
.optin { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin: 6px 0; }
.optin input { width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0; }
.hint { color: var(--muted); font-size: 13px; }

/* Lernen */
#view-study { display: flex; flex-direction: column; height: calc(100dvh - 64px - var(--bar-top)); padding-bottom: 0; }
.counts-bar { display: flex; gap: 12px; padding: 6px 16px; background: #B3E0F7; font-variant-numeric: tabular-nums; }
.counts-bar .current { text-decoration: underline; }
.card-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.card { padding: 16px; max-width: 720px; margin: 0 auto; }
.card img { max-width: 100%; height: auto; }
.card hr#answer { border: 0; border-top: 1px solid #999; margin: 16px 0; }
.answer-area { padding-bottom: var(--bar-bottom); background: #455A64; }
.btn-show {
  width: 100%; min-height: 60px; border: 0; background: #455A64; color: #fff; font-size: 18px;
}
.ease-buttons { display: grid; grid-template-columns: repeat(4, 1fr); }
.ease {
  border: 0; color: #fff; min-height: 60px; font-size: 17px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.ease small { font-weight: 400; font-size: 13px; opacity: .95; }
.ease.again { background: var(--again); }
.ease.hard { background: var(--hard); }
.ease.good { background: var(--good); }
.ease.easy { background: var(--easy); }
.ease:active, .btn-show:active { filter: brightness(.9); }

.done { text-align: center; padding: 64px 24px; }
.btn-primary {
  background: var(--blue); color: #fff; border: 0; border-radius: 22px; padding: 12px 28px; font-size: 16px;
}

.dialog { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 30; padding: 16px; }
.dialog-box { background: #fff; border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; }
.dialog-box h2 { margin-top: 0; font-size: 20px; }
.dialog-box a { color: var(--blue); }
.dialog-box .btn-primary { margin-top: 12px; float: right; }

/* Fehler melden */
.counts-bar { align-items: center; }
.report-card {
  margin-left: auto; display: flex; align-items: center; gap: 4px; background: none; border: 0;
  color: var(--blue-dark); font-size: 13px; padding: 4px 0; min-height: 32px;
}
.report-box label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.report-box select, .report-box textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 8px 10px; border: 1px solid #C4C7CC; border-radius: 8px; background: #fff;
}
.report-box textarea { resize: vertical; min-height: 96px; }
.report-card-info { background: #F3F6FA; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.report-card-info b { color: var(--text); }
.req { color: var(--again); }
.field-error { color: var(--again); font-size: 13px; margin: 4px 0 0; }
.report-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.report-actions .btn-primary { float: none; margin: 0; }
.report-pre { white-space: pre-wrap; font-size: 12px; background: #F3F6FA; padding: 8px; border-radius: 8px; user-select: all; }
.unlock label { display: block; font-weight: 600; margin-bottom: 6px; }
.unlock-row { display: flex; gap: 8px; }
.unlock-row input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px; border: 1px solid #C4C7CC; border-radius: 8px; text-transform: uppercase; }
.unlock-row .btn-primary { float: none; margin: 0; }
.mod-list { list-style: none; padding: 0; margin: 0; }
.mod-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #E53935; vertical-align: 2px; margin-left: 4px; }
.icon-btn { position: relative; }
.menu-dot { position: absolute; top: 9px; right: 9px; margin: 0; border: 2px solid var(--blue); width: 11px; height: 11px; }
.mine-row { padding: 10px 0; border-bottom: 1px solid var(--line); display: block; }
.mine-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.status-pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #EEF1F4; color: var(--muted); white-space: nowrap; }
.status-pill.s-in-arbeit { background: #FFF4E5; color: #B26A00; }
.status-pill.s-erledigt { background: #E8F5E9; color: #2E7D32; }
.status-pill.s-abgelehnt { background: #F3F4F6; color: #5F6368; }
.mine-reply { margin-top: 6px; background: #F3F6FA; border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.mine-reply.new { background: #E6F0FA; border-left: 3px solid var(--blue); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #EEF1F4; border-radius: 10px; padding: 4px; margin: 4px 0 6px; }
.segmented button { border: 0; background: none; border-radius: 8px; padding: 9px 6px; font-size: 14px; color: var(--muted); }
.segmented button[aria-checked="true"] { background: #fff; color: var(--blue); font-weight: 600; box-shadow: 0 1px 3px #0002; }
.mod-row .btn-secondary { padding: 8px 14px; font-size: 14px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 8px; margin: 8px auto; width: min(260px, 100%); aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; }
.sync-code { text-align: center; font: 600 20px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 1px; margin: 6px 0 10px; }
.sync-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sync-wide { float: none !important; width: 100%; margin: 8px 0 4px !important; }
.w98-action { display: block; width: 100%; margin-top: 10px; height: 40px; font-weight: 700; color: #003F75; }
.steps { padding-left: 22px; margin: 6px 0 4px; }
.steps li { margin: 8px 0; }
.btn-secondary { background: none; border: 1px solid #C4C7CC; border-radius: 22px; padding: 12px 20px; font-size: 16px; color: var(--text); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bar-bottom) + 24px); z-index: 40;
  background: #323232; color: #fff; padding: 12px 18px; border-radius: 8px; max-width: calc(100% - 32px);
  box-shadow: 0 4px 16px #0004;
}

/* Karla (Win98-Büroassistenten-Stil) */
.karla {
  position: fixed; z-index: 25; left: 12px; right: 12px; bottom: calc(var(--bar-bottom) + 16px);
  display: flex; flex-direction: column; align-items: flex-start; pointer-events: none;
  animation: karla-in .45s cubic-bezier(.3, 1.6, .5, 1) both;
}
.karla > * { pointer-events: auto; }
@keyframes karla-in { from { transform: translateY(400px); opacity: 0; } }
.karla.out { animation: karla-out .25s ease-in both; }
@keyframes karla-out { to { transform: translateY(200px); opacity: 0; } }
.bubble {
  background: #FFFFE1; color: #000; border: 1px solid #000; border-radius: 10px;
  padding: 12px; max-width: 320px; box-shadow: 0 4px 12px #0003;
}
.bubble strong { font-size: 16px; }
.bubble p { margin: 6px 0 0; font-size: 14px; }
.bubble-row { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 12px; }
.progress { color: #555; font-size: 12px; margin-right: 2px; }
.w98 {
  min-width: 72px; height: 36px; padding: 0 10px; font-size: 13px; color: #000;
  background: #C0C0C0; border: 0; border-radius: 0;
  box-shadow: inset -1px -1px #000, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #DFDFDF;
}
.w98:active { box-shadow: inset 1px 1px #000, inset -1px -1px #fff, inset 2px 2px #808080, inset -2px -2px #DFDFDF; }
.w98.invisible { visibility: hidden; }
.link { display: block; margin: 8px 0 0 auto; background: none; border: 0; color: #0000EE; font-size: 13px; min-height: 32px; }
.tail { margin-left: 28px; margin-top: -1px; }
.figure { animation: karla-float .9s ease-in-out infinite alternate; transform-origin: 50% 90%; }
@keyframes karla-float { to { transform: translateY(-6px); } }
.figure.wiggle { animation: karla-wiggle .5s ease-in-out; }
/* Freudensprung beim Freischalten */
.figure.jump { animation: karla-jump 1.2s cubic-bezier(.3, .7, .4, 1); }
@keyframes karla-jump {
  0% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-46px) rotate(-8deg); }
  40% { transform: translateY(0) rotate(0); }
  55% { transform: translateY(-24px) rotate(6deg); }
  70%, 100% { transform: translateY(0) rotate(0); }
}
.confetti {
  position: absolute; bottom: 70px; z-index: 3; width: 8px; height: 11px; border-radius: 2px; pointer-events: none;
  animation: confetti 1.4s ease-out both;
}
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x), -220px) rotate(var(--r)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .figure.jump, .confetti { animation: none; } .confetti { display: none; } }
@keyframes karla-wiggle { 20% { transform: rotate(-10deg); } 50% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }

@media (prefers-reduced-motion: reduce) {
  .karla, .figure, .karla.out { animation: none; }
}

/* Tastenkürzel in Anleitungen */
kbd { display: inline-block; border: 1px solid #c3c9d1; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 0.85em; font-family: inherit; }

/* Karten pausieren */
#btn-report-card { margin-left: 14px; }
.toast-action { background: none; border: 0; color: #7FB2E5; font: inherit; font-weight: 700; padding: 0 0 0 8px; cursor: pointer; }
.paused-list { list-style: none; padding: 0; margin: 4px 0 12px; }
.paused-list li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line, #E3E6EA); font-size: 14px; }
.btn-link { background: none; border: 0; color: var(--blue, #005CA9); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; padding: 0; }

/* Vorherige Karte (unten links) */
.answer-area { display: flex; align-items: stretch; }
.answer-main { flex: 1; min-width: 0; }
.undo-btn { flex: 0 0 52px; display: grid; place-items: center; border: 0; background: #37474F; color: #fff; cursor: pointer; border-right: 1px solid #ffffff22; }
.undo-btn:active { filter: brightness(.9); }
.undo-btn[hidden] { display: none; }
.btn-link-light { background: none; border: 0; color: var(--blue, #005CA9); font: inherit; font-weight: 600; cursor: pointer; margin-top: 8px; }

/* Karten merken (Stern) */
.star-btn { margin-left: auto; background: none; border: 0; font-size: 22px; line-height: 1; color: #8A94A0; cursor: pointer; padding: 2px 8px; min-height: 32px; }
.star-btn.on { color: #F5B301; }
.star-btn + .report-card { margin-left: 4px; }
.star-deck .name { font-weight: 700; color: #B07A00; }
#btn-pause-card { margin-left: 4px; }

/* Karteikarten durchsuchen */
.search-bar { padding: 10px 12px 4px; }
.search-bar[hidden] { display: none; }
.search-bar input { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px 10px 36px; border: 1px solid #C4C7CC; border-radius: 10px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18' height='18'%3E%3Cpath d='M15.5 14h-.8l-.3-.3A6.5 6.5 0 1 0 9.5 16a6.5 6.5 0 0 0 4.2-1.6l.3.3v.8l5 5 1.5-1.5-5-5zm-6 0a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z' fill='%23707780'/%3E%3C/svg%3E") no-repeat 10px center; color: #1A1A1A; }
.search-results { list-style: none; margin: 0; padding: 4px 12px 16px; }
.search-count { color: var(--muted, #5F6368); font-size: 13px; padding: 6px 2px; }
.search-hit { padding: 10px 4px; border-bottom: 1px solid #E3E6EA; cursor: pointer; }
.search-hit:active { background: #EEF3F9; }
.sh-q { font-weight: 600; }
.sh-a { font-size: 14px; color: #3D434A; margin-top: 3px; }
.sh-deck { font-size: 12px; color: var(--muted, #5F6368); margin-top: 3px; }
.sh-star { color: #F5B301; }
.search-hit mark { background: #FFF3CD; color: inherit; padding: 0 1px; border-radius: 2px; }
.preview-card { text-align: left; font-size: 16px; max-height: 60vh; overflow: auto; border: 1px solid #E3E6EA; border-radius: 8px; padding: 10px; }
.preview-actions { display: flex; gap: 18px; margin: 10px 0 0; }
#btn-search.active { background: #ffffff33; border-radius: 50%; }

/* Kategorien in der Suche */
.tag-suggest { padding: 6px 2px 2px; font-size: 13px; color: var(--muted, #5F6368); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip { border: 0; border-radius: 14px; padding: 4px 10px; background: var(--blue, #005CA9); color: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.tag-chip small { opacity: .8; margin-left: 2px; }
.sh-tags { color: var(--blue, #005CA9); }
.preview-actions .btn-primary { float: none; margin: 0; }
.preview-actions { align-items: center; }
.search-count .btn-link { margin-left: 10px; font-size: 13px; }
.preview-actions .btn-primary { white-space: nowrap; padding: 10px 16px; }
