/* ============================================================
   VocabHero – Design-System
   Modern, freundlich, motivierend (Zielgruppe 10–17 Jahre)
   ============================================================ */

:root {
  --brand-1: #4f46e5;
  --brand-2: #06b6d4;
  --accent: #ff7a59;
  --accent-2: #fbbf24;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;

  --bg: #f2f4fd;
  --bg-soft: #e9edfb;
  --card: #ffffff;
  --card-2: #f7f8ff;
  --text: #1e2243;
  --text-soft: #5b6183;
  --line: #dfe3f5;
  --shadow: 0 10px 30px -12px rgba(46, 50, 120, .25);
  --shadow-sm: 0 4px 14px -6px rgba(46, 50, 120, .2);

  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
}
html[data-theme="dark"] {
  --bg: #12142b;
  --bg-soft: #191c3a;
  --card: #1e2142;
  --card-2: #252a52;
  --text: #eef0ff;
  --text-soft: #a6ade0;
  --line: #323764;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, .6);
  --shadow-sm: 0 6px 16px -8px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--brand-1); }
html[data-theme="dark"] a { color: #8f88ff; }

/* ---------- App-Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: 0 0 240px;
  background: linear-gradient(180deg, var(--brand-1), #3730a3 60%, #1e1b4b);
  color: #fff;
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo {
  font-size: 1.35rem; font-weight: 800; letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 18px;
}
.sidebar .logo .bolt { filter: drop-shadow(0 0 8px rgba(6, 182, 212, .8)); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 12px;
  color: #cfd2ff; text-decoration: none; font-weight: 600; font-size: .95rem;
  transition: background .15s, transform .1s;
  border: none; background: none; cursor: pointer; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .18); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.nav-item .ico { width: 22px; text-align: center; font-size: 1.1rem; }
.sidebar .spacer { flex: 1; }
.sidebar .user-box {
  background: rgba(255, 255, 255, .1); border-radius: 14px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar .user-box .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand-1));
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff;
}
.sidebar .user-box .meta { min-width: 0; }
.sidebar .user-box .name { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user-box .sub { font-size: .75rem; color: #b9bdff; }

.main { flex: 1; min-width: 0; padding: 22px clamp(14px, 3vw, 34px) 90px; max-width: 1180px; margin: 0 auto; width: 100%; }

/* Mobile: Bottom-Navigation */
.mobile-top { display: none; }
.bottom-nav { display: none; } /* nur auf Mobilgeräten sichtbar (Media Query unten) */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .mobile-top {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
    background: linear-gradient(90deg, var(--brand-1), #3730a3);
    color: #fff; padding: 12px 16px;
  }
  .mobile-top .logo { font-weight: 800; font-size: 1.1rem; display: flex; gap: 6px; align-items: center; }
  .main { padding-bottom: 110px; }
  .bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--card); border-top: 1px solid var(--line);
    display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px -10px rgba(0,0,0,.25);
  }
  .bottom-nav .nav-item { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 8px; border-radius: 10px; color: var(--text-soft); }
  .bottom-nav .nav-item.active { background: var(--bg-soft); color: var(--brand-1); box-shadow: none; }
}

/* ---------- Karten & Layouts ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: clamp(1.3rem, 2.6vw, 1.7rem); }
.page-head .sub { color: var(--text-soft); font-size: .92rem; margin-top: 2px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.hero {
  background: linear-gradient(120deg, var(--brand-1) 0%, var(--brand-2) 100%);
  border-radius: 22px; color: #fff; padding: 24px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,.25), transparent 70%); border-radius: 50%;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.hero p { margin: 0; opacity: .92; }

.stat-chip { display: flex; flex-direction: column; gap: 4px; }
.stat-chip .value { font-size: 1.6rem; font-weight: 800; }
.stat-chip .label { color: var(--text-soft); font-size: .82rem; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: .95rem;
  padding: 11px 22px; color: #fff;
  background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  box-shadow: var(--shadow-sm); transition: transform .12s, filter .15s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--card-2); color: var(--text); border: 1.5px solid var(--line); box-shadow: none; }
.btn.accent { background: linear-gradient(120deg, var(--accent), var(--accent-2)); }
.btn.ok { background: linear-gradient(120deg, var(--ok), #34d399); }
.btn.danger { background: linear-gradient(120deg, var(--bad), #f87171); }
.btn.sm { padding: 7px 14px; font-size: .84rem; }
.btn.big { padding: 15px 30px; font-size: 1.05rem; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--brand-1); }
html[data-theme="dark"] .btn.ghost { color: #8f88ff; }

input[type=text], input[type=password], input[type=number], select, textarea {
  font-family: inherit; font-size: .98rem; color: var(--text);
  background: var(--card-2); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 14px; width: 100%;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, .15);
}
label.fld { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .88rem; color: var(--text-soft); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 4px; border-bottom: 1px dashed var(--line);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .lbl { font-weight: 600; }
.switch-row .hint { font-weight: 400; color: var(--text-soft); font-size: .82rem; }
.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: 0 0 52px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .2s; cursor: pointer;
}
.switch .track::before {
  content: ''; position: absolute; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.switch input:checked + .track { background: linear-gradient(120deg, var(--brand-1), var(--brand-2)); }
.switch input:checked + .track::before { transform: translateX(22px); }

.seg { display: inline-flex; background: var(--card-2); border: 1.5px solid var(--line); border-radius: 999px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button {
  border: none; background: none; font-family: inherit; font-weight: 700; font-size: .86rem;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; color: var(--text-soft);
}
.seg button.active { background: linear-gradient(120deg, var(--brand-1), var(--brand-2)); color: #fff; }

/* ---------- Chips / Badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-2); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: var(--text-soft);
}
.chip.clickable { cursor: pointer; }
.chip.clickable:hover { border-color: var(--brand-2); color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); }
.lvl-badge {
  display: inline-block; padding: 3px 10px; border-radius: 8px;
  font-size: .74rem; font-weight: 800; color: #fff;
}
.lvl-A1 { background: #22c55e; } .lvl-A2 { background: #0ea5e9; }
.lvl-B1 { background: #6366f1; } .lvl-B2 { background: #a855f7; }
.lvl-C1 { background: #f43f5e; } .lvl-C2 { background: #b45309; }
html[data-theme="dark"] .lvl-C2 { background: #d97706; }

/* ---------- Fortschritt ---------- */
.pbar { height: 12px; background: var(--card-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.pbar > div { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand-1)); border-radius: 999px; transition: width .4s ease; }
.pbar.ok > div { background: linear-gradient(90deg, #34d399, var(--ok)); }
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; font-weight: 800; font-size: .95rem; }

/* ---------- Lernkarte ---------- */
.quiz-wrap { max-width: 640px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.quiz-top .pbar { flex: 1; }
.quiz-top .count { font-weight: 700; font-size: .9rem; color: var(--text-soft); white-space: nowrap; }
.quiz-card {
  background: var(--card); border-radius: 24px; padding: 30px 26px;
  box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center;
  position: relative; overflow: hidden;
}
.quiz-card .qword { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800; margin: 10px 0 4px; word-break: break-word; }
.quiz-card .qmeta { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.quiz-card .speak-btn {
  border: none; background: var(--card-2); border-radius: 50%; width: 42px; height: 42px;
  font-size: 1.15rem; cursor: pointer; transition: transform .12s; box-shadow: var(--shadow-sm);
}
.quiz-card .speak-btn:hover { transform: scale(1.1); }
.opt-btn {
  display: block; width: 100%; text-align: left;
  font-family: inherit; font-size: 1.02rem; font-weight: 600; color: var(--text);
  background: var(--card-2); border: 2px solid var(--line); border-radius: 14px;
  padding: 13px 16px; margin-top: 10px; cursor: pointer; transition: border .12s, transform .1s;
}
.opt-btn:hover:not(:disabled) { border-color: var(--brand-2); transform: translateY(-1px); }
.opt-btn:disabled { cursor: default; }
.opt-btn.correct { border-color: var(--ok); background: rgba(16, 185, 129, .12); }
.opt-btn.wrong { border-color: var(--bad); background: rgba(239, 68, 68, .12); }
.opt-btn .key { display: inline-block; width: 22px; height: 22px; line-height: 22px; border-radius: 7px; background: var(--bg-soft); font-size: .75rem; text-align: center; margin-right: 10px; font-weight: 800; color: var(--text-soft); }

.type-input { display: flex; gap: 10px; margin-top: 18px; }
.feedback { border-radius: 14px; padding: 14px 16px; margin-top: 16px; text-align: left; animation: pop .25s ease; }
.feedback.correct { background: rgba(16, 185, 129, .12); border: 1.5px solid var(--ok); }
.feedback.almost { background: rgba(245, 158, 11, .12); border: 1.5px solid var(--warn); }
.feedback.wrong { background: rgba(239, 68, 68, .1); border: 1.5px solid var(--bad); }
.feedback .fb-title { font-weight: 800; margin-bottom: 4px; }
.feedback .fb-word { font-size: 1.25rem; font-weight: 800; }
.feedback .fb-ex { margin-top: 8px; color: var(--text-soft); font-size: .92rem; }
.feedback .fb-ex b { color: var(--text); }
.xp-float {
  position: absolute; top: 14px; right: 18px; font-weight: 800; color: var(--accent-2);
  animation: xpfloat 1.2s ease forwards; pointer-events: none;
}
@keyframes xpfloat { from { opacity: 0; transform: translateY(6px); } 20% { opacity: 1; } to { opacity: 0; transform: translateY(-26px); } }
@keyframes pop { from { transform: scale(.94); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
.shake { animation: shake .5s; }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Listen & Tabellen ---------- */
.list-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 8px; transition: border .12s;
}
.list-row:hover { border-color: var(--brand-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .word { font-weight: 700; }
.list-row .trans { color: var(--text-soft); font-size: .9rem; }
.list-row .ex { color: var(--text-soft); font-size: .82rem; margin-top: 2px; }
.list-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--text-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; }
table.tbl tr:hover td { background: var(--card-2); }
.tbl-scroll { overflow-x: auto; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input[type=text] { max-width: 260px; }
.filter-bar select { width: auto; }

/* ---------- Toast & Modal ---------- */
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-left: 5px solid var(--brand-2);
  border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow);
  animation: slidein .25s ease; font-weight: 600; font-size: .92rem;
}
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 12, 40, .55); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border-radius: 20px; padding: 22px;
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow); animation: popIn .2s ease;
}
.modal h3 { margin: 0 0 14px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Login / Setup ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 500px at 10% 10%, rgba(79, 70, 229, .25), transparent),
    radial-gradient(700px 500px at 90% 90%, rgba(6, 182, 212, .25), transparent),
    var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 26px; padding: 34px 30px; box-shadow: var(--shadow); border: 1px solid var(--line);
  text-align: center;
}
.auth-card .logo-big { font-size: 3rem; margin-bottom: 4px; filter: drop-shadow(0 6px 14px rgba(79, 70, 229, .4)); }
.auth-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.auth-card .sub { color: var(--text-soft); margin-bottom: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }

/* ---------- Konfetti ---------- */
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 200; }

/* ---------- Grammatik-Übungen ---------- */
.word-chip {
  display: inline-flex; align-items: center; background: var(--card-2);
  border: 2px solid var(--line); border-radius: 12px; padding: 8px 14px;
  font-weight: 700; cursor: pointer; margin: 4px; font-size: .95rem; transition: all .12s;
}
.word-chip:hover { border-color: var(--brand-2); }
.word-chip.used { opacity: .25; pointer-events: none; }
.word-chip.wrong-mark { border-color: var(--bad); background: rgba(239, 68, 68, .12); }
.word-chip.picked { border-color: var(--brand-1); background: rgba(79, 70, 229, .1); }
.built-line {
  min-height: 52px; border: 2px dashed var(--line); border-radius: 12px;
  padding: 8px; margin: 10px 0; display: flex; flex-wrap: wrap; align-items: center;
}
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.match-grid .word-chip { width: 100%; justify-content: center; margin: 0; }
.match-grid .word-chip.sel { border-color: var(--accent); background: rgba(255, 122, 89, .12); }
.match-grid .word-chip.done { opacity: .35; pointer-events: none; }

/* ---------- Badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-card {
  text-align: center; padding: 16px 10px; border-radius: 16px;
  background: var(--card-2); border: 1.5px solid var(--line);
}
.badge-card .b-icon { font-size: 2rem; }
.badge-card .b-name { font-weight: 800; margin-top: 6px; font-size: .9rem; }
.badge-card .b-desc { font-size: .74rem; color: var(--text-soft); margin-top: 4px; }
.badge-card.earned { border-color: var(--accent-2); background: linear-gradient(160deg, rgba(251, 191, 36, .15), var(--card-2)); box-shadow: 0 0 18px -6px rgba(251, 191, 36, .5); }
.badge-card.locked { filter: grayscale(.9); opacity: .7; }

/* ---------- Sonstiges ---------- */
.empty {
  text-align: center; color: var(--text-soft); padding: 34px 10px;
}
.empty .big-emoji { font-size: 2.6rem; margin-bottom: 8px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand-1);
  animation: spin .8s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.boot-logo { font-size: 3rem; animation: popIn .5s ease; }
.boot-text { color: var(--text-soft); font-weight: 600; }
.muted { color: var(--text-soft); }
.small { font-size: .84rem; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill-streak {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 800;
  background: linear-gradient(120deg, #f97316, var(--accent-2)); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-size: .9rem;
  box-shadow: 0 4px 12px -4px rgba(249, 115, 22, .6);
}
textarea { resize: vertical; min-height: 90px; }
.kbd { font-family: monospace; background: var(--card-2); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 7px; font-size: .85em; }
.dropzone {
  border: 2.5px dashed var(--line); border-radius: 16px; padding: 26px;
  text-align: center; color: var(--text-soft); cursor: pointer; transition: border .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand-2); background: rgba(6, 182, 212, .06); }
