:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #657180;
  --line: #d9ded8;
  --green: #1d7a63;
  --green-soft: #dff0e9;
  --amber: #b86b19;
  --amber-soft: #fff0d6;
  --blue: #245e9c;
  --blue-soft: #e3eef9;
  --rose: #9d3f55;
  --red-soft: #f7e3df;
  --shadow: 0 16px 40px rgba(38, 43, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.12;
  letter-spacing: 0;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  min-width: 90px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 20px;
}

.controls {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 420px);
  gap: 14px;
  align-items: center;
  margin: 20px 0 14px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 10px 0;
  background: rgba(244, 242, 236, 0.9);
  backdrop-filter: blur(12px);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 260px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mode-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.mode-tab.active {
  background: var(--ink);
  color: #fff;
}

.accent-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: 132px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.accent-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.accent-button.active {
  background: var(--blue);
  color: #fff;
}

.search-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-wrap span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.selector-panel {
  margin-bottom: 18px;
}

.practice-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.practice-tab {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.practice-tab.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 10px 20px rgba(29, 122, 99, 0.18);
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.chip.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.hidden {
  display: none;
}

.summary-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 12px;
}

.view-label {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
}

h2 {
  margin-top: 4px;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.2;
  letter-spacing: 0;
}

.view-meta {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.summary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.checkin-button,
.copy-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 15px;
  box-shadow: 0 12px 26px rgba(31, 41, 51, 0.14);
}

.copy-button {
  width: fit-content;
  background: var(--green);
}

.task-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.task-pill {
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.task-pill:first-child {
  border-color: rgba(29, 122, 99, 0.34);
  background: linear-gradient(135deg, #fff, var(--green-soft));
}

.task-pill strong {
  display: block;
  margin-bottom: 3px;
  font-size: 16px;
}

.task-pill span {
  color: var(--muted);
  font-size: 13px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 12px;
}

.word-card {
  min-height: 166px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.word-card:hover,
.word-card:focus-within {
  border-color: rgba(36, 94, 156, 0.38);
  box-shadow: 0 18px 46px rgba(36, 94, 156, 0.12);
  transform: translateY(-2px);
}

.word-card.speaking {
  border-color: var(--blue);
  background: linear-gradient(180deg, #ffffff, var(--blue-soft));
}

.word-card.correct {
  border-color: rgba(29, 122, 99, 0.45);
  background: linear-gradient(180deg, #ffffff, #ecf8f3);
}

.word-card.wrong {
  border-color: rgba(157, 63, 85, 0.45);
  background: linear-gradient(180deg, #ffffff, #fff0f2);
}

.word-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.word-title {
  min-width: 0;
}

.review-mode-card .word-title {
  cursor: pointer;
}

.word {
  overflow-wrap: anywhere;
  font-size: 24px;
  font-weight: 850;
  line-height: 1.1;
}

.phonetic {
  margin-top: 6px;
  color: var(--blue);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.35;
}

.badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 850;
}

.badge.review {
  color: var(--amber);
  background: var(--amber-soft);
}

.meaning {
  color: #2d3742;
  font-size: 16px;
  line-height: 1.55;
}

.meaning.revealed {
  padding: 12px;
  border: 1px solid rgba(29, 122, 99, 0.2);
  border-radius: 8px;
  background: var(--green-soft);
}

.meaning-cover {
  width: 100%;
  min-height: 52px;
  border: 1px dashed rgba(36, 94, 156, 0.34);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  cursor: pointer;
  font-weight: 850;
}

.dictation-title {
  display: grid;
  gap: 4px;
}

.dictation-prompt {
  color: var(--ink);
  font-size: 21px;
  font-weight: 850;
  line-height: 1.2;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
}

.answer-input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-weight: 760;
}

.answer-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 94, 156, 0.13);
}

.answer-check {
  min-width: 66px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
}

.answer-result {
  margin-top: 10px;
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.answer-result.correct {
  color: var(--green);
}

.answer-result.wrong {
  color: var(--rose);
}

.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  text-align: center;
  font-weight: 760;
}

.checkin-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 18px;
  border: 1px solid rgba(29, 122, 99, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #eef6f3 58%, #fff8ea);
  box-shadow: var(--shadow);
}

.checkin-panel.hidden {
  display: none;
}

.checkin-kicker {
  color: var(--rose);
  font-size: 13px;
  font-weight: 850;
}

.checkin-panel h3 {
  margin: 3px 0 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.checkin-panel pre {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(101, 113, 128, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.62;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .summary-row {
    align-items: start;
    flex-direction: column;
  }

  .summary-actions {
    width: 100%;
    align-items: stretch;
    justify-content: space-between;
  }

  .checkin-button {
    flex: 1;
  }

  .stats {
    width: 100%;
    justify-content: stretch;
  }

  .stats span {
    flex: 1 1 80px;
  }

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

  .mode-tabs {
    width: 100%;
  }

  .accent-toggle {
    width: 100%;
  }

  .practice-tabs {
    grid-template-columns: 1fr;
  }

  .chip-grid {
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  }

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