:root {
  --canvas: #f6f1e9;
  --paper: #fffdf9;
  --ink: #213c35;
  --ink-soft: #4d625b;
  --muted: #80918a;
  --line: #e7e0d5;
  --coral: #df7965;
  --coral-dark: #b65345;
  --green: #427767;
  --shadow: 0 18px 48px rgba(55, 48, 35, 0.07);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: "Avenir Next", Avenir, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgba(223, 121, 101, 0.35); outline-offset: 2px; }

.app-shell { width: min(100% - 40px, 1040px); margin: 0 auto; }
main { padding: 50px 0 42px; }
.date-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.eyebrow, .section-label { margin: 0; color: var(--coral-dark); font-size: 10px; font-weight: 800; letter-spacing: 0.17em; line-height: 1.4; text-transform: uppercase; }
.date-actions { display: flex; align-items: center; gap: 10px; }
.offline-pill { padding: 5px 8px; border: 1px solid #e7c9a7; border-radius: 999px; color: #9a6534; background: #fff5e7; font-size: 10px; font-weight: 800; }
.install-control { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); font-size: 11px; font-weight: 800; cursor: pointer; }
.install-control:hover { border-color: var(--ink); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(245px, 0.8fr); gap: 16px; }
.dose-card, .next-card { min-height: 295px; border-radius: 21px; box-shadow: var(--shadow); }
.dose-card { display: flex; flex-direction: column; padding: 25px 27px 22px; color: var(--paper); background: var(--ink); }
.dose-card-topline, .next-card-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.dose-card .section-label { color: rgba(246, 241, 233, 0.62); }
.phase-badge { padding: 6px 9px; border: 1px solid rgba(255, 253, 249, 0.15); border-radius: 999px; color: rgba(255, 253, 249, 0.76); font-size: 10px; font-weight: 700; }
.dose-card-content { display: flex; align-items: center; flex: 1; }
.dose-date { margin: 0 0 10px; color: rgba(246, 241, 233, 0.62); font-size: 12px; }
.dose-copy h1 { margin: 0; color: var(--paper); font-size: clamp(36px, 5vw, 54px); font-weight: 680; letter-spacing: -0.07em; line-height: 1; }
.dose-detail { margin: 12px 0 0; color: rgba(246, 241, 233, 0.68); font-size: 13px; }
.dose-action-row { display: flex; align-items: center; gap: 13px; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 14px; border: 0; border-radius: 11px; color: var(--ink); background: var(--paper); font-size: 12px; font-weight: 800; cursor: pointer; transition: transform 160ms ease, background 160ms ease; }
.primary-button:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.primary-button:active:not(:disabled) { transform: translateY(0); }
.primary-button:disabled { color: rgba(246, 241, 233, 0.47); background: rgba(246, 241, 233, 0.12); cursor: not-allowed; }
.button-icon { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: var(--paper); background: var(--coral); font-size: 11px; line-height: 1; }
.primary-button:disabled .button-icon { color: rgba(246, 241, 233, 0.35); background: rgba(246, 241, 233, 0.16); }
.logged-message { margin: 0; color: rgba(246, 241, 233, 0.55); font-size: 11px; }

.next-card { display: flex; flex-direction: column; padding: 25px 24px; border: 1px solid var(--line); background: var(--paper); }
.next-card .section-label { color: var(--muted); }
.muted-label { color: var(--muted); }
.pack-size { color: var(--muted); font-size: 11px; }
.pack-number { margin-top: 42px; font-size: 54px; font-weight: 700; letter-spacing: -0.08em; line-height: 0.9; }
.pack-status { margin: 8px 0 15px; color: var(--ink-soft); font-size: 12px; }
.pack-track { height: 6px; border-radius: 999px; background: #e4ded5; overflow: hidden; }
.pack-track span { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--green); transition: width 200ms ease, background 200ms ease; }
.pack-alert { margin: 11px 0 0; color: var(--coral-dark); font-size: 11px; font-weight: 800; line-height: 1.4; }
.next-divider { height: 1px; margin: auto 0 16px; background: var(--line); }
.next-dose { margin-top: 7px; font-size: 18px; font-weight: 700; letter-spacing: -0.04em; }

.progress-section, .history-section { margin-top: 58px; }
.section-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading-row h2 { margin: 6px 0 0; font-size: 23px; font-weight: 700; letter-spacing: -0.055em; }
.progress-summary { padding-bottom: 2px; color: var(--green); font-size: 11px; font-weight: 800; }
.progress-track { height: 6px; border-radius: 999px; background: #e4ded5; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--coral); transition: width 250ms ease; }
.progress-caption { margin: 9px 0 20px; color: var(--muted); font-size: 11px; }
.schedule-strip { display: grid; grid-template-columns: repeat(14, minmax(44px, 1fr)); gap: 6px; }
.schedule-day { position: relative; min-height: 101px; padding: 11px 4px 8px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: rgba(255, 253, 249, 0.55); cursor: pointer; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.schedule-day:hover { border-color: rgba(33, 60, 53, 0.38); transform: translateY(-1px); }
.schedule-day.selected { border-color: var(--coral); box-shadow: 0 0 0 2px rgba(223, 121, 101, 0.13); }
.schedule-day.today { background: var(--paper); }
.schedule-day.taken { color: var(--paper); border-color: var(--green); background: var(--green); }
.schedule-day.rest { color: var(--muted); background: rgba(231, 224, 213, 0.34); }
.schedule-weekday, .schedule-number, .schedule-dose { display: block; }
.schedule-weekday { color: var(--muted); font-size: 10px; font-weight: 700; }
.schedule-day.taken .schedule-weekday { color: rgba(255, 253, 249, 0.65); }
.schedule-number { margin-top: 8px; font-size: 21px; font-weight: 750; letter-spacing: -0.06em; }
.schedule-dose { margin-top: 10px; color: var(--coral-dark); font-size: 10px; font-weight: 800; }
.schedule-day.taken .schedule-dose { color: rgba(255, 253, 249, 0.78); }
.schedule-check { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; color: var(--green); background: var(--paper); font-size: 9px; font-weight: 900; }

.compact-heading { align-items: center; margin-bottom: 13px; }
.history-hint { color: var(--muted); font-size: 10px; }
.history-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.history-row { display: grid; grid-template-columns: minmax(90px, 1fr) auto auto 13px; align-items: center; gap: 9px; width: 100%; min-height: 59px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: rgba(255, 253, 249, 0.55); text-align: left; cursor: pointer; }
.history-row:hover, .history-row.selected { border-color: rgba(223, 121, 101, 0.75); background: var(--paper); }
.history-date strong, .history-date span { display: block; }
.history-date strong { font-size: 11px; }
.history-date span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.history-dose { color: var(--ink-soft); font-size: 10px; font-weight: 700; white-space: nowrap; }
.history-status { font-size: 9px; font-weight: 800; white-space: nowrap; }
.history-status.complete { color: var(--green); }
.history-status.missing { color: var(--coral-dark); }
.history-chevron { color: var(--muted); font-size: 18px; font-weight: 300; line-height: 1; }
.empty-history { grid-column: 1 / -1; margin: 0; padding: 20px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); font-size: 11px; text-align: center; }

.settings-panel { margin-top: 48px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.settings-panel summary { display: flex; align-items: center; justify-content: space-between; padding: 19px 0; cursor: pointer; list-style: none; }
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-panel summary svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; transition: transform 160ms ease; }
.settings-panel[open] summary svg { transform: rotate(180deg); }
.settings-title { font-size: 13px; font-weight: 750; }
.settings-content { padding: 0 0 23px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0 19px; border-top: 1px solid var(--line); }
.setting-row label { font-size: 12px; font-weight: 750; }
.setting-row input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--paper); font-size: 12px; }
.plan-outline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan-outline > div { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); }
.plan-outline strong, .plan-outline span { display: block; }
.plan-outline strong { font-size: 10px; }
.plan-outline span { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.download-button { display: inline-block; margin-top: 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--paper); font-size: 10px; font-weight: 800; text-decoration: none; }
.download-button:hover { border-color: var(--ink); }
.care-note { margin: 18px 0; color: var(--ink-soft); font-size: 10px; line-height: 1.45; }
.text-button { padding: 0; border: 0; background: transparent; font-size: 10px; font-weight: 800; cursor: pointer; }
.danger-button { color: var(--coral-dark); }
.danger-button:hover { text-decoration: underline; }
.toast { position: fixed; bottom: 20px; left: 50%; z-index: 10; max-width: calc(100% - 32px); padding: 11px 14px; border-radius: 10px; color: var(--paper); background: var(--ink); box-shadow: 0 10px 30px rgba(33, 60, 53, 0.2); font-size: 11px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 28px, 680px); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .next-card { min-height: 230px; }
  .pack-number { margin-top: 30px; }
  .schedule-strip { display: flex; overflow-x: auto; padding: 2px 1px 9px; scrollbar-width: none; }
  .schedule-strip::-webkit-scrollbar { display: none; }
  .schedule-day { flex: 0 0 64px; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 24px, 500px); }
  main { padding-top: 30px; }
  .dose-card { min-height: 300px; padding: 23px 20px 20px; }
  .dose-copy h1 { font-size: 42px; }
  .dose-action-row { display: block; }
  .primary-button { width: 100%; }
  .logged-message { margin-top: 9px; text-align: center; }
  .progress-section, .history-section { margin-top: 46px; }
  .section-heading-row h2 { font-size: 21px; }
  .history-list { grid-template-columns: 1fr; }
  .plan-outline { grid-template-columns: 1fr; }
}

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