:root {
  color-scheme: light;
  --ink: #17302d;
  --muted: #667773;
  --paper: #f7f3ea;
  --paper-deep: #eee8db;
  --card: rgba(255, 255, 255, 0.82);
  --line: rgba(23, 48, 45, 0.13);
  --green: #1c5a50;
  --green-dark: #143f39;
  --sage: #a7c1a9;
  --mist: #dbe8de;
  --gold: #c49b52;
  --shadow: 0 20px 50px rgba(36, 52, 48, 0.10);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 5%, rgba(167, 193, 169, 0.35), transparent 34rem),
    radial-gradient(circle at 90% 25%, rgba(196, 155, 82, 0.13), transparent 30rem),
    var(--paper);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(28, 90, 80, 0.35); outline-offset: 3px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header, .app-footer {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header { padding: 22px 0 14px; }
.app-footer { padding: 18px 0 28px; color: var(--muted); font-size: 0.78rem; gap: 16px; }

.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; background: var(--green); color: white; font-size: 1.25rem;
  box-shadow: 0 8px 25px rgba(28, 90, 80, 0.2);
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -0.02em; }
.brand small { color: var(--muted); margin-top: 2px; }

main { flex: 1; }
.screen { display: none; width: min(1080px, calc(100% - 32px)); margin: 0 auto; }
.screen.active { display: block; animation: fadeIn 380ms ease both; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

.hero-card { padding: 44px 46px; border-radius: 32px; background: linear-gradient(135deg, var(--green-dark), #275f55); color: white; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero-card::after { content: "十八"; position: absolute; right: 24px; bottom: -40px; font-family: Georgia, serif; font-size: 10rem; opacity: 0.07; }
.hero-card h1 { margin: 4px 0 12px; max-width: 720px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(2.3rem, 6vw, 4.7rem); line-height: 0.98; letter-spacing: -0.045em; }
.hero-card p:last-child { max-width: 620px; color: rgba(255,255,255,0.78); font-size: 1.05rem; line-height: 1.6; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; font-weight: 800; }

.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.panel { background: var(--card); backdrop-filter: blur(16px); border: 1px solid rgba(255,255,255,0.75); border-radius: var(--radius); padding: 24px; box-shadow: 0 10px 35px rgba(36,52,48,0.07); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 1.2rem; }
.step-label { margin: 0; width: 25px; height: 25px; display: grid; place-items: center; background: var(--mist); border-radius: 50%; font-size: 0.75rem; font-weight: 800; color: var(--green); }
.subtle { color: var(--muted); font-size: 0.85rem; }

.segmented-control { display: grid; gap: 10px; }
.segmented-control label, .set-option, .duration-presets label { cursor: pointer; }
.segmented-control input, .set-option input, .duration-presets input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; transition: 160ms ease; }
.segmented-control small { color: var(--muted); }
.segmented-control input:checked + span { border-color: var(--green); background: var(--mist); box-shadow: inset 0 0 0 1px var(--green); }

.set-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.set-option span { min-height: 78px; display: grid; place-items: center; align-content: center; border: 1px solid var(--line); border-radius: 16px; transition: 160ms ease; background: rgba(255,255,255,0.4); }
.set-option strong { display: block; font-size: 1.2rem; }
.set-option small { color: var(--muted); }
.set-option input:checked + span { background: var(--green); color: white; border-color: var(--green); transform: translateY(-1px); box-shadow: 0 9px 20px rgba(28,90,80,0.18); }
.set-option input:checked + span small { color: rgba(255,255,255,0.72); }

.duration-presets { display: flex; flex-wrap: wrap; gap: 10px; }
.duration-presets label > span { display: inline-grid; place-items: center; min-height: 48px; padding: 0 17px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.45); transition: 160ms ease; }
.duration-presets input[type="radio"]:checked + span { background: var(--green); color: white; border-color: var(--green); }
.custom-duration { display: inline-flex; align-items: center; gap: 8px; }
.custom-duration input[type="number"] { width: 76px; height: 48px; border: 1px solid var(--line); border-radius: 14px; padding: 0 10px; background: white; color: var(--ink); }

.sound-heading { align-items: center; }
.range-row { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.range-row input { accent-color: var(--green); width: 100%; }
.tip { margin: 18px 0 0; color: var(--muted); line-height: 1.5; font-size: 0.88rem; }

.start-area { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 8px 2px 18px; }
.session-preview { color: var(--muted); line-height: 1.5; }
.session-preview strong { color: var(--ink); }

.primary-button, .ghost-button, .danger-button, .text-button, .icon-button, .round-button, .pause-button { border: 0; cursor: pointer; transition: 160ms ease; }
.primary-button { padding: 16px 26px; border-radius: 999px; background: var(--green); color: white; font-weight: 800; box-shadow: 0 10px 24px rgba(28,90,80,0.22); }
.primary-button:hover { transform: translateY(-2px); background: var(--green-dark); }
.ghost-button { padding: 10px 15px; border-radius: 999px; background: rgba(255,255,255,0.68); border: 1px solid var(--line); }
.ghost-button:hover { background: white; }
.text-button { background: none; color: var(--green); font-weight: 800; padding: 7px; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.68); border: 1px solid var(--line); }
.danger-button { padding: 11px 16px; border-radius: 999px; background: #8d3732; color: white; font-weight: 700; }

.practice-screen { min-height: calc(100vh - 130px); }
.practice-screen.active { display: flex; flex-direction: column; }
.practice-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.practice-topbar .icon-button { justify-self: end; }
.session-type { font-weight: 800; color: var(--muted); }
.practice-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 0 38px; }

.progress-ring { --progress: 0deg; width: min(47vw, 270px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) var(--progress), rgba(28,90,80,0.11) 0); position: relative; }
.progress-ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--paper); }
.progress-ring-inner { position: relative; z-index: 1; display: flex; flex-direction: column; }
.progress-ring-inner strong { font-size: clamp(2.7rem, 10vw, 4.4rem); font-variant-numeric: tabular-nums; letter-spacing: -0.05em; }
.progress-ring-inner small { color: var(--muted); }
.exercise-counter { font-weight: 800; color: var(--green); margin-bottom: 5px; }

.exercise-copy { max-width: 820px; margin: 32px auto 20px; }
.exercise-copy h1 { min-height: 2.2em; margin: 7px 0 8px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(2rem, 6vw, 4.8rem); line-height: 1.02; letter-spacing: -0.045em; text-wrap: balance; }
.exercise-copy .eyebrow { color: var(--green); }
.future-media-note { color: var(--muted); font-size: 0.82rem; }

.progress-dots { display: flex; flex-wrap: wrap; justify-content: center; max-width: 520px; gap: 7px; margin: 5px 0 23px; }
.progress-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(28,90,80,0.16); }
.progress-dot.done { background: var(--sage); }
.progress-dot.current { background: var(--green); transform: scale(1.45); }
.time-summary { display: flex; align-items: baseline; gap: 9px; color: var(--muted); margin-bottom: 25px; }
.time-summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.playback-controls { display: flex; align-items: center; gap: 16px; }
.round-button { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,0.7); border: 1px solid var(--line); font-size: 2rem; line-height: 1; }
.round-button:disabled { opacity: 0.3; cursor: not-allowed; }
.pause-button { min-width: 132px; height: 58px; border-radius: 999px; background: var(--green); color: white; font-weight: 800; }

.complete-screen { min-height: calc(100vh - 140px); text-align: center; padding: 70px 0; }
.complete-screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.completion-symbol { width: 118px; height: 118px; display: grid; place-items: center; border: 1px solid var(--sage); color: var(--green); border-radius: 50%; font-size: 4rem; margin-bottom: 28px; }
.complete-screen h1 { margin: 6px 0 12px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(2.5rem, 7vw, 5.2rem); letter-spacing: -0.05em; }
.complete-screen > p:not(.eyebrow) { color: var(--muted); font-size: 1.05rem; }
.completion-actions { display: flex; gap: 12px; margin-top: 25px; }

.form-error { margin: 12px 0 0; color: #8d3732; font-weight: 700; }
.hidden { display: none !important; }

dialog { border: 0; border-radius: 22px; padding: 0; box-shadow: var(--shadow); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(10,26,24,0.45); backdrop-filter: blur(4px); }
.dialog-card { padding: 28px; min-width: min(380px, calc(100vw - 36px)); }
.dialog-card h2 { margin-top: 0; }
.dialog-card p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@media (max-width: 760px) {
  .app-header { padding-top: max(16px, env(safe-area-inset-top)); }
  .brand small { display: none; }
  .hero-card { padding: 34px 25px; border-radius: 25px; }
  .setup-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .start-area { flex-direction: column; align-items: stretch; }
  .start-area .primary-button { width: 100%; }
  .session-preview { text-align: center; }
  .app-footer { flex-direction: column; align-items: flex-start; }
  .exercise-copy h1 { min-height: 2.7em; }
}

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