: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; }

.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; }

.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); }

.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;
}

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

.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-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;
  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;
}

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

.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; }

.modal-card {
  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; }

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

.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;
}

.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: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.badge-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 22px 0;
}

.badge {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #fff7d9;
  font-size: 34px;
}

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

.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);
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .topbar, .hero-panel { flex-direction: column; align-items: stretch; }
  .status-strip, .grid.two, .island-map { grid-template-columns: 1fr; }
  .word-row { grid-template-columns: 1fr; }
  .word-meta { display: flex; flex-wrap: wrap; }
  .choice-grid { grid-template-columns: 1fr; }
}
