*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #f8f6f1;
  --surface: #f2efea;
  --border:  rgba(28,25,22,0.1);
  --border2: rgba(28,25,22,0.2);
  --red:     #b91c1c;
  --text:    #1c1916;
  --muted:   #7a6f66;
  --dim:     #b8afa6;
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.75;
  min-height: 100vh;
}

/* ── Nav ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 40px;
  gap: 20px;
}
.nav-brand {
  font-family: 'Noto Serif JP', serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.04em;
}
.nav-sub {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.nav-right { margin-left: auto; display: flex; gap: 20px; align-items: center; }
.nav-stat { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; }
.nav-stat span { color: var(--text); }

/* ── Container ── */
.container { max-width: 900px; margin: 0 auto; padding: 0 40px; }

/* ── Hero ── */
.hero {
  padding: 72px 0 56px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}
.hero-deco {
  position: absolute;
  top: -10px;
  right: -20px;
  font-family: 'Noto Serif JP', serif;
  font-size: 9rem;
  font-weight: 600;
  color: rgba(28,25,22,0.04);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}
.hero-label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 14px;
}
.hero-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  line-height: 1.3;
}
.hero-sub {
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

/* ── Section label ── */
.section-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 24px;
}

/* ── Lesson list ── */
.lesson-list { padding-bottom: 80px; }

.lesson-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 0 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  position: relative;
  transition: color 0.15s;
  cursor: pointer;
}
.lesson-row::before {
  content: '';
  position: absolute;
  left: -40px;
  right: -40px;
  top: 0;
  bottom: 0;
  background: rgba(28,25,22,0.025);
  opacity: 0;
  transition: opacity 0.15s;
}
.lesson-row:hover::before { opacity: 1; }
.lesson-row:hover .lesson-row-num { color: var(--red); }

.lesson-row.locked {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
}

.lesson-row-num {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--dim);
  transition: color 0.15s;
}
.lesson-row-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.lesson-row-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.lesson-row-meta {
  font-size: 0.72rem;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-align: right;
  white-space: nowrap;
}

/* ── Lesson page header ── */
.lesson-header {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}
.lesson-header-deco {
  position: absolute;
  right: -10px;
  top: -20px;
  font-family: 'Noto Serif JP', serif;
  font-size: 8rem;
  font-weight: 600;
  color: rgba(28,25,22,0.04);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}
.breadcrumb a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--text); }
.lesson-number {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 10px;
}
.lesson-title-jp {
  font-family: 'Noto Serif JP', serif;
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  line-height: 1.3;
}
.lesson-title-cn { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.lesson-theme {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-left: 2px solid var(--red);
  padding-left: 10px;
  display: inline-block;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  font-weight: 500;
  padding: 10px 24px 10px 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  margin-right: 28px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--red); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Vocab ── */
.vocab-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.vocab-search {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 8px 0;
  outline: none;
  width: 200px;
  transition: border-color 0.15s;
}
.vocab-search::placeholder { color: var(--dim); }
.vocab-search:focus { border-bottom-color: var(--red); }
.vocab-count { font-size: 0.72rem; color: var(--dim); letter-spacing: 0.04em; }

.vocab-table { width: 100%; border-collapse: collapse; margin-bottom: 60px; }
.vocab-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 16px 12px 0;
  border-bottom: 1px solid var(--border);
}
.vocab-table td {
  padding: 13px 16px 13px 0;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(28,25,22,0.05);
  vertical-align: middle;
}
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table tr:hover td { background: rgba(28,25,22,0.02); }
.vocab-word {
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.vocab-reading { color: var(--muted); font-size: 0.8rem; }

.type-badge { font-size: 0.65rem; letter-spacing: 0.06em; font-weight: 500; }
.type-名词   { color: #1d4ed8; }
.type-动词   { color: var(--red); }
.type-形容词 { color: #0f766e; }
.type-副词   { color: #b45309; }
.type-代词   { color: #6d28d9; }
.type-接尾词 { color: var(--muted); }
.type-感叹词 { color: var(--muted); }
.type-连体词 { color: #0f766e; }
.type-接续   { color: #0369a1; }

/* ── Grammar ── */
.grammar-list { display: flex; flex-direction: column; padding-bottom: 80px; }
.grammar-card {
  padding: 28px 0 28px 24px;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid var(--red);
  transition: border-left-color 0.2s;
}
.grammar-card:hover { border-left-color: #dc2626; }
.grammar-pattern {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.grammar-meaning { font-size: 0.88rem; color: var(--muted); margin-bottom: 14px; }
.grammar-formation {
  font-size: 0.78rem;
  color: var(--red);
  letter-spacing: 0.06em;
  display: inline-block;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(185,28,28,0.25);
  padding-bottom: 2px;
}
.grammar-note { font-size: 0.8rem; color: var(--muted); margin-bottom: 16px; }
.grammar-examples { margin-bottom: 18px; }
.example-row { margin-bottom: 10px; }
.example-jp {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.96rem;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.example-cn { font-size: 0.78rem; color: var(--muted); }

.grammar-related { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.related-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-right: 4px;
}
.related-chip {
  font-size: 0.72rem;
  padding: 3px 10px;
  border: 1px solid var(--border2);
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.related-chip:hover { border-color: var(--red); color: var(--text); }

/* ── Speak button ── */
.speak-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dim);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.speak-btn:hover { color: var(--red); }

.speak-line {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.speak-line-icon {
  color: var(--dim);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.speak-line:hover .speak-line-icon { opacity: 1; color: var(--red); }

/* ── Dialogue ── */
.dialogue-toolbar {
  margin-bottom: 28px;
}
.translation-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.translation-toggle input { accent-color: var(--red); cursor: pointer; }

.dialogue-list { padding-bottom: 80px; }

.dialogue-scene {
  margin-bottom: 48px;
}
.dialogue-scene-title {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.dialogue-line {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 0 20px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(28,25,22,0.04);
  align-items: baseline;
}
.dialogue-speaker {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--red);
  padding-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialogue-jp {
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
  margin-bottom: 3px;
}
.dialogue-cn {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.dialogue-empty {
  font-family: 'Noto Serif JP', serif;
  color: var(--dim);
  font-size: 0.9rem;
  padding: 40px 0;
}

/* ── Examples (例文) ── */
.reibun-list { padding-bottom: 80px; }
.reibun-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.reibun-item:last-child { border-bottom: none; }
.reibun-num {
  min-width: 1.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--red);
  padding-top: 0.2rem;
  flex-shrink: 0;
}
.reibun-lines { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.reibun-line {
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.reibun-line:hover { color: var(--red); }
.reibun-reply {
  color: var(--muted);
  padding-left: 1rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  nav { padding: 0 20px; }
  .container { padding: 0 20px; }
  .hero { padding: 48px 0 36px; }
  .hero-title { font-size: 1.9rem; }
  .lesson-row { grid-template-columns: 56px 1fr; }
  .lesson-row-meta { display: none; }
  .vocab-table th:nth-child(2),
  .vocab-table td:nth-child(2) { display: none; }
}
