:root {
  --ink: #17211d;
  --muted: #66736d;
  --line: #dce4df;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --jade: #0d7c66;
  --jade-dark: #095744;
  --red: #c7483a;
  --gold: #e0a72e;
  --sky: #2f72b7;
  --soft: #edf6f2;
  --shadow: 0 18px 45px rgba(23, 33, 29, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(251, 252, 250, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand,
.topbar nav,
footer nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--jade);
  border-radius: 8px;
  font-weight: 900;
}

.topbar nav,
footer nav {
  color: var(--muted);
  font-size: 0.95rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 560px);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  min-height: 64vh;
  padding: clamp(38px, 7vw, 92px) clamp(18px, 4vw, 56px) 34px;
  background:
    linear-gradient(130deg, rgba(13, 124, 102, 0.18), transparent 38%),
    linear-gradient(330deg, rgba(224, 167, 46, 0.24), transparent 42%),
    #f6f7f2;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  width: fit-content;
  margin: 0 0 18px;
  padding: 8px 12px;
  color: var(--jade-dark);
  background: #e3f3ed;
  border: 1px solid #bfe2d4;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
}

h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(2.6rem, 5.8vw, 4.9rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.subhead {
  max-width: 650px;
  color: #4f5f58;
  font-size: clamp(1.08rem, 2vw, 1.35rem);
  line-height: 1.6;
}

.tool-panel,
.practice-box,
.sidebar,
.card-stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 22px;
}

.tool-panel label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search-row input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid #cbd8d1;
  border-radius: 8px;
  outline: 0;
}

.search-row input:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 4px rgba(13, 124, 102, 0.14);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--jade);
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--jade-dark);
}

.search-row button {
  padding: 0 18px;
}

.quick-filters,
.topic-list,
.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-filters {
  margin-top: 14px;
}

.filter-btn,
.topic-btn,
.quiz-option {
  min-height: 38px;
  padding: 0 12px;
  color: var(--ink);
  background: #eef4f1;
  border: 1px solid #d4e2dc;
}

.filter-btn.active,
.topic-btn.active,
.quiz-option.correct {
  color: #fff;
  background: var(--jade);
  border-color: var(--jade);
}

.quiz-option.wrong {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.ad-band {
  padding: 20px clamp(18px, 4vw, 56px);
}

.ad-slot {
  display: grid;
  min-height: 92px;
  place-items: center;
  color: #718079;
  background: #f0f3f1;
  border: 1px dashed #b9c7c0;
  border-radius: 8px;
  font-size: 0.9rem;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  padding: 0 clamp(18px, 4vw, 56px) 56px;
}

.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  padding: 18px;
}

.section-title,
.box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.section-title strong {
  color: var(--jade-dark);
}

.topic-list {
  flex-direction: column;
}

.topic-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  color: var(--ink);
}

.content-stack {
  display: grid;
  gap: 22px;
}

.card-stage {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
  min-height: 230px;
  padding: clamp(22px, 4vw, 34px);
}

.hanzi {
  margin: 0 0 10px;
  font-size: clamp(3.6rem, 10vw, 7rem);
  line-height: 1;
  font-weight: 900;
}

.pinyin {
  color: var(--red);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
}

.meaning {
  color: var(--ink);
  font-size: 1.25rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.tag {
  padding: 6px 9px;
  color: #4f5f58;
  background: #f0f4f2;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 750;
}

.primary-play {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  background: var(--red);
  border-radius: 50%;
  font-size: 2rem;
}

.primary-play:hover {
  background: #9e3429;
}

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

.practice-box {
  min-height: 178px;
  padding: 18px;
  box-shadow: none;
}

.practice-box h2 {
  margin: 0;
  font-size: 1.05rem;
}

.practice-box p {
  color: var(--muted);
  line-height: 1.55;
}

.icon-btn {
  display: grid;
  width: 44px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border-radius: 50%;
}

#writeCanvas {
  width: 100%;
  height: 220px;
  background:
    linear-gradient(90deg, transparent 49.6%, rgba(199, 72, 58, 0.25) 49.8%, transparent 50.2%),
    linear-gradient(transparent 49.6%, rgba(199, 72, 58, 0.25) 49.8%, transparent 50.2%),
    #fffdf8;
  border: 1px solid #e1d8ca;
  border-radius: 8px;
  touch-action: none;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

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

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-card h3 {
  margin: 0;
  font-size: 1.9rem;
}

.result-card h3 a:hover {
  color: var(--jade);
}

.result-card .mini-play {
  min-width: 40px;
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

.result-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 30px clamp(18px, 4vw, 56px);
  color: #52615b;
  background: #eef3f0;
  border-top: 1px solid var(--line);
}

footer p {
  max-width: 620px;
  margin: 8px 0 0;
}

.simple-page,
.detail-page {
  padding: clamp(42px, 7vw, 92px) clamp(18px, 4vw, 56px);
}

.simple-page {
  min-height: 72vh;
}

.simple-page h1,
.detail-hero h1 {
  max-width: 980px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 34px;
}

.contact-box {
  max-width: 560px;
  margin-top: 28px;
}

.text-link {
  color: var(--jade-dark);
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--muted);
  font-weight: 750;
}

.breadcrumb a {
  color: var(--jade-dark);
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: center;
  padding-bottom: 34px;
}

.detail-pinyin {
  margin-top: 14px;
}

.pronunciation-card {
  min-height: auto;
}

.lesson-copy {
  max-width: 860px;
  padding: 28px 0 10px;
}

.lesson-copy h2 {
  margin-top: 0;
}

.lesson-copy p {
  color: #4f5f58;
  font-size: 1.08rem;
  line-height: 1.75;
}

.page-section {
  margin-top: 20px;
}

@media (max-width: 900px) {
  .hero,
  .workspace,
  .card-stage,
  footer,
  .detail-hero,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .sidebar {
    position: static;
  }

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar nav {
    width: 100%;
    justify-content: space-between;
  }

  .search-row,
  .practice-grid,
  .topic-list {
    grid-template-columns: 1fr;
  }

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

  .primary-play {
    justify-self: center;
  }

  footer {
    flex-direction: column;
  }
}
