/* ==========================================================================
   StudyGo – Styles
   Modern, freundlich, spielerisch. Mobile-first, responsive.
   ========================================================================== */

:root {
  --primary: #6C5CE7;
  --primary-dark: #5445d6;
  --primary-soft: #ECEAFD;
  --green: #22C55E;
  --green-dark: #16a34a;
  --green-soft: #DCFCE7;
  --yellow: #F5B700;
  --yellow-soft: #FEF3C7;
  --red: #EF4444;
  --red-soft: #FEE2E2;
  --blue: #3B82F6;
  --orange: #F97316;

  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #F1F2F8;
  --text: #1F2233;
  --text-2: #6B7085;
  --text-3: #A0A4B8;
  --border: #E6E8F0;

  --shadow-sm: 0 1px 3px rgba(20, 24, 60, .06), 0 1px 2px rgba(20, 24, 60, .04);
  --shadow: 0 6px 20px rgba(20, 24, 60, .08);
  --shadow-lg: 0 16px 40px rgba(20, 24, 60, .14);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;

  --topbar-h: 60px;
  --nav-h: 66px;
  --max-w: 760px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --anim: 1;
}

html[data-theme="dark"] {
  --primary: #8B7CFF;
  --primary-dark: #7a6cf0;
  --primary-soft: #2A2750;
  --green-soft: #12351f;
  --yellow-soft: #3a2f0a;
  --red-soft: #3f1717;
  --bg: #121420;
  --surface: #1C1F2E;
  --surface-2: #262A3D;
  --text: #F1F2F8;
  --text-2: #A7ABC2;
  --text-3: #6E738C;
  --border: #2E3247;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
}

html[data-anim="off"] *,
html[data-anim="off"] *::before,
html[data-anim="off"] *::after {
  animation: none !important;
  transition: none !important;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.01em; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { height: 12px; }

/* ---------- Layout ---------- */
#app { min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: var(--max-w); margin: 0 auto;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.15rem; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #A29BFE);
  color: #fff; display: grid; place-items: center; font-size: 1rem;
  box-shadow: 0 4px 10px rgba(108, 92, 231, .35);
}
.stats { display: flex; gap: 6px; }
.stat {
  background: var(--surface-2); border-radius: 999px;
  padding: 5px 10px; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.stat b { font-weight: 800; }
.stat.bump { animation: bump .45s ease; }
@keyframes bump { 0% { transform: scale(1);} 40% { transform: scale(1.25);} 100% { transform: scale(1);} }

.view {
  max-width: var(--max-w); margin: 0 auto;
  padding: 20px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav { display: flex; justify-content: center; }
.navitem {
  flex: 1; max-width: 152px; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .7rem; font-weight: 700; color: var(--text-3);
  transition: color .15s;
}
.navitem .navicon { font-size: 1.35rem; line-height: 1; transition: transform .15s; }
.navitem.active { color: var(--primary); }
.navitem.active .navicon { transform: translateY(-2px) scale(1.1); }
.navitem:active .navicon { transform: scale(.9); }

/* ---------- Typo ---------- */
.page-title { font-size: 1.7rem; margin-bottom: 4px; }
.page-sub { color: var(--text-2); margin-bottom: 20px; }
.section-title { font-size: 1.05rem; margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: 16px;
  font-weight: 800; font-size: 1rem; line-height: 1;
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 0 var(--primary-dark);
  transition: transform .08s, box-shadow .08s, filter .15s;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.big { padding: 18px 24px; font-size: 1.1rem; border-radius: 20px; }
.btn.green { background: var(--green); box-shadow: 0 4px 0 var(--green-dark); }
.btn.green:active { box-shadow: 0 1px 0 var(--green-dark); }
.btn.yellow { background: var(--yellow); color: #3b2f00; box-shadow: 0 4px 0 #c99600; }
.btn.yellow:active { box-shadow: 0 1px 0 #c99600; }
.btn.red { background: var(--red); box-shadow: 0 4px 0 #b91c1c; }
.btn.red:active { box-shadow: 0 1px 0 #b91c1c; }
.btn.ghost {
  background: var(--surface); color: var(--text);
  border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border);
}
.btn.ghost:active { box-shadow: 0 0 0 var(--border); }
.btn.soft { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn.soft:active { transform: scale(.97); }
.btn.sm { padding: 9px 14px; font-size: .85rem; border-radius: 12px; box-shadow: none; }
.btn.icon { width: 42px; height: 42px; padding: 0; border-radius: 12px; font-size: 1.1rem; box-shadow: none; }
.btn-link { color: var(--primary); font-weight: 700; padding: 6px 4px; }

.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ---------- Cards / Tiles ---------- */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  padding: 18px;
}
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  padding: 18px 16px 14px; min-height: 128px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  text-align: left; width: 100%;
  transition: transform .12s, box-shadow .12s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile:active { transform: scale(.98); }
.tile .tile-icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.5rem; color: #fff;
}
.tile .tile-name { font-weight: 800; font-size: 1rem; }
.tile .tile-meta { color: var(--text-2); font-size: .78rem; font-weight: 600; }
.tile.add {
  border: 2px dashed var(--border); background: transparent; box-shadow: none;
  align-items: center; justify-content: center; color: var(--text-2); font-weight: 800;
}
.tile.add .tile-icon { background: var(--surface-2); color: var(--text-2); }
.tile .tile-stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }

.list-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  transition: transform .12s;
}
.list-item:active { transform: scale(.985); }
.list-item .li-icon {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  font-size: 1.3rem; flex-shrink: 0; color: #fff;
}
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 800; }
.list-item .li-sub { color: var(--text-2); font-size: .8rem; margin-top: 2px; }
.list-item .li-arrow { color: var(--text-3); font-size: 1.2rem; }

/* ---------- Progress bars ---------- */
.bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--primary); width: 0;
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}
.bar.green > span { background: var(--green); }
.bar.yellow > span { background: var(--yellow); }
.bar.thin { height: 8px; }
.bar.big { height: 16px; }
.bar-label { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }

/* ---------- Home ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #8E7BFF 60%, #A29BFE 100%);
  color: #fff; border-radius: var(--radius-lg); padding: 22px 20px;
  box-shadow: 0 12px 30px rgba(108, 92, 231, .35); margin-bottom: 18px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  border-radius: 50%; background: rgba(255,255,255,.12);
}
.hero h1 { font-size: 1.5rem; margin-bottom: 4px; }
.hero p { opacity: .9; font-size: .9rem; }
.hero .bar { background: rgba(255,255,255,.25); margin-top: 12px; }
.hero .bar > span { background: #fff; }
.hero .bar-label { color: rgba(255,255,255,.9); }
.goal-done { background: linear-gradient(135deg, var(--green) 0%, #34d399 100%); box-shadow: 0 12px 30px rgba(34,197,94,.35); }

.level-box { display: flex; align-items: center; gap: 14px; }
.level-badge {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 1.2rem;
  box-shadow: 0 6px 14px rgba(249,115,22,.35);
}

.due-banner {
  display: flex; align-items: center; gap: 12px; background: var(--yellow-soft);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  color: #6b4e00; font-weight: 700;
}
html[data-theme="dark"] .due-banner { color: #ffd87a; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 6px; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; padding: 13px 14px; border-radius: 14px;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-size: 1rem;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; transition: transform .1s; }
.color-dot.selected { border-color: var(--text); transform: scale(1.12); }
.icon-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-pick { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); font-size: 1.3rem; display: grid; place-items: center; border: 2px solid transparent; }
.icon-pick.selected { border-color: var(--primary); background: var(--primary-soft); }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle:last-child { border-bottom: 0; }
.toggle-label { font-weight: 700; }
.toggle-sub { color: var(--text-2); font-size: .8rem; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--border); transition: background .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform .2s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(20px); }

/* ---------- Option tiles (Lernstoff hinzufügen) ---------- */
.option-tile {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px; transition: border-color .15s, transform .1s;
}
.option-tile:hover { border-color: var(--primary); }
.option-tile:active { transform: scale(.985); }
.option-tile .ot-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); display: grid; place-items: center; font-size: 1.6rem; flex-shrink: 0; }
.option-tile .ot-title { font-weight: 800; font-size: 1.05rem; }
.option-tile .ot-sub { color: var(--text-2); font-size: .82rem; }

/* ---------- OCR ---------- */
.ocr-preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-2); display: block; }
.ocr-status { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--primary-soft); border-radius: var(--radius-sm); color: var(--primary); font-weight: 700; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(108,92,231,.25); border-top-color: var(--primary); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Karten-Vorschau (Editor) ---------- */
.edit-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.edit-card .ec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.edit-card .ec-num { font-weight: 800; color: var(--text-3); font-size: .8rem; }
.edit-card .textarea { min-height: 54px; padding: 10px 12px; font-size: .95rem; }
.edit-card .ec-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 6px 0 4px; }
.tag { display: inline-block; font-size: .7rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }

/* ---------- Lernmodus ---------- */
.learn-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.learn-head .bar { flex: 1; }
.flashcard-wrap { perspective: 1200px; margin: 8px 0 18px; }
.flashcard {
  position: relative; min-height: 300px;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  padding: 28px 24px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; transition: transform .35s cubic-bezier(.2,.8,.2,1);
  animation: cardIn .3s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateX(30px) rotate(2deg);} to { opacity: 1; transform: none;} }
.flashcard.flip { animation: flipIn .35s ease; }
@keyframes flipIn { 0% { transform: rotateY(90deg); opacity: .3;} 100% { transform: rotateY(0); opacity: 1;} }
.flashcard .fc-label { position: absolute; top: 16px; left: 20px; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.flashcard .fc-text { font-size: 1.35rem; font-weight: 800; line-height: 1.35; word-break: break-word; }
.flashcard .fc-answer { font-size: 1.2rem; font-weight: 700; color: var(--primary); line-height: 1.4; }
.flashcard .fc-divider { width: 60px; height: 4px; border-radius: 4px; background: var(--border); margin: 18px 0; }
.flashcard .fc-question-small { font-size: .95rem; color: var(--text-2); font-weight: 600; }
.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rate-btn { padding: 16px 8px; border-radius: 18px; font-weight: 800; font-size: .9rem; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .08s; }
.rate-btn:active { transform: scale(.95); }
.rate-btn span:first-child { font-size: 1.4rem; }
.rate-btn.r0 { background: var(--red); box-shadow: 0 4px 0 #b91c1c; }
.rate-btn.r1 { background: var(--yellow); color: #3b2f00; box-shadow: 0 4px 0 #c99600; }
.rate-btn.r2 { background: var(--green); box-shadow: 0 4px 0 var(--green-dark); }

/* ---------- Quiz ---------- */
.quiz-q { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 28px 22px; text-align: center; font-size: 1.25rem; font-weight: 800; margin-bottom: 16px; min-height: 120px; display: grid; place-items: center; animation: cardIn .3s ease; }
.quiz-options { display: grid; gap: 10px; }
.quiz-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  padding: 14px 16px; font-weight: 700; font-size: 1rem; box-shadow: 0 3px 0 var(--border);
  transition: transform .08s, border-color .15s, background .2s;
}
.quiz-opt .qo-letter { width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-weight: 900; flex-shrink: 0; }
.quiz-opt:hover { border-color: var(--primary); }
.quiz-opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.quiz-opt:disabled { pointer-events: none; }
.quiz-opt.correct { background: var(--green-soft); border-color: var(--green); box-shadow: 0 3px 0 var(--green); animation: pop .4s ease; }
.quiz-opt.correct .qo-letter { background: var(--green); color: #fff; }
.quiz-opt.wrong { background: var(--red-soft); border-color: var(--red); box-shadow: 0 3px 0 var(--red); animation: shake .4s ease; }
.quiz-opt.wrong .qo-letter { background: var(--red); color: #fff; }
.quiz-opt.dim { opacity: .45; }
@keyframes pop { 0% { transform: scale(1);} 40% { transform: scale(1.04);} 100% { transform: scale(1);} }
@keyframes shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-6px);} 75% { transform: translateX(6px);} }
.quiz-feedback { margin-top: 14px; padding: 14px 16px; border-radius: 14px; font-weight: 700; animation: fadeIn .2s; }
.quiz-feedback.ok { background: var(--green-soft); color: var(--green-dark); }
.quiz-feedback.bad { background: var(--red-soft); color: #b91c1c; }
html[data-theme="dark"] .quiz-feedback.ok { color: #86efac; }
html[data-theme="dark"] .quiz-feedback.bad { color: #fca5a5; }

/* ---------- Ergebnis / Abschluss ---------- */
.result-hero { text-align: center; padding: 30px 16px 10px; }
.result-hero .big-emoji { font-size: 4rem; animation: bounce .8s ease; display: block; }
@keyframes bounce { 0% { transform: scale(.3); opacity: 0;} 50% { transform: scale(1.15);} 70% { transform: scale(.95);} 100% { transform: scale(1); opacity: 1;} }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.result-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 8px; text-align: center; }
.result-stat b { display: block; font-size: 1.4rem; }
.result-stat span { font-size: .75rem; color: var(--text-2); font-weight: 700; }

/* ---------- Statistik ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.stat-card .sc-icon { font-size: 1.5rem; }
.stat-card .sc-value { font-size: 1.5rem; font-weight: 900; margin-top: 6px; }
.stat-card .sc-label { color: var(--text-2); font-size: .78rem; font-weight: 700; }
.subject-progress { margin-bottom: 14px; }
.subject-progress .sp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.subject-progress .sp-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 1rem; }
.subject-progress .sp-name { font-weight: 800; flex: 1; }
.subject-progress .sp-pct { font-weight: 800; color: var(--text-2); font-size: .85rem; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); }
.empty .empty-icon { font-size: 3rem; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- Header row within a page ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.back-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.page-head .ph-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-size: 1.3rem; }
.page-head h1 { font-size: 1.35rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 40, .55); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; backdrop-filter: blur(2px); }
@media (min-width: 560px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--surface); width: 100%; max-width: 480px;
  border-radius: 24px 24px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1); max-height: 90vh; overflow-y: auto;
}
@media (min-width: 560px) { .modal { border-radius: 24px; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0;} to { transform: none; opacity: 1;} }
.modal h2 { font-size: 1.2rem; margin-bottom: 14px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; font-size: .9rem; max-width: 90vw; }
.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.95);} to { opacity: 1; transform: none;} }

/* ---------- FX: XP float & confetti ---------- */
.xp-float { position: fixed; z-index: 80; font-weight: 900; color: var(--yellow); font-size: 1.3rem; text-shadow: 0 2px 6px rgba(0,0,0,.2); animation: floatUp 1s ease forwards; pointer-events: none; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(10px) scale(.8);} 20% { opacity: 1; transform: translateY(0) scale(1.1);} 100% { opacity: 0; transform: translateY(-60px) scale(1);} }
.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 80; pointer-events: none; animation: confettiFall linear forwards; border-radius: 2px; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0); opacity: 1;} 100% { transform: translateY(105vh) rotate(720deg); opacity: .6;} }

/* ---------- Data / misc ---------- */
.kbd-hint { color: var(--text-3); font-size: .75rem; text-align: center; margin-top: 10px; }
@media (max-width: 559px) { .kbd-hint { display: none; } }
.danger-zone { border-color: var(--red-soft); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: .82rem; }
.chip.green { background: var(--green-soft); color: var(--green-dark); }
.chip.red { background: var(--red-soft); color: #b91c1c; }
.chip.yellow { background: var(--yellow-soft); color: #7a5b00; }
html[data-theme="dark"] .chip.green { color: #86efac; }
html[data-theme="dark"] .chip.red { color: #fca5a5; }
html[data-theme="dark"] .chip.yellow { color: #fde68a; }
