:root {
  --page-bg: #d8d2cb;
  --paper: #f7f2ec;
  --paper-2: #fffdf9;
  --ink: #302725;
  --muted: #746966;
  --line: #d9cec5;

  --coral: #c95f4d;
  --coral-strong: #973d32;
  --coral-soft: #f7dfd8;

  --plum: #76536f;
  --plum-soft: #eee4ec;

  --amber: #a97119;
  --amber-soft: #f7ebc9;

  --leaf: #3f7058;
  --leaf-soft: #e0ece4;

  --danger: #9c352f;
  --danger-soft: #f7dcda;

  --shadow: 0 18px 60px rgba(49, 38, 34, .16);
  --nav-height: 76px;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 16px;
}

html.large-text {
  font-size: 18px;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

button,
a,
summary,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(201, 95, 77, .35);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.phone-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 60px;
  padding: max(8px, env(safe-area-inset-top)) 14px 7px;
  border-bottom: 1px solid rgba(48, 39, 37, .1);
  background: rgba(247, 242, 236, .96);
  backdrop-filter: blur(16px);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  background: transparent;
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper-2);
  font-family: STSong, "Songti SC", serif;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 1.35rem;
  cursor: pointer;
}

.icon-button.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

#app {
  min-height: calc(100dvh - 60px);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
}

.bottom-nav {
  position: fixed;
  z-index: 40;
  right: max(0px, calc((100vw - 430px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 430px) / 2));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(48, 39, 37, .12);
  background: rgba(255, 253, 249, .97);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: grid;
  min-width: 0;
  min-height: 56px;
  place-content: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: #807673;
  cursor: pointer;
}

.bottom-nav button > span {
  font-size: 1.35rem;
  line-height: 1;
}

.bottom-nav small {
  font-size: .75rem;
  line-height: 1.2;
}

.bottom-nav button.is-active {
  color: var(--coral-strong);
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 90;
  right: 50%;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 18px);
  width: max-content;
  max-width: min(350px, calc(100vw - 32px));
  padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: .88rem;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 10px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

h1,
h2,
h3,
p,
span,
small {
  overflow-wrap: anywhere;
}

h1,
h2,
.display-title {
  font-family: STSong, "Songti SC", "Noto Serif CJK SC", serif;
}

.page-heading {
  padding: 28px 20px 22px;
}

.page-heading.is-warm {
  background: var(--coral-soft);
}

.page-heading.is-dark {
  background: var(--ink);
  color: #fff;
}

.page-kicker {
  margin: 0 0 8px;
  color: var(--coral-strong);
  font-size: .76rem;
  font-weight: 900;
}

.page-heading.is-dark .page-kicker {
  color: #f2b6a9;
}

.page-heading h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.page-summary {
  max-width: 34rem;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.page-heading.is-dark .page-summary {
  color: rgba(255, 255, 255, .76);
}

.content-section {
  padding: 24px 20px;
}

.content-section + .content-section {
  border-top: 1px solid var(--line);
}

.section-heading {
  margin: 0 0 8px;
  font-size: 1.45rem;
  line-height: 1.3;
}

.section-intro {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.65;
}

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 19px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  line-height: 1.35;
  cursor: pointer;
}

.button-primary {
  background: var(--ink);
  color: #fff;
}

.button-coral {
  background: var(--coral);
  color: #fff;
}

.button-secondary {
  border-color: var(--ink);
  background: transparent;
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.button-danger-outline {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button-wide {
  width: 100%;
}

.button:disabled {
  cursor: default;
  opacity: .58;
}

.search-box {
  position: relative;
  margin-top: 18px;
}

.search-box span {
  position: absolute;
  top: 50%;
  left: 16px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px 0 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 1rem;
}

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

.course-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.course-signal {
  position: relative;
  display: grid;
  min-height: 176px;
  place-content: center;
  overflow: hidden;
  background: var(--plum-soft);
  color: var(--plum);
}

.signal-word {
  position: relative;
  z-index: 2;
  font-family: STSong, "Songti SC", serif;
  font-size: 2.7rem;
  font-weight: 900;
}

.signal-bars {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  height: 10px;
}

.signal-bars i:nth-child(1) {
  background: var(--coral);
}

.signal-bars i:nth-child(2) {
  background: var(--amber);
}

.signal-bars i:nth-child(3) {
  background: var(--leaf);
}

.course-card-body {
  min-width: 0;
  padding: 16px;
}

.course-type {
  margin: 0 0 6px;
  color: var(--coral-strong);
  font-size: .75rem;
  font-weight: 900;
}

.course-card h2 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.35;
}

.course-card p {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.6;
}

.course-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .76rem;
}

.course-card .button {
  min-height: 46px;
}

.empty-search {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

.course-hero {
  padding: 28px 20px 24px;
  background: var(--plum-soft);
  border-bottom: 8px solid var(--coral);
}

.course-hero h1 {
  max-width: 360px;
  margin: 0;
  font-size: 2.15rem;
  line-height: 1.12;
}

.course-hero p {
  margin: 12px 0 20px;
  color: #65535f;
  font-size: 1rem;
  line-height: 1.7;
}

.course-progress {
  padding: 15px 20px;
  background: var(--ink);
  color: #fff;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-row strong {
  flex: 0 0 auto;
  font-size: .9rem;
}

.progress-track {
  flex: 1;
  height: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, .2);
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--amber);
}

.progress-row small {
  color: rgba(255, 255, 255, .72);
}

.day-list {
  display: grid;
}

.day-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  min-height: 84px;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.day-row:last-child {
  border-bottom: 0;
}

.day-badge {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--plum);
  border-radius: 50%;
  color: var(--plum);
  font-weight: 900;
}

.day-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.4;
}

.day-row small {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}

.day-status {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
}

.day-status.is-done {
  color: var(--leaf);
}

.day-status.is-next {
  color: var(--coral-strong);
}

.safety-link {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 66px;
  padding: 11px 13px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  text-align: left;
  cursor: pointer;
}

.safety-link > span:first-child {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
}

.safety-link strong {
  display: block;
  margin-bottom: 3px;
}

.safety-link small {
  color: #764843;
  line-height: 1.4;
}

.disclaimer {
  margin: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: #eee9e3;
  color: #665d59;
  font-size: .78rem;
  line-height: 1.65;
}

.day-head {
  padding: 23px 20px 20px;
}

.day-kicker {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--coral-strong);
  font-size: .76rem;
  font-weight: 900;
}

.day-head h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.18;
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}

.day-tabs button {
  min-width: 0;
  min-height: 52px;
  padding: 7px 4px;
  border: 0;
  border-bottom: 4px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  cursor: pointer;
}

.day-tabs button.is-current {
  border-bottom-color: var(--coral);
  color: var(--ink);
  font-weight: 900;
}

.day-tabs button.is-done {
  color: var(--leaf);
}

.action-panel {
  margin: 20px;
  padding: 20px;
  border-left: 6px solid var(--coral);
  border-radius: var(--radius);
  background: var(--coral-soft);
}

.action-label {
  margin-bottom: 8px;
  color: var(--coral-strong);
  font-size: .76rem;
  font-weight: 900;
}

.action-panel h2 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.45;
}

.action-reason {
  margin: 13px 0 0;
  color: #604b46;
  line-height: 1.7;
}

.observe-block {
  margin: 18px 0;
  padding-top: 16px;
  border-top: 1px solid rgba(151, 61, 50, .24);
}

.observe-block strong {
  display: block;
  margin-bottom: 6px;
  color: var(--coral-strong);
}

.observe-block p {
  margin: 0;
  line-height: 1.7;
}

.action-followup {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.reading-list {
  border-top: 1px solid var(--line);
}

.reading-section {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 23px 20px;
  border-bottom: 1px solid var(--line);
}

.section-number {
  color: var(--plum);
  font-family: STSong, "Songti SC", serif;
  font-size: 1.45rem;
  font-weight: 900;
}

.reading-section h2 {
  margin: 0 0 9px;
  font-size: 1.32rem;
  line-height: 1.4;
}

.reading-section p {
  margin: 0;
  color: #504744;
  font-size: 1rem;
  line-height: 1.8;
}

.branch-list {
  display: grid;
  gap: 9px;
}

.branch-list details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
}

.branch-list summary {
  min-height: 52px;
  padding: 14px 42px 14px 14px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.45;
}

.branch-list details p {
  margin: 0;
  padding: 0 14px 16px;
  color: var(--muted);
  line-height: 1.7;
}

.care-head {
  padding: 26px 20px 22px;
  background: var(--danger-soft);
  border-bottom: 7px solid var(--danger);
}

.care-head h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.18;
}

.care-head p {
  margin: 10px 0 0;
  color: #704944;
  line-height: 1.7;
}

.care-matrix {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.care-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-left-width: 7px;
  border-radius: var(--radius);
  background: var(--paper-2);
}

.care-card.is-immediate {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.care-card.is-prompt {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.care-card.is-self {
  border-left-color: var(--leaf);
  background: var(--leaf-soft);
}

.care-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.care-level {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.care-card h2 {
  margin: 0;
  font-size: 1.3rem;
}

.care-card p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.75;
}

.care-card .button {
  margin-top: 15px;
}

.care-note {
  margin: 0 20px 20px;
  padding: 14px;
  border-left: 4px solid var(--plum);
  background: var(--plum-soft);
  line-height: 1.65;
}

.results-summary {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 24px 20px;
  background: var(--ink);
  color: #fff;
}

.result-count {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border: 3px solid var(--amber);
  border-radius: 50%;
  color: var(--amber-soft);
  font-family: STSong, "Songti SC", serif;
  font-size: 1.7rem;
  font-weight: 900;
}

.results-summary h1 {
  margin: 0 0 7px;
  font-size: 1.8rem;
}

.results-summary p {
  margin: 0;
  color: rgba(255, 255, 255, .74);
  line-height: 1.6;
}

.result-course {
  padding: 21px 20px;
  border-bottom: 1px solid var(--line);
}

.result-course header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.result-course h2 {
  margin: 0;
  font-size: 1.35rem;
}

.result-course header span {
  color: var(--leaf);
  font-size: .8rem;
  font-weight: 900;
}

.result-days {
  display: grid;
  gap: 0;
  margin: 15px 0 0;
  padding: 0;
  list-style: none;
}

.result-day {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.result-day.is-done .status-dot {
  border-color: var(--leaf);
  background: var(--leaf);
}

.result-day strong {
  display: block;
  margin-bottom: 4px;
}

.result-day small {
  color: var(--muted);
  line-height: 1.5;
}

.settings-section {
  padding: 0 20px;
  background: var(--paper-2);
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.setting-row strong {
  display: block;
  margin-bottom: 4px;
}

.setting-row small {
  color: var(--muted);
  line-height: 1.5;
}

.setting-row input {
  width: 24px;
  height: 24px;
  accent-color: var(--coral);
}

.danger-zone {
  padding: 25px 20px;
  border-top: 1px solid var(--line);
}

.danger-zone h2 {
  margin: 0 0 7px;
  font-size: 1.25rem;
}

.danger-zone p {
  margin: 0 0 15px;
  color: var(--muted);
  line-height: 1.65;
}

.confirm-dialog {
  width: min(350px, calc(100% - 32px));
  padding: 24px;
  border: 0;
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(48, 39, 37, .62);
}

.confirm-dialog h2 {
  margin: 0 0 9px;
  font-size: 1.45rem;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 21px;
}

.app-error {
  padding: 42px 20px;
  text-align: center;
}

.app-error h1 {
  margin: 0 0 10px;
  font-size: 1.7rem;
}

.app-error p {
  color: var(--muted);
  line-height: 1.7;
}

@media (hover: hover) {
  .button:not(:disabled):hover,
  .day-row:hover,
  .safety-link:hover {
    filter: brightness(.96);
  }
}

@media (min-width: 560px) {
  body {
    padding: 24px 0;
  }

  .phone-shell {
    min-height: calc(100dvh - 48px);
    border: 1px solid rgba(48, 39, 37, .16);
    border-radius: 24px;
    box-shadow: var(--shadow);
  }

  .topbar {
    border-radius: 24px 24px 0 0;
  }

  .bottom-nav {
    right: calc((100vw - 430px) / 2);
    bottom: 24px;
    left: calc((100vw - 430px) / 2);
    border-radius: 0 0 24px 24px;
  }

  .toast {
    bottom: calc(var(--nav-height) + 42px);
  }
}

@media (max-width: 350px) {
  .course-card {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .course-hero h1,
  .day-head h1,
  .care-head h1 {
    font-size: 1.75rem;
  }

  .day-row {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .day-status {
    grid-column: 2;
  }

  .results-summary {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .result-count {
    width: 80px;
    height: 80px;
    font-size: 1.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
