:root {
  --green: #6fa91c;
  --green-dark: #4d7d0e;
  --green-light: #eef6e2;
  --blue: #0b68b3;
  --blue-light: #e6f0fa;
  --red: #d64541;
  --red-light: #fdecea;
  --amber: #e69a00;
  --amber-light: #fff5dc;
  --text: #1f2a33;
  --muted: #61707d;
  --border: #d9e1e8;
  --bg: #f6f8f4;
  --card: #ffffff;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.45;
}

button { font: inherit; cursor: pointer; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(90deg, var(--blue) 0%, #1e86d4 100%);
  border-bottom: 5px solid var(--green);
  color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; padding: 0; }
.brand-mark { background: var(--green); font-weight: 800; padding: 4px 8px; border-radius: 8px; letter-spacing: .5px; }
.brand-text { font-weight: 600; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 6px; }
.navbtn { background: rgba(255,255,255,.15); color: #fff; border: 0; padding: 7px 14px; border-radius: 999px; }
.navbtn.active { background: #fff; color: var(--blue); font-weight: 600; }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 1.6rem; margin: 6px 0 4px; }
h2 { font-size: 1.15rem; margin: 26px 0 10px; color: var(--blue); }
.sub { color: var(--muted); margin: 0 0 14px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* Statistik */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.s-master b { color: var(--green-dark); }
.stat.s-learn b { color: var(--amber); }
.stat.s-hard b { color: var(--red); }

/* Unit-Auswahl */
.unit { margin-bottom: 10px; }
.unit-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--green-light); border-radius: var(--radius) var(--radius) 0 0; border: 1px solid var(--border); border-bottom: 0; }
.unit-head label { font-weight: 700; flex: 1; cursor: pointer; }
.unit-head small { color: var(--muted); font-weight: 400; }
.unit-body { border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); background: #fff; }
.sec { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid #eef2f5; cursor: pointer; }
.sec:first-child { border-top: 0; }
.sec span.name { flex: 1; }
.sec .count { color: var(--muted); font-size: .85rem; min-width: 64px; text-align: right; }
input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--green); cursor: pointer; }

.bar { height: 8px; width: 90px; border-radius: 99px; background: #e8edf1; overflow: hidden; flex-shrink: 0; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* Modi */
.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mode { background: #fff; border: 2px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: left; }
.mode .ico { font-size: 1.6rem; display: block; }
.mode b { display: block; margin-top: 4px; }
.mode small { color: var(--muted); font-size: .82rem; }
.mode.active { border-color: var(--green); background: var(--green-light); }

.options { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin-top: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 13px; color: var(--muted); }
.seg button.active { background: var(--blue); color: #fff; }
.opt-label { font-size: .85rem; color: var(--muted); margin-right: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

.start-row { display: flex; align-items: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 600; background: var(--green); color: #fff; }
.btn:hover { background: var(--green-dark); }
.btn:disabled { background: #b8c2ca; cursor: not-allowed; }
.btn.big { font-size: 1.15rem; padding: 14px 30px; }
.btn.secondary { background: #fff; color: var(--blue); border: 2px solid var(--blue); }
.btn.secondary:hover { background: var(--blue-light); }
.btn.red { background: var(--red); }
.btn.ghost { background: none; color: var(--muted); font-weight: 400; text-decoration: underline; padding: 6px; }
.hint { color: var(--muted); font-size: .9rem; }

/* Quiz */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress { flex: 1; height: 12px; background: #e3e9ee; border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); transition: width .3s; }
.quiz-top .num { color: var(--muted); font-size: .9rem; white-space: nowrap; }

.qcard { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px; text-align: center; box-shadow: 0 4px 18px rgba(0,0,0,.05); }
.qlabel { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.prompt { font-size: 1.9rem; font-weight: 700; margin: 10px 0 6px; word-wrap: break-word; }
.prompt.sentence { font-size: 1.45rem; font-weight: 600; }
.prompt .gap { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--blue); color: var(--blue); }
.section-tag { display: inline-block; font-size: .78rem; color: var(--green-dark); background: var(--green-light); border-radius: 99px; padding: 2px 10px; }

.speak { border: 0; background: var(--blue-light); color: var(--blue); width: 46px; height: 46px; border-radius: 50%; font-size: 1.3rem; vertical-align: middle; }
.speak:hover { background: #d3e5f7; }
.speak.small { width: 34px; height: 34px; font-size: 1rem; }
.speak.huge { width: 96px; height: 96px; font-size: 2.6rem; margin: 10px 0; }

.answer-input { width: 100%; max-width: 480px; font-size: 1.35rem; padding: 12px 16px; border: 2px solid var(--border); border-radius: 12px; margin-top: 18px; text-align: center; outline: none; }
.qcard .answer-input { display: block; margin: 18px auto 0; }
.answer-input:focus { border-color: var(--blue); }
.answer-input.ok { border-color: var(--green); background: var(--green-light); }
.answer-input.bad { border-color: var(--red); background: var(--red-light); }
.answer-input.almost { border-color: var(--amber); background: var(--amber-light); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.choice { background: #fff; border: 2px solid var(--border); border-radius: 12px; padding: 14px 10px; font-size: 1.05rem; text-align: center; }
.choice:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-light); }
.choice .key { display: inline-block; color: var(--muted); font-size: .75rem; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: middle; }
.choice.ok { border-color: var(--green); background: var(--green-light); font-weight: 600; }
.choice.bad { border-color: var(--red); background: var(--red-light); }
.choice:disabled { cursor: default; color: var(--text); opacity: 1; }
.choice:disabled:not(.ok):not(.bad) { opacity: .55; }

.feedback { margin-top: 18px; padding: 14px; border-radius: 12px; text-align: left; }
.feedback.ok { background: var(--green-light); }
.feedback.bad { background: var(--red-light); }
.feedback.almost { background: var(--amber-light); }
.feedback .title { font-weight: 700; font-size: 1.1rem; }
.feedback .sol { font-size: 1.2rem; margin-top: 4px; }
.feedback .ex { margin-top: 8px; color: #33424f; font-style: italic; }
.feedback .note { margin-top: 6px; font-size: .9rem; color: #7a4c00; }

.actions { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Karteikarte */
.flash { min-height: 230px; display: flex; flex-direction: column; justify-content: center; }
.flash .back { border-top: 2px dashed var(--border); margin-top: 18px; padding-top: 16px; }

/* Ergebnis */
.result { text-align: center; }
.result .stars { font-size: 2.8rem; letter-spacing: 6px; }
.result .score { font-size: 2.2rem; font-weight: 800; margin: 6px 0; }
.wronglist { text-align: left; margin-top: 16px; }

/* Wortliste */
.search { width: 100%; padding: 10px 14px; font-size: 1rem; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
table.words { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
table.words td { padding: 8px 10px; border-top: 1px solid #eef2f5; vertical-align: top; }
table.words td.en { font-weight: 600; width: 38%; }
table.words td.ex { color: var(--muted); font-size: .88rem; font-style: italic; }
table.words tr.sechead td { background: var(--green-light); font-weight: 700; color: var(--green-dark); }
.box { display: inline-flex; gap: 2px; }
.box i { width: 7px; height: 14px; border-radius: 2px; background: #e1e7ec; }
.box i.on { background: var(--green); }

/* Seitenkopf */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.btn.mini { padding: 4px 10px; font-size: .82rem; font-weight: 600; background: var(--blue-light); color: var(--blue); }
.btn.mini:hover { background: #d3e5f7; }

/* Startseite: Kacheln */
.tiles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; background: #fff;
  border: 2px solid var(--border); border-radius: 18px; padding: 18px; min-height: 190px; transition: transform .1s, border-color .1s; }
.tile:hover:not(.disabled) { border-color: var(--green); transform: translateY(-2px); }
.tile-ico { font-size: 2.4rem; line-height: 1; }
.tile-title { font-size: 1.3rem; }
.tile-sub { color: var(--muted); font-size: .9rem; }
.tile-stats { display: flex; flex-direction: column; gap: 2px; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.tile-stats .hard { color: var(--red); font-weight: 600; }
.tile-units { margin-top: auto; font-size: .78rem; color: var(--green-dark); background: var(--green-light); border-radius: 99px; padding: 2px 10px; }
.tile.disabled { opacity: .55; cursor: default; background: #f1f3f0; }
.bar.wide { width: 100%; }
.tip { margin-top: 18px; background: var(--amber-light); border-color: #f0d28a; }

/* Grammatik-Themenliste */
.gsec { cursor: default; }
.gsec .name { flex: 1; cursor: pointer; }
.gsec .de { display: block; color: var(--muted); font-size: .8rem; }
.code { display: inline-block; min-width: 30px; text-align: center; font-weight: 800; font-size: .8rem; color: #fff;
  background: var(--blue); border-radius: 6px; padding: 1px 6px; margin-right: 4px; }
.mode .cnt { display: block; margin-top: 4px; color: var(--green-dark); font-weight: 600; }
.mode:disabled { opacity: .45; cursor: not-allowed; }

/* Aufgaben */
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt .fill, .sol .fill { color: var(--green-dark); text-decoration: underline; }
.choices.two { grid-template-columns: 1fr 1fr; }
.cue { display: inline-block; margin-top: 10px; padding: 6px 18px; border-radius: 99px; font-weight: 700; font-size: 1.1rem; }
.cue.yes { background: var(--green-light); color: var(--green-dark); }
.cue.no { background: var(--red-light); color: var(--red); }
.build { min-height: 62px; margin: 18px auto 10px; max-width: 620px; padding: 10px; border: 2px dashed var(--border);
  border-radius: 14px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.build.ok { border-color: var(--green); background: var(--green-light); border-style: solid; }
.build.bad { border-color: var(--red); background: var(--red-light); border-style: solid; }
.build-ph { color: #a9b4bd; }
.build .punct { font-size: 1.3rem; font-weight: 700; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 620px; margin: 0 auto; }
.wtile { border: 2px solid var(--blue); background: #fff; color: var(--blue); border-radius: 10px; padding: 8px 14px;
  font-size: 1.1rem; font-weight: 600; box-shadow: 0 2px 0 var(--blue); }
.wtile:hover { background: var(--blue-light); }
.wtile.in { background: var(--blue); color: #fff; }
.de-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: #eef2f5; color: var(--muted); border-radius: 4px; padding: 1px 6px; margin-right: 4px; }
.pic { font-size: 5.5rem; line-height: 1.1; margin: 10px 0 4px; }
.pic.small { font-size: 3rem; margin: 6px 0 0; }
.wtile.letter { min-width: 46px; font-size: 1.35rem; padding: 8px 10px; text-transform: none; }
.build.letters { gap: 6px; }
.code-cell { width: 60px; font-weight: 700; color: var(--blue); }

/* Regelkarte */
.modal { position: fixed; inset: 0; background: rgba(20, 35, 50, .45); z-index: 50; display: flex; align-items: flex-start;
  justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 20px; max-width: 680px; width: 100%; padding: 20px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-x { border: 0; background: #eef2f5; width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; }
.rule p { margin: 10px 0; }
table.rt { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .93rem; }
table.rt th { background: var(--green); color: #fff; padding: 6px 8px; text-align: left; }
table.rt td { border: 1px solid var(--border); padding: 6px 8px; vertical-align: top; }

/* My progress */
.progress-table td.barcell { width: 45%; }
.progress-table td.pct { width: 60px; text-align: right; color: var(--muted); }
.reset-row { margin-top: 10px; padding-top: 12px; border-top: 1px solid #eef2f5; }
.reset-row select { padding: 9px 12px; border-radius: 12px; border: 1px solid var(--border); font-size: .95rem; }

@media (max-width: 760px) {
  .tiles-grid { grid-template-columns: 1fr; }
  .tile { min-height: 0; }
  .navbtn span { display: none; }
  .brand-text { display: none; }
}

/* Installieren-Hinweis */
.install-card { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--blue-light); border-color: #bcd6ef; }
.ios-share { display: inline-block; border: 1.5px solid var(--blue); color: var(--blue); border-radius: 5px; padding: 0 5px; font-size: .85rem; }

/* Handy & Tablet */
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
main { padding-bottom: max(60px, env(safe-area-inset-bottom)); }
@media (hover: none) and (pointer: coarse) {
  /* Tastenkürzel gibt es auf Touch-Geräten nicht */
  .kbd-hint, .choice .key { display: none; }
  .choice { padding: 16px 10px; }
  .wtile { padding: 10px 16px; }
}

.plural-hint { display: inline-block; margin-top: 8px; padding: 4px 12px; border-radius: 99px; background: var(--amber-light); color: #7a4c00; font-weight: 600; }
.voice-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.voice-row select { flex: 1; min-width: 220px; padding: 10px 12px; font-size: 1rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.voice-warn { background: var(--amber-light); border: 1px solid #f0d28a; border-radius: 12px; padding: 12px 14px; }

.kbd-hint { margin-top: 14px; font-size: .8rem; color: var(--muted); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .choices { grid-template-columns: 1fr; }
  .prompt { font-size: 1.5rem; }
  .prompt.sentence { font-size: 1.2rem; }
  .bar { width: 50px; }
  table.words td.ex { display: none; }
}
