:root {
  --oat: #f4efe3;
  --paper: #fbf8f0;
  --forest: #183c32;
  --forest-soft: #31594e;
  --sage: #dce5d5;
  --sage-deep: #afc3ad;
  --coral: #d85d4a;
  --coral-dark: #9f3e32;
  --marigold: #e6ad35;
  --ink-muted: #5e6d65;
  --line: #d4d4c4;
  --shadow: 0 18px 45px rgba(24, 60, 50, 0.12);
  --page-width: 720px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--forest);
  background-color: var(--oat);
  background-image: radial-gradient(rgba(24, 60, 50, 0.045) 0.65px, transparent 0.65px);
  background-size: 5px 5px;
  font-family: ui-rounded, "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 3px; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 12px 16px; background: var(--forest); color: white; }
.skip-link:focus { top: 12px; }

.site-header {
  width: min(100% - 32px, var(--page-width));
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px 9px 14px 9px; background: var(--forest); transform: rotate(-4deg); }
.brand-mark span { width: 8px; height: 13px; border-radius: 50%; background: var(--marigold); transform: rotate(24deg); }
.icon-button { width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); cursor: pointer; font-weight: 800; }
.icon-button:hover { border-color: var(--forest); transform: translateY(-1px); }

main { width: min(100% - 32px, var(--page-width)); margin: 0 auto; padding-bottom: 230px; }
.view { animation: enter 360ms ease both; }
.view[hidden] { display: none; }
.eyebrow { margin: 0 0 8px; color: var(--forest-soft); font-size: 0.76rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2, h3, p { text-wrap: pretty; }
h1, h2, h3 { line-height: 1.08; letter-spacing: -0.035em; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.45rem, 10vw, 4.8rem); font-weight: 500; }
.today-intro { padding: 32px 0 30px; }
.status-line { display: flex; align-items: center; gap: 9px; margin: 20px 0 0; color: var(--forest-soft); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sage-deep); box-shadow: 0 0 0 5px rgba(175, 195, 173, 0.25); }

.next-panel { position: relative; overflow: hidden; display: grid; gap: 22px; padding: 24px; border: 1px solid var(--forest); border-radius: 22px 22px 42px 22px; background: var(--forest); color: var(--paper); box-shadow: var(--shadow); }
.next-panel::after { content: ""; position: absolute; width: 120px; height: 120px; right: -58px; top: -58px; border: 24px solid rgba(230, 173, 53, 0.2); border-radius: 50%; }
.next-panel .eyebrow { color: #d4dfd5; }
.next-panel h2 { margin: 0 0 8px; font-size: 2.35rem; }
.next-panel p { margin: 0; max-width: 470px; }
.countdown { align-self: end; width: fit-content; padding: 8px 12px; background: var(--marigold); color: var(--forest); border-radius: 10px; font-size: 0.82rem; font-weight: 900; }

.timeline-section { padding: 50px 0 0; }
.checks-section { padding: 48px 0 0; }
.episode-instruction { margin: 18px 0 6px; padding: 15px 17px; border-left: 5px solid var(--marigold); background: #f8eaca; color: #445249; }
.check-list { margin: 0; padding: 0; list-style: none; }
.check-details { margin-top: 8px; border-top: 1px solid var(--line); }
.check-details summary { display: flex; justify-content: space-between; gap: 16px; padding: 15px 2px; cursor: pointer; color: var(--forest-soft); font-weight: 850; }
.check-details summary::marker { content: ""; }
.check-details[open] summary { border-bottom: 1px solid var(--line); }
.featured-check .check-task { border-bottom: 0; }
.checks-complete { margin: 16px 0 8px; padding: 14px; background: var(--sage); font-weight: 750; }
.check-task { display: grid; grid-template-columns: 86px 1fr auto; gap: 14px; align-items: center; padding: 17px 0; border-bottom: 1px solid var(--line); }
.check-time strong, .check-time span, .check-copy strong, .check-copy span { display: block; }
.check-time span { width: fit-content; margin-top: 4px; padding: 2px 6px; border-radius: 6px; background: var(--sage); color: var(--forest-soft); font-size: 0.68rem; font-weight: 900; text-transform: uppercase; }
.check-copy span { color: var(--ink-muted); font-size: 0.82rem; }
.check-task.due .check-time span { background: var(--marigold); color: var(--forest); }
.check-task.missed { opacity: 0.72; }
.check-task.completed .check-time span { background: var(--forest); color: white; }
.check-task button:disabled { cursor: default; opacity: 0.72; box-shadow: none; }
.recheck-banner { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; margin-top: 18px; padding: 18px; border: 2px solid var(--coral); border-radius: 16px 16px 28px 16px; background: #f8ded8; }
.recheck-banner[hidden] { display: none; }
.recheck-banner strong, .recheck-banner span { display: block; }
.recheck-banner strong { font-family: Georgia, serif; font-size: 1.45rem; }
.recheck-banner span { color: #70493f; font-size: 0.82rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-weight: 500; font-size: 1.75rem; }
.section-heading > span { white-space: nowrap; color: var(--ink-muted); font-size: 0.86rem; font-weight: 700; }
.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; top: 0; bottom: 0; left: 23px; width: 1px; background: var(--line); }
.meal-item { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 15px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.meal-marker { position: relative; z-index: 1; width: 47px; display: grid; justify-items: center; align-content: start; padding-top: 5px; }
.meal-dot { width: 13px; height: 13px; border: 3px solid var(--oat); border-radius: 50%; background: var(--sage-deep); box-shadow: 0 0 0 1px var(--sage-deep); }
.meal-item.current .meal-dot { background: var(--marigold); box-shadow: 0 0 0 6px rgba(230, 173, 53, 0.18); }
.meal-item.done .meal-dot { width: 19px; height: 19px; display: grid; place-items: center; border: 0; background: var(--forest); color: white; font-size: 0.7rem; }
.meal-card { min-width: 0; }
.meal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meal-time { font-weight: 900; letter-spacing: 0.01em; }
.meal-name { margin: 6px 0 16px; color: var(--forest-soft); line-height: 1.45; }
.meal-item.done .meal-name { text-decoration: line-through; opacity: 0.65; }
.meal-action { min-height: 42px; padding: 8px 16px; border: 1px solid var(--forest); border-radius: 12px; background: transparent; cursor: pointer; font-weight: 800; }
.meal-action:hover { background: var(--forest); color: white; }
.meal-item.done .meal-action { border-color: var(--line); color: var(--ink-muted); }
.optional-tag { display: inline-block; margin-left: 6px; color: var(--ink-muted); font-size: 0.75rem; font-weight: 700; }
.time-marker { position: absolute; left: 17px; right: 0; z-index: 2; height: 2px; background: var(--coral); pointer-events: none; }
.time-marker::before { content: ""; position: absolute; left: 0; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); }
.time-marker span { position: absolute; right: 0; top: -12px; padding: 2px 7px; background: var(--oat); color: var(--coral-dark); font-size: 0.7rem; font-weight: 900; text-transform: uppercase; }

.page-heading { padding: 46px 0 32px; }
.page-heading h1 { font-size: clamp(2.35rem, 9vw, 4.2rem); }
.page-heading > p:last-child { max-width: 600px; margin: 18px 0 0; color: var(--forest-soft); }
.log-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.button { min-height: 48px; padding: 11px 17px; border: 1px solid transparent; border-radius: 13px; cursor: pointer; font-weight: 850; }
.button.primary { background: var(--forest); color: white; }
.button.secondary { border-color: var(--forest); background: var(--paper); }
.button.text-button { background: transparent; color: var(--forest); }
.button.danger { background: var(--coral); color: white; }
.button:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(24, 60, 50, 0.12); }
.empty-state { padding: 52px 24px; border-top: 1px solid var(--line); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-mark { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 16px; background: var(--sage); font-weight: 900; }
.empty-state h2 { margin: 0; }
.empty-state p { margin-bottom: 0; color: var(--ink-muted); }
.log-list { margin: 0; padding: 0; list-style: none; }
.log-entry { display: grid; grid-template-columns: auto 1fr auto; gap: 15px; align-items: start; padding: 20px 0; border-top: 1px solid var(--line); }
.log-symbol { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--sage); font-weight: 900; }
.log-entry h3 { margin: 0 0 5px; font-size: 1rem; }
.log-entry p { margin: 0; color: var(--ink-muted); font-size: 0.9rem; }
.delete-entry { border: 0; background: transparent; cursor: pointer; color: var(--coral-dark); font-weight: 800; }

.notice { margin-bottom: 24px; padding: 22px; border-left: 5px solid var(--marigold); background: #f8eaca; }
.notice strong { font-family: Georgia, serif; font-size: 1.3rem; }
.notice p { color: #4d594e; }
.permission-status { margin-bottom: 0; font-size: 0.85rem; font-weight: 750; }
.schedule-settings { border-top: 1px solid var(--line); }
.plan-tools { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 24px; }
.reminder-row { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.reminder-row strong { display: block; }
.reminder-row span { color: var(--ink-muted); font-size: 0.9rem; }
.slot-editor { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.slot-editor input[type="time"] { min-width: 0; padding: 7px; }
.slot-meal { overflow: hidden; border: 0; background: transparent; text-align: left; cursor: pointer; }
.slot-meal strong, .slot-meal span { display: block; }
.slot-meal strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-meal span { color: var(--ink-muted); font-size: 0.78rem; }
.switch { position: relative; width: 50px; height: 29px; }
.switch input { position: absolute; opacity: 0; }
.switch-control { position: absolute; inset: 0; border-radius: 18px; background: #bfc4ba; cursor: pointer; transition: background 160ms ease; }
.switch-control::after { content: ""; position: absolute; top: 4px; left: 4px; width: 21px; height: 21px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: transform 160ms ease; }
.switch input:checked + .switch-control { background: var(--forest); }
.switch input:checked + .switch-control::after { transform: translateX(21px); }
.switch input:focus-visible + .switch-control { outline: 3px solid var(--marigold); outline-offset: 3px; }
.settings-block { display: grid; gap: 20px; margin-top: 40px; padding: 26px; border: 1px solid var(--line); background: var(--paper); }
.settings-block h2 { margin: 0 0 8px; font-family: Georgia, serif; font-weight: 500; }
.settings-block p { margin: 0; color: var(--ink-muted); }
.inline-form label { display: block; margin-bottom: 7px; font-size: 0.84rem; font-weight: 800; }
.inline-form > div { display: flex; gap: 8px; }
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #9da79e; border-radius: 10px; background: white; color: var(--forest); }
.setting-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.setting-line span, .setting-line strong, .setting-line small { display: block; }
.setting-line small { color: var(--ink-muted); }
.setting-line input { width: 24px; min-height: 24px; accent-color: var(--forest); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .field { margin: 14px 0 0; }
.field label span { color: var(--ink-muted); font-size: 0.8rem; font-weight: 500; }
.chip-field { margin: 18px 0; padding: 0; border: 0; }
.chip-field legend { font-weight: 800; }
.safety-note { margin: 18px 0; padding: 13px; border-left: 4px solid var(--sage-deep); background: var(--sage); color: var(--forest-soft); font-size: 0.85rem; }
.full-button { width: 100%; }
.privacy-note { border-left: 5px solid var(--sage-deep); }

.episode-trigger { position: fixed; left: 50%; bottom: calc(76px + var(--safe-bottom)); z-index: 20; width: min(calc(100% - 24px), 696px); min-height: 68px; transform: translateX(-50%); display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 17px; border: 0; border-radius: 18px; background: var(--coral); color: white; box-shadow: 0 15px 36px rgba(116, 37, 27, 0.3); text-align: left; cursor: pointer; }
.episode-trigger:hover { background: var(--coral-dark); }
.episode-trigger strong, .episode-trigger small { display: block; }
.episode-trigger strong { line-height: 1.25; }
.episode-trigger small { margin-top: 3px; opacity: 0.88; }
.episode-icon { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid currentColor; border-radius: 50%; font-family: Georgia, serif; font-size: 1.35rem; font-weight: 800; }
.bottom-nav { position: fixed; inset: auto 0 0; z-index: 19; height: calc(72px + var(--safe-bottom)); padding: 8px max(20px, calc((100% - 620px) / 2)) var(--safe-bottom); display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--paper); }
.bottom-nav a { display: grid; justify-items: center; align-content: center; gap: 2px; text-decoration: none; color: var(--ink-muted); font-size: 0.77rem; font-weight: 800; }
.bottom-nav a span { font-size: 1rem; }
.bottom-nav a.active { color: var(--forest); }
.disclaimer { width: min(100% - 32px, var(--page-width)); margin: 0 auto; padding: 8px 0 calc(170px + var(--safe-bottom)); color: var(--ink-muted); text-align: center; font-size: 0.75rem; }

dialog { color: var(--forest); }
dialog::backdrop { background: rgba(16, 35, 29, 0.58); }
.sheet-dialog { width: min(100% - 20px, 620px); max-height: min(90vh, 780px); margin: auto; padding: 0; border: 0; border-radius: 24px 24px 34px 24px; background: var(--paper); box-shadow: var(--shadow); }
.dialog-shell { padding: 24px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.episode-step { padding-top: 22px; }
.episode-step h3 { margin: 0 0 10px; font-size: 1.3rem; }
.episode-step p { color: var(--forest-soft); }
.danger-check { padding: 18px; border-left: 5px solid var(--coral); background: #f8ded8; }
.danger-check label { display: flex; gap: 12px; align-items: start; font-weight: 800; }
.danger-check input { width: 22px; min-height: 22px; accent-color: var(--coral); }
.symptom-safety { margin-top: 20px; }
.symptom-safety[hidden] { display: none; }
.field { margin: 18px 0; }
.field label { display: block; margin-bottom: 7px; font-weight: 800; }
.reading-wrap { position: relative; }
.reading-wrap input { padding-right: 74px; font-size: 1.25rem; font-weight: 800; }
.reading-wrap span { position: absolute; right: 13px; top: 13px; font-weight: 800; color: var(--ink-muted); }
.choice-row { display: flex; flex-wrap: wrap; gap: 9px; margin: 12px 0; }
.choice-row label { display: inline-flex; gap: 7px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.choice-row input { width: auto; min-height: auto; accent-color: var(--forest); }
.response-box { margin: 18px 0; padding: 20px; border: 1px solid var(--forest); background: var(--sage); }
.response-box.urgent { border-color: var(--coral-dark); background: #f8ded8; }
.response-box h3 { font-family: Georgia, serif; font-size: 1.45rem; }
.response-box ol { padding-left: 22px; }
.response-box li { margin: 9px 0; }
.call-link { display: block; margin: 12px 0; text-align: center; text-decoration: none; }
.help-content { padding-top: 20px; }
.help-content h3 { margin-top: 26px; }
.picker-note { padding: 12px; border-left: 4px solid var(--sage-deep); background: var(--sage); color: var(--forest-soft); font-size: 0.88rem; }
.meal-results { max-height: 310px; overflow-y: auto; border-block: 1px solid var(--line); }
.meal-option { width: 100%; padding: 13px 6px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.meal-option:hover, .meal-option.active { padding-left: 12px; background: var(--sage); }
.meal-option strong, .meal-option small { display: block; }
.meal-option small { margin-top: 3px; color: var(--ink-muted); }
.custom-meal { padding-top: 18px; }
.custom-meal > label { display: block; margin-bottom: 7px; font-weight: 800; }
.custom-meal > div { display: flex; gap: 8px; }
.contract { margin-top: 22px; padding: 15px; border: 1px solid var(--line); }
.contract summary { cursor: pointer; font-weight: 800; }
.contract pre { overflow-x: auto; white-space: pre-wrap; color: var(--forest-soft); font-size: 0.78rem; }
.draft-list { padding: 0; list-style: none; }
.draft-list li { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.draft-source { color: var(--ink-muted); font-size: 0.85rem; }
.confirm-dialog { width: min(100% - 32px, 400px); padding: 24px; border: 0; border-radius: 20px; background: var(--paper); }
.confirm-dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 170px; z-index: 100; transform: translate(-50%, 20px); padding: 10px 15px; border-radius: 9px; background: var(--forest); color: white; opacity: 0; pointer-events: none; transition: 180ms ease; font-weight: 750; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-width: 700px) {
  .site-header { height: 92px; }
  .next-panel { grid-template-columns: 1fr auto; padding: 30px; }
  .meal-item { grid-template-columns: 58px 1fr; gap: 20px; }
  .timeline::before { left: 28px; }
  .meal-marker { width: 57px; }
  .settings-block { grid-template-columns: 1.2fr 1fr; align-items: center; }
  .privacy-note { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .slot-editor { grid-template-columns: 88px 1fr; }
  .slot-editor .switch { grid-column: 2; }
  .check-task { grid-template-columns: 72px 1fr; }
  .check-task .button { grid-column: 2; width: 100%; }
  .recheck-banner { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
}

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