:root {
  color-scheme: light;
  --bg: #efe8d3;
  --surface: #fffaf0;
  --surface-2: #e7e0c6;
  --ink: #17160f;
  --muted: #6f6552;
  --line: #c9bea2;
  --green: #4d7c3a;
  --green-soft: #e3efd8;
  --amber: #ad6b1f;
  --amber-soft: #f7dfaa;
  --blue: #2563eb;
  --blue-soft: #e6efff;
  --red: #c2412d;
  --red-soft: #f6d6c8;
  --violet: #7656a6;
  --violet-soft: #e8ddf3;
  --shadow: 0 10px 0 rgba(23, 22, 15, .08), 0 22px 50px rgba(84, 67, 36, .12);
}

* {
  box-sizing: border-box;
}

html {
  background:
    linear-gradient(90deg, rgba(23, 22, 15, .04) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(23, 22, 15, .04) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
}

.game-backdrop {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

.game-token {
  align-items: center;
  background: rgba(255, 250, 240, .72);
  border: 2px solid rgba(23, 22, 15, .18);
  border-radius: 8px;
  box-shadow: 0 6px 0 rgba(23, 22, 15, .06);
  color: rgba(23, 22, 15, .28);
  display: inline-flex;
  font-size: clamp(30px, 5vw, 72px);
  font-weight: 900;
  height: clamp(58px, 9vw, 110px);
  justify-content: center;
  position: absolute;
  width: clamp(58px, 9vw, 110px);
}

.token-arrow {
  right: 8vw;
  top: 8vh;
  transform: rotate(-8deg);
}

.token-block {
  left: 22vw;
  top: 66vh;
  transform: rotate(7deg);
}

.token-water {
  right: 16vw;
  top: 72vh;
  transform: rotate(11deg);
}

.token-screw {
  left: 48vw;
  top: 16vh;
  transform: rotate(-12deg);
}

.sidebar {
  background:
    linear-gradient(135deg, rgba(247, 223, 170, .08) 25%, transparent 25%) 0 0 / 22px 22px,
    #24351f;
  color: #fffaf0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  display: grid;
  gap: 10px;
}

.brand-mark {
  align-items: center;
  background: #f7dfaa;
  border: 2px solid rgba(23, 22, 15, .7);
  border-radius: 8px;
  color: #101313;
  display: inline-flex;
  font-weight: 800;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.15;
  margin: 0;
}

.brand p {
  color: #d7d3bd;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-button,
.tab-button,
.ghost-button,
.primary-button,
.chip {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
}

.nav-button {
  background: transparent;
  border: 1px solid rgba(255, 250, 240, .18);
  color: #ebe6ce;
  justify-content: flex-start;
  width: 100%;
}

.nav-button.is-active {
  background: #f7dfaa;
  border-color: #f7dfaa;
  color: #101313;
  font-weight: 700;
}

.sidebar-meter {
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  padding: 14px;
}

.sidebar-meter strong {
  display: block;
  font-size: 26px;
  margin-bottom: 8px;
}

.audio-toggle {
  align-items: center;
  background: rgba(255, 250, 240, .08);
  border: 1px solid rgba(255, 250, 240, .22);
  border-radius: 8px;
  color: #ebe6ce;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

.audio-toggle span {
  align-items: center;
  background: #f7dfaa;
  border: 2px solid rgba(23, 22, 15, .7);
  border-radius: 8px;
  color: #101313;
  display: inline-flex;
  font-size: 18px;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.audio-toggle strong {
  font-size: 13px;
}

.audio-toggle.is-on {
  background: #f7dfaa;
  border-color: #f7dfaa;
  color: #101313;
}

.progress-track {
  background: rgba(255, 255, 255, .14);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  background: #f1b84b;
  border-radius: inherit;
  display: block;
  height: 100%;
  width: var(--value, 0%);
}

.content {
  padding: 28px clamp(18px, 3vw, 42px) 96px;
  position: relative;
  z-index: 1;
}

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

.topline p {
  color: var(--muted);
  margin: 0;
}

.search-box {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 8px;
  display: flex;
  min-width: min(360px, 100%);
  overflow: hidden;
}

.search-box input {
  border: 0;
  flex: 1;
  min-height: 44px;
  min-width: 0;
  outline: 0;
  padding: 0 14px;
}

.hero-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
}

.hero-panel,
.panel,
.term-card,
.lesson-card,
.quiz-card,
.term-detail {
  background: var(--surface);
  border: 2px solid rgba(23, 22, 15, .72);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  background:
    linear-gradient(135deg, rgba(77, 124, 58, .10) 0 25%, transparent 25% 50%, rgba(194, 65, 45, .08) 50% 75%, transparent 75%) 0 0 / 48px 48px,
    var(--surface);
  display: grid;
  gap: 24px;
  min-height: 420px;
  padding: clamp(22px, 4vw, 42px);
}

.eyebrow {
  color: #8a3f00;
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 8px;
}

.hero-panel h2,
.page-title {
  font-size: clamp(32px, 5vw, 62px);
  line-height: 1.02;
  margin: 0;
  text-shadow: 0 3px 0 rgba(23, 22, 15, .08);
}

.hero-panel .lead {
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.7;
  max-width: 720px;
}

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

.primary-button {
  background: #c2412d;
  border: 2px solid var(--ink);
  color: white;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--ink);
}

.ghost-button {
  background: var(--surface);
  border: 2px solid var(--ink);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(23, 22, 15, .18);
}

.visual-panel {
  background: #101313;
  border-radius: 8px;
  overflow: hidden;
}

.visual-panel img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.stat-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  background: #efe3bd;
  border: 2px solid rgba(23, 22, 15, .32);
  border-radius: 8px;
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 28px;
}

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

.section {
  margin-top: 22px;
}

.section-header {
  align-items: end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h3,
.panel h3 {
  font-size: 20px;
  margin: 0;
}

.section-header p,
.panel p {
  color: var(--muted);
  margin: 6px 0 0;
}

.category-grid,
.term-grid,
.lesson-grid {
  display: grid;
  gap: 12px;
}

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

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

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

.panel {
  padding: 18px;
  text-align: left;
}

.term-card,
.lesson-card {
  padding: 16px;
  text-align: left;
}

.term-card {
  background: var(--surface);
  border: 2px solid rgba(23, 22, 15, .72);
}

.term-card-head,
.term-title-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.term-title-row {
  flex-wrap: wrap;
}

.term-copy-button {
  margin-left: auto;
}

.term-icon {
  align-items: center;
  background: #f7dfaa;
  border: 2px solid rgba(23, 22, 15, .72);
  border-radius: 8px;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 22px;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.detail-icon {
  font-size: 32px;
  height: 58px;
  width: 58px;
}

.tone-line {
  background: #f7efd8;
  border-left: 4px solid #c2412d;
  color: #574a36;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
  margin: 0 0 12px;
  padding: 8px 10px;
}

.detail-tone {
  font-size: 15px;
  margin-top: 12px;
}

.term-card h4,
.lesson-card h4 {
  font-size: 18px;
  line-height: 1.25;
  margin: 0 0 8px;
}

.term-card p,
.lesson-card p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 12px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  background: #efe3bd;
  border: 1px solid rgba(23, 22, 15, .18);
  border-radius: 999px;
  color: #38443e;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.pill.risk-watch {
  background: var(--amber-soft);
  color: #8a3f00;
}

.pill.risk-danger {
  background: var(--red-soft);
  color: #b91c1c;
}

.filter-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 16px;
}

.filter-bar select,
.filter-bar input {
  background: var(--surface);
  border: 2px solid rgba(23, 22, 15, .5);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
}

.split-view {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .46fr);
}

.detail-sticky {
  align-self: start;
  position: sticky;
  top: 20px;
}

.term-detail {
  padding: 20px;
}

.term-detail h3 {
  font-size: 28px;
  margin: 0 0 8px;
}

.term-detail dl {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
}

.term-detail dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.term-detail dd {
  line-height: 1.7;
  margin: 4px 0 0;
}

.related-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.official-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

.official-link {
  background: #e3efd8;
  border-color: rgba(77, 124, 58, .48);
  color: #294b20;
  text-decoration: none;
}

.chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 34px;
  padding: 7px 10px;
}

.interaction-panel {
  border-top: 2px dashed var(--line);
  display: grid;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
}

.share-actions {
  border-top: 2px dashed var(--line);
  padding-top: 18px;
}

.share-card-output:empty {
  display: none;
}

.share-card-panel {
  background: #f7efd8;
  border: 2px solid rgba(23, 22, 15, .28);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
}

.share-card-preview {
  background: var(--surface);
  border: 2px solid rgba(23, 22, 15, .5);
  border-radius: 8px;
  box-shadow: 0 6px 0 rgba(23, 22, 15, .1);
  display: block;
  max-width: min(100%, 360px);
  width: 100%;
}

.share-download {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
}

.interaction-stats {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-pill {
  background: #f7efd8;
  border: 1px solid rgba(23, 22, 15, .16);
  border-radius: 999px;
  color: #574a36;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 10px;
}

.like-chip.is-liked {
  background: var(--red-soft);
  border-color: rgba(194, 65, 45, .4);
  color: #9a2f22;
}

.comment-form {
  display: grid;
  gap: 8px;
}

.comment-form input,
.comment-form textarea {
  background: var(--surface);
  border: 2px solid rgba(23, 22, 15, .34);
  border-radius: 8px;
  color: var(--ink);
  outline: 0;
  padding: 10px 12px;
  width: 100%;
}

.comment-form textarea {
  line-height: 1.5;
  resize: vertical;
}

.comment-form .primary-button {
  justify-self: start;
}

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

.comment-item {
  border-top: 1px solid rgba(23, 22, 15, .12);
  padding-top: 10px;
}

.comment-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  justify-content: space-between;
}

.comment-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.comment-item p,
.empty-comment {
  color: var(--muted);
  line-height: 1.6;
  margin: 6px 0 0;
}

.lesson-card {
  display: grid;
  gap: 12px;
}

.lesson-status {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.quiz-card {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 820px;
  padding: clamp(18px, 4vw, 28px);
}

.quiz-card h3 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.2;
  margin: 0;
}

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

.option-button {
  background: var(--surface);
  border: 2px solid rgba(23, 22, 15, .6);
  border-radius: 8px;
  color: var(--ink);
  min-height: 52px;
  padding: 12px 14px;
  text-align: left;
}

.option-button.is-correct {
  background: var(--green-soft);
  border-color: var(--green);
}

.option-button.is-wrong {
  background: var(--red-soft);
  border-color: var(--red);
}

.feedback {
  background: #f7efd8;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  line-height: 1.7;
  padding: 12px 14px;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 30px;
  text-align: center;
}

.bottom-nav {
  display: none;
}

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

  .sidebar {
    display: none;
  }

  .hero-grid,
  .split-view {
    grid-template-columns: 1fr;
  }

  .detail-sticky {
    position: static;
  }

  .glossary-detail-first .detail-sticky {
    order: -1;
  }

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

@media (max-width: 760px) {
  .content {
    padding: 18px 14px calc(86px + env(safe-area-inset-bottom));
  }

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

  .hero-panel {
    min-height: auto;
  }

  .stat-grid,
  .category-grid,
  .term-grid,
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .visual-panel {
    min-height: 210px;
  }

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

  .filter-bar select,
  .filter-bar input {
    width: 100%;
  }

  .bottom-nav {
    background: rgba(255, 255, 255, .95);
    border-top: 2px solid var(--ink);
    bottom: 0;
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(5, 1fr);
    left: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 20;
  }

  .bottom-nav .nav-button,
  .bottom-audio {
    border-color: var(--line);
    color: var(--ink);
    font-size: 13px;
    justify-content: center;
    min-height: 42px;
    padding: 8px;
  }

  .bottom-audio {
    background: var(--surface);
    gap: 4px;
  }

  .bottom-audio span {
    border-width: 1px;
    font-size: 13px;
    height: 22px;
    width: 22px;
  }

  .bottom-audio strong {
    font-size: 11px;
  }

  .bottom-nav .nav-button.is-active {
    background: #c2412d;
    border-color: var(--ink);
    color: white;
  }

  .bottom-audio.is-on {
    background: #f7dfaa;
    border-color: var(--ink);
    color: var(--ink);
  }
}
