:root {
  color-scheme: light;
  --bg: #f5f2eb;
  --surface: #fffdf8;
  --surface-2: #ebe7dc;
  --ink: #18231f;
  --muted: #66736e;
  --line: #ded7c8;
  --green: #2e6f61;
  --green-dark: #1f4d43;
  --gold: #d4a037;
  --blue: #315d86;
  --red: #b85a4c;
  --shadow: 0 24px 70px rgba(43, 53, 47, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(46, 111, 97, 0.15), transparent 34rem),
    linear-gradient(135deg, #f5f2eb 0%, #edf2ef 54%, #f8f3e6 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar,
.study-area {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

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

h1 {
  font-size: 24px;
  line-height: 1.15;
}

.eyebrow,
.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.panel,
.word-card,
.topbar,
.empty-state {
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid rgba(222, 215, 200, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 750;
}

.icon-button,
.text-button,
.ghost-button,
.danger-button,
.tab,
.primary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.text-button,
.ghost-button,
.danger-button,
.tab {
  padding: 0 14px;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: none;
  background: var(--green);
  color: #fff;
  font-weight: 760;
}

.shortcut-hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.danger-button {
  color: var(--red);
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.plan-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.plan-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 34px;
  line-height: 1;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.setting-row input,
#searchInput {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.setting-row input {
  width: 86px;
}

.progress-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 168px;
  margin: 8px auto 18px;
}

.progress-ring svg {
  width: 168px;
  height: 168px;
  transform: rotate(-90deg);
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 12;
}

.ring-track {
  stroke: #e8e0d1;
}

.ring-fill {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 240ms ease;
}

.progress-ring > div {
  position: absolute;
  display: grid;
  place-items: center;
  gap: 2px;
}

.progress-ring strong {
  font-size: 28px;
}

.progress-ring span {
  color: var(--muted);
  font-size: 12px;
}

.stats-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.stats-list div {
  padding: 10px;
  border-radius: 8px;
  background: #f7f4ed;
}

.stats-list dt {
  color: var(--muted);
  font-size: 12px;
}

.stats-list dd {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 760;
}

.mini-quiz p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.quiz-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quiz-options button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  padding: 8px 10px;
}

.quiz-options button.correct {
  border-color: var(--green);
  background: #eaf4ef;
}

.quiz-options button.wrong {
  border-color: var(--red);
  background: #faeeeb;
}

.study-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 12px;
}

.tabs,
.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.word-card {
  min-height: 520px;
  border-radius: 8px;
  padding: clamp(22px, 5vw, 56px);
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}

#levelBadge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
}

.word-main {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 230px;
  text-align: center;
}

#phonetic {
  color: var(--green);
  font-size: 18px;
}

#wordText {
  margin-top: 8px;
  font-size: clamp(44px, 8vw, 88px);
  line-height: 1;
}

.sound-button {
  width: 48px;
  aspect-ratio: 1;
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green-dark);
}

.answer {
  display: grid;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto 24px;
  text-align: center;
}

.meaning {
  font-size: 24px;
  font-weight: 750;
}

.example {
  color: #3d4945;
  font-size: 17px;
  line-height: 1.7;
}

.note {
  color: var(--muted);
  font-size: 14px;
}

.rating-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.rating {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.rating span,
.rating small {
  display: block;
}

.rating span {
  font-size: 18px;
  font-weight: 760;
}

.rating small {
  margin-top: 4px;
  color: var(--muted);
}

.rating.forgot:hover {
  border-color: var(--red);
}

.rating.vague:hover {
  border-color: var(--gold);
}

.rating.known:hover {
  border-color: var(--green);
}

.empty-state {
  border-radius: 8px;
  padding: 40px;
  text-align: center;
}

.empty-state p {
  margin: 10px auto 22px;
  max-width: 520px;
  color: var(--muted);
}

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

#searchInput {
  width: min(360px, 100%);
}

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

.word-item {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  padding: 14px;
}

.word-item strong {
  display: block;
  font-size: 20px;
}

.word-item p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.word-item span {
  display: inline-block;
  margin-top: 10px;
  color: var(--green);
  font-size: 12px;
}

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

  .sidebar {
    order: 2;
  }

  .study-area {
    order: 1;
  }

  .word-card {
    min-height: 460px;
  }
}

@media (max-width: 620px) {
  .topbar,
  .word-list-header {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .top-actions,
  .rating-bar {
    grid-template-columns: 1fr;
  }

  .rating-bar {
    display: grid;
  }

  .top-actions > *,
  .tabs > * {
    flex: 1;
  }

  .stats-list {
    grid-template-columns: 1fr;
  }
}
