/* Vokabeltrainer – handyoptimiert (iPhone Safari), helles und dunkles Design */
:root {
  --rot: #c60b1e;
  --rot-dunkel: #9d0716;
  --gelb: #ffc400;
  --gruen: #1f8a4c;
  --orange: #c56a00;
  --bg: #fbf6ee;
  --card: #ffffff;
  --ink: #2a211b;
  --ink2: #5e5249;
  --muted: #8a7d72;
  --line: #e9dfd2;
  --soft: #f4ece1;
  --bar: #c60b1e;
  --ok-bg: #e5f5eb;
  --fast-bg: #fff4d6;
  --bad-bg: #fde8e8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --card: #262019;
    --ink: #f4ede4;
    --ink2: #cfc3b6;
    --muted: #9c8f83;
    --line: #3a3129;
    --soft: #2f2820;
    --bar: #ff6b6b;
    --ok-bg: #173825;
    --fast-bg: #3a2f10;
    --bad-bg: #3d1a1a;
    --gruen: #4cc27e;
    --orange: #f0a03c;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; min-height: 100dvh;
  padding-top: calc(52px + var(--safe-top));
  padding-bottom: calc(70px + var(--safe-bottom));
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
body.no-tabs { padding-bottom: calc(16px + var(--safe-bottom)); }
a { color: var(--rot); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { height: 12px; }

/* Kopfzeile */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(52px + var(--safe-top)); padding: var(--safe-top) 12px 0;
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { font-size: 30px; line-height: 1; background: none; border: 0; color: var(--rot); padding: 4px 10px 6px 0; min-height: 44px; }
.top-right { font-size: 15px; color: var(--ink2); white-space: nowrap; }

main { max-width: 640px; margin: 0 auto; padding: 14px 14px 8px; outline: none; }

/* Tab-Leiste unten */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 11px; color: var(--muted); text-decoration: none; min-height: 48px; justify-content: center;
}
.tabs a span { font-size: 22px; line-height: 1.1; filter: grayscale(.6); opacity: .75; }
.tabs a.active { color: var(--rot); font-weight: 600; }
.tabs a.active span { filter: none; opacity: 1; }

/* Karten / Flaechen */
.box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; border: 1px solid var(--line); }
.box h2 { font-size: 17px; margin: 0 0 10px; }
.box h3 { font-size: 15px; margin: 14px 0 6px; color: var(--ink2); }

/* Knoepfe */
button, .btn { font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px; border: 0;
  background: var(--rot); color: #fff; font-weight: 650; font-size: 17px; text-decoration: none;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.big { width: 100%; min-height: 58px; font-size: 19px; border-radius: 16px; }
.btn.light { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--rot); border: 1px solid var(--line); }
.btn.green { background: var(--gruen); }
.btn.danger { background: transparent; color: var(--rot); border: 1px solid var(--rot); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Formulare: mindestens 16px, sonst zoomt Safari beim Antippen */
input, textarea, select {
  font: inherit; font-size: 17px; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 160px; resize: vertical; line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--rot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rot) 20%, transparent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 14px; color: var(--ink2); margin-bottom: 4px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.check input { width: 24px; height: 24px; -webkit-appearance: checkbox; appearance: auto; accent-color: var(--rot); }
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--ink2); font-size: 15px; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }

/* Startseite */
.hero { display: flex; gap: 16px; align-items: center; }
.ring { width: 132px; height: 132px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--soft); }
.ring .fill { stroke: var(--rot); transition: stroke-dashoffset .6s ease; }
.ring.done .fill { stroke: var(--gruen); }
.ring .label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .label b { font-size: 34px; line-height: 1; }
.ring .label small { font-size: 13px; color: var(--muted); }
.stat-lines { flex: 1; display: grid; gap: 8px; }
.flame { font-size: 30px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.flame.off { filter: grayscale(1); opacity: .6; }
.siesta { font-size: 14px; color: var(--ink2); }
.kaesten { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.kaesten div { background: var(--soft); border-radius: 12px; padding: 8px 2px; }
.kaesten b { display: block; font-size: 20px; }
.kaesten small { font-size: 11px; color: var(--muted); display: block; line-height: 1.2; }
.kaesten .k4 { background: color-mix(in srgb, var(--gelb) 30%, var(--soft)); }
.frase { font-size: 19px; font-weight: 650; margin: 0 0 4px; }
.level-bar { height: 10px; background: var(--soft); border-radius: 6px; overflow: hidden; margin: 8px 0 4px; }
.level-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--rot), var(--gelb)); border-radius: 6px; }
.fokus { background: var(--fast-bg); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }

/* Lernen */
.progress { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink2); margin-bottom: 10px; }
.progress .bar { flex: 1; height: 8px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--rot); transition: width .4s; }
.progress.done .bar i { background: var(--gruen); }
.flash { text-align: center; padding: 22px 16px 18px; min-height: 150px; display: flex; flex-direction: column; justify-content: center; }
.flash .meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-block; background: var(--soft); border-radius: 20px; padding: 2px 10px; font-size: 13px; color: var(--ink2); }
.chip.k4 { background: color-mix(in srgb, var(--gelb) 35%, var(--soft)); }
.prompt { font-size: 27px; font-weight: 700; line-height: 1.25; word-break: break-word; }
.dir { font-size: 13px; color: var(--muted); margin-top: 8px; }
.answer-wrap { position: relative; }
.answer-wrap input { font-size: 20px; padding: 14px 56px 14px 16px; min-height: 58px; }
.mic { position: absolute; right: 6px; top: 6px; width: 46px; height: 46px; border-radius: 12px; border: 0; background: var(--soft); font-size: 22px; }
.mic.listening { background: var(--rot); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.accents { display: flex; gap: 5px; margin: 8px 0 12px; overflow-x: auto; }
.accents button { flex: 1 0 32px; padding: 0; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 20px; touch-action: manipulation; }
.accents button:active { background: var(--soft); }
.feedback { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.fast { background: var(--fast-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback .verdict { font-weight: 800; font-size: 19px; margin-bottom: 4px; }
.feedback .sol { font-size: 22px; font-weight: 700; margin: 4px 0; }
.feedback .hint { font-weight: 650; }
.feedback .hint.artikel { color: var(--rot-dunkel); font-size: 18px; }
@media (prefers-color-scheme: dark) { .feedback .hint.artikel { color: #ff9b9b; } }
.feedback .note { font-size: 15px; color: var(--ink2); margin-top: 6px; }
.feedback .given { font-size: 14px; color: var(--ink2); }
.speak { border: 0; background: none; font-size: 22px; padding: 4px 8px; vertical-align: middle; }
.combo {
  position: fixed; left: 50%; top: 36%; z-index: 50; transform: translate(-50%, -50%);
  font-size: 40px; font-weight: 900; color: var(--rot); text-shadow: 0 2px 0 var(--gelb), 0 4px 18px rgba(0,0,0,.2);
  pointer-events: none; animation: combo 1.4s ease-out forwards; white-space: nowrap;
}
@keyframes combo { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 70% { opacity: 1; transform: translate(-50%, -60%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -90%) scale(.9); } }
.combo-count { font-weight: 700; color: var(--orange); }

/* Ueberlagerung (Feier, Fragen) */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(20, 12, 6, .55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.overlay .sheet { background: var(--card); border-radius: 22px; padding: 24px 20px; max-width: 420px; width: 100%; text-align: center; animation: pop .35s ease; }
.overlay .sheet .big-emoji { font-size: 64px; line-height: 1.1; }
.overlay .sheet h2 { margin: 8px 0; font-size: 24px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a.item, .list .item { display: flex; gap: 10px; align-items: center; padding: 12px 2px; color: inherit; text-decoration: none; min-height: 52px; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item .t span { display: block; color: var(--ink2); font-size: 15px; overflow-wrap: anywhere; }
.boxnum { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--ink2); }
.boxnum.b4 { background: color-mix(in srgb, var(--gelb) 40%, var(--soft)); }
.boxnum.b0 { opacity: .5; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.filters input { grid-column: 1 / -1; }
.preview td, .preview th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; font-size: 15px; vertical-align: top; }
.preview { width: 100%; border-collapse: collapse; }
.preview .err { color: var(--rot); }

/* Wochenrueckblick: ein Datensatz, eine Farbe, duenne Balken mit 4px-Rundung oben, Ziel-Linie */
.week { position: relative; height: 170px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; align-items: end; padding: 0 2px 26px; }
.week .goal { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--muted); opacity: .7; }
.week .goal span { position: absolute; right: 0; top: -18px; font-size: 12px; color: var(--muted); }
.week .col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: pointer; }
.week .col i { display: block; width: 60%; max-width: 26px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.week .col.erfuellt i { background: var(--gruen); }
.week .col small { position: absolute; bottom: -22px; font-size: 12px; color: var(--ink2); }
.week .col .tip { position: absolute; bottom: calc(100% + 4px); background: var(--ink); color: var(--bg); font-size: 12px; padding: 3px 6px; border-radius: 6px; white-space: nowrap; display: none; z-index: 2; }
.week .col:hover .tip, .week .col.show .tip { display: block; }
.week-base { border-top: 1px solid var(--line); margin: -26px 0 26px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 16px; }
.kv b { text-align: right; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; }
.topicbar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--soft); gap: 2px; }
.topicbar i { display: block; height: 100%; }

/* Reise */
.map { width: 100%; height: auto; display: block; }
.map .land { fill: var(--soft); stroke: var(--line); stroke-width: 3; }
.map .route { fill: none; stroke: var(--muted); stroke-width: 3; stroke-dasharray: 8 8; }
.map .route.done { stroke: var(--rot); stroke-dasharray: none; }
.map circle { stroke: var(--card); stroke-width: 4; }
.map .city { fill: var(--muted); }
.map .city.done { fill: var(--rot); }
.map .city.here { fill: var(--gelb); stroke: var(--rot); stroke-width: 5; }
.map text { font-size: 42px; fill: var(--ink2); font-weight: 600; }
.city-list li .item { align-items: flex-start; }
.city-list .done .boxnum { background: var(--rot); color: #fff; }
.city-list .here .boxnum { background: var(--gelb); color: #000; }

/* Medaillen */
.medals { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.medal { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.medal .i { font-size: 38px; }
.medal b { display: block; font-size: 15px; }
.medal span { font-size: 13px; color: var(--ink2); }
.medal.off { opacity: .45; filter: grayscale(1); }

.login { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.login .logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); }
.notice { background: var(--soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; text-align: left; }
.err-text { color: var(--rot); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
