:root {
  --bg: #eef7f4;
  --ink: #1c2b2e;
  --muted: #66757a;
  --panel: #ffffff;
  --line: #d7e5e1;
  --green: #2fb36d;
  --teal: #1c9aa6;
  --yellow: #f8c94a;
  --red: #ee6c64;
  --blue: #4b7ee8;
  --shadow: 0 18px 48px rgba(31, 69, 68, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #e7f7fb 0%, var(--bg) 42%, #f7fbf2 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  background: rgba(255,255,255,.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--yellow);
  color: #3f3100;
  font-size: 28px;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08);
}

.brand h1, .brand p, .topbar h2, .topbar p, .panel h3, .hero-panel h3 {
  margin: 0;
}

.brand h1 { font-size: 20px; }
.brand p { margin-top: 4px; color: var(--muted); font-size: 13px; }

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 13px 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
}

.nav-item.active {
  background: #dff5ef;
  color: #0f6f50;
}

.side-card {
  margin-top: 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.side-label, .eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.side-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.side-card p {
  color: var(--muted);
  line-height: 1.5;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.topbar h2 { margin-top: 4px; font-size: 30px; }

.topbar-sub {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.topbar-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.topbar-tools.hidden {
  display: none;
}

.topbar-tools > span {
  color: var(--muted);
  font-weight: 900;
  font-size: 13px;
}

.topbar-filters {
  margin-bottom: 0;
}

.topbar-count {
  align-self: center;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 92px);
  gap: 10px;
}

.status-strip div {
  padding: 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}

.status-strip span {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.status-strip small { color: var(--muted); }

.view { display: none; }
.view.active { display: block; }

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 24px;
  border-radius: 8px;
  background: #173f45;
  color: white;
  box-shadow: var(--shadow);
}

.hero-panel h3 { margin-top: 6px; font-size: 28px; }
.hero-panel p:not(.eyebrow) { color: rgba(255,255,255,.76); max-width: 640px; line-height: 1.6; }

.grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.grid.two { grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }

#wordbank .grid.two {
  grid-template-columns: minmax(0, 1fr);
}

.study-plan-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 330px;
  padding: 54px 28px;
  margin-bottom: 18px;
  text-align: center;
}

.study-plan-empty h3 {
  margin: 4px 0 0;
  font-size: 30px;
}

.study-plan-empty > p:not(.eyebrow) {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.plan-empty-action {
  min-width: 240px;
  min-height: 58px;
  margin-top: 18px;
  font-size: 18px;
}

.study-plan-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.study-plan-actions .ghost-action {
  min-width: 148px;
  background: rgba(255, 255, 255, .72);
  border-color: #c8d9d5;
  color: #52666a;
  box-shadow: none;
}

.study-plan-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.study-plan-option {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdfc;
  color: var(--ink);
  text-align: left;
}

.study-plan-option span {
  color: var(--muted);
  font-size: 13px;
}

.study-plan-option.active {
  border-color: #68c8b8;
  background: #e3f7f3;
}

.study-plan-option:disabled {
  cursor: default;
  opacity: 1;
}

.plan-chooser-card {
  width: min(720px, 100%);
}

.plan-chooser-hint {
  margin: -4px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.plan-builder {
  display: grid;
  gap: 18px;
}

.plan-builder-card {
  width: min(980px, 100%);
}

.library-config-panel {
  display: grid;
  gap: 20px;
}

.library-config-panel .panel-head {
  margin-bottom: 0;
}

.library-config-panel .panel-head h3 {
  margin: 5px 0 0;
}

.library-config-step {
  display: grid;
  gap: 10px;
}

.textbook-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.textbook-option,
.unit-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  text-align: left;
}

.textbook-option {
  display: grid;
  gap: 6px;
  padding: 15px;
}

.textbook-option span,
.unit-option span {
  color: var(--muted);
  font-size: 13px;
}

.textbook-option.active,
.unit-option.active {
  border-color: #68c8b8;
  background: #e3f7f3;
  box-shadow: inset 0 0 0 1px #68c8b8;
}

.unit-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.unit-picker-head span {
  color: var(--muted);
  font-weight: 800;
}

.unit-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 8px;
}

.unit-option {
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 11px;
}

.config-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.config-message.error {
  color: #bd3e36;
  font-weight: 800;
}

.library-save-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4faf8;
}

.library-save-row p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.primary-action:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.confirm-card > h3 {
  margin: 7px 0 10px;
}

.confirm-card > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.65;
}

.confirm-summary {
  display: grid;
  gap: 5px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4faf8;
}

.confirm-summary span {
  color: var(--muted);
}

.panel {
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head span { color: var(--muted); font-weight: 800; }

.progress-track {
  height: 12px;
  background: #e8eeee;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width .28s ease;
}

.task-list, .review-list, .tips-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.task-item, .review-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.task-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e9f6ff;
  font-weight: 900;
}

.task-item.done .task-icon { background: #dff7e8; color: #13884b; }
.task-item h4, .review-item h4 { margin: 0 0 4px; font-size: 15px; }
.task-item p, .review-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fbfdfc;
  color: var(--muted);
  font-weight: 800;
}

.filter-chip.active {
  border-color: #8ad5c8;
  background: #e3f7f3;
  color: #0d7565;
}

.library-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6faf9;
}

.library-tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.library-tab.active {
  background: #dff5ef;
  color: #0f6f50;
}

.library-tab-panel {
  display: none;
}

.library-tab-panel.active {
  display: block;
}

.word-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.word-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdfc;
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

.word-search input:focus {
  border-color: #8ad5c8;
  box-shadow: 0 0 0 3px rgba(28, 154, 166, .12);
}

.wordbank-list {
  display: grid;
  gap: 10px;
}

.compact-head {
  margin-top: 18px;
}

.textbook-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5fbfa;
}

.textbook-card strong {
  display: block;
  font-size: 22px;
  margin-bottom: 8px;
}

.textbook-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0 4px;
}

.knowledge-card {
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6faf9;
}

.knowledge-card strong,
.knowledge-card span {
  display: block;
}

.knowledge-card strong {
  font-size: 17px;
}

.knowledge-card span {
  margin: 8px 0;
  color: var(--teal);
  font-weight: 900;
}

.knowledge-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.knowledge-list {
  display: grid;
  gap: 12px;
}

.knowledge-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.knowledge-section h4 {
  margin: 0 0 10px;
}

.knowledge-section ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.word-row.mastered { border-color: #9bdfbc; background: #f5fff8; }
.word-row.hard { border-color: #f1b0aa; background: #fff7f6; }
.word-row.sprint-completed { border: 2px solid #55c686; background: linear-gradient(135deg, #f4fff7 0%, #e1fae9 100%); }
.word-row.sprint-completed .word-title strong, .word-row.sprint-completed .word-meta strong { color: #176b3b; }
.word-row.sprint-not-completed { border-color: #d7dadd; background: #fafbfb; }
.word-row.sprint-not-completed .word-meta strong { color: #8c9298; }

.word-title {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}

.word-title strong {
  font-size: 22px;
}

.word-title span, .word-row small {
  color: var(--muted);
}

.word-row p {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.45;
}

.word-meta {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.word-meta span, .word-meta strong {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef6f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.word-meta strong {
  background: #e8f4ff;
  color: #245fa8;
}

.schema-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.schema-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f6faf9;
  border: 1px solid var(--line);
}

.schema-list span {
  color: var(--muted);
  text-align: right;
}

.muted-action {
  opacity: .55;
  cursor: not-allowed;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-grid div {
  padding: 18px;
  border-radius: 8px;
  background: #f4faf8;
}

.metric-grid strong {
  display: block;
  font-size: 30px;
}

.metric-grid span { color: var(--muted); font-weight: 700; }

.primary-action, .success-action, .ghost-action, .small-action {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 900;
}

.primary-action { background: var(--blue); color: white; }
.success-action { background: var(--green); color: white; }
.ghost-action { background: #edf2f1; color: var(--ink); }
.small-action { padding: 9px 12px; background: #e7f4ff; color: #245fa8; }

.island-map {
  display: grid;
  gap: 16px;
}

.challenge-setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.challenge-type-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.challenge-type {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
  color: var(--ink);
  text-align: center;
}

.challenge-type.active {
  border-color: #8ad5c8;
  background: #e3f7f3;
}

.challenge-type strong,
.challenge-type em {
  display: block;
}

.challenge-type strong {
  font-size: 16px;
}

.challenge-type em {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.35;
}

.challenge-type-icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
  background: #f6faf9;
  box-shadow: 0 8px 20px rgba(31, 69, 68, .12);
}

.challenge-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.challenge-status h3,
.challenge-status p {
  margin: 0;
}

.challenge-status h3 {
  margin-top: 6px;
}

.challenge-status p:not(.eyebrow) {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.challenge-meters {
  display: grid;
  grid-template-columns: repeat(4, 96px);
  gap: 10px;
}

.challenge-meters div,
.challenge-hud > div:not(.challenge-item-actions) {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6faf9;
  text-align: center;
}

.challenge-meters strong,
.challenge-hud strong {
  display: block;
  color: #d43f57;
  font-size: 22px;
  letter-spacing: 1px;
}

.challenge-meters span,
.challenge-hud span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inventory-strip,
.challenge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.item-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff7d9;
  color: #735400;
  font-weight: 900;
}

.item-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(248, 201, 74, .45);
}

.item-pill:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.item-control {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.item-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 30;
  width: 220px;
  transform: translateX(-50%) translateY(4px);
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #c8ded8;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(20, 48, 52, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.item-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 1px solid #c8ded8;
  border-bottom: 1px solid #c8ded8;
  background: #ffffff;
}

.item-bubble strong {
  color: #0f6f50;
  font-size: 15px;
}

.item-bubble span,
.item-bubble em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.4;
}

.item-control.active .item-bubble {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.item-use-action {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.item-control:not(.active) .item-use-action {
  display: none;
}

.active-buff {
  align-self: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: #e9f1ff;
  color: #2d5bbf;
  font-weight: 900;
  font-size: 13px;
}

.challenge-levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 16px;
}

.map-node {
  min-height: 160px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-node .task-icon {
  margin-bottom: 14px;
}

.level-stars {
  display: flex;
  gap: 3px;
  margin: 8px 0 6px;
  color: #f2b617;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.level-stars.empty {
  color: #bec9c7;
}

.boss-lock-note {
  color: #8a6a00;
  font-weight: 900;
}

.map-node.done { border-color: #96ddbb; background: #f4fff8; }

.map-node.current {
  border-color: #8ad5c8;
  box-shadow: 0 18px 48px rgba(28, 154, 166, .18);
}

.map-node.boss {
  border-color: #f8c94a;
  background: linear-gradient(180deg, #fff9df, #ffffff 62%);
}

.map-node.boss .task-icon {
  width: auto;
  min-width: 64px;
  padding: 0 10px;
  background: #f8c94a;
  color: #3f3100;
  font-size: 14px;
}

.map-node.boss.current {
  box-shadow: 0 18px 48px rgba(248, 201, 74, .24);
}

.map-node.locked {
  opacity: .54;
  background: #f3f6f5;
}

.map-node button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.challenge-hud {
  display: grid;
  grid-template-columns: repeat(3, 94px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.challenge-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 24, 28, .56);
  z-index: 10;
}

.modal.hidden { display: none; }

#libraryConfirmModal,
#planSwitchModal {
  z-index: 20;
}

#libraryConfirmModal:not(.hidden) ~ #planBuilderModal {
  display: none;
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0,0,0,.22);
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  margin-bottom: 18px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #edf2f1;
  font-size: 24px;
}

.practice-body {
  min-height: 260px;
  display: grid;
  gap: 16px;
  align-content: center;
}

.prompt-card {
  padding: 22px;
  border-radius: 8px;
  background: #f5fbfa;
  border: 1px solid var(--line);
  text-align: center;
}

.prompt-main {
  margin: 8px 0;
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 900;
}

.prompt-main.listening-prompt {
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.25;
}

.prompt-sub {
  color: var(--muted);
  font-size: 18px;
}

.speak-action {
  margin-top: 18px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--yellow);
  color: #3f3100;
  font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
  font-weight: 900;
}

.choice.selected { border-color: var(--blue); background: #eef4ff; }
.choice.correct { border-color: var(--green); background: #ecfbf2; }
.choice.wrong { border-color: var(--red); background: #fff1f0; }
.choice.eliminated { opacity: .35; text-decoration: line-through; }

.answer-input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  font-size: 24px;
  text-align: center;
}

.spelling-panel {
  display: grid;
  gap: 14px;
}

.spelling-slots {
  min-height: 74px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  border-radius: 8px;
  background: #f7fbfa;
  border: 1px solid var(--line);
}

.spelling-slot {
  width: 34px;
  height: 42px;
  border: 0;
  border-bottom: 4px solid #93a0a6;
  background: transparent;
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-transform: lowercase;
  outline: none;
  border-radius: 0;
  padding: 0 0 4px;
}

.spelling-slot:focus {
  border-bottom-color: var(--blue);
  background: #eef4ff;
}

.spelling-gap {
  width: 16px;
  height: 42px;
}

.builder-hint {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.builder-answer {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-placeholder {
  color: var(--muted);
  font-weight: 800;
}

.cloze-card {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 22px 18px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.8;
}

.blank-input {
  width: 132px;
  border: 2px dashed #9fb5c3;
  border-radius: 8px;
  background: #f7fbff;
  padding: 6px 8px;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.blank-input:focus {
  background: #fff8de;
  border-color: var(--yellow);
}

.blank-input.correct {
  background: #e8f8ee;
  border: 2px solid var(--green);
  border-bottom-width: 4px;
  color: #13743c;
}

.blank-input.wrong {
  background: #fff1f0;
  border: 2px solid var(--red);
  border-bottom-width: 4px;
  color: #b3261e;
}

.translation-card {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 26px 18px;
  background: white;
  display: flex;
  align-items: end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 10px;
}

.translation-input {
  min-width: 64px;
  max-width: 180px;
  border: 0;
  border-bottom: 4px solid #93a0a6;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 6px 2px 8px;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.translation-input:focus {
  border-bottom-color: var(--blue);
  background: #f3f7ff;
}

.translation-input.correct {
  border-bottom-color: var(--green);
  color: #13743c;
  background: #f3fbf6;
}

.translation-input.wrong {
  border-bottom-color: var(--red);
  color: #b3261e;
  background: #fff5f4;
}

.letter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.letter {
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8f4ff;
  font-weight: 900;
  user-select: none;
  touch-action: none;
}

.letter.used {
  opacity: .42;
  background: #eef2f2;
  color: var(--muted);
  cursor: not-allowed;
}

.builder-source,
.builder-answer {
  transition: border-color .15s ease, background .15s ease;
}

.builder-source.drop-active,
.builder-answer.drop-active {
  border-color: var(--blue);
  background: #eef4ff;
}

.answer-chip {
  min-width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px solid #4a5560;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.answer-chip:active {
  cursor: grabbing;
}

.letter.dragging,
.answer-chip.dragging {
  opacity: .28;
  box-shadow: none;
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2000;
  opacity: .95;
  pointer-events: none;
  box-shadow: 0 14px 30px rgba(15, 38, 42, .22);
  transition: none;
}

.drop-marker {
  width: 54px;
  height: 42px;
  border: 2px dashed var(--blue);
  border-radius: 8px;
  background: #eef4ff;
  box-shadow: inset 0 0 0 3px rgba(73, 122, 232, .08);
}

.builder-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.practice-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.practice-actions .ghost-action,
.practice-actions .success-action {
  min-width: 86px;
  padding: 10px 14px;
  font-size: 16px;
  opacity: .9;
}

.practice-actions .primary-action {
  min-width: 150px;
  padding: 16px 30px;
  border-radius: 10px;
  font-size: 22px;
  box-shadow: 0 12px 26px rgba(75, 126, 232, .28);
  transform: translateY(-2px);
}

.finish-card {
  text-align: center;
}

.finish-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

#finishSecondary {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  color: #6d7b80;
  font-size: 24px;
  line-height: 1;
}

.finish-stars {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
  color: #c9d3d1;
  font-size: 54px;
  font-weight: 900;
  line-height: 1;
}

.finish-stars span {
  display: inline-block;
}

.finish-stars .filled {
  color: #f2b617;
  text-shadow: 0 8px 18px rgba(242, 182, 23, .28);
  animation: finishStarPop .72s cubic-bezier(.2, 1.4, .35, 1) both;
}

@keyframes finishStarPop {
  0% { opacity: 0; transform: scale(.35) rotate(-18deg); }
  55% { opacity: 1; transform: scale(1.24) rotate(8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.report-bars {
  display: grid;
  gap: 12px;
}

.bar-row label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
}

.bar-bg {
  height: 10px;
  border-radius: 999px;
  background: #e8eeee;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

.tips-list {
  padding-left: 20px;
  line-height: 1.7;
  color: var(--muted);
}

.correct-confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
  pointer-events: none;
}

.item-effect {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
}

.item-effect-core {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 8px;
  min-width: 150px;
  min-height: 120px;
  padding: 18px 22px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(19, 49, 54, .2);
  animation: itemCorePop .78s ease forwards;
}

.item-effect-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  font-weight: 900;
}

.item-effect strong {
  font-size: 22px;
}

.item-effect.health .item-effect-icon { background: #d43f57; }
.item-effect.shield .item-effect-icon,
.item-effect.shieldBreak .item-effect-icon { background: #4b7ee8; }
.item-effect.swap .item-effect-icon { background: #1c9aa6; }
.item-effect.eliminate .item-effect-icon { background: #ee6c64; }

.item-effect-ring {
  position: absolute;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 4px solid rgba(75, 126, 232, .45);
  animation: itemRingPulse .9s ease-out forwards;
}

.item-effect-ring.delay {
  animation-delay: .13s;
}

.item-effect.health .item-effect-ring {
  border-color: rgba(212, 63, 87, .44);
}

.item-effect.swap .item-effect-ring {
  border-radius: 8px;
  border-color: rgba(28, 154, 166, .42);
  animation-name: itemCardFlip;
}

.item-effect.eliminate .item-effect-ring {
  border-color: rgba(238, 108, 100, .44);
  animation-name: itemSlashOut;
}

@keyframes itemCorePop {
  0% { opacity: 0; transform: scale(.78) translateY(14px); }
  20% { opacity: 1; transform: scale(1.05) translateY(0); }
  72% { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(.96) translateY(-10px); }
}

@keyframes itemRingPulse {
  0% { opacity: .8; transform: scale(.8); }
  100% { opacity: 0; transform: scale(3.3); }
}

@keyframes itemCardFlip {
  0% { opacity: .8; transform: rotate(-8deg) scale(.72); }
  55% { opacity: .45; transform: rotate(8deg) scale(2.3); }
  100% { opacity: 0; transform: rotate(18deg) scale(3); }
}

@keyframes itemSlashOut {
  0% { opacity: .75; transform: rotate(45deg) scale(.65, .15); }
  100% { opacity: 0; transform: rotate(45deg) scale(5, .22); }
}

.sprint-empty { max-width: 760px; margin: 24px auto; padding: 40px; text-align: center; }
.sprint-orb { width: 76px; height: 76px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 24px; background: #f8c94a; color: #3f3100; font-size: 30px; font-weight: 800; box-shadow: 0 12px 24px rgba(184, 135, 24, .2); }
.sprint-empty h3 { margin: 8px 0 12px; font-size: 30px; }
.sprint-empty > p:not(.eyebrow) { max-width: 590px; margin: 0 auto 22px; color: var(--muted); line-height: 1.8; }
.sprint-feature-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.sprint-feature-row span, .sprint-stepper span { padding: 7px 11px; border-radius: 999px; background: #fff8e4; color: #806524; font-size: 13px; }
.sprint-hero { margin-bottom: 18px; }
.sprint-hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.sprint-metrics { grid-template-columns: repeat(4, 1fr); margin: 18px 0 22px; gap: 10px; }
.metric-card { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.sprint-calendar-card .metric-card { min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.sprint-calendar-card .metric-card:nth-child(1) { border-color: #f2c766; background: #fff8dc; }
.sprint-calendar-card .metric-card:nth-child(2) { border-color: #8bd4ae; background: #edfff3; }
.sprint-mastered-metric { width: 100%; font: inherit; text-align: left; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease; }
.sprint-mastered-metric:hover { filter: saturate(1.08); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(47, 171, 100, .14); }
.sprint-mastered-metric:focus-visible { outline: 3px solid rgba(47, 171, 100, .3); outline-offset: 2px; }
.sprint-calendar-card .metric-card:nth-child(3) { border-color: #aebcf2; background: #f0f3ff; }
.sprint-calendar-card .metric-card:nth-child(4) { border-color: #f2aaa0; background: #fff0ed; }
.metric-card strong { font-size: 28px; color: var(--ink); }
.sprint-calendar-card .metric-card strong { font-size: 22px; }
.metric-card span, .sprint-progress-copy { color: var(--muted); font-size: 13px; }
.sprint-progress-copy { display: flex; justify-content: space-between; margin-top: 10px; }
.sprint-wizard-card { max-width: 720px; }
.sprint-stepper { display: flex; gap: 8px; margin: 4px 0 22px; flex-wrap: wrap; }
.sprint-stepper span { background: #f2f3f4; color: #82878d; }
.sprint-stepper span.active { background: #fff0bb; color: #6f5200; font-weight: 700; }
.sprint-analysis { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; margin: 18px 0; }
.sprint-analysis-card { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fffdf8; }
.sprint-analysis-card strong { display: block; font-size: 26px; margin-bottom: 4px; }
.sprint-analysis-card span { color: var(--muted); font-size: 13px; }
.sprint-sample-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.sprint-sample-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; background: #fff; }
.sprint-sample-item.selected { border-color: #e0b32f; background: #fff7d9; }
.sprint-sample-item strong, .sprint-sample-item span { display: block; }
.sprint-sample-item span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.sprint-choice-row, .sprint-wizard-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sprint-wizard-actions { justify-content: flex-end; margin-top: 22px; }
.sprint-days-control { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.sprint-days-control input { width: 82px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; text-align: center; }
.sprint-task-card { max-width: 560px; }
.sprint-word-card { padding: 24px; text-align: center; background: #fffdf8; border-radius: 18px; }
.sprint-word-card .sprint-word { font-size: 34px; font-weight: 800; margin: 12px 0 6px; }
.sprint-question-card { text-align: left; }
.sprint-question-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sprint-question-type { padding: 5px 9px; border-radius: 999px; background: #fff0bb; color: #765800; font-size: 12px; font-weight: 700; }
.sprint-question-prompt { margin: 12px 0; color: var(--muted); }
.sprint-phonics { color: var(--muted); text-align: center; }
.sprint-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.sprint-choice { min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); cursor: pointer; font: inherit; text-align: left; }
.sprint-choice:hover, .sprint-choice.selected { border-color: #e0b32f; background: #fff7d9; }
.sprint-choice.correct { border-color: #55c686; background: #ddf9e6; color: #176b3b; }
.sprint-choice.wrong { border-color: #e39a8d; background: #fff0ed; color: #a54d40; }
.sprint-listen-button { margin: 4px 0 6px; }
.sprint-context-box { margin: 14px 0; padding: 14px; border-radius: 14px; background: #f4f0ff; border: 1px solid #d7cafa; }
.sprint-context-box strong { color: #6551a6; }
.sprint-context-box p { margin: 8px 0 4px; line-height: 1.65; }
.sprint-context-box span { color: var(--muted); font-size: 13px; }
.sprint-spelling-prompt { margin: 16px 0 10px; color: #315d95; font-size: 24px; font-weight: 800; text-align: center; }
.sprint-spelling-input { width: 100%; box-sizing: border-box; padding: 13px 14px; border: 2px solid #b8c7ee; border-radius: 12px; font: inherit; font-size: 18px; text-align: center; outline: none; }
.sprint-spelling-input:focus { border-color: #7187d0; box-shadow: 0 0 0 3px rgba(113, 135, 208, .14); }
.sprint-answer-feedback { margin: 14px 0 0; padding: 11px 12px; border-radius: 10px; font-weight: 700; }
.sprint-answer-feedback.is-correct { background: #ddf9e6; color: #176b3b; }
.sprint-answer-feedback.is-wrong { background: #fff0ed; color: #a54d40; }
.sprint-word-card .sprint-context { color: var(--muted); line-height: 1.7; margin: 12px 0; }
.sprint-task-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.sprint-calendar-card { margin-top: 18px; }
.calendar-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.calendar-nav { display: flex; gap: 6px; }
.sprint-calendar-weekdays, .sprint-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.sprint-calendar-weekdays { margin: 18px 0 6px; color: var(--muted); font-size: 12px; text-align: center; }
.sprint-calendar-day { min-height: 72px; padding: 9px 8px; border: 1px solid var(--line); border-radius: 12px; background: #fffdf8; color: var(--ink); }
.sprint-calendar-day.completed { width: 100%; box-sizing: border-box; font: inherit; text-align: left; cursor: pointer; }
.sprint-calendar-day.completed:hover { filter: saturate(1.08) brightness(.98); }
.sprint-calendar-day strong { display: block; font-size: 15px; }
.sprint-calendar-day small { display: inline-block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.sprint-calendar-day.outside { visibility: hidden; border-color: transparent; background: transparent; }
.sprint-calendar-day.completed { border: 2px solid #55c686; background: linear-gradient(145deg, #eaffef 0%, #c9f5d8 100%); box-shadow: 0 5px 0 #8bd9a9, 0 8px 16px rgba(47, 171, 100, .16); transform: translateY(-2px); }
.sprint-calendar-day.completed strong { color: #176b3b; }
.sprint-calendar-day.completed small { color: #168044; font-weight: 800; }
.sprint-calendar-day.today { border: 2px solid #e0b32f; background: #fff8dc; }
.sprint-calendar-day.today small { color: #8a6500; font-weight: 700; }
.sprint-calendar-day.empty { border-color: #e7b1a8; background: #fff1ee; }
.sprint-calendar-day.empty small { color: #bd6558; }
.sprint-calendar-day.review { border: 2px solid #9caeea; background: #eef2ff; }
.sprint-calendar-day.review small { color: #536ab8; font-weight: 700; }
.sprint-calendar-day.planned { background: #fafafa; color: #9a9da1; }
.sprint-calendar-day.planned small { color: #a6a9ad; }
.sprint-calendar-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 12px; }
.sprint-calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #d8dadd; }
.legend-dot.completed { background: #63b47f; }
.legend-dot.today { background: #e0b32f; }
.legend-dot.empty { background: #d47b6c; }
.legend-dot.review { background: #7187d0; }
.sprint-completed-card { max-width: 560px; }
.sprint-completed-summary { margin: 0 0 14px; color: var(--muted); }
.sprint-completed-list { display: grid; gap: 8px; max-height: 52vh; overflow-y: auto; }
.sprint-completed-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: #f5fff7; border: 1px solid #c5ead0; }
.sprint-completed-row strong { color: #176b3b; }
.sprint-completed-row span { color: var(--muted); font-size: 13px; text-align: right; }
.sprint-completed-empty { padding: 18px; border-radius: 12px; background: #fff8dc; color: #765800; line-height: 1.7; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 100vw; overflow: hidden; }
  .sidebar { position: static; width: 100%; min-width: 0; padding: 16px; }
  .brand { margin-bottom: 14px; }
  .nav-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item {
    flex: 0 0 auto;
    width: auto;
    padding: 10px 12px;
    white-space: nowrap;
  }
  .side-card { display: none; }
  .main { width: 100%; min-width: 0; padding: 16px; }
  .topbar, .hero-panel { flex-direction: column; align-items: stretch; }
  .study-plan-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .study-plan-list { grid-template-columns: 1fr; }
  .grid.two, .island-map, .challenge-setup, .challenge-status, .challenge-levels { grid-template-columns: 1fr; }
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status-strip div { padding: 9px 6px; }
  .challenge-type-grid { grid-template-columns: 1fr; }
  .challenge-meters, .challenge-hud {
    grid-template-columns: 1fr;
  }
  .challenge-item-actions { justify-content: flex-start; }
  .knowledge-grid { grid-template-columns: 1fr; }
  .sprint-metrics, .sprint-analysis { grid-template-columns: 1fr 1fr; }
  .sprint-empty { padding: 28px 18px; }
  .sprint-empty h3 { font-size: 24px; }
  .textbook-options, .unit-picker { grid-template-columns: 1fr 1fr; }
  .library-save-row { align-items: stretch; flex-direction: column; }
  .topbar-tools { align-items: stretch; }
  .topbar-filters { width: 100%; }
  .library-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .library-tab { padding-inline: 10px; }
  .word-search { grid-template-columns: 1fr; }
  .sprint-analysis { grid-template-columns: 1fr; }
  .sprint-calendar-weekdays, .sprint-calendar-grid { gap: 4px; }
  .sprint-calendar-day { min-height: 58px; padding: 7px 5px; border-radius: 9px; }
  .sprint-calendar-card .sprint-metrics { gap: 6px; }
  .sprint-calendar-card .metric-card { padding: 11px 9px; }
  .sprint-calendar-card .metric-card strong { font-size: 18px; }
  .sprint-completed-row { align-items: flex-start; flex-direction: column; gap: 4px; }
  .sprint-completed-row span { text-align: left; }
  .sprint-calendar-day small { margin-top: 7px; font-size: 10px; }
  .sprint-calendar-legend { gap: 9px; }
  .word-row { grid-template-columns: 1fr; }
  .word-meta { display: flex; flex-wrap: wrap; }
  .choice-grid { grid-template-columns: 1fr; }
  .practice-actions {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
  }
  .practice-actions .primary-action,
  .practice-actions .ghost-action,
  .practice-actions .success-action {
    min-width: 0;
    width: 100%;
  }
  .practice-actions .primary-action {
    padding-inline: 12px;
  }
}
