:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #eef0f6; --border: #dfe2ec;
  --text: #1c2030; --muted: #5e6478; --accent: #4f46e5; --accent-text: #ffffff; --accent-soft: #e8e7fd;
  --good: #14804a; --good-soft: #e1f5ea; --close: #9a6200; --close-soft: #fdf1d7; --bad: #c0362c; --bad-soft: #fde8e6;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12141c; --surface: #1c1f2b; --surface-2: #272b3a; --border: #343949;
  --text: #eceef5; --muted: #a3a9bd; --accent: #8b85ff; --accent-text: #11122a; --accent-soft: #2b2a55;
  --good: #5fd39a; --good-soft: #173527; --close: #f0bd5a; --close-soft: #3a2e12; --bad: #ff8a80; --bad-soft: #40201d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.1rem; }
p { margin: .4em 0 .8em; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
kbd {
  font: 600 .75rem/1 ui-monospace, monospace; padding: .25em .45em; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
mark { background: var(--accent-soft); color: inherit; padding: 0 .15em; border-radius: 4px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.boot { text-align: center; padding: 4rem 1rem; color: var(--muted); }

/* ---------- Gerüst */
.shell { max-width: 860px; margin: 0 auto; padding: 0 1rem 2rem; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .9rem 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.logo {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.logo.big { width: 4rem; height: 4rem; font-size: 2rem; border-radius: 18px; }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tab { border: 0; background: none; padding: .5rem .8rem; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.profile-chip {
  display: flex; align-items: center; gap: .45rem; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: .25rem .8rem .25rem .3rem;
}
.chip-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer { margin-top: 2rem; text-align: center; font-size: .8rem; color: var(--muted); }
.stack { display: grid; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.row.center { justify-content: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }

/* ---------- Bedienelemente */
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: .6rem 1rem; border-radius: 10px; font-weight: 600;
  min-height: 2.75rem;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.big { width: 100%; font-size: 1.1rem; padding: .9rem; margin-top: 1rem; }
.btn.small { min-height: 2.25rem; padding: .35rem .7rem; font-size: .9rem; }
.icon-btn { border: 0; background: none; font-size: 1.15rem; padding: .3rem .45rem; border-radius: 8px; line-height: 1; vertical-align: middle; }
.icon-btn:hover { background: var(--surface-2); }
.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: .5rem .9rem; border-radius: 9px; font-weight: 600; color: var(--muted); min-height: 2.5rem; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: .45rem .9rem; font-weight: 500; min-height: 2.5rem; }
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.active::before { content: "✓ "; }
.chip-count { color: var(--muted); font-size: .8rem; }
.check { display: flex; align-items: flex-start; gap: .55rem; margin: .7rem 0; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .18rem; accent-color: var(--accent); flex: none; }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-height: 2.75rem;
}
.field { display: grid; gap: .3rem; margin-bottom: .9rem; }
.field-label { font-weight: 600; font-size: .9rem; }
.field-hint { font-size: .8rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; align-items: start; }
details { margin: .5rem 0 1rem; }
summary { cursor: pointer; font-weight: 600; padding: .4rem 0; }
.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ---------- Kennzahlen */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface-2); border-radius: 12px; padding: .85rem 1rem; }
.tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-label { font-size: .85rem; color: var(--muted); }
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; flex: 1; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.done-box { display: grid; gap: .2rem; text-align: center; padding: 1rem 0 .5rem; }
.done-box + .btn { display: block; margin: .5rem auto 0; }

/* ---------- Profile */
.profiles-screen { max-width: 720px; margin: 0 auto; padding: 3rem 1rem; text-align: center; display: grid; gap: .5rem; justify-items: center; }
.profile-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: 1.5rem 0; }
.profile-card {
  width: 9.5rem; padding: 1.2rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  display: grid; gap: .45rem; justify-items: center; box-shadow: var(--shadow);
}
.profile-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.profile-card.add { border-style: dashed; box-shadow: none; background: transparent; color: var(--muted); }
.profile-name { font-weight: 600; overflow-wrap: anywhere; }
.profile-meta { font-size: .8rem; min-height: 1.2em; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent-soft); border: 2px solid transparent; width: 2.6rem; height: 2.6rem; font-size: 1.4rem; line-height: 1; padding: 0; }
.avatar.small { width: 1.9rem; height: 1.9rem; font-size: 1.05rem; }
.avatar.large { width: 4.5rem; height: 4.5rem; font-size: 2.4rem; }
.avatar-picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.avatar-picker .avatar.active { border-color: var(--accent); }

/* ---------- Lernkarte */
.learn { display: grid; gap: 1rem; }
.learn-top { display: flex; align-items: center; gap: .8rem; }
.flashcard { padding: 1.5rem; }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge { font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: .2rem .6rem; border-radius: 999px; }
.badge.new { background: var(--accent-soft); color: var(--accent); }
.prompt { font-size: clamp(1.9rem, 6vw, 2.8rem); font-weight: 700; text-align: center; margin: 1.6rem 0 1.4rem; overflow-wrap: anywhere; line-height: 1.2; }
.answer-form { display: flex; gap: .6rem; }
.answer-input { font-size: 1.15rem !important; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.option {
  display: flex; align-items: center; gap: .7rem; text-align: left; padding: .8rem 1rem; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); font-size: 1.05rem; min-height: 3.2rem;
}
.option:hover { border-color: var(--accent); background: var(--accent-soft); }
.hint-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.hint { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; background: var(--surface-2); border-radius: 10px; padding: .7rem .9rem; margin-bottom: .7rem; }
.hint-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.shortcuts { margin-top: .9rem; }
.verdict { font-weight: 700; padding: .65rem .9rem; border-radius: 10px; }
.verdict.good { background: var(--good-soft); color: var(--good); }
.verdict.close { background: var(--close-soft); color: var(--close); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.your-answer { color: var(--muted); margin: .6rem 0 0; }
.solution { margin: .9rem 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.solution-main { font-size: 1.6rem; font-weight: 700; }
.solution-more { color: var(--muted); font-size: 1.05rem; }
.example { border-left: 3px solid var(--accent); padding: .2rem 0 .2rem .9rem; margin: .9rem 0; display: grid; gap: .2rem; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: 1.2rem; }
.rating {
  display: grid; gap: .25rem; justify-items: center; padding: .6rem .3rem; border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
}
.rating:hover { background: var(--surface-2); }
.rating.suggested { border-color: var(--accent); background: var(--accent-soft); }
.rating-label { font-weight: 700; }
.rating-interval { font-size: .8rem; color: var(--muted); }
.summary .big-emoji { font-size: 3rem; }

/* ---------- Statistik */
.bars { display: flex; align-items: stretch; gap: 2px; height: 190px; padding-top: 2.6rem; border-bottom: 1px solid var(--border); margin-bottom: 1.6rem !important; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 0; }
.bar-col:hover, .bar-col:focus-visible { background: var(--surface-2); outline: none; }
.bar { width: min(100%, 26px); background: var(--accent); border-radius: 4px 4px 0 0; }
.bar-value { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-label { position: absolute; bottom: -1.4rem; font-size: .72rem; color: var(--muted); }
.bar-col[data-tip]:hover::after, .bar-col[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: -2.3rem; left: 50%; transform: translateX(-50%); z-index: 2; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: .78rem; padding: .3rem .55rem; border-radius: 6px; pointer-events: none;
}
.bar-col:nth-child(-n+3)[data-tip]::after { left: 0; transform: none; }
.bar-col:nth-last-child(-n+3)[data-tip]::after { left: auto; right: 0; transform: none; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .4rem; text-align: left; border-bottom: 1px solid var(--border); font-weight: 400; }
thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
th.num, td.num { text-align: right; }
.stage-table th { width: 46%; font-weight: 600; }
.stage-bar-cell { width: 40%; }
.stage-bar { height: 10px; background: var(--accent); border-radius: 0 4px 4px 0; }

/* ---------- Dialoge & Hinweise */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 24, .55); display: grid; place-items: center; padding: 1rem; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.4rem; width: min(100%, 440px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
#toasts { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 60; width: min(92vw, 460px); }
.toast { background: var(--text); color: var(--bg); padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .95rem; }
.toast.error { background: var(--bad); color: #fff; }
.toast.success { background: var(--good); color: #fff; }
[data-theme="dark"] .toast.error, [data-theme="dark"] .toast.success { color: #111; }

/* ---------- Akzentfarben (pro Profil wählbar) */
[data-accent="blue"] { --accent: #2563eb; --accent-soft: #dbe7fe; }
[data-accent="teal"] { --accent: #0f766e; --accent-soft: #d3f1ec; }
[data-accent="green"] { --accent: #15803d; --accent-soft: #dcf3e3; }
[data-accent="rose"] { --accent: #be185d; --accent-soft: #fbe0ec; }
[data-accent="orange"] { --accent: #c2410c; --accent-soft: #fde6d8; }
[data-theme="dark"][data-accent="blue"], [data-theme="dark"] [data-accent="blue"] { --accent: #7aa7ff; --accent-soft: #1e2f55; }
[data-theme="dark"][data-accent="teal"], [data-theme="dark"] [data-accent="teal"] { --accent: #4fd1c0; --accent-soft: #12403b; }
[data-theme="dark"][data-accent="green"], [data-theme="dark"] [data-accent="green"] { --accent: #6ad48d; --accent-soft: #173a25; }
[data-theme="dark"][data-accent="rose"], [data-theme="dark"] [data-accent="rose"] { --accent: #ff86b7; --accent-soft: #4a1f33; }
[data-theme="dark"][data-accent="orange"], [data-theme="dark"] [data-accent="orange"] { --accent: #ffa36b; --accent-soft: #4a2a17; }
[data-accent="indigo"] .swatch[data-accent="indigo"], .swatch[data-accent="indigo"] { --accent: #4f46e5; }
[data-theme="dark"] .swatch[data-accent="indigo"] { --accent: #8b85ff; }
.swatches { display: flex; gap: .6rem; flex-wrap: wrap; }
.swatch { width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 3px solid var(--surface); background: var(--accent); box-shadow: 0 0 0 1px var(--border); padding: 0; }
.swatch.active { box-shadow: 0 0 0 3px var(--text); }

/* ---------- Serie, Hörmodus, Wortliste */
.flame { display: inline-flex; align-items: center; gap: .2rem; font-weight: 700; font-variant-numeric: tabular-nums; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.flame .flame-icon { filter: grayscale(1); opacity: .55; display: inline-block; transform-origin: 50% 90%; }
.flame.lit { background: var(--close-soft); color: var(--close); }
.flame.lit .flame-icon { filter: none; opacity: 1; animation: flicker 1.6s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.18) rotate(4deg); } }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }
.sub-option { margin-top: .8rem; }
.prompt.listen { display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.listen-btn {
  width: 6rem; height: 6rem; border-radius: 50%; border: 0; font-size: 2.6rem; line-height: 1; background: var(--accent-soft);
  box-shadow: 0 0 0 0 var(--accent); animation: ring 2.2s ease-out infinite;
}
.listen-btn:hover { filter: brightness(1.05); }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 18px transparent; } }
.word-filters { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; margin-bottom: .6rem; }
.word-filters select { width: auto; }
input[type="search"] { width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-height: 2.75rem; }
.word-list { display: grid; margin-top: .5rem; }
.word-row {
  display: grid; grid-template-columns: minmax(7rem, 1fr) 2fr auto; gap: .8rem; align-items: center; text-align: left;
  border: 0; border-bottom: 1px solid var(--border); background: none; padding: .65rem .4rem; min-height: 2.9rem;
}
.word-row:hover { background: var(--surface-2); }
.word-en { font-weight: 700; overflow-wrap: anywhere; }
.word-de { color: var(--muted); overflow-wrap: anywhere; }
.word-list > .btn { margin-top: .8rem; justify-self: center; }
.badge.stage-learning { background: var(--close-soft); color: var(--close); }
.badge.stage-young, .badge.stage-mature { background: var(--good-soft); color: var(--good); }

/* ---------- Lernkalender */
.heat-wrap { overflow-x: auto; padding: 2.2rem 0 .4rem; margin-top: -1.4rem; }
.heat { display: flex; gap: 2px; width: max-content; margin: 0 auto; }
.heat-week { display: grid; grid-template-rows: 1.1rem repeat(7, 12px); gap: 2px; }
.heat-month { font-size: .68rem; color: var(--muted); white-space: nowrap; overflow: visible; width: 12px; }
.heat-day { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); position: relative; }
.heat-day.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.heat-day.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.heat-day.l3 { background: color-mix(in srgb, var(--accent) 78%, var(--surface-2)); }
.heat-day.l4 { background: var(--accent); }
.heat-day[data-tip]:hover { outline: 2px solid var(--text); outline-offset: 1px; z-index: 3; }
.heat-day[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: 150%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: .78rem; padding: .3rem .55rem; border-radius: 6px; pointer-events: none;
}
.heat-day.tip-right[data-tip]:hover::after { left: 0; transform: none; }
.heat-day.tip-left[data-tip]:hover::after { left: auto; right: 0; transform: none; }
.heat-legend { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
.heat-scale { display: inline-flex; align-items: center; gap: 3px; }
.heat-scale .heat-day { display: inline-block; }

/* ---------- Animationen */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }
.flashcard.anim-in { animation: card-in .28s ease-out; }
.flashcard.anim-correct, .flashcard.anim-close { animation: flip .45s ease-out, glow-good .9s ease-out; }
.flashcard.anim-wrong { animation: shake .45s ease-in-out, glow-bad .9s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateX(28px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes flip { from { transform: perspective(900px) rotateX(-75deg); opacity: .3; } to { transform: perspective(900px) rotateX(0); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes glow-good { 0% { box-shadow: 0 0 0 4px var(--good); } 100% { box-shadow: var(--shadow); } }
@keyframes glow-bad { 0% { box-shadow: 0 0 0 4px var(--bad); } 100% { box-shadow: var(--shadow); } }
.summary .big-emoji { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); display: inline-block; }
@keyframes pop { from { transform: scale(0) rotate(-30deg); } to { transform: none; } }
.meter-fill { transition: width .45s cubic-bezier(.3, 1.3, .5, 1); }
.btn.primary:active, .option:active, .rating:active { transform: scale(.97); }

@media (max-width: 620px) {
  .tab { padding: .5rem .3rem; font-size: .92rem; }
  .word-filters { grid-template-columns: 1fr 1fr; }
  .word-filters .search { grid-column: 1 / -1; }
  .word-filters select { width: 100%; }
  .word-row { grid-template-columns: 1fr auto; }
  .word-row .word-de { grid-column: 1 / -1; grid-row: 2; }

  .brand-name { display: none; }
  .tabs { margin-left: 0; order: 3; width: 100%; justify-content: space-between; }
  .tab { flex: 1; }
  .profile-chip { margin-left: auto; }
  .answer-form { flex-direction: column; }
  .ratings { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
