/* Dose — a calm medicine alarm. */
:root {
  --bg: #100e0c;
  --ink: #f6f1ea;
  --muted: #b7ab9e;
  --faint: rgba(246, 241, 234, 0.08);
  --line: rgba(246, 241, 234, 0.14);
  --amber: #e7a44a;
  --paper: rgba(246, 241, 234, 0.055);
  --good: #8dcea8;
  --miss: #ef8d72;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --font: "Outfit", -apple-system, BlinkMacSystemFont, sans-serif;
  --display: "Fraunces", "Iowan Old Style", Palatino, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body.locked { overflow: hidden; }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(90% 50% at 80% -10%, rgba(231, 164, 74, 0.16), transparent 55%),
    linear-gradient(180deg, #17130f 0%, var(--bg) 42%);
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
}
.orb-a { width: 46vw; height: 46vw; left: -12vw; top: 8vh; background: rgba(231, 164, 74, 0.14); }
.orb-b { width: 40vw; height: 40vw; right: -14vw; bottom: 6vh; background: rgba(110, 200, 179, 0.08); }

.app {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 0 18px calc(36px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: calc(14px + var(--safe-top)) 0 16px;
  background: linear-gradient(180deg, rgba(16, 14, 12, 0.94) 55%, rgba(16, 14, 12, 0));
}
.eyebrow {
  margin: 0 0 2px;
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -0.03em; }
h1 { margin: 0; font-size: clamp(2rem, 8vw, 2.7rem); line-height: 0.95; }
.date-label { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }
.top-actions { display: flex; gap: 8px; padding-bottom: 4px; }
.icon-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--faint);
  border: 1px solid var(--line);
}
.icon-btn-add { background: var(--ink); color: #1a140f; border-color: transparent; }
.icon-btn:active, .btn:active { transform: scale(0.98); }

.setup { margin: 4px 0 18px; }
.setup-card, .ready-row {
  border: 1px solid rgba(231, 164, 74, 0.28);
  background: rgba(231, 164, 74, 0.08);
  border-radius: 22px;
  padding: 16px;
}
.setup-card h2 { margin: 0 0 6px; font-size: 1.45rem; }
.setup-card p, .ready-row p { margin: 0; color: var(--muted); }
.steps { margin: 12px 0 0; padding-left: 18px; color: var(--ink); }
.steps li + li { margin-top: 6px; }
.setup-actions, .ready-row { display: flex; gap: 8px; align-items: center; }
.setup-actions { margin-top: 14px; flex-wrap: wrap; }
.ready-row { justify-content: space-between; border-color: var(--line); background: var(--paper); }
.ready-copy { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(141, 206, 168, 0.16);
}
.warn { margin-top: 10px; color: #f0c7a2; font-size: 0.92rem; }

.empty { padding: 28px 6px 10px; }
.empty-capsule {
  width: 92px;
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f6f0e6 50%, #e7a44a 50%);
  transform: rotate(-16deg);
  box-shadow: 0 16px 40px rgba(231, 164, 74, 0.28);
  margin: 8px 0 22px;
}
.empty h2 { margin: 0; font-size: clamp(2.4rem, 10vw, 3.4rem); line-height: 0.95; max-width: 9ch; }
.empty p { color: var(--muted); font-size: 1.05rem; max-width: 34ch; }
.empty .btn { margin-top: 6px; }

.hero {
  position: relative;
  overflow: hidden;
  margin: 6px 0 22px;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid rgba(231, 164, 74, 0.24);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(231, 164, 74, 0.18), transparent 46%),
    rgba(246, 241, 234, 0.045);
  box-shadow: var(--shadow);
}
.hero h2 { margin: 4px 0 0; font-size: clamp(2.3rem, 9vw, 3.3rem); line-height: 0.96; }
.hero-time {
  margin: 10px 0 0;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  color: var(--ink);
}
.hero-when { margin: 4px 0 0; color: var(--amber); font-weight: 650; font-size: 1.15rem; }
.hero-meta { margin: 8px 0 0; color: var(--muted); }
.hero.is-done { border-color: rgba(141, 206, 168, 0.28); }
.hero.is-done .hero-when { color: var(--good); }
.hero.is-due { border-color: rgba(231, 164, 74, 0.7); }

.block { margin-top: 8px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 8px 2px 10px;
}
.section-head h2 { margin: 0; font-size: 1.7rem; }
.section-head span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.quiet { color: var(--muted); margin: 0 2px 8px; }

.timeline, .med-list { display: flex; flex-direction: column; gap: 8px; }
.slot, .med {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid transparent;
}
.slot-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--muted);
}
.slot-title, .med-title { display: flex; align-items: center; gap: 8px; }
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.slot-title strong, .med-title strong { font-size: 1.02rem; font-weight: 650; }
.slot p, .med p { margin: 3px 0 0; color: var(--muted); font-size: 0.9rem; }
.slot.is-due { background: rgba(231, 164, 74, 0.12); border-color: rgba(231, 164, 74, 0.38); }
.slot.is-taken, .slot.is-skipped { opacity: 0.62; }
.slot.is-missed .status { color: var(--miss); }
.status { font-weight: 650; }
.status.due { color: var(--amber); }
.mini {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(246, 241, 234, 0.08);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 650;
}
.slot.is-due .mini { background: var(--ink); color: #1a140f; border-color: transparent; }

.med {
  grid-template-columns: 1fr auto;
  padding: 6px 8px 6px 0;
  overflow: hidden;
}
.med-main {
  text-align: left;
  padding: 12px 8px 12px 14px;
  border-left: 4px solid var(--c, var(--amber));
}
.med.is-off { opacity: 0.55; }
.switch {
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  padding: 3px;
  margin-right: 8px;
}
.switch span {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  transition: transform 0.18s ease;
}
.switch[aria-checked="true"] { background: var(--amber); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

.btn {
  height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  background: #f3ecdf;
  color: #1a140f;
  font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.text { background: transparent; color: var(--muted); height: 42px; }
.btn.danger { color: #f0b2a2; }
.btn.wide { width: 100%; }

.fine-print { margin: 28px 4px 0; color: var(--muted); }
.fine-print summary { cursor: pointer; font-weight: 600; }
.fine-print p { margin: 8px 0 0; line-height: 1.5; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 6, 4, 0.62);
  backdrop-filter: blur(8px);
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(480px, 100%);
  margin: 0 auto;
  max-height: min(92dvh, 920px);
  overflow: auto;
  background: #1b1713;
  border-radius: 28px 28px 0 0;
  padding: 8px 18px calc(16px + var(--safe-bottom));
  box-shadow: 0 -24px 80px rgba(0, 0, 0, 0.45);
}
.handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  margin: 6px auto 10px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 2rem; }
.draft-summary { color: var(--amber); margin: 4px 0 16px; min-height: 1.4em; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field > span { color: var(--muted); font-size: 0.82rem; font-weight: 650; }
input[type="text"], input[type="time"] {
  width: 100%;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  padding: 0 14px;
  font-size: 16px;
}
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 700;
}
.day[aria-pressed="true"] { background: #f3ecdf; color: #1a140f; border-color: transparent; }
.quick-times, .time-chips, .colors { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-times button, .time-chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.92rem;
}
.time-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.time-chip { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.color {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18);
}
.color[aria-pressed="true"] { box-shadow: 0 0 0 2px #1b1713, 0 0 0 4px #f3ecdf; }
.sheet-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0 4px;
  background: linear-gradient(180deg, rgba(27, 23, 19, 0), #1b1713 28%);
}

.alarm {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  padding: calc(22px + var(--safe-top)) 22px calc(14px + var(--safe-bottom));
  background: #140f0c;
  color: #fff8ef;
}
.alarm-glow {
  position: absolute;
  width: min(120vw, 640px);
  height: min(120vw, 640px);
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--glow, #e7a44a) 42%, transparent), transparent 68%);
  pointer-events: none;
}
.alarm[data-sound="on"] .alarm-glow { animation: glow 1.7s ease-in-out infinite; }
.alarm-content {
  position: relative;
  z-index: 1;
  flex: 1;
  width: min(480px, 100%);
  align-self: center;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.alarm-scroll { flex: 1; overflow: auto; padding-bottom: 8px; }
.alarm-kicker {
  margin: 8px 0 0;
  color: var(--glow, var(--amber));
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.alarm-clock {
  margin: 0;
  color: rgba(255, 248, 239, 0.7);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}
.capsule {
  width: 86px;
  height: 34px;
  margin: 22px 0 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f7f1e6 50%, var(--glow, #e7a44a) 50%);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--glow, #e7a44a) 40%, transparent);
}
.alarm h2 {
  margin: 0;
  font-size: clamp(3rem, 13vw, 4.6rem);
  line-height: 0.92;
  max-width: 10ch;
}
.alarm-dose, .alarm-note, .alarm-time { margin: 8px 0 0; font-size: 1.15rem; }
.alarm-note { color: rgba(255, 248, 239, 0.72); }
.alarm-time { color: var(--glow, var(--amber)); font-weight: 700; }
.alarm-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.alarm-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 248, 239, 0.06);
  border: 1px solid rgba(255, 248, 239, 0.08);
}
.alarm-row h3 { margin: 0; font-size: 1.6rem; }
.alarm-row p { margin: 4px 0 0; color: rgba(255, 248, 239, 0.7); }
.alarm-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.alarm-actions .btn { height: 62px; font-size: 1.12rem; border-radius: 18px; }
.alarm-actions .btn.ghost { color: #fff8ef; border-color: rgba(255, 248, 239, 0.28); }
.sound-hint { margin: 0 0 8px; color: #ffd89a; font-weight: 700; text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 90;
  transform: translateX(-50%) translateY(12px);
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: #f3ecdf;
  color: #1a140f;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes glow {
  0%, 100% { opacity: 0.72; transform: translateX(-50%) scale(0.96); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .alarm[data-sound="on"] .alarm-glow { animation: none; }
  .switch span, .toast { transition: none; }
}
