:root {
  color-scheme: light;
  --ink: #18242d;
  --ink-soft: #35434d;
  --muted: #6e7a82;
  --line: #d8dee1;
  --line-strong: #c4ccd0;
  --paper: #fbfbf9;
  --canvas: #edf1f2;
  --copper: #b9683d;
  --copper-soft: #f3e6dd;
  --petrol: #2e5962;
  --petrol-soft: #dce8ea;
  --success: #3d7366;
  --danger: #9d3c36;
  --shadow: 0 14px 40px rgba(24, 36, 45, 0.08);
  --radius-lg: 24px;
  --radius-md: 17px;
  --radius-sm: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% -10%, rgba(46, 89, 98, 0.1), transparent 34rem),
    var(--canvas);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(185, 104, 61, 0.26);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid rgba(196, 204, 208, 0.8);
  background: rgba(237, 241, 242, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 720;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  align-items: end;
  gap: 3px;
  width: 18px;
  height: 22px;
  padding: 2px;
}

.brand-mark i { display: block; border-radius: 4px; background: var(--ink); }
.brand-mark i:nth-child(1) { height: 9px; }
.brand-mark i:nth-child(2) { height: 18px; background: var(--copper); }
.brand-mark i:nth-child(3) { height: 13px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.dashboard {
  display: grid;
  gap: 18px;
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 18px 14px 110px;
}

.overview-card, .principle-card, .card {
  border: 1px solid rgba(196, 204, 208, 0.75);
  background: rgba(251, 251, 249, 0.94);
  box-shadow: var(--shadow);
}

.overview-card, .card { border-radius: var(--radius-lg); }

.overview-card { padding: 22px 18px 19px; }

.overview-heading, .section-heading, .day-header, .dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow, .section-kicker, .phase-label {
  margin: 0 0 4px;
  color: var(--copper);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 { margin-bottom: 0; font-size: clamp(1.75rem, 7vw, 2.45rem); line-height: 1.1; letter-spacing: -0.045em; }
h2 { margin-bottom: 8px; font-size: clamp(1.62rem, 6vw, 2.25rem); line-height: 1.2; letter-spacing: -0.04em; }
h3 { margin-bottom: 0; font-size: 1.18rem; line-height: 1.35; letter-spacing: -0.02em; }

.total-progress {
  display: grid;
  place-items: center;
  flex: 0 0 74px;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: conic-gradient(var(--copper) var(--progress, 0%), #e4e8e9 0);
  position: relative;
}

.total-progress::before { content: ""; position: absolute; inset: 6px; border-radius: inherit; background: var(--paper); }
.total-progress strong, .total-progress span { position: relative; z-index: 1; line-height: 1; }
.total-progress strong { font-size: 1rem; }
.total-progress span { margin-top: -12px; color: var(--muted); font-size: 0.68rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 22px 0 19px;
  border-block: 1px solid var(--line);
}

.stats-row div { display: grid; gap: 0; padding: 13px 8px; text-align: center; }
.stats-row div + div { border-left: 1px solid var(--line); }
.stats-row strong { font-size: 1.25rem; line-height: 1.25; }
.stats-row span { color: var(--muted); font-size: 0.75rem; }

.day-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }

.day-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #e8ecee;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 710;
  transition: transform 160ms ease, background 160ms ease;
}

.day-cell:hover { transform: translateY(-1px); }
.day-cell[data-phase="2"] { background: #e1ebec; }
.day-cell[data-phase="3"] { background: #eee9e4; }
.day-cell.is-selected { border-color: var(--ink); background: var(--ink); color: white; }
.day-cell.is-complete { background: var(--success); color: white; }
.day-cell.is-today::after { content: ""; position: absolute; bottom: 4px; width: 3px; height: 3px; border-radius: 50%; background: currentColor; }

.phase-legend { display: flex; flex-wrap: wrap; gap: 8px 13px; margin-top: 13px; color: var(--muted); font-size: 0.72rem; }
.phase-legend span { display: inline-flex; align-items: center; gap: 5px; }
.phase-legend i { width: 7px; height: 7px; border-radius: 2px; background: #d3dadd; }
.phase-legend .phase-two { background: #bed1d4; }
.phase-legend .phase-three { background: #d9cbc0; }

.principle-card { display: none; margin: 14px 0 0; border-radius: var(--radius-md); padding: 20px; }
.principle-card p { margin-bottom: 8px; font-family: ui-serif, "Songti SC", serif; font-size: 1.05rem; }
.principle-card cite { color: var(--muted); font-size: 0.75rem; font-style: normal; }

.work-panel { display: grid; gap: 14px; min-width: 0; }
.day-header { padding: 10px 5px 6px; }
.day-header > div { min-width: 0; }
.day-header > div > p:last-child { max-width: 44rem; margin-bottom: 0; color: var(--muted); }
.day-count { flex: 0 0 auto; padding-top: 4px; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }

.card { padding: 22px 18px; }
.section-heading { align-items: center; margin-bottom: 18px; }
.section-score { flex: 0 0 auto; border-radius: 999px; padding: 5px 10px; background: var(--copper-soft); color: #854624; font-size: 0.78rem; font-weight: 720; }

.check-list { display: grid; gap: 8px; }

.check-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 160ms ease, background 160ms ease;
}

.check-item:hover { border-color: var(--line-strong); }
.check-item:has(input:checked) { border-color: rgba(61, 115, 102, 0.34); background: #f1f7f4; }
.check-item input { position: absolute; opacity: 0; pointer-events: none; }

.custom-check {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  margin-top: 2px;
  border: 1.5px solid #9aa6ab;
  border-radius: 7px;
  color: transparent;
}

.check-item input:checked + .custom-check { border-color: var(--success); background: var(--success); color: white; }
.check-item input:focus-visible + .custom-check { outline: 3px solid rgba(185, 104, 61, 0.26); outline-offset: 2px; }
.custom-check::after { content: "✓"; font-size: 0.8rem; font-weight: 800; }
.check-copy { display: grid; gap: 2px; min-width: 0; }
.check-copy strong { font-size: 0.98rem; font-weight: 700; }
.check-copy small { color: var(--muted); font-size: 0.79rem; line-height: 1.45; }
.check-item:has(input:checked) .check-copy strong { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.compact .check-item { min-height: 48px; align-items: center; padding-block: 10px; }
.compact .custom-check { margin-top: 0; }

.task-intro { margin: -5px 0 16px; color: var(--muted); }
.output-callout { display: grid; gap: 2px; margin: 16px 0 18px; border-left: 3px solid var(--copper); padding: 8px 12px; background: var(--copper-soft); }
.output-callout span { color: #8d5434; font-size: 0.75rem; font-weight: 720; letter-spacing: 0.08em; }
.output-callout strong { font-size: 0.95rem; }

.field-label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 0.86rem; font-weight: 700; }

textarea, input[type="text"], input[type="date"], input[type="number"], select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 108px; resize: vertical; padding: 12px 13px; line-height: 1.6; }
input[type="text"], input[type="date"], input[type="number"], select { min-height: 46px; padding: 9px 12px; }
::placeholder { color: #9aa3a8; }

.daily-notes { margin-top: 15px; border-top: 1px solid var(--line); padding-top: 13px; }
.daily-notes summary, .rules-card summary { color: var(--ink-soft); font-size: 0.84rem; font-weight: 720; cursor: pointer; }
.daily-notes-grid { display: grid; gap: 12px; padding-top: 14px; }
.daily-notes-grid label, .review-field { color: var(--ink-soft); font-size: 0.84rem; font-weight: 680; }
.daily-notes-grid input, .review-field input, .review-field textarea, .review-field select { display: block; margin-top: 6px; font-weight: 400; }

.review-card { border-color: rgba(185, 104, 61, 0.3); background: linear-gradient(145deg, #fffaf6, var(--paper) 62%); }
.review-seal { flex: 0 0 auto; color: #8d5434; font-family: ui-serif, "Songti SC", serif; font-size: 0.75rem; letter-spacing: 0.08em; }
.review-fields { display: grid; gap: 14px; }
.review-scores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.review-score { display: grid; grid-template-columns: 1fr 78px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; background: rgba(255,255,255,0.68); }
.review-score input { margin: 0; text-align: center; }
.review-score small { color: var(--muted); font-weight: 500; }

.reflection-grid { display: grid; gap: 13px; }
.reflection-grid label { color: var(--ink-soft); font-size: 0.86rem; font-weight: 680; }
.reflection-grid input { display: block; margin-top: 6px; font-weight: 400; }

.ratings { display: grid; gap: 10px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.rating-row { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; }
.rating-row > span { color: var(--ink-soft); font-size: 0.82rem; font-weight: 700; }
.rating-row > div { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rating-button { min-height: 32px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); font-size: 0.78rem; font-weight: 720; }
.rating-button.is-active { border-color: var(--petrol); background: var(--petrol); color: white; }

.day-nav { position: fixed; z-index: 15; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 11px 14px calc(11px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-strong); background: rgba(251, 251, 249, 0.95); backdrop-filter: blur(18px); }

.quiet-button, .primary-button, .danger-button, .icon-button {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 700;
}

.quiet-button { border: 1px solid var(--line-strong); background: rgba(251, 251, 249, 0.88); color: var(--ink); padding: 8px 12px; }
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; padding: 8px 14px; }
.danger-button { width: 100%; border: 1px solid rgba(157, 60, 54, 0.35); background: #fff5f3; color: var(--danger); padding: 9px 14px; }
.icon-button { display: grid; place-items: center; width: 42px; border: 1px solid var(--line-strong); background: rgba(251, 251, 249, 0.78); color: var(--ink); }
.icon-button svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.7; }
.install-button { display: none; min-height: 38px; font-size: 0.82rem; }

dialog { width: min(92vw, 450px); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 0; background: var(--paper); color: var(--ink); box-shadow: 0 28px 90px rgba(24, 36, 45, 0.26); }
dialog::backdrop { background: rgba(19, 29, 36, 0.52); backdrop-filter: blur(4px); }
dialog form { padding: 24px; }
.dialog-heading { align-items: center; margin-bottom: 22px; }
.dialog-heading h2 { margin-bottom: 0; }
.dialog-heading .icon-button { border: 0; background: transparent; font-size: 1.7rem; font-weight: 400; }
.field-help { margin: 8px 0 20px; color: var(--muted); font-size: 0.78rem; }
.install-help { margin: 18px 0; border-block: 1px solid var(--line); padding: 16px 0; }
.install-help strong { font-size: 0.92rem; }
.install-help p { margin: 4px 0 0; color: var(--muted); font-size: 0.8rem; }
.rules-card { margin: 0 0 18px; border-bottom: 1px solid var(--line); padding: 0 0 16px; }
.rules-card ol { margin: 12px 0 8px; padding-left: 1.25rem; color: var(--ink-soft); font-size: 0.82rem; }
.rules-card li + li { margin-top: 5px; }
.rules-card p { margin: 10px 0 0; color: var(--muted); font-size: 0.78rem; }
.confirm-dialog p:not(.section-kicker) { color: var(--muted); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 92px; max-width: calc(100vw - 32px); transform: translate(-50%, 20px); border-radius: 999px; padding: 9px 15px; background: var(--ink); color: white; font-size: 0.84rem; opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 760px) {
  .topbar { padding-inline: 28px; }
  .dashboard { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); align-items: start; gap: 24px; padding: 32px 24px 56px; }
  .overview-panel { position: sticky; top: 96px; }
  .principle-card { display: block; }
  .card { padding: 28px; }
  .reflection-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .daily-notes-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .review-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-field:has(textarea) { grid-column: 1 / -1; }
  .day-nav { position: static; grid-template-columns: auto 1fr auto; padding: 8px 0 0; border: 0; background: transparent; backdrop-filter: none; }
  #jumpToday { justify-self: center; }
  .install-button:not([hidden]) { display: inline-flex; align-items: center; }
}

@media (min-width: 1020px) {
  .dashboard { grid-template-columns: 340px minmax(0, 1fr); gap: 34px; padding-top: 40px; }
  .overview-card { padding: 27px 24px 23px; }
  .work-panel { gap: 18px; }
  .fixed-card .check-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fixed-card .check-item:last-child { grid-column: 1 / -1; }
}

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