:root {
  --bg: #f6f3ed;
  --paper: #fffaf0;
  --panel: #ffffff;
  --ink: #25211c;
  --muted: #756f67;
  --line: #e4ddd0;
  --accent: #d95f35;
  --accent-dark: #9f3d22;
  --mint: #d9ede2;
  --blue: #dbe8f6;
  --yellow: #f7dfa0;
  --shadow: 0 22px 50px -28px rgba(75, 54, 34, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 14% 6%, rgba(217, 95, 53, 0.14), transparent 28rem),
    linear-gradient(135deg, #f8f4eb 0%, #eef4ef 100%);
  color: var(--ink);
  font-family: ui-rounded, "Avenir Next", "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  padding: 28px 20px;
  border-right: 1px solid rgba(76, 55, 32, 0.12);
  background: rgba(255, 250, 240, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  letter-spacing: -0.03em;
  box-shadow: 5px 5px 0 var(--ink);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.progress-card {
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.progress-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.progress-card strong {
  font-size: 34px;
  line-height: 1;
}

.progress-track {
  height: 10px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee5d7;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 280ms ease;
}

.module-list {
  display: grid;
  gap: 8px;
}

.book-heading {
  margin: 22px 8px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-button {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.module-button:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.module-button:active {
  transform: scale(0.985);
}

.module-button.is-active {
  border-color: rgba(217, 95, 53, 0.35);
  background: #fff;
  box-shadow: 0 12px 28px -22px rgba(37, 33, 28, 0.5);
}

.module-button span:first-child {
  font-weight: 800;
}

.module-button small {
  color: var(--muted);
  font-weight: 700;
}

.main {
  padding: 28px clamp(18px, 4vw, 48px) 48px;
}

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

.menu-button {
  display: none;
}

.icon-button,
.ghost-button,
.primary-button,
.soft-button,
.choice-button,
.letter-button {
  border: 0;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.icon-button:active,
.ghost-button:active,
.primary-button:active,
.soft-button:active,
.choice-button:active,
.letter-button:active {
  transform: scale(0.98);
}

.ghost-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-weight: 800;
}

.ghost-button:hover {
  color: var(--ink);
  background: #fff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats-grid div {
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
}

.stats-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid strong {
  font-size: 30px;
  line-height: 1;
}

.scope-tabs,
.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scope-tabs {
  margin-bottom: 10px;
}

.mode-tabs {
  margin-bottom: 18px;
}

.scope-tab,
.tab {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.scope-tab.is-active,
.tab.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffaf0;
}

.activity-panel {
  min-height: 480px;
  border: 1px solid rgba(76, 55, 32, 0.14);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 240, 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.activity-inner {
  display: grid;
  min-height: 480px;
  align-content: center;
  gap: 22px;
  padding: clamp(22px, 4vw, 44px);
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.activity-header p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.word-card {
  display: grid;
  min-height: 250px;
  place-items: center;
  padding: clamp(24px, 5vw, 54px);
  border: 2px solid var(--ink);
  border-radius: 24px;
  background: var(--yellow);
  box-shadow: 9px 9px 0 var(--ink);
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.word-card small {
  display: block;
  margin-bottom: 12px;
  color: var(--accent-dark);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.word-card strong {
  display: block;
  font-size: clamp(42px, 9vw, 86px);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.word-card em {
  display: block;
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  font-style: normal;
  line-height: 1.4;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.soft-button {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  font-weight: 900;
}

.primary-button {
  background: var(--accent);
  color: #fffaf0;
  box-shadow: 0 12px 24px -18px var(--accent-dark);
}

.soft-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.quiz-question,
.builder-target {
  padding: 20px;
  border-radius: 22px;
  background: var(--mint);
}

.quiz-question span,
.builder-target span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.quiz-question strong,
.builder-target strong {
  display: block;
  font-size: clamp(34px, 7vw, 70px);
  line-height: 1;
  letter-spacing: -0.05em;
}

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

.choice-button {
  min-height: 78px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  text-align: left;
}

.choice-button:hover {
  border-color: rgba(217, 95, 53, 0.45);
}

.choice-button.is-correct {
  border-color: #5f946d;
  background: #e2f2e6;
}

.choice-button.is-wrong {
  border-color: #bf5d4d;
  background: #f7dfd9;
}

.feedback {
  min-height: 28px;
  color: var(--muted);
  font-weight: 850;
}

.letter-bank,
.answer-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-bank {
  min-height: 58px;
  padding: 10px;
  border: 1px dashed rgba(37, 33, 28, 0.28);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.letter-button {
  min-width: 46px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: var(--blue);
  color: var(--ink);
  font-size: 20px;
  font-weight: 950;
  box-shadow: 4px 4px 0 var(--ink);
}

.letter-button:disabled {
  opacity: 0.25;
  cursor: default;
}

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

.phrase-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.phrase-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
}

.phrase-card span {
  color: var(--muted);
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 30px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
  font-size: 30px;
  letter-spacing: -0.03em;
}

.empty-state p {
  max-width: 52ch;
  color: var(--muted);
  line-height: 1.55;
}

.drawer-shade {
  display: none;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(86vw, 340px);
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  .drawer-shade {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: none;
    background: rgba(37, 33, 28, 0.28);
  }

  body.drawer-open .drawer-shade {
    display: block;
  }

  .main {
    padding: 18px 14px 32px;
  }

  .menu-button {
    display: inline-grid;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 12px;
    background: var(--ink);
  }

  .menu-button span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #fffaf0;
  }

  .topbar {
    align-items: center;
  }

  .topbar .ghost-button {
    display: none;
  }

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

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .word-card {
    min-height: 220px;
    box-shadow: 6px 6px 0 var(--ink);
  }
}

@media (max-width: 520px) {
  .stats-grid div {
    min-height: 74px;
    padding: 13px;
  }

  .stats-grid strong {
    font-size: 24px;
  }

  .activity-panel,
  .activity-inner {
    min-height: 430px;
  }

  .activity-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
