:root {
  --bg: #f6f3eb;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --text: #1e1f23;
  --muted: #666d78;
  --line: #ddd4c3;
  --accent: #d96c27;
  --accent-dark: #8f3f12;
  --accent-soft: #fde4d3;
  --green-soft: #e1f6ea;
  --red-soft: #ffe3df;
  --shadow: 0 18px 40px rgba(74, 49, 20, 0.08);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #fff9ef 0, var(--bg) 55%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

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

.brand-block {
  flex: 0 1 360px;
  min-width: 0;
}

.brand {
  display: inline-block;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.subtitle,
.muted,
.record-row p,
.theme-card p {
  color: var(--muted);
}

.subtitle {
  max-width: 340px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav a,
.user-chip,
.badge {
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.page,
.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dashboard-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 18px;
}

.stack.compact {
  gap: 12px;
}

.hero,
.card,
.theme-card,
.word-card {
  background: var(--panel);
  border: 1px solid rgba(193, 175, 143, 0.45);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 28px;
  align-items: center;
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(1.9rem, 3vw, 3rem);
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero-stats,
.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.stat {
  min-width: 110px;
  padding: 16px;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  text-align: center;
}

.stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat strong {
  font-size: 1.4rem;
}

.grid.two,
.theme-grid,
.word-list {
  display: grid;
  gap: 18px;
}

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

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

.word-list {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card,
.theme-card,
.word-card {
  padding: 22px;
}

.word-card {
  display: flex;
  flex-direction: column;
}

.word-card p {
  margin: 0 0 14px;
}

.word-card > div:not(.word-head):not(.word-footer) {
  margin-bottom: 14px;
}

.section-head,
.word-head,
.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.record-row {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.record-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.practice-inline-phonetic {
  color: var(--accent-dark);
  font-size: 1.02rem;
  white-space: nowrap;
  font-weight: 500;
}

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

.grade-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.primary,
.secondary,
button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 16px;
  padding: 12px 16px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.secondary,
button {
  background: #fff;
  border-color: var(--line);
}

input[type="text"] {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
  background: #fff;
}

.inline-form {
  margin: 0;
}

.user-select {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.review-item {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.review-item.correct {
  background: var(--green-soft);
}

.review-item.wrong {
  background: var(--red-soft);
}

.sentence-list {
  margin: 8px 0 0 18px;
  padding: 0;
}

.phonetic-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.inline-audio-row {
  flex-wrap: wrap;
  vertical-align: middle;
}

.phonetic {
  margin: 0;
}

.audio-button {
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0 0 14px;
  border-radius: 999px;
  background: #fff8ee;
  border-color: #ecd5b6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  vertical-align: middle;
}

.audio-button.is-playing {
  background: var(--accent-soft);
  border-color: #efb38a;
}

.audio-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.audio-icon-speaker-fill,
.audio-icon-wave-fill {
  fill: #e1a42f;
}

.word-footer {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
}

.word-actions {
  display: grid;
  gap: 10px;
  width: 160px;
  flex: 0 0 160px;
  align-self: flex-end;
}

.study-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.95rem;
  flex: 1 1 auto;
  min-width: 0;
}

.studied-button {
  width: 100%;
  background: #ff5e5e;
  color: #fff;
  border-color: #ff5e5e;
}

.studied-button.is-active {
  background: #df4f4f;
  border-color: #df4f4f;
}

.pass-button {
  width: 100%;
  background: #f0f0f0;
  color: #59616d;
  border-color: #d9d9d9;
}

.pass-button.is-active {
  background: #dfe3e8;
  border-color: #c8d0d8;
  color: #444c56;
}

.word-card.is-processed {
  background: #f3efe6;
  border-color: rgba(193, 175, 143, 0.42);
  box-shadow: none;
}

.word-card.is-processed h2,
.word-card.is-processed p,
.word-card.is-processed strong,
.word-card.is-processed li,
.word-card.is-processed .phonetic {
  color: #7a8088;
}

.word-card.is-processed .badge {
  opacity: 0.72;
}

.word-card.is-processed .audio-button {
  opacity: 0.72;
}

.word-card.is-processed .word-footer,
.word-card.is-processed .sentence-list {
  opacity: 0.82;
}

.word-card.is-studied {
  background: #f7eeeb;
  border-color: rgba(223, 79, 79, 0.22);
}

.word-card.is-passed {
  background: #f1f0ec;
  border-color: rgba(180, 180, 180, 0.34);
}

.notice {
  padding: 14px 18px;
  border-radius: 18px;
  background: var(--red-soft);
  border: 1px solid #f2b4aa;
}

@media (max-width: 800px) {
  .topbar,
  .hero,
  .grid.two,
  .dashboard-columns {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .grid.two,
  .grade-grid {
    grid-template-columns: 1fr;
  }

  .word-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .word-actions {
    width: 100%;
    flex-basis: auto;
    align-self: stretch;
  }
}

.grid.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.big-number {
  margin: 10px 0;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #efe4d4;
  overflow: hidden;
  margin: 12px 0 14px;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb46a, #d96c27);
}

.timer-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
}

@media (max-width: 800px) {
  .grid.three {
    grid-template-columns: 1fr;
  }
}
