:root {
  --bg: #f4f0e2;
  --bg-strong: #e7f0da;
  --panel: rgba(255, 252, 244, 0.86);
  --panel-strong: rgba(244, 251, 237, 0.95);
  --line: rgba(62, 110, 70, 0.22);
  --ink: #243525;
  --muted: #617463;
  --accent: #3e7b53;
  --accent-strong: #2c5c3c;
  --accent-soft: rgba(62, 123, 83, 0.14);
  --danger: #a34b33;
  --danger-soft: rgba(163, 75, 51, 0.12);
  --shadow: 0 24px 60px rgba(51, 78, 56, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-display: "Kaiti SC", "STKaiti", "Songti SC", "Noto Serif SC", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(185, 215, 161, 0.45), transparent 30%),
    radial-gradient(circle at bottom right, rgba(230, 205, 157, 0.42), transparent 24%),
    linear-gradient(180deg, #f8f4e7 0%, #efe9d6 100%);
  font-family: var(--font-body);
}

.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(63, 116, 79, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63, 116, 79, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 85%);
}

.site-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 40px 0 24px;
}

.page-header > div,
.panel-heading > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.88rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.03em;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
}

h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.lede {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.student-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
  padding-bottom: 44px;
}

.intro-card {
  grid-column: span 5;
}

.playback-card {
  grid-column: span 7;
}

.words-card,
.login-card {
  grid-column: 1 / -1;
}

.demo-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  padding-bottom: 44px;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(120, 160, 115, 0.18);
  border-radius: calc(var(--radius-xl) - 10px);
  pointer-events: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-grid,
.settings-grid,
.stat-row,
.action-row,
.stack-form,
.selection-list,
.lesson-grid,
.word-grid {
  position: relative;
  z-index: 1;
}

.control-grid,
.settings-grid {
  display: grid;
  gap: 16px;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.field span {
  color: var(--ink);
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(87, 125, 82, 0.24);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(62, 123, 83, 0.55);
  box-shadow: 0 0 0 4px rgba(62, 123, 83, 0.12);
}

textarea {
  resize: vertical;
  min-height: 220px;
  line-height: 1.8;
}

#manual-upload-spec,
#grade-upload-spec {
  overflow: auto;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 1.7;
}

input[type="range"] {
  padding: 0;
}

.section-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.lesson-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lesson-chip,
.list-item {
  border: 1px solid rgba(62, 123, 83, 0.18);
  background: rgba(255, 255, 255, 0.72);
}

.lesson-chip {
  padding: 10px 14px;
  max-width: 100%;
  border-radius: 999px;
  color: var(--accent-strong);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.lesson-chip:hover,
.list-item:hover {
  transform: translateY(-1px);
  border-color: rgba(62, 123, 83, 0.4);
}

.lesson-chip.is-active,
.list-item.is-active {
  background: rgba(62, 123, 83, 0.14);
  border-color: rgba(62, 123, 83, 0.42);
  box-shadow: inset 0 0 0 1px rgba(62, 123, 83, 0.08);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(62, 123, 83, 0.16);
  background: rgba(255, 255, 255, 0.7);
}

.stat-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.action-row.wrap {
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button.primary {
  background: linear-gradient(135deg, #4a8d5d, #2e603d);
  color: #f8f6ef;
}

.button.secondary {
  border-color: rgba(62, 123, 83, 0.25);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-strong);
}

.button.ghost {
  border-color: rgba(62, 123, 83, 0.2);
  background: rgba(255, 255, 255, 0.45);
  color: var(--accent-strong);
}

.button.danger {
  border-color: rgba(163, 75, 51, 0.26);
  background: var(--danger-soft);
  color: var(--danger);
}

.callout {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--accent-strong);
  line-height: 1.7;
}

.callout.subtle {
  color: var(--muted);
}

.compact-note {
  margin-top: 14px;
  margin-bottom: 0;
}

.inline-callout {
  min-height: 52px;
  margin: 0;
  display: flex;
  align-items: center;
}

.audio-card {
  display: grid;
  gap: 14px;
}

.audio-card audio {
  width: 100%;
  margin-top: 6px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.word-sheet {
  position: relative;
  padding: 20px;
  border-radius: 22px;
  border: 1px solid rgba(110, 151, 95, 0.24);
  background:
    linear-gradient(180deg, rgba(248, 252, 244, 0.96), rgba(242, 247, 238, 0.88));
  min-height: 240px;
}

.word-sheet.is-hidden .sheet-overlay {
  opacity: 1;
  pointer-events: auto;
}

.word-sheet.is-hidden .word-grid {
  filter: blur(10px);
}

.sheet-overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(247, 244, 232, 0.92);
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

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

.word-card {
  padding: 14px 12px;
  border-radius: 16px;
  border: 1px solid rgba(95, 141, 89, 0.16);
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
  transition: transform 140ms ease, background 140ms ease;
}

.word-card.is-active {
  background: rgba(255, 234, 188, 0.76);
  transform: translateY(-2px);
}

.selection-list {
  display: grid;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  cursor: pointer;
}

.list-item > div {
  min-width: 0;
  flex: 1;
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item > div small,
.list-item > small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item small,
small {
  color: var(--muted);
}

.admin-layout {
  display: grid;
  grid-template-columns: 280px 300px minmax(0, 1fr);
  gap: 20px;
  padding-bottom: 40px;
}

.stack-form {
  display: grid;
  gap: 16px;
}

.compact-form {
  margin-top: 18px;
}

.import-section {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid rgba(62, 123, 83, 0.16);
}

.compact-heading {
  margin-bottom: 0;
}

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

.hidden {
  display: none !important;
}

.empty-state {
  padding: 20px;
  border-radius: 18px;
  border: 1px dashed rgba(62, 123, 83, 0.22);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
}

@media (max-width: 1024px) {
  .student-layout,
  .admin-layout,
  .demo-layout {
    grid-template-columns: 1fr;
  }

  .intro-card,
  .playback-card {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .site-shell {
    width: min(100vw - 20px, 1120px);
  }

  .page-header {
    flex-direction: column;
    padding-top: 24px;
  }

  .settings-grid,
  .stat-row,
  .two-columns {
    grid-template-columns: 1fr;
  }

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

  .button {
    width: 100%;
  }

  .action-row {
    flex-direction: column;
  }
}
