/* ============================================================
   German Trainer — styles
   Mobile-first, works on phone and desktop. Light + dark aware.
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc2626;
  /* German noun-gender colors (der/die/das) */
  --der: #2563eb;   /* masculine — blue */
  --die: #db2777;   /* feminine  — pink/red */
  --das: #16a34a;   /* neuter    — green */
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.08);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a22;
    --surface-2: #1f2430;
    --text: #e6e8ee;
    --muted: #9aa2b1;
    --border: #2a2f3b;
    --accent: #7c83ff;
    --accent-ink: #0f1117;
    --der: #60a5fa;
    --die: #f472b6;
    --das: #4ade80;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

/* Ensure the [hidden] attribute always wins over element display rules
   (e.g. the back button, which is display:inline-flex when shown). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__brand {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--text); font-size: 18px; font-weight: 700;
}
.topbar__flag { font-size: 22px; }
.topbar__back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none; padding: 0;
  border: none; background: transparent; color: var(--text);
  font-size: 24px; line-height: 1; cursor: pointer; border-radius: 9px;
}
@media (hover: hover) { .topbar__back:hover { background: var(--surface-2); } }
.topbar__back:active { transform: translateY(1px); }
.topbar__acct { margin-left: auto; }
.topbar__acct .avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px;
}

/* ---------- Layout ---------- */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}
.stack { display: grid; gap: 14px; }
.screen-title { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.screen-sub { color: var(--muted); margin: 0 0 8px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
@media (hover: hover) { .btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); } }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--block { width: 100%; }
.btn--good { background: var(--good); color: #fff; border-color: transparent; }
.btn--bad  { background: var(--bad);  color: #fff; border-color: transparent; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }

/* ---------- Cards / tiles ---------- */
.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .06s ease, border-color .15s ease;
}
@media (hover: hover) { .tile:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); } }
.tile:active { transform: translateY(1px); }
.tile__emoji { font-size: 28px; width: 40px; text-align: center; flex: none; }
.tile__body { display: grid; gap: 2px; }
.tile__title { font-weight: 700; font-size: 17px; }
.tile__desc { color: var(--muted); font-size: 14px; }
.tile__meta { margin-left: auto; color: var(--muted); font-size: 13px; text-align: right; flex: none; }

.grid { display: grid; gap: 12px; }
@media (min-width: 560px) { .grid--2 { grid-template-columns: 1fr 1fr; } }

/* progress pill */
.pill {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.pill--done { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill--streak { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #f59e0b; }

/* progress bar */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Flashcard ---------- */
.card {
  position: relative;
  min-height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 28px 22px;
  cursor: pointer;
  user-select: none;
}
.card__hint { position: absolute; top: 12px; right: 14px; color: var(--muted); font-size: 12px; }
.card__word { font-size: 34px; font-weight: 800; margin: 6px 0; }
.card__sub { color: var(--muted); font-size: 16px; }
.card__example { margin-top: 16px; font-size: 15px; text-align: left; width: 100%; }
.card__example .de { font-weight: 600; }
.card__example .en { color: var(--muted); }
.card__example .ex { margin-top: 8px; }
.card__example .ex:first-child { margin-top: 0; }
.row__ex .ex { margin-top: 4px; }
.row__ex .ex .de { color: var(--text); font-weight: 600; }
.row__ex .ex .en { color: var(--muted); }
.card__section { margin-top: 14px; width: 100%; }

/* conjugation table */
.conj { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
.conj td { padding: 5px 8px; border-top: 1px solid var(--border); text-align: left; }
.conj td:first-child { color: var(--muted); width: 42%; }
.conj td:last-child { font-weight: 600; }

/* article coloring */
.art-der { color: var(--der); font-weight: 800; }
.art-die { color: var(--die); font-weight: 800; }
.art-das { color: var(--das); font-weight: 800; }

/* ---------- Quiz ---------- */
.q-prompt { font-size: 26px; font-weight: 800; text-align: center; margin: 10px 0 4px; }
.q-sub { text-align: center; color: var(--muted); margin: 0 0 12px; }
.options { display: grid; gap: 10px; }
.option {
  width: 100%; text-align: left; padding: 14px 16px; font-size: 16px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer;
}
@media (hover: hover) { .option:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); } }
.option--correct { background: color-mix(in srgb, var(--good) 20%, var(--surface)); border-color: var(--good); }
.option--wrong { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); border-color: var(--bad); }
.option:disabled { cursor: default; }

.text-answer {
  width: 100%; padding: 14px 16px; font-size: 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.text-answer:focus { outline: 2px solid var(--accent); border-color: transparent; }

.feedback { text-align: center; font-weight: 700; min-height: 24px; }
.feedback--good { color: var(--good); }
.feedback--bad { color: var(--bad); }

.scorebar { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; }

/* ---------- Browse ---------- */
.search {
  width: 100%; padding: 12px 14px; font-size: 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.list { display: grid; gap: 8px; margin-top: 12px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.row__de { font-weight: 700; font-size: 16px; }
.row__en { color: var(--muted); }
.row__ex { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.row__ex .de { color: var(--text); }
.row__badge { font-size: 12px; }

/* ---------- Misc ---------- */
/* speaker / pronunciation button */
.spk {
  appearance: none; border: none; background: transparent; cursor: pointer;
  padding: 2px 5px; margin-left: 4px; border-radius: 8px;
  font-size: 0.62em; line-height: 1; vertical-align: middle; opacity: .7;
}
@media (hover: hover) { .spk:hover { opacity: 1; background: var(--surface-2); } }
.spk:active { transform: translateY(1px); }
.spk--sm { font-size: 0.95em; padding: 1px 4px; }

.center { text-align: center; }
.muted { color: var(--muted); }
.big-emoji { font-size: 56px; }
.spacer { height: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 13px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.chip--on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.sr-note { font-size: 13px; color: var(--muted); }
