:root {
  color-scheme: light;
  --paper: #f7f1e8;
  --surface: #fffaf4;
  --surface-strong: #fff4e9;
  --ink: #241d18;
  --muted: #70645a;
  --soft: #a6907f;
  --brand: #bd5729;
  --brand-dark: #8f391a;
  --brand-soft: #f0d7c7;
  --line: #ead9cb;
  --shadow: 0 20px 46px rgba(77, 45, 25, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(189, 87, 41, 0.14), transparent 25rem),
    linear-gradient(180deg, #fbf7f0 0%, var(--paper) 100%);
}

button {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0 44px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 850;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.brand-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-title strong {
  font-size: 0.98rem;
  white-space: nowrap;
}

.brand-title span {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pill,
.round-button,
.ghost-button,
.primary-button {
  border: 1px solid var(--line);
  background: rgba(255, 250, 244, 0.88);
  color: var(--ink);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 13px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.round-button {
  width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--brand);
}

.primary-button {
  border: 0;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.ghost-button {
  border-radius: 8px;
  background: #fffdf8;
  font-weight: 720;
}

.pill:hover,
.round-button:hover,
.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  border-color: #ddb8a1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: stretch;
  margin: 6px 0 16px;
}

.hero-panel,
.study-panel,
.sidebar-panel,
.lesson-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.94);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: clamp(22px, 5vw, 44px);
  min-height: 310px;
  display: grid;
  align-content: end;
}

.eyebrow {
  color: var(--brand);
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.35rem, 8vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: 0;
  max-width: 820px;
}

.hero-copy {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.68;
  font-size: 1.02rem;
  max-width: 760px;
}

.study-panel {
  padding: 18px;
  display: grid;
  gap: 15px;
  align-content: start;
}

.study-panel h2,
.sidebar-panel h2 {
  margin: 0;
  font-size: 1.06rem;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.meter {
  height: 10px;
  background: #ead8c9;
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #d98248);
  transition: width 0.2s ease;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.main-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.sidebar-panel {
  position: sticky;
  top: 70px;
  padding: 14px;
}

.lesson-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lesson-tab {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.lesson-tab.active {
  border-color: #d9a98b;
  background: var(--surface-strong);
}

.lesson-tab strong {
  display: block;
  color: var(--brand);
  margin-bottom: 4px;
}

.lesson-tab span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.reader {
  display: grid;
  gap: 14px;
}

.lesson-section {
  overflow: hidden;
}

.section-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 244, 233, 0.75);
}

.section-header h2 {
  margin: 0;
  font-size: 1.24rem;
}

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

.line-list {
  display: grid;
}

.line-card {
  padding: 18px 20px;
  border-top: 1px solid rgba(234, 217, 203, 0.8);
}

.line-card:first-child {
  border-top: 0;
}

.english-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.english {
  margin: 0;
  color: var(--brand);
  font-size: clamp(1.32rem, 3.6vw, 2.35rem);
  line-height: 1.25;
  font-weight: 780;
}

.translation {
  margin: 9px 0 0 48px;
  color: #5f574f;
  line-height: 1.72;
  font-size: 1.02rem;
}

.phrase {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  cursor: pointer;
  border-radius: 4px;
}

.phrase:hover {
  background: var(--brand-soft);
}

.dictionary {
  position: sticky;
  top: 70px;
  display: grid;
  gap: 12px;
}

.word-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.96);
  box-shadow: var(--shadow);
}

.word-card h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.word {
  margin: 0;
  color: var(--brand);
  font-weight: 850;
  font-size: 1.55rem;
}

.word-cn {
  margin: 3px 0 10px;
  color: var(--ink);
  font-weight: 750;
}

.word-note {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 14px;
}

.saved-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-list li {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 0.88rem;
}

.hidden-cn .translation {
  display: none;
}

.mobile-lesson-title {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 90px);
  z-index: 30;
  background: #2d251e;
  color: #fff;
  border-radius: 999px;
  padding: 10px 15px;
  transition: transform 0.2s ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .hero,
  .main-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    position: static;
  }

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

  .dictionary {
    position: static;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 6px;
  }

  .app-header {
    align-items: flex-start;
  }

  .brand-title span {
    display: none;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .pill {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.86rem;
  }

  .hero-panel {
    min-height: auto;
    padding: 22px;
  }

  .hero h1 {
    font-size: 2.35rem;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .lesson-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .lesson-tab {
    min-width: 245px;
    scroll-snap-align: start;
  }

  .section-header,
  .line-card {
    padding: 16px;
  }

  .english {
    font-size: 1.58rem;
  }

  .translation {
    margin-left: 0;
  }

  .dictionary {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 0 10px 10px;
    pointer-events: none;
  }

  .word-card {
    pointer-events: auto;
    box-shadow: 0 -18px 45px rgba(77, 45, 25, 0.18);
  }
}
