:root {
  --bg: #f6f3e8;
  --surface: #fffdf7;
  --surface-soft: #f2f5eb;
  --ink: #1f2e28;
  --muted: #586961;
  --brand: #24594c;
  --brand-dark: #194238;
  --accent: #dfa93f;
  --accent-soft: #fcf3d9;
  --border: #dce4d2;
  --danger: #a63b32;
  --radius: 18px;
  --shadow: 0 10px 28px rgba(28, 56, 46, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.48; cursor: not-allowed; }
[hidden] { display: none !important; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px;
  background: rgba(246, 243, 232, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--brand); font-weight: 700; font-size: 17px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.4px; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.edition-tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-soft); color: var(--brand); border: 1px solid var(--border); font-weight: 600; }
.text-button { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--brand); }
.text-button:hover { background: var(--surface-soft); }

.app-shell { max-width: 1120px; margin: 0 auto; padding: 28px 24px calc(48px + env(safe-area-inset-bottom)); }
.journey-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--brand); letter-spacing: 0.4px; }
.journey-heading h1 { margin: 0 0 8px; font-size: 32px; line-height: 1.24; letter-spacing: -0.3px; }
.journey-heading .intro { margin: 0; font-size: 15px; color: var(--muted); }
.first-day-label { font-size: 12px; color: var(--muted); border-left: 2px solid var(--border); padding-left: 12px; white-space: nowrap; }

.loading-card, .error-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; text-align: center; box-shadow: var(--shadow); }
.loading-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-right: 8px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.experience-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) 320px; gap: 24px; align-items: start; }
.story-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.story-illustration { position: relative; height: 196px; overflow: hidden; background: #e8eacb; }
.story-illustration svg { width: 100%; height: 100%; display: block; }
.chapter-badge, .team-badge {
  position: absolute; bottom: 14px; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; backdrop-filter: blur(8px);
}
.chapter-badge { left: 16px; background: rgba(25, 66, 56, 0.88); color: #fff; }
.team-badge { right: 16px; background: rgba(255, 253, 247, 0.92); color: var(--brand); border: 1px solid rgba(36, 89, 76, 0.16); max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.story-body { padding: 20px 24px 26px; }

/* 7天切换栏：电脑换行 / 手机横向滚动 */
.day-tabs-wrap { margin: 0 0 18px; }
.day-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.day-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-soft); font-size: 13px; font-weight: 600; color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.day-tab:hover:not(:disabled) { border-color: var(--brand); }
.day-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.day-tab.done:not(.active) { background: #e8f2ea; border-color: #b8d3bf; color: var(--brand-dark); }
.day-tab .day-num { font-size: 11px; opacity: 0.82; }

.chapter-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.place-tag { font-size: 12px; color: var(--muted); }
#episode-title { margin: 2px 0 14px; font-size: 24px; line-height: 1.3; }

.part-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.part-tabs button {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-size: 14px; font-weight: 600; color: var(--muted);
}
.part-tabs button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

.example-notice {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 12px;
  background: #f3f7f4; border: 1px solid #cce0d2; font-size: 13px; color: var(--brand-dark);
}

.interaction-shortcut {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; margin-bottom: 14px; border-radius: 14px;
  background: var(--surface-soft); border: 1px solid var(--border);
}
.interaction-shortcut strong { display: block; font-size: 13px; }
.interaction-shortcut p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.node-progress { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.node-progress span {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-soft); color: var(--muted); border: 1px solid var(--border);
}
.node-progress span.node-done { background: #e3f2e7; color: var(--brand-dark); border-color: #b4d5be; font-weight: 600; }

.reading-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.status-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #9db0a4; }
.status-chip.playing { color: var(--brand); }
.status-chip.playing .status-dot { background: #2e8b57; animation: pulse 1.1s infinite; }
.status-chip.waiting { color: #9c6812; }
.status-chip.waiting .status-dot { background: var(--accent); }
.status-chip.error { color: var(--danger); }
.status-chip.error .status-dot { background: var(--danger); }

.transcript {
  min-height: 112px; padding: 18px 20px; border-radius: 16px;
  background: #fbfaf4; border: 1px solid var(--border); margin-bottom: 18px;
}
#spoken-text { margin: 0; font-size: 18px; line-height: 1.85; color: var(--ink); white-space: pre-line; }
.closed-transcript { text-align: center; padding: 26px 16px; border-radius: 16px; background: var(--surface-soft); margin-bottom: 18px; color: var(--muted); }
.closed-transcript span { font-size: 24px; display: block; margin-bottom: 4px; }

/* 互动区 */
.choice-card {
  padding: 20px; margin-bottom: 18px; border-radius: 18px;
  background: linear-gradient(180deg, #fffdf5 0%, #f8f4e3 100%);
  border: 2px solid #e7cd84;
}
.choice-eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: #9c6812; }
.choice-card h3 { margin: 0 0 6px; font-size: 20px; line-height: 1.35; }
.choice-hint { margin: 0 0 16px; font-size: 13px; color: var(--muted); }

/* 开放输入专属区 */
.open-input-panel label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.name-row { display: flex; gap: 10px; }
.name-row input {
  flex: 1; min-width: 0; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid #c6d3c2; background: #fff;
  font-size: 16px; /* 防止 iOS 自动放大 */
}
.name-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(36, 89, 76, 0.14); }
.input-help { margin: 8px 0 14px; font-size: 12px; color: var(--muted); }
.suggestion-box { padding-top: 12px; border-top: 1px dashed #dfd1a6; }
.suggestion-label { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.name-suggestions { display: flex; flex-wrap: wrap; gap: 10px; }
.name-suggestions button {
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid #c7d5c3; background: #fff; font-size: 15px; font-weight: 600; color: var(--brand);
}
.name-suggestions button:hover { background: var(--surface-soft); border-color: var(--brand); }

/* 选择卡片专属区（纯点选） */
.choice-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.choice-option {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 62px; padding: 14px 16px; border-radius: 16px;
  border: 2px solid #cad8c5; background: #fff; font-size: 16px; font-weight: 700; color: var(--ink);
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.choice-option:hover:not(:disabled) { border-color: var(--brand); background: #f4faf6; transform: translateY(-1px); }
.choice-option:active:not(:disabled) { transform: scale(0.99); }
.option-badge {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 800;
}

.other-choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(206, 189, 134, 0.45); }
.other-choices button {
  min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid #d2cbb2; background: rgba(255, 255, 255, 0.85); font-size: 13px; color: var(--muted); font-weight: 600;
}
.other-choices button:hover:not(:disabled) { color: var(--ink); border-color: var(--brand); }

.silence-details { margin-top: 12px; font-size: 12px; color: var(--muted); }
.silence-details summary { cursor: pointer; }

.primary-button {
  min-height: 46px; padding: 10px 20px; border-radius: 12px; border: none;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 700; white-space: nowrap;
}
.primary-button:hover:not(:disabled) { background: var(--brand-dark); }
.outline-button {
  min-height: 42px; padding: 8px 16px; border-radius: 12px;
  border: 1.5px solid var(--brand); background: transparent; color: var(--brand); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.outline-button:hover:not(:disabled) { background: var(--surface-soft); }
.small-link { background: none; border: none; padding: 6px 4px; font-size: 13px; font-weight: 600; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }

.section-end { text-align: center; padding: 24px 18px; margin-bottom: 18px; border-radius: 16px; background: var(--surface-soft); border: 1px solid var(--border); }
.end-icon { display: inline-block; font-size: 22px; color: var(--accent); margin-bottom: 6px; }
.section-end h3 { margin: 0 0 6px; font-size: 20px; }
.section-end p { margin: 0 0 16px; font-size: 14px; color: var(--muted); white-space: pre-line; }
.section-end .primary-button { margin-right: 10px; }

.audio-error { padding: 14px 16px; margin-bottom: 16px; border-radius: 14px; background: #fdf1ef; border: 1px solid #ecc6c1; color: var(--danger); font-size: 13px; }
.audio-error p { margin: 0 0 8px; }
.audio-error div { display: flex; flex-wrap: wrap; gap: 12px; }

/* 播放器控制 */
.player-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 14px; }
.play-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 190px; min-height: 54px; padding: 12px 24px; border-radius: 999px; border: none;
  background: var(--brand); color: #fff; font-size: 16px; font-weight: 700; box-shadow: 0 6px 16px rgba(36, 89, 76, 0.24);
}
.play-button:hover:not(:disabled) { background: var(--brand-dark); }
.play-button svg { width: 20px; height: 20px; fill: currentColor; }
.round-button {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--brand);
}
.round-button svg { width: 18px; height: 18px; fill: currentColor; }
.round-button:hover:not(:disabled) { background: var(--surface-soft); }

.player-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.speed-control select { margin-left: 4px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.playback-progress { height: 6px; border-radius: 999px; background: #e5eadb; overflow: hidden; margin-bottom: 10px; }
#progress-fill { display: block; height: 100%; width: 0%; background: var(--brand); transition: width 0.2s; }
.audio-source-note { margin: 4px 0; font-size: 12px; color: var(--muted); }
.auto-talk { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--ink); }
.auto-talk small { display: block; color: var(--muted); font-size: 12px; }

/* 侧栏 */
.journey-sidebar { display: flex; flex-direction: column; gap: 16px; }
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: 0 4px 14px rgba(28, 56, 46, 0.05); }
.side-card h2, .side-card h3 { margin: 0 0 8px; font-size: 17px; }
.side-card p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.journey-steps { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.journey-step { display: flex; gap: 10px; align-items: flex-start; }
.journey-step span { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-soft); color: var(--brand); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.journey-step strong { display: block; font-size: 13px; }
.journey-step p { margin: 0; font-size: 12px; }
.saved-card { display: flex; gap: 12px; align-items: flex-start; }
.save-symbol { width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: #9c6812; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: 0 0 auto; }
.unlock-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--brand-dark); margin: 8px 0 12px; }
.test-buttons { display: flex; flex-direction: column; gap: 8px; }
.test-buttons button { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-soft); font-size: 12px; text-align: left; }
.restart-link { align-self: flex-start; }

.page-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); }
.page-footer p { margin: 0; }

/* 弹窗 & Toast */
.app-dialog { width: min(600px, calc(100vw - 24px)); max-height: 86vh; border: 1px solid var(--border); border-radius: 20px; padding: 20px; background: var(--surface); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22); }
.app-dialog::backdrop { background: rgba(20, 36, 30, 0.45); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-heading h2 { margin: 0; font-size: 20px; }
.dialog-description p { margin: 0 0 8px; font-size: 14px; }
.history-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; max-height: 38vh; overflow-y: auto; }
.history-entry { padding: 12px 14px; border-radius: 12px; background: var(--surface-soft); border: 1px solid var(--border); }
.history-entry h3 { margin: 0 0 4px; font-size: 14px; }
.history-entry p { margin: 2px 0; font-size: 12px; color: var(--muted); }
.parent-topic { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 14px; font-size: 13px; }
.parent-topic p { margin: 4px 0 0; }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: rgba(25, 66, 56, 0.94); color: #fff; font-size: 13px; z-index: 50; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); }

/* 平板与手机响应式适配 */
@media (max-width: 900px) {
  .experience-grid { grid-template-columns: minmax(0, 1fr); }
  .journey-heading { flex-direction: column; align-items: flex-start; gap: 8px; }
  .first-day-label { border-left: none; padding-left: 0; }
}

@media (max-width: 640px) {
  .site-header { padding: 12px 16px; }
  .edition-tag { display: none; }
  .app-shell { padding: 16px 12px calc(36px + env(safe-area-inset-bottom)); }
  .journey-heading h1 { font-size: 24px; }
  .story-illustration { height: 148px; }
  .story-body { padding: 16px 14px 20px; }

  /* 手机端 7 天横向平滑滚动 */
  .day-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .day-tab { flex: 0 0 auto; scroll-snap-align: start; min-height: 42px; }

  #episode-title { font-size: 21px; }
  .interaction-shortcut { flex-direction: column; align-items: stretch; }
  .interaction-shortcut .outline-button { width: 100%; }

  #spoken-text { font-size: 17px; line-height: 1.8; }
  .choice-card { padding: 16px 14px; }
  .choice-options { grid-template-columns: minmax(0, 1fr); }
  .choice-option { min-height: 58px; font-size: 16px; }
  .name-row { flex-direction: column; }
  .name-row .primary-button { width: 100%; }

  .play-button { flex: 1; min-width: 0; }
}
