/* AP1 Lernen — premium study surface
   Direction: cool ink + forest teal on mist surfaces (not purple, not cream-terracotta) */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,550;9..144,700&family=Sora:wght@400;500;600;700&display=swap");

/* Author display rules must not override the hidden attribute */
[hidden] { display: none !important; }

:root {
  --bg: #eef3f7;
  --bg-elev: rgba(255, 255, 255, 0.78);
  --bg-solid: #ffffff;
  --bg-soft: #e3ebf2;
  --ink: #102033;
  --text: #152536;
  --muted: #5b6b7c;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-2: #1d4e89;
  --danger: #c23b4a;
  --ok: #1f8a5b;
  --border: rgba(16, 32, 51, 0.1);
  --shadow: 0 18px 50px rgba(16, 32, 51, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --font: "Sora", ui-sans-serif, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: calc(68px + var(--safe-bottom));
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.35, .64, 1);
  --input-fs: 16px;
  --ring: color-mix(in srgb, var(--accent) 30%, transparent);
  color-scheme: light;
}

html[data-theme="dark"],
html[data-theme="system"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"],
  html:not([data-theme]) {
    --bg: #0b1219;
    --bg-elev: rgba(18, 28, 40, 0.82);
    --bg-solid: #121c28;
    --bg-soft: #1a2736;
    --ink: #f3f7fb;
    --text: #e8eef5;
    --muted: #9aabbd;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-2: #7db4ff;
    --danger: #fb7185;
    --ok: #34d399;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

html[data-theme="dark"] {
  --bg: #0b1219;
  --bg-elev: rgba(18, 28, 40, 0.82);
  --bg-solid: #121c28;
  --bg-soft: #1a2736;
  --ink: #f3f7fb;
  --text: #e8eef5;
  --muted: #9aabbd;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-2: #7db4ff;
  --danger: #fb7185;
  --ok: #34d399;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  --bg: #eef3f7;
  --bg-elev: rgba(255, 255, 255, 0.78);
  --bg-solid: #ffffff;
  --bg-soft: #e3ebf2;
  --ink: #102033;
  --text: #152536;
  --muted: #5b6b7c;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-2: #1d4e89;
  --danger: #c23b4a;
  --ok: #1f8a5b;
  --border: rgba(16, 32, 51, 0.1);
  --shadow: 0 18px 50px rgba(16, 32, 51, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 8% -8%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 58%),
    radial-gradient(780px 460px at 100% 0%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 52%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-solid) 55%, transparent), transparent 42%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 22px,
      color-mix(in srgb, var(--ink) 2.2%, transparent) 22px,
      color-mix(in srgb, var(--ink) 2.2%, transparent) 23px
    );
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

/* Stack page chrome above the body::before wash — but do NOT force
   position:relative on fixed/sticky chrome (that unsticks the tabbar). */
.app-body > *:not(.tabbar):not(.toast):not(.topbar),
.auth-body > * { position: relative; z-index: 1; }
.app-body > .topbar { position: sticky; z-index: 20; }
.app-body > .tabbar { position: fixed; z-index: 40; }
.app-body > .toast { position: fixed; z-index: 80; }

.skip-link { position: absolute; left: -999px; top: 0; }
.skip-link:focus {
  left: 12px; top: 12px; z-index: 50;
  background: var(--bg-solid); color: var(--ink);
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
}

/* —— chrome —— */
.app-body { padding-bottom: calc(var(--tabbar-h) + 18px); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  backdrop-filter: blur(18px) saturate(1.2);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1;
}
.brand span {
  display: inline-block;
  margin-left: .28em;
  color: var(--accent);
  font-style: italic;
  font-weight: 550;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff; font-family: var(--display); font-weight: 700; font-size: .95rem;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 28%, transparent);
}
.brand-lockup { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }

.main {
  max-width: 720px; margin: 0 auto;
  padding: 22px 18px 10px;
  animation: page-in .55s var(--ease-out) both;
}

.tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 40;
  height: 64px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-solid) 86%, transparent);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  box-shadow: var(--shadow);
}
.tabbar a span { font-size: .62rem; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-decoration: none; color: var(--muted);
  font-size: .68rem; font-weight: 600; min-height: 44px; border-radius: 16px;
  transition: color .2s var(--ease-out), background .2s, transform .15s;
}
.tabbar a.active {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tabbar a:active { transform: scale(.96); }
.tab-ico {
  width: 1.35rem; height: 1.35rem; display: block;
  transition: transform .25s var(--ease-spring);
}
.tabbar a.active .tab-ico { transform: translateY(-1px) scale(1.06); }

/* —— type & sections —— */
.hero-block { margin-bottom: 22px; }
.hero-home {
  min-height: min(42dvh, 340px);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 8px 2px 6px;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .12em;
  font-size: .68rem; font-weight: 600; color: var(--muted); margin: 0 0 10px;
}
.hero-block h1,
.display {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.08;
  color: var(--ink);
}
.hero-block .lede,
.lede { margin: 0; color: var(--muted); line-height: 1.5; font-size: 1.02rem; max-width: 36ch; }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin-top: 16px; color: var(--muted); font-size: .92rem;
}
.hero-meta strong { color: var(--ink); font-weight: 650; }

.section-title {
  font-family: var(--display);
  font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em;
  margin: 0 0 12px; color: var(--ink);
}

.stat-rail {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 0 0 18px;
}
.stat-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center;
  backdrop-filter: blur(10px);
  transition: transform .2s var(--ease-out), border-color .2s;
  animation: rise-in .5s var(--ease-out) both;
}
.stat-tile:nth-child(2) { animation-delay: .04s; }
.stat-tile:nth-child(3) { animation-delay: .08s; }
.stat-tile:nth-child(4) { animation-delay: .12s; }
.stat-tile:active { transform: scale(.98); }
.stat-num {
  font-family: var(--display);
  font-size: 1.55rem; font-weight: 700; color: var(--ink); letter-spacing: -.03em;
}
.stat-label { font-size: .68rem; color: var(--muted); font-weight: 600; margin-top: 2px; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 color-mix(in srgb, #fff 40%, transparent) inset;
  animation: rise-in .5s var(--ease-out) both;
}
.panel h2, .panel .section-title { margin: 0 0 12px; font-size: 1.05rem; }
.panel.highlight { text-align: center; padding: 28px 18px; }
.grade-big {
  font-family: var(--display);
  font-size: clamp(3.4rem, 14vw, 4.5rem);
  font-weight: 700; margin: 6px 0; letter-spacing: -.04em; color: var(--ink);
}

.btn {
  appearance: none; border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--ink);
  border-radius: 16px; padding: 14px 16px;
  font-family: var(--font); font-size: 1rem; font-weight: 650;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px;
  transition: transform .15s var(--ease-out), filter .15s, border-color .2s, background .2s, box-shadow .2s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent-strong));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn-primary:active { filter: brightness(.97); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.cta-stack { display: grid; gap: 10px; margin-bottom: 18px; }

#quiz-options {
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 6px 0 4px;
}
#quiz-options .quiz-option {
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  line-height: 1.35;
  padding: 14px 16px;
  min-height: 52px;
  font-weight: 500;
}

.bar {
  height: 7px; background: var(--bg-soft); border-radius: 99px; overflow: hidden;
}
.bar > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .55s var(--ease-out);
}

.topic-list, .simple-list, .grade-scale, .check-list, .steps { list-style: none; margin: 0; padding: 0; }
.topic-list li { margin-bottom: 14px; }
.topic-row {
  display: flex; justify-content: space-between; gap: 12px;
  margin-bottom: 7px; font-size: .92rem; font-weight: 500;
}
.muted { color: var(--muted); }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--danger); }
.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--bg-solid));
  border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--border));
  padding: 12px 14px; border-radius: 14px;
  animation: shake-x .45s var(--ease-out);
}
.grade-scale li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-size: .95rem;
}
.grade-scale li.is-current {
  color: var(--accent-strong);
  font-weight: 650;
}

.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 7px; font-size: .88rem; font-weight: 600; color: var(--muted); }

input, select, textarea {
  font-size: var(--input-fs) !important;
  line-height: 1.35;
  max-width: 100%;
  font-family: var(--font);
}
.form-stack input,
.form-stack select,
.form-stack textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-solid);
  color: var(--text);
  padding: 13px 14px;
  min-height: 52px;
  transition: border-color .2s, box-shadow .2s, background .2s;
  touch-action: manipulation;
}
.form-stack input:focus,
.form-stack select:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow: 0 0 0 4px var(--ring);
}
.check { display: flex !important; align-items: center; gap: 10px; color: var(--text); }
.check input { width: auto; min-height: 22px; }

.auth-body {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: calc(28px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
}
.auth-shell { width: min(440px, 100%); animation: page-in .55s var(--ease-out) both; }
.auth-shell.wide { width: min(560px, 100%); }
.auth-shell .brand {
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  margin-bottom: 8px;
}
.auth-shell .hero-block h1 {
  font-size: clamp(1.55rem, 5vw, 1.9rem);
  font-weight: 550;
}

/* —— Study subnav + deck picker —— */
.study-shell {
  padding-bottom: 8px;
}
.study-subnav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.easy-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: var(--ink);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.35;
}
.teach-tip {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  font-size: .9rem;
  line-height: 1.45;
  color: var(--muted);
}
.teach-tip strong { color: var(--ink); }
#block-formula p {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin: 0;
}
.study-subnav a {
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  font-size: .92rem;
  padding: 10px 12px;
  border-radius: 12px;
}
.study-subnav a.is-active {
  background: var(--bg-solid);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--border);
}
.deck-setup { display: grid; gap: 14px; }
.deck-hero h1 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 6vw, 2.2rem);
  margin: 0 0 6px;
  letter-spacing: -.02em;
}
.deck-hero .muted { margin: 0; }
.deck-scope, .deck-actions-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.is-active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-soft));
  color: var(--accent-strong);
}
.topic-pick {
  display: grid;
  gap: 8px;
  max-height: min(42dvh, 360px);
  overflow: auto;
  padding-right: 2px;
}
.topic-pick label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  cursor: pointer;
}
.topic-pick label.is-on {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-elev));
}
.topic-pick input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.topic-pick .t-title { font-weight: 650; color: var(--ink); }
.topic-pick .t-meta { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.deck-save h2, .deck-presets h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}
.deck-save input[type="text"] {
  width: 100%;
  margin: 0 0 10px;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  font-size: var(--input-fs);
}
.preset-list { display: grid; gap: 8px; }
.preset-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}
.preset-row .preset-open {
  text-align: left;
  justify-content: flex-start;
}
.preset-row .preset-meta {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}
.linkish {
  border: 0;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
  margin-left: 8px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* —— Quizlet-style flip cards —— */
.flip-mode {
  animation: page-in .45s var(--ease-out) both;
}
.flip-scene {
  perspective: 1200px;
  -webkit-perspective: 1200px;
  margin: 8px 0 14px;
  /* do not use overflow:hidden — kills preserve-3d */
}
.flip-card {
  position: relative;
  display: block;
  width: 100%;
  min-height: min(58dvh, 460px);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.flip-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 28px;
}
.flip-inner {
  position: relative;
  width: 100%;
  min-height: inherit;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform .52s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}
.flip-card.is-flipped .flip-inner { transform: rotateY(180deg); }
.flip-card.is-animating { pointer-events: none; }
.flip-card.is-exit {
  opacity: 0;
  transform: translateX(-28px) scale(.98);
  transition: opacity .28s var(--ease-out), transform .28s var(--ease-out);
}
.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 22px 32px;
  border-radius: 26px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
}
.flip-front { transform: rotateY(0deg) translateZ(1px); }
.flip-back { transform: rotateY(180deg) translateZ(1px); }
.flip-back .flip-meta { opacity: .92; }
.flip-side-label {
  position: absolute;
  top: 14px; left: 16px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.flip-question {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 5.2vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
  color: var(--ink);
  max-width: 28ch;
}
.flip-answer {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 4.6vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.3;
  color: var(--accent-strong);
  max-width: 32ch;
}
.flip-hint {
  position: absolute;
  bottom: 16px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
}
.flip-meta {
  margin-top: 8px;
  max-width: 36ch;
  display: grid;
  gap: 8px;
}
.flip-explain, .flip-trap, .flip-mnem {
  margin: 0;
  font-size: .92rem;
  line-height: 1.45;
  color: var(--muted);
}
.flip-trap { color: color-mix(in srgb, var(--danger) 75%, var(--muted)); }
.flip-mnem { color: color-mix(in srgb, var(--accent) 70%, var(--muted)); font-weight: 600; }
.flip-controls {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}
.flip-swipe-hint {
  text-align: center;
  font-size: .78rem;
  margin: 0 0 8px;
}
.flip-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}
.flip-card.is-swipe-left {
  transform: translateX(-42px) rotate(-3deg);
  opacity: .75;
  transition: transform .18s var(--ease-out), opacity .18s;
}
.flip-card.is-swipe-right {
  transform: translateX(42px) rotate(3deg);
  opacity: .75;
  transition: transform .18s var(--ease-out), opacity .18s;
}
.flip-rate {
  animation: rise-in .35s var(--ease-out) both;
}
.rate-grid-flip {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) {
  .rate-grid-flip { grid-template-columns: repeat(5, 1fr); }
}

.card-face {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 22px 18px 26px;
  min-height: 54dvh;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  transition: border-color .25s, box-shadow .25s, transform .35s var(--ease-out);
}
.card-face.is-enter { animation: card-enter .42s var(--ease-out) both; }
.card-face.is-success {
  border-color: color-mix(in srgb, var(--ok) 50%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok) 28%, transparent), var(--shadow);
  animation: pulse-ok .55s var(--ease-out);
}
.card-face.is-error {
  border-color: color-mix(in srgb, var(--danger) 50%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 28%, transparent), var(--shadow);
  animation: shake-x .5s var(--ease-out);
}
.card-face h1 {
  font-family: var(--display);
  font-size: clamp(1.35rem, 4.8vw, 1.75rem);
  line-height: 1.25; margin: 0 0 18px; letter-spacing: -.02em; color: var(--ink);
}
.answer-block {
  margin: 14px 0; padding: 14px;
  border-radius: 16px; background: var(--bg-soft);
  animation: rise-in .35s var(--ease-out) both;
}
.answer-block h2 {
  margin: 0 0 6px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 700;
}
.answer-block p { margin: 0; line-height: 1.5; }
.rate-label { margin: 18px 0 8px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.rate-grid { display: grid; gap: 8px; }
.rate-q1 {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 14%, var(--bg-soft));
  color: color-mix(in srgb, var(--danger) 70%, var(--ink));
}
.rate-q2 {
  border-color: color-mix(in srgb, #e8890c 55%, var(--border));
  background: color-mix(in srgb, #e8890c 14%, var(--bg-soft));
  color: color-mix(in srgb, #e8890c 65%, var(--ink));
}
.rate-q3 {
  border-color: color-mix(in srgb, #c9a227 50%, var(--border));
  background: color-mix(in srgb, #c9a227 12%, var(--bg-soft));
  color: color-mix(in srgb, #c9a227 55%, var(--ink));
}
.rate-q4 {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-soft));
  color: color-mix(in srgb, var(--accent) 55%, var(--ink));
}
.rate-q5 {
  border-color: color-mix(in srgb, var(--ok) 60%, var(--border));
  background: color-mix(in srgb, var(--ok) 16%, var(--bg-soft));
  color: color-mix(in srgb, var(--ok) 55%, var(--ink));
}

.quiz-option.is-correct {
  border-color: color-mix(in srgb, var(--ok) 65%, transparent) !important;
  background: color-mix(in srgb, var(--ok) 14%, var(--bg-soft));
  animation: pop-ok .4s var(--ease-spring);
}
.quiz-option.is-wrong {
  border-color: color-mix(in srgb, var(--danger) 65%, transparent) !important;
  background: color-mix(in srgb, var(--danger) 12%, var(--bg-soft));
  animation: shake-x .45s var(--ease-out);
}

.feedback-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 0 14px; padding: 8px 12px; border-radius: 12px;
  font-size: .88rem; font-weight: 700;
  animation: pop-ok .4s var(--ease-spring);
}
.feedback-chip.ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, var(--bg-soft));
}
.feedback-chip.bad {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--bg-soft));
}

.study-progress { margin-bottom: 14px; }
.study-progress .muted { font-size: .88rem; font-weight: 500; }
.steps { padding-left: 1.15rem; list-style: decimal; }
.steps li { margin: 7px 0; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--ink);
  width: 42px; height: 42px; border-radius: 14px;
  transition: transform .15s var(--ease-out);
  touch-action: manipulation;
}
.icon-btn:active { transform: scale(.94); }

.toast {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(12px + 64px + 12px + var(--safe-bottom));
  z-index: 80;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease-out), transform .22s var(--ease-out);
  font-size: .92rem;
  font-weight: 600;
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.is-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.toast.is-bad { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }

.surface-note {
  font-size: .92rem; color: var(--muted); line-height: 1.45; margin: 0;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes card-enter {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes shake-x {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes pulse-ok {
  0% { transform: scale(1); }
  40% { transform: scale(1.012); }
  100% { transform: scale(1); }
}
@keyframes pop-ok {
  0% { transform: scale(.96); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (min-width: 900px) {
  .stat-rail { gap: 12px; }
  .main { padding-top: 28px; }
  .rate-grid { grid-template-columns: repeat(2, 1fr); }
  .tabbar { left: max(12px, calc(50% - 360px)); right: max(12px, calc(50% - 360px)); }
}

/* —— special task UIs —— */
.special-stage { margin: 0 0 14px; }
.field-label {
  display: block; margin: 0 0 6px;
  font-size: .82rem; font-weight: 650; color: var(--muted);
}
.calc-box input,
.special-stage input[type="text"],
.special-stage input[type="number"],
.special-stage textarea,
.special-stage select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-solid);
  color: var(--text);
  padding: 12px 14px;
  font-size: var(--input-fs) !important;
  font-family: var(--font);
  min-height: 52px;
}
.special-stage textarea { min-height: 110px; resize: vertical; }
.code-block {
  margin: 0 0 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.dnd-box { display: grid; gap: 10px; }
.dnd-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
  align-items: center;
}
.dnd-left {
  font-weight: 650;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.netzplan-grid { display: grid; gap: 8px; margin-bottom: 10px; }
.netzplan-head, .netzplan-row {
  display: grid;
  grid-template-columns: 64px 64px repeat(auto-fit, minmax(64px, 1fr));
  gap: 6px;
  align-items: center;
}
.netzplan-head { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.netzplan-id { font-family: var(--display); font-weight: 700; font-size: 1.1rem; }
.layer-stack { display: grid; gap: 6px; margin-bottom: 12px; }
.layer-row {
  padding: 10px 12px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-size: .9rem; font-weight: 600;
}
.layer-row.is-focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-soft));
}
.port-grid, .topo-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.port-chip, .topo-node, .topo-slot {
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-soft);
  font-size: .88rem; font-weight: 650;
}
.topo-slot {
  border-style: dashed;
  color: var(--muted);
}
.quiz-option.is-picked {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-soft));
}
.exam-top {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
}
.exam-timer {
  font-family: var(--display);
  font-size: 1.6rem; font-weight: 700;
  min-width: 5ch; text-align: right;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

@media (max-width: 520px) {
  .dnd-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .toast { opacity: 1; transform: translate(-50%, 0); }
}
