:root {
  --bg: #eef7ff;
  --surface: #ffffff;
  --surface-soft: #f3f8ff;
  --text: #113147;
  --muted: #4a687d;
  --primary: #1d8f5a;
  --primary-strong: #146c44;
  --danger: #c6483d;
  --danger-strong: #9b2f26;
  --border: #b7cfe7;
  --shadow: 0 14px 34px rgba(17, 49, 71, 0.12);
  --focus: #005fcc;
  --accent-blue: #3a9be0;
  --accent-yellow: #f6c544;
  --accent-orange: #f4893c;
  --accent-mint: #34b89b;
  --accent-rose: #e66d8d;
  --accent-sky: #66b7ff;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.theme-dark {
  --bg: #101c19;
  --surface: #162723;
  --surface-soft: #20332d;
  --text: #e8f4ee;
  --muted: #afc9be;
  --primary: #1f8f57;
  --primary-strong: #166f44;
  --danger: #bf5146;
  --danger-strong: #9a3f36;
  --border: #33564b;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  --focus: #8fc7ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", Verdana, sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(102, 183, 255, 0.24) 0, rgba(102, 183, 255, 0) 44%),
    radial-gradient(circle at 100% 0%, rgba(230, 109, 141, 0.18) 0, rgba(230, 109, 141, 0) 38%),
    radial-gradient(circle at 0% 100%, rgba(52, 184, 155, 0.2) 0, rgba(52, 184, 155, 0) 40%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 62%);
  color: var(--text);
  overflow-x: hidden;
}

body.theme-dark {
  background: radial-gradient(circle at top left, #1a3028 0%, var(--bg) 56%);
}

body.theme-dark .app-header {
  background: linear-gradient(135deg, rgba(67, 152, 209, 0.14), rgba(58, 192, 138, 0.12));
}

body.theme-dark .panel-head {
  background: rgba(22, 39, 35, 0.9);
}

body.theme-dark .tab-btn {
  color: var(--text);
}

body.theme-dark .status-text {
  color: #9de9c3;
}

body.theme-dark #exercise-focus {
  background: rgba(24, 43, 38, 0.9);
  border-color: #4a6b60;
  color: #bdeccf;
}

body.theme-dark .tab-btn:nth-child(1),
body.theme-dark .tab-btn:nth-child(2),
body.theme-dark .tab-btn:nth-child(3),
body.theme-dark .tab-btn:nth-child(4),
body.theme-dark .tab-btn:nth-child(5),
body.theme-dark .tab-btn:nth-child(6) {
  --tab-bg: #1f332e;
  --tab-border: #3c5d53;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-right: calc(0.75rem + env(safe-area-inset-right));
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  padding-left: calc(0.75rem + env(safe-area-inset-left));
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.1rem;
  background:
    linear-gradient(120deg, rgba(58, 155, 224, 0.16), rgba(52, 184, 155, 0.14)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.75));
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 1.05rem;
}

.eyebrow {
  margin: 0;
  color: #185d88;
  font-weight: 700;
  letter-spacing: 0.03em;
}

body.theme-dark .eyebrow {
  color: #8fcdf7;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
}

h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

h3 {
  font-size: 1.1rem;
}

.subhead {
  margin: 0.45rem 0 0;
  color: var(--muted);
  max-width: 65ch;
}

.header-tools {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.layout {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.tab-nav {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.74);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.tab-btn {
  border: 1px solid var(--tab-border, var(--border));
  background: var(--tab-bg, var(--surface));
  color: var(--text);
  border-radius: 0.8rem;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
  flex: 0 0 auto;
}

.tab-btn:nth-child(1) {
  --tab-bg: #eaf6ff;
  --tab-border: #b9dfff;
}

.tab-btn:nth-child(2) {
  --tab-bg: #ecfff8;
  --tab-border: #b9ecd9;
}

.tab-btn:nth-child(3) {
  --tab-bg: #fff2f7;
  --tab-border: #f0bfd1;
}

.tab-btn:nth-child(4) {
  --tab-bg: #fff2e8;
  --tab-border: #f4d0b8;
}

.tab-btn:nth-child(5) {
  --tab-bg: #f4efff;
  --tab-border: #d8cbf7;
}

.tab-btn:nth-child(6) {
  --tab-bg: #eff9f0;
  --tab-border: #c9e7cf;
}

.card {
  scroll-margin-top: 4.4rem;
}

#tab-exercises .grid,
#tab-grammar .grid {
  scroll-snap-type: y proximity;
}

#tab-exercises .card,
#tab-grammar .card {
  scroll-snap-align: start;
}

.exercise-stepper {
  margin-bottom: 0.95rem;
  border: 1px solid #e6be79;
  background: linear-gradient(180deg, #fff8e8, #fff4de);
}

.step-nav {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.step-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 999px;
  min-height: 40px;
  padding: 0.35rem 0.72rem;
  font-weight: 700;
}

.step-chip.active {
  background: linear-gradient(180deg, #f4aa44, #f07f2d);
  border-color: #da6d1f;
  color: #ffffff;
}

.exercise-card {
  display: none;
}

.exercise-card.active {
  display: grid;
  align-content: start;
  min-height: 420px;
}

.path-chip {
  min-height: 40px;
}

.path-chip.active {
  background: linear-gradient(180deg, #2f79be, #285f95);
  border-color: #285f95;
  color: #ffffff;
}

.tab-btn:hover {
  background: var(--surface-soft);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

main {
  display: grid;
  min-width: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  min-width: 0;
}

.panel-head {
  margin-bottom: 0.9rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed var(--border);
  border-radius: 1rem;
  padding: 0.75rem 0.85rem;
}

.panel-head-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.panel-head-inline h2 {
  margin: 0;
}

.panel-head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.panel-head .status-text {
  margin-top: 0.55rem;
}

.grid {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.two-col {
  align-items: stretch;
}

.two-col > .card {
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  box-shadow: var(--shadow);
  padding: 1.02rem;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-mint));
}

#tab-vocab .card::before {
  background: linear-gradient(90deg, #34b89b, #1d8f5a);
}

#tab-library .card::before {
  background: linear-gradient(90deg, #3a9be0, #5fb8f0);
}

#tab-exercises .card::before {
  background: linear-gradient(90deg, #f6c544, #f4893c);
}

#tab-sentences .card::before {
  background: linear-gradient(90deg, #e66d8d, #f38b70);
}

#tab-errors .card::before {
  background: linear-gradient(90deg, #f3a856, #ea6f39);
}

#tab-grammar .card::before {
  background: linear-gradient(90deg, #e66d8d, #8b7be6);
}

.card-head {
  margin-bottom: 0.75rem;
}

.card-head.between {
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.status-text {
  margin: 0;
  font-weight: 700;
  color: var(--primary-strong);
  overflow-wrap: anywhere;
}

#exercise-focus {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  margin: 0;
}

#tab-exercises .panel-head-inline {
  margin-bottom: 0.12rem;
}

#tab-exercises .panel-head-inline #exercise-focus {
  margin-left: auto;
}

#tab-exercises .mode-filter {
  margin: 0.4rem 0 0.2rem;
}

#tab-exercises #exercise-mode-hint {
  margin-top: 0.1rem;
  font-weight: 700;
  color: var(--muted);
}

#tab-exercises .mode-chip {
  min-height: 34px;
  padding: 0.24rem 0.65rem;
  font-weight: 800;
}

body.theme-dark #tab-exercises .mode-chip {
  background: #2b4453;
  border-color: #7da8cb;
  color: #f1f8ff;
}

body.theme-dark #tab-exercises .mode-chip.active {
  background: linear-gradient(180deg, #2f79be, #285f95);
  border-color: #9dc8ed;
  color: #ffffff;
}

.hint-text {
  margin: 0.65rem 0 0;
  color: var(--muted);
}

.flashcard {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.95rem;
  min-height: 210px;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-soft) 100%);
}

.flashcard h4 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.flashcard p {
  margin: 0.35rem 0;
}

#vocab-flashcards-card .flashcard {
  flex: 1 1 auto;
}

.button-row {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

button,
input,
textarea,
select {
  font: inherit;
  font-size: 16px;
}

button {
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.65rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn,
.tag-chip,
.word-chip,
.step-chip {
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ok-btn {
  background: linear-gradient(180deg, #25a868, var(--primary));
  border-color: var(--primary);
  color: #fff;
}

.ok-btn:hover {
  background: var(--primary-strong);
}

.danger-btn {
  background: linear-gradient(180deg, #d65c52, var(--danger));
  border-color: var(--danger);
  color: #fff;
}

.danger-btn:hover {
  background: var(--danger-strong);
}

.ghost-btn {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
}

.ghost-btn:hover {
  background: var(--surface-soft);
}

button:focus,
.tab-btn:focus,
button:focus-visible,
.tab-btn:focus-visible,
.tag-chip:focus,
.word-chip:focus,
.step-chip:focus,
.tag-chip:focus-visible,
.word-chip:focus-visible,
.step-chip:focus-visible {
  outline: none;
  box-shadow: none;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.exercise-box {
  display: grid;
  gap: 0.6rem;
  overflow-wrap: anywhere;
}

.choice-btn {
  text-align: left;
}

.choice-btn small {
  display: block;
  margin-top: 0.25rem;
  font-weight: 500;
  color: var(--muted);
}

.choice-btn.selected {
  border-color: var(--primary);
  background: #e7f8ed;
}

.feedback {
  margin: 0.3rem 0 0;
  border-radius: 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.feedback.good {
  border-color: #6ab08d;
  background: #e7f8ed;
  color: #145b36;
}

.feedback.bad {
  border-color: #d88f89;
  background: #fdecec;
  color: #7f251c;
}

body.theme-dark .feedback.good {
  background: #173728;
  color: #c8f2d8;
}

body.theme-dark .feedback.bad {
  background: #3b1f1d;
  color: #ffd8d5;
}

body.theme-dark .flashcard {
  background: linear-gradient(180deg, #21372f 0%, #1b2f28 100%);
}

body.theme-dark .ghost-btn {
  background: #223832;
  color: #eef8f3;
  border-color: #4a6b60;
}

body.theme-dark .ghost-btn:hover {
  background: #2a453d;
}

body.theme-dark .ok-btn {
  background: linear-gradient(180deg, #208a54, #166f44);
  border-color: #2daa70;
  color: #ffffff;
}

body.theme-dark .ok-btn:hover {
  background: #145f3b;
}

body.theme-dark .danger-btn {
  background: linear-gradient(180deg, #b84a41, #943932);
  border-color: #cd695f;
  color: #ffffff;
}

body.theme-dark .danger-btn:hover {
  background: #7f302a;
}

body.theme-dark .tag-chip {
  background: #223832;
  color: #eef8f3;
  border-color: #4a6b60;
}

body.theme-dark .tag-chip.active {
  background: linear-gradient(180deg, #1f8f57, #166f44);
  border-color: #3cb577;
  color: #ffffff;
}

body.theme-dark .choice-btn.selected {
  background: #2b5845;
  border-color: #52b987;
  color: #f0fbf6;
}

.tag-filter {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0.65rem 0;
}

.tag-chip {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.72rem;
  cursor: pointer;
}

.tag-chip.active {
  background: linear-gradient(180deg, #25a868, var(--primary));
  color: #fff;
  border-color: var(--primary);
}

.vocab-list {
  max-height: 390px;
  overflow: auto;
  display: grid;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-height: 0;
}

.vocab-item {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.6rem;
  background: var(--surface-soft);
}

.vocab-item p {
  margin: 0.2rem 0;
}

.mission-list {
  display: grid;
  gap: 0.55rem;
}

.mission-item {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-soft);
  padding: 0.55rem 0.62rem;
}

.mission-item p {
  margin: 0.14rem 0;
}

.mission-item.done {
  border-color: #6ab08d;
  background: #e7f8ed;
}

.mission-progress {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f1f6fc;
}

.mission-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1d8f5a, #4ec68c);
}

body.theme-dark .mission-item {
  background: #1f3444;
  border-color: #4f6b82;
}

body.theme-dark .mission-item.done {
  background: #1f4734;
  border-color: #53b681;
}

body.theme-dark .mission-progress {
  border-color: #4f6b82;
  background: #1a2a37;
}

#boss-quiz-card .choice-btn {
  min-height: 40px;
}

.progress-wrap {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  margin-top: 0.8rem;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1d8f5a, #4ec68c);
}

body.theme-dark .progress-bar {
  background: linear-gradient(90deg, #37af72, #6ce0a7);
}

input,
select,
textarea {
  width: 100%;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.62rem;
  min-height: 44px;
}

textarea {
  resize: vertical;
  min-height: 240px;
  line-height: 1.5;
}

.hidden {
  display: none;
}

fieldset {
  min-inline-size: 0;
  margin: 0;
}

.word-bank,
.answer-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.word-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 0.35rem 0.66rem;
  cursor: pointer;
}

.word-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.answer-bank {
  min-height: 48px;
  padding: 0.4rem;
  border: 1px dashed var(--border);
  border-radius: 0.65rem;
}

#ex-question,
#sentence-box {
  gap: 0.75rem;
}

#ex-question .question-instruction,
#sentence-box .question-instruction {
  margin: 0.2rem 0 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid #b8cfe4;
  border-radius: 0.65rem;
  background: #f2f8ff;
  color: #173a57;
  font-weight: 700;
  line-height: 1.35;
}

#ex-question .question-label,
#sentence-box .question-label {
  margin: 0.2rem 0 0;
  color: #1d4f75;
  font-weight: 700;
}

#ex-question .question-bank,
#sentence-box .question-bank {
  border: 1px solid #b8cfe4;
  background: #f7fbff;
  border-radius: 0.75rem;
  padding: 0.5rem;
}

#ex-question .question-answer,
#sentence-box .question-answer {
  min-height: 56px;
  border: 2px dashed #8db4d6;
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 0.5rem;
}

#ex-question .word-chip,
#sentence-box .word-chip {
  border-color: #95b8d7;
  background: #ffffff;
  color: #123a57;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
  min-height: 42px;
  line-height: 1.2;
}

#ex-question .word-chip:hover,
#sentence-box .word-chip:hover {
  background: #eaf4ff;
}

#ex-question .question-answer .word-chip,
#sentence-box .question-answer .word-chip {
  background: #e6f2ff;
  border-color: #78a9d3;
}

#ex-question .button-row .ghost-btn,
#sentence-box .button-row .ghost-btn {
  background: #f3f9ff;
  border-color: #95b8d7;
  color: #133a57;
}

#ex-question .button-row .ghost-btn:hover,
#sentence-box .button-row .ghost-btn:hover {
  background: #e7f2ff;
}

.match-grid {
  display: grid;
  gap: 0.6rem;
}

.match-row {
  display: grid;
  gap: 0.4rem;
}

.match-row small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
}

.errors-list {
  display: grid;
  gap: 0.65rem;
}

.error-group {
  display: grid;
  gap: 0.55rem;
}

.error-item {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-soft);
  padding: 0.65rem;
}

.error-item p {
  margin: 0.25rem 0;
  line-height: 1.4;
}

.order-steps {
  margin: 0.1rem 0 0.2rem;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.35rem;
}

.order-list {
  display: grid;
  gap: 0.55rem;
}

.order-fixed {
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
  background: #f7fbff;
  padding: 0.55rem 0.6rem;
}

.order-fixed p {
  margin: 0.15rem 0;
}

.order-item {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface-soft);
  padding: 0.55rem 0.6rem;
}

.order-pos {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #25a868, var(--primary));
}

.order-text {
  margin: 0;
  line-height: 1.35;
}

.order-controls {
  display: flex;
  gap: 0.3rem;
}

.order-controls .ghost-btn {
  min-width: 44px;
  padding: 0.5rem;
}

.order-divider {
  margin: 0.2rem 0;
  border: 0;
  border-top: 1px dashed var(--border);
}

.order-solution {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.order-solution li {
  margin: 0.18rem 0;
}

.grammar-mini {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-soft);
  padding: 0.7rem;
  display: grid;
  gap: 0.5rem;
}

.grammar-mini h4 {
  margin: 0;
}

.grammar-mini p {
  margin: 0;
  line-height: 1.45;
}

.grammar-mini ul {
  margin: 0;
  padding-left: 1.1rem;
}

.grammar-mini li {
  margin: 0.2rem 0;
}

.grammar-mini .word-bank {
  margin-top: 0.15rem;
}

.motivation-card {
  max-width: 560px;
}

.motivation-quote {
  margin: 0.75rem 0 0;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 0.8rem;
  padding: 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
}

#tab-grammar .panel-head {
  background: linear-gradient(135deg, rgba(106, 150, 225, 0.15), rgba(111, 196, 186, 0.12));
  border-style: solid;
}

#tab-grammar .grammar-mini,
#tab-grammar .card {
  border-color: #afc8e6;
  background: #f5f9ff;
}

#tab-grammar .word-chip {
  border-color: #afc8e6;
  background: #ffffff;
  color: #183c5e;
}

#tab-grammar .word-chip.selected {
  background: linear-gradient(180deg, #2f79be, #285f95);
  border-color: #285f95;
  color: #ffffff;
}

#tab-grammar .tag-chip.active {
  background: linear-gradient(180deg, #2f79be, #285f95);
  border-color: #285f95;
}

body.theme-dark #tab-grammar .panel-head {
  background: linear-gradient(135deg, rgba(74, 130, 170, 0.28), rgba(65, 159, 144, 0.24));
  border-color: #567086;
}

body.theme-dark #tab-grammar .card {
  background: #1a2a34;
  border-color: #486174;
}

body.theme-dark #tab-grammar .status-text {
  color: #b8dcff;
}

body.theme-dark #tab-grammar .hint-text {
  color: #c4d7e8;
}

body.theme-dark #tab-grammar .grammar-mini,
body.theme-dark #tab-grammar .card {
  background: #223541;
  border-color: #5d798f;
}

body.theme-dark #tab-grammar .ghost-btn {
  background: #2a4150;
  border-color: #6d8ca5;
  color: #f3f8ff;
}

body.theme-dark #tab-grammar .ghost-btn:hover {
  background: #355466;
}

body.theme-dark #tab-grammar .tag-chip {
  background: #2a4150;
  border-color: #6d8ca5;
  color: #f3f8ff;
}

body.theme-dark #tab-grammar .tag-chip.active {
  background: linear-gradient(180deg, #2e6fa5, #245885);
  border-color: #84b9ea;
}

body.theme-dark #tab-grammar .word-chip {
  background: #2a4150;
  border-color: #6d8ca5;
  color: #f3f8ff;
}

body.theme-dark #tab-grammar .word-chip.selected {
  background: linear-gradient(180deg, #2e6fa5, #245885);
  border-color: #84b9ea;
  color: #ffffff;
}

body.theme-dark .step-chip {
  background: #263d36;
  border-color: #4a6b60;
  color: #eaf8f1;
}

body.theme-dark .tab-nav {
  background: #1b2f29;
  border-color: #385a4f;
}

body.theme-dark .step-chip.active {
  background: linear-gradient(180deg, #e49b37, #ca6a27);
  border-color: #ebaf66;
  color: #ffffff;
}

body.theme-dark .path-chip.active {
  background: linear-gradient(180deg, #2e6fa5, #245885);
  border-color: #84b9ea;
}

body.theme-dark .order-fixed {
  background: #243a33;
  border-color: #4a6b60;
}

body.theme-dark #ex-question .question-instruction,
body.theme-dark #sentence-box .question-instruction {
  border-color: #5d7f9b;
  background: #253a49;
  color: #e9f5ff;
}

body.theme-dark #ex-question .question-label,
body.theme-dark #sentence-box .question-label {
  color: #c7dff2;
}

body.theme-dark #ex-question .question-bank,
body.theme-dark #sentence-box .question-bank {
  border-color: #5d7f9b;
  background: #243945;
}

body.theme-dark #ex-question .question-answer,
body.theme-dark #sentence-box .question-answer {
  border-color: #7da8cb;
  background: #213441;
}

body.theme-dark #ex-question .word-chip,
body.theme-dark #sentence-box .word-chip {
  border-color: #7da8cb;
  background: #2b4453;
  color: #f1f8ff;
}

body.theme-dark #ex-question .word-chip:hover,
body.theme-dark #sentence-box .word-chip:hover {
  background: #36586d;
}

body.theme-dark #ex-question .question-answer .word-chip,
body.theme-dark #sentence-box .question-answer .word-chip {
  background: #306182;
  border-color: #9dc8ed;
  color: #ffffff;
}

body.theme-dark #ex-question .button-row .ghost-btn,
body.theme-dark #sentence-box .button-row .ghost-btn {
  background: #2b4453;
  border-color: #7da8cb;
  color: #f1f8ff;
}

body.theme-dark #ex-question .button-row .ghost-btn:hover,
body.theme-dark #sentence-box .button-row .ghost-btn:hover {
  background: #36586d;
}

body.theme-dark .motivation-quote {
  background: #21372f;
  border-color: #4a6b60;
  color: #eaf8f1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(6, 20, 15, 0.45);
  display: grid;
  place-items: center;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-right: calc(1rem + env(safe-area-inset-right));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  padding-left: calc(1rem + env(safe-area-inset-left));
}

.modal.hidden {
  display: none;
}

.modal-card {
  max-width: 520px;
  width: 100%;
  max-height: 88dvh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.modal-card p {
  line-height: 1.5;
}

@media (min-width: 780px) {
  .app-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col > .card {
    height: 100%;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding-top: calc(0.8rem + env(safe-area-inset-top));
    padding-right: calc(0.6rem + env(safe-area-inset-right));
    padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
    padding-left: calc(0.6rem + env(safe-area-inset-left));
  }

  .header-tools {
    width: 100%;
  }

  .header-tools .ghost-btn {
    width: 100%;
  }

  .card {
    padding: 0.85rem;
  }

  .tab-nav {
    padding-bottom: 0.4rem;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row > button {
    width: 100%;
  }

  .vocab-list {
    max-height: 300px;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: clamp(1.45rem, 7.2vw, 1.9rem);
  }

  h2 {
    font-size: clamp(1.18rem, 6vw, 1.45rem);
  }

  .tab-nav {
    gap: 0.4rem;
  }

  .tab-btn {
    font-size: 0.92rem;
    padding: 0.62rem 0.72rem;
  }

  .order-item {
    grid-template-columns: 1.7rem 1fr;
  }

  .order-controls {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  textarea {
    min-height: 200px;
  }
}

@media (min-width: 760px) {
  .layout {
    grid-template-columns: 240px 1fr;
    align-items: start;
  }

  .tab-nav {
    display: grid;
    gap: 0.6rem;
    position: sticky;
    top: 0.8rem;
    align-content: start;
    overflow: visible;
  }

  .tab-btn {
    text-align: left;
    width: 100%;
  }
}

/* Modern UI refresh (April 2026) */
:root {
  --bg: #f3f8ff;
  --surface: #ffffff;
  --surface-soft: #f6faff;
  --text: #11293d;
  --muted: #4a6174;
  --primary: #0f9b72;
  --primary-strong: #0a7b5a;
  --danger: #cb4d40;
  --danger-strong: #a7392f;
  --border: #c2d6e8;
  --shadow: 0 18px 34px rgba(16, 41, 61, 0.11);
  --focus: #0c66cc;
  --radius-sm: 0.75rem;
  --radius-md: 1rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.5rem;
}

body.theme-dark {
  --bg: #0f1a24;
  --surface: #172634;
  --surface-soft: #213546;
  --text: #edf4fb;
  --muted: #c0cfdd;
  --primary: #2fba8f;
  --primary-strong: #219d75;
  --danger: #dc695d;
  --danger-strong: #c15045;
  --border: #3f5b73;
  --shadow: 0 16px 32px rgba(2, 8, 14, 0.42);
  --focus: #8bc4ff;
}

html {
  scroll-behavior: smooth;
}

body {
  line-height: 1.45;
}

.app-shell {
  width: min(1320px, 100%);
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-right: calc(0.85rem + env(safe-area-inset-right));
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  padding-left: calc(0.85rem + env(safe-area-inset-left));
}

.app-header {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2.2vw, 1.4rem);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.84rem;
}

.subhead {
  font-size: 1.01rem;
}

.header-tools {
  align-items: stretch;
}

.layout {
  gap: 1.1rem;
}

main {
  gap: 1rem;
}

.tab-panel.active {
  display: grid;
  gap: 1rem;
}

.tab-nav {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border-radius: var(--radius-md);
  border-width: 1px;
  min-height: 52px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.tab-icon {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 900;
  color: #0f3958;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(17, 49, 71, 0.2);
  flex: 0 0 auto;
}

.tab-label {
  display: inline-block;
}

.tab-btn.active .tab-icon {
  background: rgba(255, 255, 255, 0.95);
  color: #0d3652;
  border-color: rgba(17, 49, 71, 0.3);
}

body.theme-dark .tab-nav {
  background: rgba(23, 38, 52, 0.92);
}

body.theme-dark .tab-btn {
  color: var(--text);
}

body.theme-dark .tab-icon {
  background: rgba(16, 28, 39, 0.92);
  border-color: #5d7b94;
  color: #ddecfb;
}

.panel-head {
  border-style: solid;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.93), rgba(255, 255, 255, 0.82));
  box-shadow: 0 8px 20px rgba(23, 49, 72, 0.06);
  padding: 0.9rem 1rem;
}

body.theme-dark .panel-head {
  background: linear-gradient(180deg, rgba(24, 40, 54, 0.96), rgba(20, 34, 47, 0.96));
}

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: clamp(0.88rem, 1.7vw, 1.15rem);
}

.card::before {
  height: 4px;
}

.two-col {
  align-items: stretch;
  grid-auto-rows: 1fr;
}

.two-col > .card {
  min-height: 0;
}

.exercise-stepper {
  position: sticky;
  top: 0.45rem;
  z-index: 7;
  border-radius: var(--radius-lg);
}

.step-nav {
  gap: 0.5rem;
}

.step-chip {
  border-radius: 999px;
  min-height: 38px;
  padding: 0.32rem 0.7rem;
  font-size: 0.92rem;
}

.exercise-card.active {
  min-height: 440px;
}

.exercise-box {
  gap: 0.68rem;
}

#tab-exercises .exercise-box {
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed rgba(25, 79, 114, 0.2);
  border-radius: var(--radius-md);
  padding: 0.72rem;
}

body.theme-dark #tab-exercises .exercise-box {
  background: rgba(17, 30, 42, 0.68);
  border-color: rgba(147, 188, 220, 0.36);
}

.vocab-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 0.5rem;
}

.vocab-item {
  border-radius: 0.82rem;
  background: #ffffff;
}

body.theme-dark .vocab-item {
  background: #1d3041;
}

.flashcard {
  border-radius: var(--radius-md);
  min-height: 238px;
  padding: 1rem;
}

.tag-chip,
.word-chip,
.step-chip {
  transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease;
}

.tag-chip:hover,
.word-chip:hover,
.step-chip:hover {
  transform: translateY(-1px);
}

button {
  border-radius: 0.9rem;
  border-width: 1px;
  min-height: 44px;
  padding: 0.62rem 0.95rem;
  letter-spacing: 0.01em;
}

.ok-btn,
.danger-btn,
.ghost-btn {
  box-shadow: 0 4px 10px rgba(16, 41, 61, 0.08);
}

.ghost-btn {
  background: linear-gradient(180deg, #ffffff, #f5f9ff);
}

body.theme-dark .ghost-btn {
  background: linear-gradient(180deg, #284153, #223847);
  border-color: #6a88a1;
  color: #f3f8fe;
}

body.theme-dark .ghost-btn:hover {
  background: #35546a;
}

#tab-grammar .tag-chip,
#tab-grammar .word-chip,
#tab-grammar .step-chip {
  border-color: #9fb8d3;
}

body.theme-dark #tab-grammar .tag-chip,
body.theme-dark #tab-grammar .word-chip,
body.theme-dark #tab-grammar .step-chip {
  background: #2a4254;
  border-color: #88abca;
  color: #f3f8ff;
}

body.theme-dark #tab-grammar .tag-chip.active,
body.theme-dark #tab-grammar .word-chip.selected,
body.theme-dark #tab-grammar .step-chip.active {
  background: linear-gradient(180deg, #3a8ed6, #2f72aa);
  border-color: #9ec8ec;
  color: #ffffff;
}

body.theme-dark #tab-grammar .grammar-mini,
body.theme-dark #tab-grammar .card {
  color: #edf5fd;
}

body.theme-dark #tab-grammar .status-text {
  color: #cae5ff;
}

body.theme-dark #tab-grammar .hint-text {
  color: #cfdeea;
}

body.theme-dark .choice-btn small {
  color: #d0deea;
}

body.theme-dark .feedback {
  border-color: #6f8ca6;
}

body.theme-dark .order-text,
body.theme-dark .order-fixed p,
body.theme-dark .question-label {
  color: #e3eef8;
}

@media (max-width: 759px) {
  .app-shell {
    padding-bottom: calc(6.9rem + env(safe-area-inset-bottom));
  }

  .layout {
    display: block;
  }

  .tab-nav {
    position: fixed;
    left: calc(0.6rem + env(safe-area-inset-left));
    right: calc(0.6rem + env(safe-area-inset-right));
    bottom: calc(0.48rem + env(safe-area-inset-bottom));
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.38rem;
    padding: 0.42rem;
  }

  .tab-btn {
    justify-content: center;
    flex-direction: column;
    gap: 0.22rem;
    min-height: 56px;
    padding: 0.38rem 0.2rem;
    text-align: center;
    font-size: 0.74rem;
    line-height: 1.08;
    white-space: normal;
  }

  .tab-icon {
    width: 1.45rem;
    height: 1.45rem;
    font-size: 0.74rem;
  }

  .tab-label {
    font-size: 0.72rem;
  }

  .exercise-stepper {
    top: 0.3rem;
  }

  .exercise-card.active {
    min-height: 0;
  }

  .panel-head {
    padding: 0.78rem 0.84rem;
  }
}

@media (min-width: 760px) {
  .layout {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .tab-nav {
    display: grid;
    gap: 0.58rem;
    position: sticky;
    top: 0.8rem;
    overflow: visible;
    align-content: start;
    padding: 0.55rem;
  }

  .tab-btn {
    justify-content: flex-start;
    text-align: left;
    width: 100%;
    padding: 0.6rem 0.7rem;
  }
}

@media (min-width: 980px) {
  #tab-exercises .exercise-box {
    max-height: 56dvh;
    overflow: auto;
    padding-right: 0.25rem;
  }
}

/* Compact pass for reduced scrolling */
.app-header {
  position: sticky;
  top: calc(0.24rem + env(safe-area-inset-top));
  z-index: 42;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
  padding: 0.62rem 0.74rem;
}

.mini-theme-btn {
  min-height: 30px;
  padding: 0.22rem 0.45rem;
  font-size: 0.72rem;
  border-radius: 999px;
}

.mini-inline-btn {
  min-height: 30px;
  padding: 0.2rem 0.45rem;
  font-size: 0.74rem;
  border-radius: 999px;
}

.path-content.collapsed {
  display: none;
}

.app-header h1 {
  font-size: clamp(1.08rem, 2.5vw, 1.34rem);
}

.eyebrow {
  font-size: 0.72rem;
}

.subhead {
  margin-top: 0.2rem;
  font-size: 0.87rem;
  line-height: 1.28;
}

.header-tools {
  gap: 0.42rem;
}

.header-tools .ghost-btn {
  min-height: 38px;
  padding: 0.42rem 0.72rem;
  font-size: 0.84rem;
}

.tab-panel.active {
  gap: 0.72rem;
}

.grid {
  gap: 0.72rem;
}

.panel-head {
  margin-bottom: 0.45rem;
  padding: 0.48rem 0.62rem;
  border-radius: 0.82rem;
}

.panel-head h2 {
  font-size: clamp(1rem, 2.3vw, 1.2rem);
}

.panel-head p {
  margin-top: 0.16rem;
  font-size: 0.84rem;
  line-height: 1.28;
}

.card {
  padding: clamp(0.72rem, 1.2vw, 0.92rem);
}

.card-head {
  margin-bottom: 0.5rem;
}

.exercise-stepper {
  margin-bottom: 0.55rem;
  padding: 0.68rem;
}

.exercise-stepper .card-head {
  margin-bottom: 0.34rem;
}

.step-nav {
  margin-top: 0.22rem;
}

.step-chip {
  min-height: 34px;
  padding: 0.22rem 0.52rem;
  font-size: 0.82rem;
}

body.header-compact .app-header {
  gap: 0.34rem;
  padding: 0.38rem 0.56rem;
}

body.header-compact .app-header .eyebrow,
body.header-compact .app-header .subhead {
  display: none;
}

body.header-compact .app-header h1 {
  font-size: 1rem;
}

body.header-compact .header-tools {
  gap: 0.28rem;
}

body.header-compact .header-tools .ghost-btn {
  min-height: 32px;
  padding: 0.34rem 0.56rem;
  font-size: 0.75rem;
}

@media (max-width: 759px) {
  .app-header {
    top: calc(0.12rem + env(safe-area-inset-top));
    margin-bottom: 0.45rem;
    padding: 0.48rem 0.56rem;
  }

  .app-header .eyebrow,
  .app-header .subhead {
    display: none;
  }

  .app-header h1 {
    font-size: 0.97rem;
  }

  .header-tools {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 0.24rem;
  }

  .header-tools .ghost-btn {
    min-height: 30px;
    padding: 0.2rem 0.42rem;
    font-size: 0.68rem;
  }

  .panel-head {
    margin-bottom: 0.35rem;
    padding: 0.4rem 0.5rem;
  }

  .panel-head h2 {
    font-size: 0.98rem;
  }

  .panel-head p:not(.status-text) {
    display: none;
  }

  .tab-panel.active {
    gap: 0.55rem;
  }

  .card {
    padding: 0.64rem;
  }

  .step-nav {
    gap: 0.32rem;
  }

  .step-chip {
    min-height: 30px;
    font-size: 0.74rem;
    padding: 0.16rem 0.42rem;
  }
}

/* Vokabelbereich kompakter */
#vocab-flashcards-card .flashcard {
  min-height: 120px;
  max-height: 170px;
  overflow: auto;
}

#vocab-flashcards-card .button-row {
  margin-top: 0.45rem;
}

#vocab-search-card .vocab-list {
  max-height: 58dvh;
}

/* Mobile-first compact pass for grammar + exercises */
#tab-grammar .grammar-mini {
  padding: 0.56rem;
  gap: 0.4rem;
}

#tab-exercises .panel-head {
  margin-bottom: 0.35rem;
}

#tab-exercises .exercise-stepper {
  margin-bottom: 0.4rem;
  padding: 0.52rem 0.56rem;
  position: sticky;
  top: 0;
  z-index: 5;
}

#tab-exercises #exercise-step-nav {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.08rem;
}

#tab-exercises #exercise-step-nav .step-chip {
  flex: 0 0 auto;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.34rem 0.7rem;
  font-size: 1.02rem;
  font-weight: 800;
}

#tab-exercises .exercise-card.active {
  min-height: 0;
  max-height: 54dvh;
  overflow: auto;
  padding: 0.58rem;
  gap: 0.45rem;
}

#boss-quiz-card .exercise-box {
  max-height: 36dvh;
  overflow: auto;
}

#tab-exercises .exercise-card > h3 {
  margin: 0;
}

#tab-exercises .exercise-box {
  gap: 0.45rem;
  padding: 0.52rem;
}

#tab-exercises .exercise-box p {
  margin: 0.14rem 0;
  line-height: 1.3;
}

#tab-exercises .choice-btn {
  min-height: 38px;
  padding: 0.42rem 0.56rem;
}

#tab-exercises .order-item {
  padding: 0.42rem 0.5rem;
  gap: 0.45rem;
}

#tab-exercises .order-pos {
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.8rem;
}

#tab-exercises .order-controls .ghost-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0.3rem;
}

@media (max-width: 759px) {
  #tab-grammar .panel-head p,
  #tab-exercises .panel-head p:not(.status-text) {
    display: none;
  }

  #tab-exercises #exercise-mode-hint {
    display: block !important;
    font-size: 0.72rem;
    margin-top: 0.16rem;
  }

  #tab-exercises .panel-head-inline {
    flex-wrap: nowrap;
    align-items: center;
  }

  #tab-exercises .panel-head-inline #exercise-focus {
    margin-left: auto;
    font-size: 0.76rem;
    padding: 0.24rem 0.46rem;
  }

  #tab-exercises .mode-filter {
    margin-top: 0.3rem;
    gap: 0.34rem;
  }

  #tab-exercises .mode-chip {
    min-height: 30px;
    padding: 0.16rem 0.5rem;
    font-size: 0.76rem;
  }

  #tab-grammar .grammar-mini h4 {
    font-size: 0.96rem;
  }

  #tab-exercises .exercise-stepper {
    padding: 0.42rem 0.48rem;
  }

  #tab-exercises #exercise-step-title {
    font-size: 0.95rem;
  }

  #tab-exercises #exercise-step-meta {
    font-size: 0.76rem;
  }

  #tab-exercises #exercise-step-nav .step-chip {
    min-width: 2.2rem;
    min-height: 2.2rem;
    font-size: 0.95rem;
    padding: 0.28rem 0.52rem;
  }

  #tab-exercises .exercise-card > h3 {
    display: none;
  }

  #tab-exercises .exercise-card.active {
    max-height: 47dvh;
    padding: 0.48rem;
  }

  #boss-quiz-card .exercise-box {
    max-height: 30dvh;
  }

  #tab-exercises .exercise-box {
    padding: 0.44rem;
    gap: 0.38rem;
  }

  #tab-exercises .button-row {
    flex-direction: row;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.32rem;
    margin-top: 0.34rem;
  }

  #tab-exercises .button-row > button {
    width: 100%;
    min-height: 36px;
    padding: 0.32rem 0.4rem;
    font-size: 0.8rem;
  }

  #tab-exercises .word-chip {
    min-height: 34px;
    padding: 0.34rem 0.56rem;
    font-size: 0.81rem;
  }

  #tab-exercises .order-item {
    grid-template-columns: 1.55rem 1fr auto;
    gap: 0.36rem;
    padding: 0.38rem 0.42rem;
  }

  #tab-exercises .order-pos {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.72rem;
  }
}

/* Header controls + compact sentences + extra grammar cleanup */
.app-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.42rem;
  align-items: start;
}

.header-copy {
  min-width: 0;
}

.app-header .header-copy h1 {
  margin: 0;
  font-weight: 900;
}

.header-copy-actions {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  margin-top: 0.2rem;
}

.header-settings-btn {
  min-height: 30px;
  padding: 0.16rem 0.52rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
}

.header-settings-btn.active {
  background: linear-gradient(180deg, #2f79be, #285f95);
  border-color: #285f95;
  color: #ffffff;
}

.header-settings-popover {
  margin-top: 0.22rem;
  border: 1px solid var(--border);
  border-radius: 0.88rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 250, 255, 0.94));
  padding: 0.48rem 0.52rem;
  box-shadow: var(--shadow);
}

.header-settings-popover .settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.34rem;
  margin-top: 0.24rem;
}

.header-settings-popover #exercise-error-focus {
  margin-top: 0.2rem;
  width: 100%;
}

.header-settings-popover #exercise-mode-hint {
  margin-top: 0.1rem;
}

.header-settings-popover .mode-chip {
  min-height: 32px;
  padding: 0.18rem 0.56rem;
  font-weight: 800;
}

body.theme-dark .header-settings-popover {
  background: linear-gradient(180deg, rgba(29, 47, 63, 0.96), rgba(24, 40, 54, 0.94));
  border-color: #5f7d95;
}

body.theme-dark .header-settings-btn.active {
  background: linear-gradient(180deg, #3a8ed6, #2f72aa);
  border-color: #9ec8ec;
  color: #ffffff;
}

body.theme-dark .header-settings-popover .mode-chip {
  background: #2b4453;
  border-color: #7da8cb;
  color: #f1f8ff;
}

body.theme-dark .header-settings-popover .mode-chip.active {
  background: linear-gradient(180deg, #3a8ed6, #2f72aa);
  border-color: #9dc8ed;
  color: #ffffff;
}

.app-header .header-tools.top-tools {
  width: auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.36rem;
  flex-wrap: nowrap;
  margin: 0;
}

.app-header .header-tools.top-tools .mini-theme-btn {
  min-height: 30px;
  padding: 0.2rem 0.5rem;
  font-size: 0.73rem;
}

#header-library-btn.active {
  background: linear-gradient(180deg, #2f79be, #285f95);
  border-color: #285f95;
  color: #ffffff;
}

body.theme-dark #header-library-btn.active {
  background: linear-gradient(180deg, #3a8ed6, #2f72aa);
  border-color: #9ec8ec;
  color: #ffffff;
}

#tab-sentences .panel-head {
  margin-bottom: 0.35rem;
}

#tab-sentences .two-col {
  gap: 0.6rem;
}

#tab-sentences .card {
  padding: 0.58rem;
}

#tab-sentences #sentence-box {
  max-height: 54dvh;
  overflow: auto;
  gap: 0.42rem;
  padding-right: 0.14rem;
}

#tab-sentences #sentence-box p {
  margin: 0.14rem 0;
  line-height: 1.3;
}

#tab-sentences #sentence-box .question-instruction {
  margin: 0.1rem 0 0;
  padding: 0.42rem 0.5rem;
  font-size: 0.84rem;
}

#tab-sentences #sentence-box .question-bank {
  padding: 0.38rem;
}

#tab-sentences #sentence-box .question-answer {
  min-height: 44px;
  padding: 0.38rem;
}

#tab-sentences #sentence-box .word-chip {
  min-height: 34px;
  padding: 0.32rem 0.56rem;
  font-size: 0.81rem;
}

#tab-sentences #sentence-box .button-row {
  margin-top: 0.28rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.32rem;
}

#tab-sentences #sentence-box .button-row .ok-btn {
  grid-column: 1 / -1;
}

#tab-sentences #sentence-box .button-row button {
  min-height: 36px;
  padding: 0.3rem 0.42rem;
  font-size: 0.8rem;
}

#tab-grammar .grammar-stepper {
  margin-bottom: 0.4rem;
  padding: 0.52rem 0.56rem;
  position: sticky;
  top: 0;
  z-index: 5;
}

#tab-grammar #grammar-step-nav {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.32rem;
  margin-top: 0.58rem;
}

#tab-grammar #grammar-category-filter {
  margin-top: 0.5rem;
  margin-bottom: 0.05rem;
  gap: 0.34rem;
}

#tab-grammar #grammar-category-filter .tag-chip {
  min-height: 32px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 800;
}

#tab-grammar #grammar-step-nav .step-chip {
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.24rem 0;
  font-size: 1.02rem;
  font-weight: 800;
  justify-content: center;
}

#tab-grammar #grammar-concept-box {
  max-height: 56dvh;
  overflow: auto;
  padding-right: 0.14rem;
}

@media (max-width: 759px) {
  .app-header .header-tools.top-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .app-header .header-copy .eyebrow,
  .app-header .header-copy .subhead {
    display: none;
  }

  .app-header .header-copy h1 {
    font-size: 0.94rem;
  }

  #tab-grammar .grammar-stepper {
    padding: 0.42rem 0.48rem;
  }

  #tab-grammar #grammar-step-title {
    font-size: 0.95rem;
  }

  #tab-grammar #grammar-category-filter {
    margin-top: 0.36rem;
    gap: 0.28rem;
  }

  #tab-grammar #grammar-category-filter .tag-chip {
    min-height: 28px;
    padding: 0.15rem 0.46rem;
    font-size: 0.74rem;
  }

  #tab-grammar #grammar-step-meta {
    font-size: 0.76rem;
  }

  #tab-grammar #grammar-step-nav .step-chip {
    min-width: 0;
    min-height: 2.05rem;
    font-size: 0.9rem;
    padding: 0.18rem 0;
  }

  #tab-grammar #grammar-concept-box {
    max-height: 46dvh;
  }

  #tab-sentences .card-head {
    margin-bottom: 0.38rem;
  }

  #tab-sentences #sentence-box {
    max-height: 46dvh;
  }
}

/* =========================================================
   UI Redesign v3 (April 2026)
   Ziel: modernes, kindgerechtes, kompaktes Interface
   ========================================================= */
:root {
  --bg: #f2f9ff;
  --surface: #ffffff;
  --surface-soft: #f6fbff;
  --text: #0f2c43;
  --muted: #49667d;
  --primary: #11936b;
  --primary-strong: #0d7857;
  --danger: #cf4f45;
  --danger-strong: #ae3b32;
  --border: #c6d9ea;
  --shadow: 0 14px 34px rgba(16, 50, 76, 0.12);
}

body.theme-dark {
  --bg: #0f1d29;
  --surface: #182938;
  --surface-soft: #223a4d;
  --text: #edf5fd;
  --muted: #bfd1e1;
  --primary: #31ba91;
  --primary-strong: #239a76;
  --danger: #df6d62;
  --danger-strong: #c7554b;
  --border: #4a657d;
  --shadow: 0 16px 34px rgba(3, 10, 17, 0.42);
}

body {
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", Verdana, sans-serif;
  background:
    radial-gradient(circle at 7% 8%, rgba(96, 184, 255, 0.26), transparent 36%),
    radial-gradient(circle at 92% 10%, rgba(255, 180, 140, 0.18), transparent 33%),
    radial-gradient(circle at 14% 92%, rgba(73, 203, 161, 0.2), transparent 37%),
    linear-gradient(180deg, #f9fcff 0%, var(--bg) 62%);
  color: var(--text);
}

body.theme-dark {
  background:
    radial-gradient(circle at 5% 8%, rgba(56, 113, 160, 0.32), transparent 35%),
    radial-gradient(circle at 95% 8%, rgba(114, 69, 62, 0.25), transparent 33%),
    radial-gradient(circle at 15% 95%, rgba(33, 115, 93, 0.3), transparent 34%),
    linear-gradient(180deg, #101f2b 0%, var(--bg) 64%);
}

.app-shell {
  width: min(1260px, 100%);
  padding-top: calc(0.72rem + env(safe-area-inset-top));
  padding-right: calc(0.78rem + env(safe-area-inset-right));
  padding-left: calc(0.78rem + env(safe-area-inset-left));
}

.app-header {
  position: sticky;
  top: calc(0.2rem + env(safe-area-inset-top));
  z-index: 45;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.56rem;
  padding: 0.56rem 0.66rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(241, 249, 255, 0.86));
  backdrop-filter: blur(9px);
  box-shadow: var(--shadow);
}

body.theme-dark .app-header {
  background: linear-gradient(135deg, rgba(28, 48, 65, 0.94), rgba(22, 39, 53, 0.9));
}

.app-header .header-copy h1 {
  font-size: clamp(1rem, 2.5vw, 1.22rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--text);
}

.app-header .header-tools.top-tools {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}

.app-header .header-tools.top-tools .mini-theme-btn {
  min-height: 32px;
  border-radius: 999px;
  padding: 0.18rem 0.62rem;
  font-size: 0.76rem;
  font-weight: 800;
  border: 1px solid var(--border);
}

.layout {
  gap: 0.72rem;
}

main {
  display: grid;
  gap: 0.62rem;
}

.tab-panel.active {
  display: grid;
  gap: 0.62rem;
}

.tab-nav {
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

body.theme-dark .tab-nav {
  background: rgba(24, 41, 56, 0.9);
}

.tab-btn {
  min-height: 48px;
  border-radius: 0.82rem;
  border: 1px solid var(--tab-border, var(--border));
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.tab-btn.active {
  box-shadow: 0 6px 14px rgba(11, 89, 66, 0.24);
}

.tab-subnav {
  display: none;
}

.vocab-mobile-subnav {
  display: none;
}

.tab-subbtn {
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  background: linear-gradient(180deg, #ffffff, #f2f8ff);
  color: var(--text);
  min-height: 34px;
  padding: 0.2rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.tab-subbtn.active {
  background: linear-gradient(180deg, #24b180, #0f936b);
  border-color: #0f936b;
  color: #ffffff;
}

body.theme-dark .tab-subbtn {
  background: linear-gradient(180deg, #2a4458, #233a4b);
  border-color: #6b8ca4;
  color: #edf5fd;
}

body.theme-dark .tab-subbtn.active {
  background: linear-gradient(180deg, #32b68f, #249673);
  border-color: #67d4af;
}

.tab-icon {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 49, 74, 0.24);
}

.card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 252, 255, 0.96));
  padding: 0.72rem 0.76rem;
}

body.theme-dark .card {
  background: linear-gradient(180deg, rgba(29, 48, 65, 0.98), rgba(24, 41, 56, 0.98));
}

.card::before {
  height: 5px;
}

.panel-head {
  margin-bottom: 0.36rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.92rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 252, 255, 0.86));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

body.theme-dark .panel-head {
  background: linear-gradient(180deg, rgba(36, 58, 77, 0.92), rgba(29, 47, 62, 0.9));
}

.panel-head-inline {
  gap: 0.34rem;
}

#exercise-focus {
  padding: 0.26rem 0.52rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
}

body.theme-dark #exercise-focus {
  background: rgba(28, 48, 64, 0.95);
  border-color: #5f8097;
  color: #e6f2fd;
}

.exercise-stepper,
#tab-grammar .grammar-stepper {
  position: sticky;
  top: calc(3.5rem + env(safe-area-inset-top));
  z-index: 10;
  border-radius: 0.98rem;
  border: 1px solid #e5c086;
  background: linear-gradient(180deg, #fff8ea, #fff2de);
}

body.theme-dark .exercise-stepper,
body.theme-dark #tab-grammar .grammar-stepper {
  border-color: #7e6644;
  background: linear-gradient(180deg, #3d3427, #342b1f);
}

.step-nav {
  gap: 0.34rem;
}

.step-chip {
  min-height: 36px;
  padding: 0.24rem 0.56rem;
  border-radius: 999px;
  font-size: 0.82rem;
}

.step-chip.active {
  box-shadow: 0 5px 12px rgba(226, 125, 39, 0.3);
}

.tag-chip {
  border-radius: 999px;
  min-height: 33px;
  padding: 0.22rem 0.62rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.flashcard {
  min-height: 138px;
  max-height: 188px;
  overflow: auto;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #f6fbff);
}

body.theme-dark .flashcard {
  background: linear-gradient(180deg, #243c50, #1f3446);
  border-color: #5c7b93;
}

.button-row {
  margin-top: 0.5rem;
  gap: 0.38rem;
}

.button-row.compact-row {
  margin-top: 0.24rem;
}

.button-row.compact-row .ghost-btn,
.button-row.compact-row .ok-btn {
  min-height: 34px;
  padding: 0.2rem 0.56rem;
  font-size: 0.76rem;
}

#exercise-error-focus.active {
  background: linear-gradient(180deg, #24b180, #0f936b);
  border-color: #0f936b;
  color: #ffffff;
}

body.theme-dark #exercise-error-focus.active {
  background: linear-gradient(180deg, #32b68f, #249673);
  border-color: #67d4af;
}

button {
  min-height: 38px;
  border-radius: 0.8rem;
  font-size: 0.83rem;
  font-weight: 800;
}

.ok-btn {
  background: linear-gradient(180deg, #24b180, #0f936b);
  border-color: #0f936b;
}

.danger-btn {
  background: linear-gradient(180deg, #db6459, #c74b40);
  border-color: #c74b40;
}

.ghost-btn {
  background: linear-gradient(180deg, #ffffff, #f2f8ff);
}

body.theme-dark .ghost-btn {
  background: linear-gradient(180deg, #2a4458, #233a4b);
  border-color: #6b8ca4;
}

.exercise-card.active {
  min-height: 0;
  max-height: 55dvh;
  overflow: auto;
  padding: 0.58rem;
}

#tab-exercises .exercise-box,
#tab-grammar #grammar-concept-box,
#boss-quiz-card .exercise-box,
#tab-sentences #sentence-box {
  scrollbar-width: thin;
}

#tab-exercises .choice-btn,
#boss-quiz-card .choice-btn {
  min-height: 37px;
  padding: 0.38rem 0.54rem;
}

#boss-quiz-card {
  border-color: #f0c170;
  background: linear-gradient(180deg, #fff8e9, #fff3df);
}

body.theme-dark #boss-quiz-card {
  border-color: #7d6641;
  background: linear-gradient(180deg, #3b3223, #32291d);
}

.mission-item {
  border-radius: 0.82rem;
  padding: 0.5rem 0.58rem;
}

.mission-progress {
  height: 8px;
  border-radius: 999px;
}

#tab-library .vocab-list {
  max-height: 54dvh;
}

#tab-errors .errors-list {
  max-height: 50dvh;
  overflow: auto;
  scrollbar-width: thin;
}

#tab-grammar #grammar-concept-box {
  max-height: 52dvh;
}

@media (min-width: 760px) {
  .layout {
    grid-template-columns: 232px minmax(0, 1fr);
    align-items: start;
  }

  .tab-nav {
    position: sticky;
    top: calc(4rem + env(safe-area-inset-top));
    padding: 0.52rem;
    gap: 0.46rem;
  }

  .tab-btn {
    min-height: 44px;
    padding: 0.46rem 0.56rem;
    text-align: left;
  }

  .tab-subnav:not(.hidden) {
    display: grid;
    gap: 0.3rem;
    margin-top: -0.08rem;
    margin-bottom: 0.12rem;
    padding: 0.34rem;
    border: 1px dashed var(--border);
    border-radius: 0.82rem;
    background: rgba(255, 255, 255, 0.72);
  }

  body.theme-dark .tab-subnav:not(.hidden) {
    background: rgba(31, 52, 68, 0.8);
    border-color: #5f7d95;
  }

  .tab-icon {
    width: 1.58rem;
    height: 1.58rem;
    font-size: 0.84rem;
  }
}

@media (max-width: 759px) {
  .tab-subnav {
    display: none !important;
  }

  .vocab-mobile-subnav:not(.hidden) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.34rem;
    margin-top: 0.08rem;
  }

  .app-shell {
    padding-bottom: calc(6.2rem + env(safe-area-inset-bottom));
  }

  .app-header {
    top: calc(0.08rem + env(safe-area-inset-top));
    padding: 0.42rem 0.5rem;
    border-radius: 0.86rem;
  }

  .app-header .header-copy h1 {
    font-size: 0.92rem;
  }

  .app-header .header-tools.top-tools .mini-theme-btn {
    min-height: 28px;
    padding: 0.14rem 0.46rem;
    font-size: 0.68rem;
  }

  .tab-nav {
    left: calc(0.45rem + env(safe-area-inset-left));
    right: calc(0.45rem + env(safe-area-inset-right));
    bottom: calc(0.4rem + env(safe-area-inset-bottom));
    border-radius: 0.96rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.28rem;
    padding: 0.32rem;
  }

  .tab-btn {
    min-height: 52px;
    padding: 0.28rem 0.14rem;
    font-size: 0.69rem;
    line-height: 1.08;
    border-radius: 0.72rem;
  }

  .tab-icon {
    width: 1.36rem;
    height: 1.36rem;
    font-size: 0.72rem;
  }

  .tab-label {
    font-size: 0.66rem;
  }

  .panel-head {
    padding: 0.38rem 0.45rem;
  }

  .panel-head p:not(.status-text) {
    display: none;
  }

  #tab-exercises #exercise-mode-hint {
    display: block !important;
    font-size: 0.7rem;
    line-height: 1.2;
    margin-top: 0.12rem;
  }

  .card {
    padding: 0.56rem;
    border-radius: 0.9rem;
  }

  .exercise-stepper,
  #tab-grammar .grammar-stepper {
    top: calc(2.9rem + env(safe-area-inset-top));
    padding: 0.42rem;
  }

  .step-chip {
    min-height: 33px;
    min-width: 2.08rem;
    font-size: 0.86rem;
    padding: 0.16rem 0.38rem;
  }

  .exercise-card.active {
    max-height: 49dvh;
    padding: 0.44rem;
  }

  #tab-exercises .exercise-box {
    padding: 0.42rem;
  }

  #tab-exercises .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.28rem;
  }

  #tab-exercises .button-row > button {
    min-height: 34px;
    font-size: 0.77rem;
    padding: 0.26rem 0.34rem;
  }

  #tab-exercises .compact-row {
    grid-template-columns: 1fr;
  }

  #tab-exercises .word-chip,
  #tab-sentences #sentence-box .word-chip {
    min-height: 32px;
    font-size: 0.78rem;
    padding: 0.28rem 0.5rem;
  }

  #tab-grammar #grammar-step-nav {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.24rem;
    margin-top: 0.45rem;
  }

  #tab-grammar #grammar-step-nav .step-chip {
    min-height: 1.92rem;
    font-size: 0.82rem;
    padding: 0;
  }

  #tab-grammar #grammar-concept-box {
    max-height: 45dvh;
  }
}

/* Abenteuerkarte + Ereigniskarte + Dialog-Simulator */

.adventure-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
}

.station-btn {
  display: grid;
  gap: 0.16rem;
  justify-items: start;
  align-content: start;
  text-align: left;
  min-height: 108px;
  border-radius: 0.82rem;
  border: 1px solid #a7c9e2;
  background: linear-gradient(180deg, #f8fcff, #eef7ff);
  padding: 0.52rem 0.56rem;
}

.station-btn:hover {
  background: #e8f4ff;
}

.station-btn.done {
  border-color: #53b88d;
  background: linear-gradient(180deg, #e6faef, #d7f4e6);
}

.station-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.station-label {
  font-size: 0.86rem;
  font-weight: 900;
  color: var(--text);
}

.station-desc {
  font-size: 0.75rem;
  color: var(--muted);
}

.station-open {
  font-size: 0.72rem;
  font-weight: 800;
  color: #1e5f8f;
}

.station-meta {
  font-size: 0.7rem;
  font-weight: 800;
  color: #205780;
}

body.theme-dark .station-btn {
  border-color: #5e7f99;
  background: linear-gradient(180deg, #244055, #20374a);
}

body.theme-dark .station-btn:hover {
  background: #2a485e;
}

body.theme-dark .station-btn.done {
  border-color: #5fbf9a;
  background: linear-gradient(180deg, #255243, #22483c);
}

body.theme-dark .station-meta {
  color: #c7dcf0;
}

body.theme-dark .station-open {
  color: #b7d7f1;
}

#adventure-action {
  margin-top: 0.28rem;
  font-weight: 700;
}

#adventure-action.good {
  color: #156845;
}

#adventure-action.bad {
  color: #9a3f36;
}

body.theme-dark #adventure-action.good {
  color: #9fe4c4;
}

body.theme-dark #adventure-action.bad {
  color: #ffcfc9;
}

#event-card .exercise-box {
  max-height: 34dvh;
  overflow: auto;
  padding-right: 0.14rem;
}

#dialog-card .exercise-box {
  max-height: none;
  overflow: visible;
  padding-right: 0;
  gap: 0.42rem;
}

.event-title {
  margin: 0;
  font-size: 0.95rem;
}

.dialog-line {
  margin: 0.1rem 0;
}

.dialog-compact {
  margin: 0.14rem 0;
  line-height: 1.25;
}

#dialog-card .dialog-actions {
  margin-top: 0.24rem;
}

#dialog-card > .button-row {
  margin-top: 0.3rem;
  justify-content: flex-end;
}

#dialog-card > .button-row .ghost-btn {
  min-height: 32px;
  padding: 0.22rem 0.5rem;
  font-size: 0.74rem;
}

#event-card .choice-btn,
#dialog-card .choice-btn {
  min-height: 36px;
  padding: 0.34rem 0.5rem;
}

body.theme-dark #event-card .choice-btn,
body.theme-dark #dialog-card .choice-btn {
  background: linear-gradient(180deg, #2c475b, #253d50);
  border-color: #6f8faa;
  color: #edf4fb;
}

body.theme-dark #event-card .choice-btn.selected,
body.theme-dark #dialog-card .choice-btn.selected {
  background: #38627d;
  border-color: #9dc8ed;
  color: #ffffff;
}

@media (max-width: 759px) {
  .adventure-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.38rem;
  }

  .station-btn {
    min-height: 90px;
    padding: 0.4rem 0.44rem;
    gap: 0.1rem;
  }

  .station-icon {
    font-size: 0.96rem;
  }

  .station-label {
    font-size: 0.78rem;
  }

  .station-desc,
  .station-open,
  .station-meta {
    font-size: 0.66rem;
    line-height: 1.2;
  }

  #event-card .exercise-box {
    max-height: 33dvh;
  }
}

/* Fehlerheft 2.0 + Badges + Wochenbericht */
#errors-review-meta {
  margin-top: 0.2rem;
  font-weight: 700;
}

.badges-list {
  display: grid;
  gap: 0.45rem;
}

.badge-item {
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  padding: 0.48rem 0.54rem;
  background: var(--surface-soft);
}

.badge-item p {
  margin: 0.12rem 0;
}

.badge-item .badge-meta {
  margin-top: 0.22rem;
  font-size: 0.74rem;
  font-weight: 800;
  color: #3d6487;
}

.badge-item.unlocked {
  border-color: #55b78f;
  background: linear-gradient(180deg, #e8f9f0, #ddf5e8);
}

.badge-item.locked {
  opacity: 0.9;
}

body.theme-dark .badge-item {
  background: #243a4d;
  border-color: #64859f;
}

body.theme-dark .badge-item.unlocked {
  background: linear-gradient(180deg, #225342, #1d4739);
  border-color: #68c7a4;
}

body.theme-dark .badge-item .badge-meta {
  color: #c2daf0;
}

/* Geräteprofile für iPhone/Android */
body.device-ios .tab-nav {
  bottom: calc(0.52rem + env(safe-area-inset-bottom));
}

body.device-ios.viewport-short .tab-nav {
  bottom: calc(0.32rem + env(safe-area-inset-bottom));
}

body.device-ios.viewport-short .app-shell,
body.device-android.viewport-short .app-shell {
  padding-bottom: calc(6.7rem + env(safe-area-inset-bottom));
}

body.viewport-short #tab-exercises .exercise-card.active,
body.viewport-short #tab-sentences #sentence-box,
body.viewport-short #tab-grammar #grammar-concept-box,
body.viewport-short #event-card .exercise-box {
  max-height: 40dvh;
}

body.viewport-narrow .app-header .header-tools.top-tools {
  flex-wrap: wrap;
  row-gap: 0.2rem;
}

body.viewport-narrow .app-header .header-tools.top-tools .mini-theme-btn {
  min-height: 26px;
  font-size: 0.64rem;
  padding: 0.1rem 0.38rem;
}

.pulse-highlight {
  box-shadow: 0 0 0 2px rgba(31, 143, 87, 0.45), 0 0 0 6px rgba(31, 143, 87, 0.14);
  border-radius: 0.82rem;
}

body.theme-dark .pulse-highlight {
  box-shadow: 0 0 0 2px rgba(126, 201, 168, 0.5), 0 0 0 6px rgba(126, 201, 168, 0.16);
}

body.viewport-landscape #tab-exercises .exercise-card.active,
body.viewport-landscape #tab-grammar #grammar-concept-box,
body.viewport-landscape #tab-sentences #sentence-box {
  max-height: 44dvh;
}

@media (max-width: 759px) {
  .badge-item {
    padding: 0.42rem 0.46rem;
  }
}

/* Final UI Stabilization (mobile + accessibility) */
#tab-sentences .sentence-card {
  display: none;
}

#tab-sentences .sentence-card.active {
  display: grid;
  align-content: start;
  min-height: 0;
  max-height: 56dvh;
  overflow: auto;
  gap: 0.5rem;
}

#tab-sentences #sentence-step-nav .step-chip {
  min-width: 2.35rem;
  min-height: 2.35rem;
  font-size: 0.96rem;
  font-weight: 900;
}

#tab-exercises #exercise-step-nav .step-chip {
  min-width: 2.45rem;
  min-height: 2.45rem;
  font-size: 1rem;
  font-weight: 900;
}

#tab-exercises #exercise-step-nav .step-chip.boss-chip {
  min-width: 2.8rem;
}

#ex-card-event .exercise-box {
  max-height: 36dvh;
  overflow: auto;
}

#ex-card-boss .exercise-box {
  max-height: 38dvh;
  overflow: auto;
}

#sentence-card-dialog .exercise-box {
  max-height: 36dvh;
  overflow: auto;
}

#sentence-card-dialog .choice-btn,
#ex-card-event .choice-btn,
#ex-card-boss .choice-btn {
  min-height: 38px;
}

.vocab-boxes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.48rem;
}

.vocab-box-card {
  border: 1px solid var(--border);
  border-radius: 0.84rem;
  background: linear-gradient(180deg, #ffffff, #f3f9ff);
  padding: 0.54rem;
  text-align: center;
  display: grid;
  gap: 0.26rem;
}

.vocab-box-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 900;
}

.vocab-box-count,
.vocab-box-due {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

.vocab-box-card .ghost-btn {
  min-height: 34px;
  padding: 0.18rem 0.52rem;
  font-size: 0.74rem;
}

body.theme-dark .vocab-box-card {
  background: linear-gradient(180deg, #22384b, #1e3040);
  border-color: #5f7f97;
}

body.theme-dark .vocab-box-count,
body.theme-dark .vocab-box-due {
  color: #cfe0ef;
}

.adventure-map {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 0.62rem;
}

.station-btn {
  position: relative;
  display: grid;
  place-items: center;
  place-content: center;
  text-align: center;
  gap: 0.28rem;
  flex: 1 1 172px;
  width: min(220px, 100%);
  min-width: 160px;
  max-width: 220px;
  min-height: 136px;
  border: 2px solid #b8c8d8;
  border-radius: 1rem;
  background: linear-gradient(180deg, #f4f6f9, #e7ecf2);
  padding: 0.56rem 0.54rem;
  overflow: hidden;
}

.station-icon {
  font-size: 2.15rem;
  line-height: 1;
}

.station-label {
  font-size: 0.88rem;
  font-weight: 900;
  width: 100%;
  text-align: center;
  z-index: 1;
}

.station-goal {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  width: 100%;
  text-align: center;
  z-index: 1;
}

.station-stamp {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 90px;
  height: 90px;
  margin-left: -45px;
  margin-top: -46px;
  border: 6px solid #21a868;
  color: #21a868;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transform: rotate(-11deg);
  background: radial-gradient(circle, rgba(213, 255, 233, 0.55) 0%, rgba(165, 245, 206, 0.25) 72%, rgba(114, 224, 169, 0.2) 100%);
  box-shadow: inset 0 0 0 2px rgba(236, 255, 246, 0.4), 0 0 0 1px rgba(33, 168, 104, 0.18);
  pointer-events: none;
}

.station-stamp-icon {
  font-size: 2.05rem;
  line-height: 1;
  filter: saturate(1.15) contrast(1.05);
}

.station-btn.done {
  border-color: #49b184;
  background: linear-gradient(180deg, #e3faef, #d2f2e2);
}

.station-btn.done .station-icon,
.station-btn.done .station-label,
.station-btn.done .station-goal {
  display: none;
}

body.theme-dark .station-btn {
  border-color: #5f768b;
  background: linear-gradient(180deg, #2a3642, #25323d);
}

body.theme-dark .station-goal {
  color: #c8d9e8;
}

body.theme-dark .station-btn.done {
  border-color: #5dc49d;
  background: linear-gradient(180deg, #255343, #21463a);
}

body.theme-dark .station-stamp {
  border-color: #56d59b;
  color: #bdf5da;
  background: radial-gradient(circle, rgba(46, 115, 85, 0.45) 0%, rgba(34, 92, 67, 0.36) 72%, rgba(24, 69, 49, 0.24) 100%);
  box-shadow: inset 0 0 0 2px rgba(191, 247, 223, 0.18), 0 0 0 1px rgba(86, 213, 155, 0.34);
}

#tab-grammar .grammar-mini + .grammar-mini {
  margin-top: 0.62rem;
}

.session-code-value {
  margin: 0.2rem 0 0;
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  background: var(--surface-soft);
  padding: 0.52rem 0.62rem;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: all;
}

.session-code-value:hover {
  border-color: #2f7eb1;
}

.session-code-value:focus-visible {
  outline: 2px solid #2f7eb1;
  outline-offset: 2px;
}

.session-load-wrap {
  margin-top: 0.55rem;
}

.session-load-wrap label {
  display: block;
  margin-bottom: 0.24rem;
  font-weight: 700;
  font-size: 0.82rem;
}

.session-load-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.42rem;
}

#session-load-input {
  width: 100%;
  min-height: 38px;
  border-radius: 0.64rem;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  padding: 0.45rem 0.62rem;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#session-load-btn {
  min-height: 38px;
  white-space: nowrap;
}

body.theme-dark #session-load-input {
  border-color: #59706a;
  background: #253832;
  color: #f2f8f5;
}

body.theme-dark .session-code-value:hover {
  border-color: #8fc4ea;
}

body.theme-dark .session-code-value:focus-visible {
  outline-color: #8fc4ea;
}

.app-header .header-tools.top-tools {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  width: auto;
  max-width: none;
}

.app-header .header-tools.top-tools .mini-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  width: auto;
}

.header-stars-btn {
  margin-top: 0.12rem;
  min-height: 30px;
  padding: 0.16rem 0.52rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
  color: #176f4a;
}

.header-stars-btn.active {
  background: linear-gradient(180deg, #24b180, #0f936b);
  border-color: #0f936b;
  color: #ffffff;
}

.header-path-popover {
  margin-top: 0.22rem;
  border: 1px solid var(--border);
  border-radius: 0.88rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 250, 255, 0.94));
  padding: 0.48rem 0.52rem;
  box-shadow: var(--shadow);
}

.header-path-popover .tag-filter {
  margin-top: 0.3rem;
}

#header-path-btn.active {
  background: linear-gradient(180deg, #24b180, #0f936b);
  border-color: #0f936b;
  color: #ffffff;
}

body.theme-dark .header-path-popover {
  background: linear-gradient(180deg, rgba(29, 47, 63, 0.96), rgba(24, 40, 54, 0.94));
  border-color: #5f7d95;
}

body.theme-dark #header-path-btn.active {
  background: linear-gradient(180deg, #32b68f, #249673);
  border-color: #67d4af;
}

.sticker-album {
  margin-top: 0.22rem;
  border: 1px solid var(--border);
  border-radius: 0.88rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 250, 255, 0.94));
  padding: 0.48rem 0.52rem;
  box-shadow: var(--shadow);
}

.sticker-album-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem;
}

.sticker-item {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: 0.88rem;
  padding: 0;
  background: linear-gradient(180deg, #f8fbff, #eef6ff);
  text-align: center;
  box-shadow: 0 6px 16px rgba(30, 66, 98, 0.08);
  perspective: 800px;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.sticker-item:active {
  transform: scale(0.98);
}

.sticker-item.unlocked {
  border-color: #50bb8d;
  background: linear-gradient(180deg, #f3fff8 0%, #e8fdf0 45%, #ddf8ff 100%);
  box-shadow: 0 8px 18px rgba(39, 132, 102, 0.17);
}

.sticker-item.unlocked::before {
  content: "";
  position: absolute;
  inset: -18%;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 30%, rgba(255, 255, 255, 0.95) 0 3px, transparent 4px),
    radial-gradient(circle at 78% 12%, rgba(255, 247, 178, 0.85) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 78%, rgba(203, 255, 246, 0.75) 0 3px, transparent 4px),
    radial-gradient(circle at 85% 72%, rgba(255, 219, 232, 0.72) 0 2px, transparent 3px);
  opacity: 0.92;
  animation: stickerSparkle 2.8s ease-in-out infinite alternate;
}

.sticker-item.unlocked::after {
  content: "";
  position: absolute;
  top: -45%;
  left: -52%;
  width: 62%;
  height: 190%;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.9) 48%, transparent 100%);
  transform: rotate(12deg);
  animation: stickerShine 3.8s ease-in-out infinite;
}

.sticker-item.flipped::before,
.sticker-item.flipped::after {
  opacity: 0.14;
}

.sticker-item.locked {
  opacity: 0.88;
  background: linear-gradient(180deg, #f2f5f8, #e9edf2);
  border-style: dashed;
}

.sticker-item.locked .sticker-icon {
  filter: grayscale(1);
  opacity: 0.78;
}

.sticker-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.36rem;
  backface-visibility: hidden;
  transition: transform 320ms ease;
}

.sticker-front {
  transform: rotateY(0deg);
}

.sticker-back {
  transform: rotateY(180deg);
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.sticker-item.flipped .sticker-front {
  transform: rotateY(180deg);
}

.sticker-item.flipped .sticker-back {
  transform: rotateY(0deg);
}

.sticker-icon {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.1;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.65));
}

.sticker-back-head {
  font-size: 0.64rem;
  font-weight: 800;
  color: #2e6486;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sticker-back-text {
  font-size: 0.67rem;
  line-height: 1.28;
  color: #254c67;
}

.sticker-item.unlocked .sticker-icon {
  animation: stickerFloat 1.9s ease-in-out infinite;
}

@keyframes stickerSparkle {
  0% {
    opacity: 0.72;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1.04);
  }
}

@keyframes stickerShine {
  0% {
    transform: translateX(-118%) rotate(12deg);
    opacity: 0;
  }
  35% {
    opacity: 0.7;
  }
  100% {
    transform: translateX(285%) rotate(12deg);
    opacity: 0;
  }
}

@keyframes stickerFloat {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

body.theme-dark .header-stars-btn {
  color: #a8edcb;
}

body.theme-dark .header-stars-btn.active {
  color: #ffffff;
}

body.theme-dark .sticker-album {
  background: linear-gradient(180deg, rgba(29, 47, 63, 0.96), rgba(24, 40, 54, 0.94));
  border-color: #5f7d95;
}

body.theme-dark .sticker-item {
  border-color: #5f7d95;
  background: linear-gradient(180deg, rgba(36, 55, 72, 0.96), rgba(31, 47, 62, 0.96));
}

body.theme-dark .sticker-item.unlocked {
  border-color: #69d5a6;
  background: linear-gradient(180deg, rgba(34, 84, 64, 0.96), rgba(26, 64, 49, 0.98));
  box-shadow: 0 10px 22px rgba(19, 39, 30, 0.45);
}

body.theme-dark .sticker-back {
  background: rgba(26, 43, 57, 0.96);
  border-top-color: rgba(129, 168, 197, 0.22);
}

body.theme-dark .sticker-back-head {
  color: #9ed3ff;
}

body.theme-dark .sticker-back-text {
  color: #d8e9f9;
}

body.theme-dark .sticker-item.unlocked::before {
  background:
    radial-gradient(circle at 12% 28%, rgba(212, 255, 237, 0.65) 0 3px, transparent 4px),
    radial-gradient(circle at 80% 18%, rgba(255, 253, 195, 0.55) 0 2px, transparent 3px),
    radial-gradient(circle at 24% 82%, rgba(173, 255, 244, 0.52) 0 3px, transparent 4px),
    radial-gradient(circle at 88% 72%, rgba(255, 207, 224, 0.5) 0 2px, transparent 3px);
}

button:focus,
button:focus-visible,
.tab-btn:focus,
.tab-btn:focus-visible,
.tag-chip:focus,
.tag-chip:focus-visible,
.step-chip:focus,
.step-chip:focus-visible,
.word-chip:focus,
.word-chip:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

a,
button,
input,
textarea,
select,
.tab-btn,
.tag-chip,
.step-chip,
.word-chip {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 759px) {
  .header-copy-actions {
    gap: 0.26rem;
    margin-top: 0.1rem;
  }

  .app-header .header-tools.top-tools {
    display: flex;
    gap: 0.3rem;
    width: auto;
    max-width: none;
  }

  .app-header .header-tools.top-tools .mini-theme-btn {
    width: auto;
    min-height: 30px;
    padding: 0.12rem 0.2rem;
    font-size: 0.66rem;
  }

  .header-stars-btn {
    margin-top: 0.05rem;
    min-height: 28px;
    font-size: 0.68rem;
  }

  .header-settings-btn {
    min-height: 28px;
    font-size: 0.68rem;
    padding: 0.14rem 0.48rem;
  }

  .header-settings-popover {
    margin-top: 0.24rem;
    padding: 0.42rem 0.44rem;
  }

  .header-settings-popover .settings-actions {
    grid-template-columns: 1fr;
    gap: 0.28rem;
  }

  .header-path-popover {
    margin-top: 0.24rem;
    padding: 0.42rem 0.44rem;
  }

  .sticker-album {
    margin-top: 0.24rem;
    padding: 0.42rem 0.44rem;
  }

  .sticker-album-grid {
    gap: 0.34rem;
  }

  #tab-exercises .exercise-card.active {
    max-height: 50dvh;
  }

  #tab-sentences .sentence-card.active {
    max-height: 48dvh;
  }

  #tab-sentences #sentence-step-nav .step-chip,
  #tab-exercises #exercise-step-nav .step-chip {
    min-width: 2.2rem;
    min-height: 2.2rem;
    font-size: 0.9rem;
  }

  #tab-exercises #exercise-step-nav .step-chip.boss-chip {
    min-width: 2.5rem;
  }

  .vocab-boxes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .vocab-box-card {
    padding: 0.46rem 0.4rem;
  }

  .adventure-map {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.42rem;
  }

  .station-btn {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 112px;
    padding: 0.5rem 0.42rem 0.44rem;
  }

  .station-icon {
    font-size: 1.7rem;
  }

  .station-label {
    font-size: 0.8rem;
  }

  .station-goal {
    font-size: 0.64rem;
  }

  .station-stamp {
    width: 78px;
    height: 78px;
    margin-left: -39px;
    margin-top: -40px;
  }

}

#tab-errors #errors-session-meta {
  font-weight: 700;
}

@media (max-width: 759px) {
  #tab-errors .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.28rem;
  }

  #tab-errors #errors-drill-auto {
    grid-column: 1 / -1;
  }
}

@media (max-width: 759px) {
  body.exercise-one-screen #tab-exercises .panel-head {
    margin-bottom: 0.16rem;
  }

  body.exercise-one-screen #tab-exercises .panel-head h2 {
    font-size: 1.02rem;
  }

  body.exercise-one-screen #tab-exercises .mode-filter {
    margin: 0.18rem 0 0.2rem;
    gap: 0.26rem;
  }

  body.exercise-one-screen #tab-exercises .mode-chip {
    min-height: 28px;
    padding: 0.12rem 0.42rem;
    font-size: 0.72rem;
  }

  body.exercise-one-screen #tab-exercises .exercise-stepper {
    position: sticky;
    top: calc(0.2rem + env(safe-area-inset-top));
    margin-bottom: 0.24rem;
    padding: 0.34rem 0.4rem;
  }

  body.exercise-one-screen #tab-exercises #exercise-step-title {
    font-size: 0.88rem;
  }

  body.exercise-one-screen #tab-exercises #exercise-step-meta {
    font-size: 0.7rem;
  }

  body.exercise-one-screen #tab-exercises #exercise-step-nav .step-chip {
    min-width: 2rem;
    min-height: 2rem;
    font-size: 0.82rem;
    padding: 0.18rem 0.38rem;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active {
    max-height: var(--exercise-card-max-h, 46dvh) !important;
    overflow: hidden;
    padding: 0.38rem;
    gap: 0.28rem;
    grid-template-rows: auto 1fr auto;
    align-content: stretch;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active > h3 {
    display: none;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active .exercise-box {
    max-height: var(--exercise-box-max-h, 30dvh);
    min-height: 0;
    overflow: auto;
    padding: 0.34rem;
    gap: 0.3rem;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active .exercise-box p {
    font-size: 0.78rem;
    line-height: 1.24;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active .choice-btn {
    min-height: 34px;
    padding: 0.3rem 0.42rem;
    font-size: 0.76rem;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active .button-row {
    margin-top: 0.18rem;
    gap: 0.24rem;
  }

  body.exercise-one-screen #tab-exercises .exercise-card.active .button-row > button {
    min-height: 32px;
    font-size: 0.74rem;
    padding: 0.22rem 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
