/* ============================================================
   DEUTSCH LERNEN — Design tokens
   Konsep: warisan Bauhaus Jerman (geometris, warna primer bermakna)
   ditumpuk di atas base cream + glass yang diminta di brief.
   Signature: gender artikel (der/die/das) punya warna tetap yang
   dipakai konsisten di seluruh app sebagai sistem navigasi visual —
   bukan dekorasi, tapi encoding informasi gramatikal paling sulit
   di bahasa Jerman.
   ============================================================ */

:root {
  /* --- Light theme --- */
  --bg: #F6F1E7;
  --bg-soft: #EFE8D8;
  --surface: rgba(255, 255, 255, 0.55);
  --surface-solid: #FFFFFF;
  --border: rgba(36, 33, 28, 0.10);
  --ink: #24211C;
  --ink-soft: #5C5648;
  --ink-faint: #8C8574;

  /* Gender color system — signature element */
  --der: #2456A6;   /* maskulin — biru Prusia */
  --der-soft: #E4ECF9;
  --die: #B23A48;   /* feminin — merah Bauhaus */
  --die-soft: #F7E4E6;
  --das: #C98A1F;   /* netral — kuning mustard */
  --das-soft: #F8ECD3;

  --accent: #2456A6;
  --accent-2: #C98A1F;
  --success: #3C7A54;
  --danger: #B23A48;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --shadow-glass: 0 8px 32px rgba(36, 33, 28, 0.08);
  --font-display: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

[data-theme="dark"] {
  --bg: #191814;
  --bg-soft: #211F1A;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-solid: #221F19;
  --border: rgba(255, 255, 255, 0.09);
  --ink: #F1EBDD;
  --ink-soft: #C6BDA9;
  --ink-faint: #8A8271;

  --der: #6E97DD;
  --der-soft: rgba(110, 151, 221, 0.14);
  --die: #E08792;
  --die-soft: rgba(224, 135, 146, 0.14);
  --das: #E3B23C;
  --das-soft: rgba(227, 178, 60, 0.14);

  --accent: #6E97DD;
  --accent-2: #E3B23C;
  --success: #6FBF8B;
  --danger: #E08792;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  transition: background 0.3s ease, color 0.3s ease;
  overscroll-behavior-y: none;
}

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

h1, h2, h3, .display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-weight: 600;
  margin: 0;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 84px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  background: var(--bg);
  backdrop-filter: blur(10px);
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .flag-dot { display: flex; gap: 3px; }
.brand .flag-dot span { width: 6px; height: 6px; border-radius: 50%; }
.brand .flag-dot span:nth-child(1) { background: var(--ink); }
.brand .flag-dot span:nth-child(2) { background: var(--die); }
.brand .flag-dot span:nth-child(3) { background: var(--das); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.icon-btn:active { transform: scale(0.94); }

main { flex: 1; padding: 4px 20px 24px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: var(--surface-solid);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  overflow-x: auto;
  scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-item {
  flex: 1 0 auto;
  min-width: 62px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px;
  border-radius: var(--radius-s);
  background: none; border: none;
  color: var(--ink-faint);
  font-size: 10.5px;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--accent); }

/* ---------- Cards / glass ---------- */
.glass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-glass);
}

/* list-card: dipakai untuk item yang bisa berjumlah banyak (vocab, notebook, dll).
   Sengaja TANPA backdrop-filter & tanpa shadow berat — blur di ratusan elemen
   sekaligus bikin scroll patah-patah di HP mid-range. Dikompensasi dengan
   content-visibility supaya browser skip layout/paint untuk item di luar layar. */
.list-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  content-visibility: auto;
  contain-intrinsic-size: auto 74px;
  contain: layout style paint;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 22px 0 10px;
  font-weight: 600;
}

/* ---------- Search ---------- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-l);
  margin-top: 6px;
}
.search-bar input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 15px; color: var(--ink); font-family: var(--font-body);
}
.search-bar input::placeholder { color: var(--ink-faint); }

/* ---------- Filter chips ---------- */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Gender badge (signature element) ---------- */
.gender-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: lowercase;
}
.gender-der { background: var(--der-soft); color: var(--der); }
.gender-die { background: var(--die-soft); color: var(--die); }
.gender-das { background: var(--das-soft); color: var(--das); }

/* ---------- Vocab list ---------- */
.vocab-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px;
  border-radius: var(--radius-m);
  margin-bottom: 10px;
  border-left: 3px solid transparent;
}
.vocab-item[data-gender="der"] { border-left-color: var(--der); }
.vocab-item[data-gender="die"] { border-left-color: var(--die); }
.vocab-item[data-gender="das"] { border-left-color: var(--das); }
.vocab-item .word-main { flex: 1; min-width: 0; }
.vocab-item .word-de { font-family: var(--font-display); font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.vocab-item .word-mean { font-size: 13.5px; color: var(--ink-soft); margin-top: 2px; }
.vocab-item .word-actions { display: flex; gap: 6px; }
.round-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-solid);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
}
.round-btn.fav-active { color: var(--die); border-color: var(--die); }
.round-btn:active { transform: scale(0.92); }

/* ---------- Detail sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,18,14,0.45);
  z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 480px;
  background: var(--bg-soft);
  border-radius: 24px 24px 0 0;
  padding: 22px 22px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(.2,.9,.3,1);
  max-height: 82vh; overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 16px; }
.sheet .word-de-lg { font-family: var(--font-display); font-size: 28px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet .ipa { font-family: var(--font-mono); color: var(--ink-faint); font-size: 14px; margin-top: 4px; }
.sheet .meaning-row { display: flex; gap: 10px; margin-top: 16px; }
.meaning-pill { flex: 1; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px; }
.meaning-pill .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.meaning-pill .val { font-size: 15px; margin-top: 2px; font-weight: 500; }
.example-box { margin-top: 16px; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 14px; }
.example-box .de { font-size: 15px; font-weight: 500; }
.example-box .id { font-size: 13.5px; color: var(--ink-soft); margin-top: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn {
  flex: 1; padding: 13px; border-radius: var(--radius-s); border: none;
  font-weight: 600; font-size: 14.5px; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--surface-solid); color: var(--ink); border: 1px solid var(--border); }
.btn:active { transform: scale(0.97); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .5; }

/* ---------- Profile premium ---------- */
.profile-hero {
  position: relative;
  padding: 28px 22px 22px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(135deg, var(--accent) 0%, #1a3a72 55%, #12274d 100%);
  overflow: hidden;
  color: #fff;
}
[data-theme="dark"] .profile-hero { background: linear-gradient(135deg, #2c4a85 0%, #1a2f57 55%, #0f1c37 100%); }
.profile-hero::before {
  content: '';
  position: absolute; top: -40%; right: -20%;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(227,178,60,0.35), transparent 70%);
}
.profile-hero::after {
  content: '';
  position: absolute; bottom: -50%; left: -10%;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(178,58,72,0.3), transparent 70%);
}
.profile-avatar-ring {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #E3B23C, #C98A1F);
  color: #1a1a1a;
  font-family: var(--font-display); font-weight: 700; font-size: 24px;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25), 0 8px 24px rgba(0,0,0,0.3);
  position: relative; z-index: 1;
}
.profile-level-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  margin-top: 8px;
  backdrop-filter: blur(6px);
}
.ig-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 6px 12px; border-radius: 999px;
  font-size: 12.5px; color: #fff; margin-top: 10px;
  backdrop-filter: blur(6px);
}
.stat-icon-circle {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin: 0 auto 6px;
}
.badge-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.badge-row::-webkit-scrollbar { display: none; }
.achievement-badge {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  min-width: 76px;
  opacity: 0.35;
}
.achievement-badge.unlocked { opacity: 1; border-color: var(--accent-2); background: var(--das-soft); }
.achievement-badge .ab-icon { font-size: 22px; }
.achievement-badge .ab-label { font-size: 9.5px; text-align: center; font-weight: 600; color: var(--ink-soft); line-height: 1.2; }

/* ---------- Home dashboard grid ---------- */
.home-hero {
  padding: 20px;
  border-radius: var(--radius-l);
  background: linear-gradient(135deg, var(--der-soft), var(--das-soft));
  border: 1px solid var(--border);
}
.home-hero .eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 600; }
.home-hero .headline { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin-top: 6px; }
.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tile {
  aspect-ratio: 1;
  border-radius: var(--radius-m);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  cursor: pointer;
}
.tile:active { transform: scale(0.96); }
.tile .tile-icon { font-size: 26px; }
.tile .tile-label { font-size: 12.5px; font-weight: 600; text-align: center; padding: 0 4px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.fade-in { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
