/* ============================================================
   MediMinder — calm, private medication reminders
   ============================================================ */

:root {
  --bg: #f6f7f2;
  --bg-2: #eef1e9;
  --topbar: rgba(246, 247, 242, 0.84);
  --surface: #ffffff;
  --surface-2: #f1f4ed;
  --surface-3: #e6ebe3;
  --ink: #152924;
  --ink-2: #324a44;
  --muted: #5f716a;
  --muted-2: #71847c;
  --line: #e0e6dd;
  --line-strong: #cbd6cc;
  --brand: #0f6b5c;
  --brand-2: #178673;
  --brand-deep: #0a4b41;
  --cta-1: #126f60;
  --cta-2: #0a4b41;
  --cta-ink: #f5fffb;
  --brand-soft: #e2f1eb;
  --brand-soft-2: #d2eae1;
  --brand-glow: rgba(15, 107, 92, 0.16);
  --accent: #dd765b;
  --accent-2: #a84e36;
  --accent-soft: #fbeae4;
  --gold: #8f641b;
  --gold-soft: #f7efdc;
  --danger: #a13d33;
  --danger-soft: #fbe9e6;
  --on-brand: #f5fffb;
  --shadow-sm: 0 1px 2px rgba(18, 41, 35, 0.04), 0 8px 24px -18px rgba(18, 41, 35, 0.18);
  --shadow-md: 0 2px 4px rgba(18, 41, 35, 0.04), 0 20px 44px -28px rgba(18, 41, 35, 0.28);
  --shadow-lg: 0 30px 80px -32px rgba(10, 47, 40, 0.45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --font-sans: "Segoe UI Variable", "Segoe UI", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --focus: 0 0 0 3px var(--brand-glow), 0 0 0 1px var(--brand);
}

[data-theme="dark"] {
  --bg: #0d1715;
  --bg-2: #111f1c;
  --topbar: rgba(13, 23, 21, 0.84);
  --surface: #14221f;
  --surface-2: #1a2b27;
  --surface-3: #223530;
  --ink: #edf5f0;
  --ink-2: #c9d8d2;
  --muted: #97aaa2;
  --muted-2: #7b8d86;
  --line: #263833;
  --line-strong: #344a44;
  --brand: #73d6bf;
  --brand-2: #96e6d3;
  --brand-deep: #0b5548;
  --cta-1: #137565;
  --cta-2: #0a5145;
  --cta-ink: #f5fffb;
  --brand-soft: #173b34;
  --brand-soft-2: #1e4a41;
  --brand-glow: rgba(115, 214, 191, 0.2);
  --accent: #f0937a;
  --accent-2: #f5ab95;
  --accent-soft: #3a2722;
  --gold: #e0b364;
  --gold-soft: #352d1e;
  --danger: #f09a90;
  --danger-soft: #3c2523;
  --on-brand: #f5fffb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18), 0 8px 24px -18px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.18), 0 20px 44px -28px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.7);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.has-dialog {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 42% at 6% -4%, var(--brand-glow), transparent 62%),
    radial-gradient(42% 32% at 96% 8%, rgba(221, 118, 91, 0.08), transparent 66%);
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(60% 42% at 6% -4%, rgba(115, 214, 191, 0.09), transparent 62%),
    radial-gradient(42% 32% at 96% 8%, rgba(240, 147, 122, 0.06), transparent 66%);
}

::selection {
  background: var(--brand-soft-2);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

svg {
  display: block;
}

a {
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
}

.icon-slot svg {
  width: 100%;
  height: 100%;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 1220px;
  min-height: 74px;
  margin: 0 auto;
  padding: 10px 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--ink);
  text-decoration: none;
  border-radius: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(255, 255, 255, 0.24), transparent 52%),
    linear-gradient(150deg, #148574, #0a4b41);
  box-shadow: 0 8px 18px -10px rgba(10, 75, 65, 0.7);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand-word {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-word span {
  font-weight: 400;
  color: var(--muted);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0 auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 45, 38, 0.08), 0 4px 12px -8px rgba(20, 45, 38, 0.28);
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn .icon-slot {
  width: 19px;
  height: 19px;
}

.notify-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--topbar);
}

.icon-btn.is-on .notify-dot {
  background: #1f9d76;
}

[data-theme="dark"] .icon-btn.is-on .notify-dot {
  background: #64d6b6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.16s ease, background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(160deg, var(--cta-1), var(--cta-2));
  color: var(--cta-ink);
  box-shadow: 0 10px 22px -12px rgba(10, 75, 65, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-primary:hover {
  box-shadow: 0 14px 28px -12px rgba(10, 75, 65, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-soft {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}

.btn-soft:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.btn-ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 10px 22px -14px rgba(176, 70, 60, 0.8);
}

[data-theme="dark"] .btn-danger {
  color: #2a1310;
}

.btn-small {
  height: 36px;
  padding: 0 14px;
  font-size: 12.5px;
}

.btn-wide {
  width: 100%;
  height: 46px;
}

.add-btn {
  height: 42px;
  margin-left: 4px;
  padding: 0 19px;
}

.text-btn {
  padding: 4px 2px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--muted) 35%, transparent);
  text-underline-offset: 3px;
}

.text-btn:hover {
  color: var(--ink);
}

.danger-text {
  color: var(--danger);
}

.danger-text:hover {
  color: var(--danger);
  opacity: 0.8;
}

.shell {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 28px;
}

body[data-active-view="meds"] .hero,
body[data-active-view="history"] .hero {
  display: none;
}

body[data-active-view="meds"] .section-head,
body[data-active-view="history"] .section-head {
  margin-top: 40px;
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(410px, 0.97fr);
  gap: clamp(34px, 5.2vw, 78px);
  align-items: center;
  padding: clamp(42px, 6vw, 78px) 0 clamp(38px, 5vw, 58px);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.eyebrow-sep {
  color: var(--line-strong);
  font-weight: 400;
}

.hero h1 {
  max-width: 620px;
  font-family: var(--font-serif);
  font-size: clamp(48px, 6.1vw, 74px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.accent-word {
  position: relative;
  display: inline-block;
  color: var(--brand);
  font-style: italic;
  font-weight: 500;
  padding-right: 0.04em;
}

.underline {
  position: absolute;
  left: 2%;
  bottom: -0.17em;
  width: 97%;
  height: 0.13em;
  color: var(--accent);
  opacity: 0.82;
  overflow: visible;
}

.lede {
  max-width: 430px;
  margin-top: 26px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.62;
  letter-spacing: -0.005em;
}

.reminder-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 26px;
  color: var(--muted);
  font-size: 12.5px;
}

.live-dot {
  position: relative;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #2c9b76;
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(44, 155, 118, 0.45);
  animation: pulse-ring 2.6s ease-out infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.65); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: scale(1.55); opacity: 0; }
}

.hero-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.next-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 262px;
  padding: 26px 28px;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(130% 120% at 100% 0%, rgba(111, 211, 189, 0.38), transparent 48%),
    radial-gradient(90% 90% at 0% 100%, rgba(221, 118, 91, 0.26), transparent 52%),
    linear-gradient(145deg, #0c5a4e 0%, #0a453c 58%, #083a33 100%);
  color: var(--on-brand);
  box-shadow: 0 34px 64px -34px rgba(8, 58, 51, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  isolation: isolate;
}

.next-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -112px;
  right: -92px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  box-shadow:
    0 0 0 34px rgba(255, 255, 255, 0.035),
    0 0 0 72px rgba(255, 255, 255, 0.022);
}

.next-card.is-due {
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(247, 170, 144, 0.4), transparent 48%),
    radial-gradient(90% 90% at 0% 100%, rgba(111, 211, 189, 0.2), transparent 52%),
    linear-gradient(145deg, #124f45 0%, #0a3f38 58%, #08352f 100%);
}

.next-card.is-empty {
  justify-content: center;
}

.next-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-kicker {
  color: rgba(238, 255, 250, 0.62);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.82);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.is-due {
  border-color: rgba(255, 188, 165, 0.26);
  background: rgba(221, 118, 91, 0.24);
  color: #ffd8cc;
}

.status-pill.is-snoozed {
  border-color: rgba(255, 216, 148, 0.24);
  background: rgba(224, 179, 100, 0.18);
  color: #ffe7b8;
}

.next-main {
  padding: 18px 0;
}

.next-card h2 {
  overflow: hidden;
  color: #fff;
  font-size: clamp(26px, 2.8vw, 32px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-meta {
  margin-top: 7px;
  color: rgba(235, 255, 250, 0.66);
  font-size: 13px;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  row-gap: 10px;
}

.next-when {
  color: rgba(235, 255, 250, 0.7);
  font-size: 12px;
  font-weight: 500;
}

.next-countdown {
  margin-top: 3px;
  color: #fff;
  font-size: clamp(27px, 3.2vw, 36px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.12;
  white-space: nowrap;
}

.next-countdown.is-due {
  color: #ffc7b6;
}

.next-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: #f2fbf6;
  color: #0a453c;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.5);
  transition: transform 0.16s ease, background 0.16s ease;
}

.next-cta:hover {
  background: #fff;
  transform: translateY(-1px);
}

.next-cta .icon-slot {
  width: 15px;
  height: 15px;
}

.next-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}

.next-empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #d8f6ec;
}

.next-empty h2 {
  white-space: normal;
}

.next-empty p {
  max-width: 320px;
  color: rgba(235, 255, 250, 0.65);
  font-size: 13px;
  line-height: 1.5;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.install-banner {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(120deg, var(--brand-soft), transparent 58%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.install-banner:not([hidden]) + .hero {
  padding-top: 30px;
}

.install-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--cta-1), var(--cta-2));
  color: var(--cta-ink);
}

.install-icon .icon-slot {
  width: 19px;
  height: 19px;
}

.install-copy {
  flex: 1;
  min-width: 0;
}

.install-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.install-copy p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.install-action {
  flex: none;
  height: 34px;
  padding: 0 13px;
  font-size: 11.5px;
}

.install-dismiss {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
}

.install-dismiss .icon-slot {
  width: 15px;
  height: 15px;
}

.mini-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 128px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.mini-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mini-value {
  margin-top: 4px;
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.mini-value small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

.mini-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11.5px;
}

.progress-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ring {
  width: 48px;
  height: 48px;
  flex: none;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 5;
}

.ring-fill {
  fill: none;
  stroke: var(--brand);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.ring-fill.is-accent {
  stroke: var(--accent);
}

.spark {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 30px;
  margin-top: 12px;
}

.spark span {
  position: relative;
  flex: 1;
  min-width: 4px;
  height: 100%;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}

.spark span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--h, 20%);
  border-radius: 3px;
  background: var(--brand-soft-2);
}

.spark span:last-child::after {
  background: var(--brand);
}

.spark span.is-missed::after {
  background: var(--accent);
}

[data-theme="dark"] .spark span {
  background: var(--surface-2);
}

[data-theme="dark"] .spark span::after {
  background: var(--brand-soft-2);
}

[data-theme="dark"] .spark span:last-child::after {
  background: var(--brand);
}

[data-theme="dark"] .spark span.is-missed::after {
  background: var(--accent);
}

/* ---------- Sections ---------- */

.view {
  padding-top: 8px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 34px 0 17px;
}

.section-kicker {
  margin-bottom: 5px;
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-head h2 {
  font-family: var(--font-serif);
  font-size: clamp(27px, 3vw, 34px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.section-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.range-pill {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Today schedule ---------- */

.schedule-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.dose-row {
  position: relative;
  display: grid;
  grid-template-columns: 90px 26px minmax(0, 1fr);
  gap: 0 18px;
  padding: 21px 26px 21px 24px;
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease;
}

.dose-row:last-child {
  border-bottom: 0;
}

.dose-row.is-due {
  background: linear-gradient(90deg, var(--accent-soft), transparent 62%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.dose-row.is-snoozed {
  background: linear-gradient(90deg, var(--gold-soft), transparent 55%);
}

.dose-row.is-taken .dose-title h3,
.dose-row.is-taken .dose-meta,
.dose-row.is-skipped .dose-title h3,
.dose-row.is-skipped .dose-meta {
  opacity: 0.62;
}

.dose-time {
  padding-top: 2px;
  text-align: right;
}

.time-main {
  display: block;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.time-period {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.time-day {
  display: inline-block;
  margin-bottom: 3px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-theme="dark"] .time-day {
  color: var(--accent);
}

.dose-rail {
  position: relative;
  display: flex;
  justify-content: center;
  padding-top: 7px;
}

.dose-dot {
  position: relative;
  width: 11px;
  height: 11px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.dose-row.is-due .dose-dot {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 5px var(--accent-soft);
}

.dose-row.is-snoozed .dose-dot {
  background: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 0 5px var(--gold-soft);
}

.dose-row.is-taken .dose-dot {
  background: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 5px var(--brand-soft);
}

.dose-row.is-skipped .dose-dot {
  background: var(--muted-2);
  box-shadow: 0 0 0 1px var(--muted-2), 0 0 0 5px var(--surface-2);
}

.dose-body {
  min-width: 0;
}

.dose-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.dose-title h3 {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.chip-due {
  background: var(--accent-soft);
  color: var(--accent-2);
}

[data-theme="dark"] .chip-due {
  color: var(--accent);
}

.chip-taken {
  background: var(--brand-soft);
  color: var(--brand);
}

.chip-snoozed {
  background: var(--gold-soft);
  color: var(--gold);
}

.chip-skipped {
  background: var(--surface-2);
  color: var(--muted);
}

.chip-missed {
  background: var(--accent-soft);
  color: var(--accent-2);
}

[data-theme="dark"] .chip-missed {
  color: var(--accent);
}

.chip-upcoming {
  background: transparent;
  color: var(--muted);
  padding-left: 0;
}

.chip-upcoming::before {
  display: none;
}

.dose-meta {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dose-meta .sep {
  margin: 0 6px;
  color: var(--line-strong);
}

.dose-meta strong {
  color: var(--ink-2);
  font-weight: 500;
}

.dose-meta .dose-note {
  font-style: italic;
}

.dose-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.dose-status.is-due {
  color: var(--accent-2);
  font-weight: 600;
}

[data-theme="dark"] .dose-status.is-due {
  color: var(--accent);
}

.dose-status.is-taken {
  color: var(--brand);
}

.dose-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  flex-wrap: wrap;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.mini-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.mini-btn.primary {
  border-color: var(--cta-2);
  background: var(--cta-2);
  color: var(--cta-ink);
}

.mini-btn.primary:hover {
  background: var(--cta-1);
}

[data-theme="dark"] .mini-btn.primary {
  color: var(--cta-ink);
}

.mini-btn .icon-slot {
  width: 13px;
  height: 13px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 28px 46px;
  text-align: center;
}

.empty-art {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    radial-gradient(100% 100% at 100% 0%, var(--brand-soft), transparent 60%),
    var(--surface-2);
  color: var(--brand);
  transform: rotate(-3deg);
  box-shadow: var(--shadow-sm);
}

.empty-art svg {
  width: 42px;
  height: 42px;
}

.empty-state h3 {
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.empty-state p {
  max-width: 390px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Look ahead ---------- */

.lookahead {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.lookahead summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 22px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.lookahead summary::-webkit-details-marker {
  display: none;
}

.lookahead summary .summary-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.chev {
  display: inline-flex;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.lookahead[open] .chev {
  transform: rotate(180deg);
}

.lookahead-body {
  padding: 0 22px 10px;
  border-top: 1px solid var(--line);
}

.lookahead-day {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.lookahead-day:last-child {
  border-bottom: 0;
}

.lookahead-date {
  padding-top: 2px;
}

.lookahead-date strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}

.lookahead-date span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lookahead-items {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.lookahead-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 12.5px;
}

.lookahead-item time {
  width: 62px;
  flex: none;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.lookahead-item strong {
  font-weight: 600;
}

.lookahead-item span {
  color: var(--muted);
  font-size: 11.5px;
}

.lookahead-more {
  padding: 12px 0 4px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

/* ---------- Medications ---------- */

.meds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.med-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 21px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.med-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.med-card.is-paused {
  opacity: 0.68;
}

.med-card.is-paused:hover {
  opacity: 0.86;
}

.med-top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.med-avatar {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: none;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.med-avatar.tone-1 {
  background: var(--accent-soft);
  color: var(--accent-2);
}

[data-theme="dark"] .med-avatar.tone-1 {
  color: var(--accent);
}

.med-avatar.tone-2 {
  background: var(--gold-soft);
  color: var(--gold);
}

.med-avatar.tone-3 {
  background: var(--surface-2);
  color: var(--ink-2);
}

.med-title {
  min-width: 0;
  flex: 1;
  padding-top: 2px;
}

.med-title h3 {
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-title p {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.med-flag {
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.med-schedule {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12.5px;
}

.med-schedule .icon-slot {
  width: 15px;
  height: 15px;
  color: var(--brand);
}

.med-next {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.med-next .icon-slot {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--muted);
}

.med-next strong {
  color: var(--ink-2);
  font-weight: 600;
}

.med-next.is-due {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.med-next.is-due .icon-slot,
.med-next.is-due strong {
  color: var(--accent-2);
}

[data-theme="dark"] .med-next.is-due,
[data-theme="dark"] .med-next.is-due .icon-slot,
[data-theme="dark"] .med-next.is-due strong {
  color: var(--accent);
}

.med-notes {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.med-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.med-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease;
}

.med-action:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.med-action .icon-slot {
  width: 13px;
  height: 13px;
}

.med-action.danger {
  margin-left: auto;
  padding: 0 6px;
}

.med-action.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 28px;
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.info-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: none;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
}

.info-icon .icon-slot,
.info-icon svg {
  width: 19px;
  height: 19px;
}

.info-card h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.info-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.info-card .info-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted-2);
}

.info-card .info-note strong {
  color: var(--ink-2);
  font-weight: 600;
}

.data-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.data-actions .btn {
  height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.data-actions .text-btn {
  margin-left: 2px;
  font-size: 11px;
}

/* ---------- History ---------- */

.history-top {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
}

.history-score {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--brand-soft), transparent 58%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.score-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  flex: none;
}

.score-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring .ring-track {
  stroke-width: 7;
}

.score-ring .ring-fill {
  stroke-width: 7;
}

.score-ring strong {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.score-ring strong small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.score-copy h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.score-copy p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.score-totals {
  display: flex;
  gap: 18px;
  margin-top: 12px;
}

.score-totals span {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.score-totals strong {
  display: block;
  margin-bottom: 1px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: none;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--line);
  box-shadow: var(--shadow-sm);
}

.hstat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 16px;
  background: var(--surface);
}

.hstat span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hstat strong {
  margin-top: 5px;
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.hstat small {
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 10px;
}

.chart-card {
  margin-top: 14px;
  padding: 22px 24px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.chart-head h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.chart-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.legend i {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--brand);
}

.legend i.missed {
  background: var(--accent);
}

.legend i.skipped {
  background: var(--gold);
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 24px;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.chart-track {
  position: relative;
  width: 100%;
  max-width: 36px;
  height: 108px;
  overflow: hidden;
  border-radius: 7px;
  background:
    repeating-linear-gradient(to top, transparent 0, transparent 26px, var(--line) 26px, var(--line) 27px),
    var(--surface-2);
}

.chart-seg {
  position: absolute;
  left: 0;
  width: 100%;
  min-height: 0;
}

.chart-seg.taken {
  background: linear-gradient(to top, var(--brand), var(--brand-2));
}

.chart-seg.missed {
  background: var(--accent);
}

.chart-seg.skipped {
  background: var(--gold);
}

.chart-col.is-empty .chart-track {
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
}

.chart-day {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-count {
  color: var(--muted-2);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}

.chart-col.is-today .chart-day {
  color: var(--brand);
}

.chart-col.is-today .chart-count {
  color: var(--ink-2);
  font-weight: 600;
}

.activity-card {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.activity-head h3 {
  font-size: 14px;
  font-weight: 600;
}

.filters {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
}

.filter-btn {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease;
}

.filter-btn:hover {
  color: var(--ink);
}

.filter-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(20, 45, 38, 0.12);
}

.activity-list {
  padding: 0 22px 8px;
}

.activity-day {
  padding: 15px 0 4px;
}

.activity-day-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.activity-day-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.activity-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
}

.activity-item:last-child {
  border-bottom: 0;
}

.act-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.act-icon svg {
  width: 14px;
  height: 14px;
}

.act-icon.taken {
  background: var(--brand-soft);
  color: var(--brand);
}

.act-icon.missed {
  background: var(--accent-soft);
  color: var(--accent-2);
}

[data-theme="dark"] .act-icon.missed {
  color: var(--accent);
}

.act-icon.skipped {
  background: var(--gold-soft);
  color: var(--gold);
}

.act-main {
  min-width: 0;
}

.act-main strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.act-main span {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item .chip {
  font-size: 8.5px;
  padding: 3px 7px;
}

.activity-more {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.history-empty {
  padding: 40px 22px 44px;
  text-align: center;
}

.history-empty p {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: clamp(60px, 8vw, 96px);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 45%, transparent);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 34px 28px 40px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark-small {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.brand-mark-small svg {
  width: 19px;
  height: 19px;
}

.footer-inner p {
  max-width: 660px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.footer-meta {
  color: var(--muted-2) !important;
  font-size: 10.5px !important;
}

.footer-version {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-2);
  font-size: 10.5px;
}

.footer-version .text-btn {
  padding: 0;
  font-size: 10.5px;
}

/* ---------- Dialogs ---------- */

.dialog {
  width: min(580px, calc(100vw - 30px));
  max-width: none;
  max-height: calc(100dvh - 36px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.dialog[open] {
  animation: dialog-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog::backdrop {
  background: rgba(9, 27, 23, 0.48);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
}

.dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dialog-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  background: var(--brand-soft);
  color: var(--brand);
}

.dialog-icon .icon-slot {
  width: 22px;
  height: 22px;
}

.dialog-kicker {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dialog-head h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.dialog-close {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
}

.dialog .dialog-body {
  max-height: min(62vh, 540px);
  padding: 4px 24px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field-label,
.time-field legend,
.weekday-field legend {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.optional,
.req {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.req {
  color: var(--accent-2);
}

[data-theme="dark"] .req {
  color: var(--accent);
}

.optional {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.date-control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-control-row input {
  flex: 1;
  min-width: 0;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input,
.field select {
  height: 45px;
  padding: 0 12px;
}

.field textarea {
  padding: 10px 12px;
  resize: vertical;
  min-height: 74px;
  line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted-2);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.field input[type="date"],
.field input[type="time"] {
  color-scheme: light;
}

[data-theme="dark"] .field input[type="date"],
[data-theme="dark"] .field input[type="time"] {
  color-scheme: dark;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.segmented button {
  flex: 1;
  height: 35px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 45, 38, 0.08), 0 4px 12px -8px rgba(20, 45, 38, 0.28);
}

.time-field {
  display: block;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.time-field legend {
  margin-bottom: 8px;
}

.time-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-row[hidden] {
  display: none !important;
}

.time-control {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  max-width: 270px;
  height: 45px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.time-control:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.time-control select {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 2px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
}

.time-control select:focus {
  outline: none;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.time-control .time-minute {
  flex: 1.1;
}

.time-control .time-period {
  flex: 0.9;
  max-width: 64px;
  color: var(--ink-2);
  font-weight: 600;
}

.time-colon {
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 600;
  flex: none;
}

.time-remove {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.time-remove:hover {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.time-remove .icon-slot {
  width: 14px;
  height: 14px;
}

.add-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}

.add-time:hover {
  color: var(--brand-deep);
}

.add-time .icon-slot {
  width: 14px;
  height: 14px;
}

.field-hint {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

#end-hint {
  margin-bottom: 4px;
}

.weekday-field {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.weekday-field legend {
  margin-bottom: 8px;
}

.weekday-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.weekday {
  display: grid;
  place-items: center;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.weekday:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.weekday[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

[data-theme="dark"] .weekday[aria-pressed="true"] {
  color: #082c26;
}

.form-error {
  margin: 0 24px 12px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
}

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 50%, var(--surface));
}

.dialog-foot .btn {
  height: 38px;
  font-size: 12.5px;
}

/* Reminder dialog */

.reminder-dialog {
  width: min(420px, calc(100vw - 28px));
  padding: 30px 30px 24px;
  overflow: visible;
  text-align: center;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--brand-soft), transparent 62%),
    var(--surface);
}

.reminder-dialog[open] {
  animation: reminder-in 0.36s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes reminder-in {
  from { opacity: 0; transform: scale(0.94) translateY(14px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.reminder-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 4px auto 18px;
}

.reminder-orb::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: linear-gradient(150deg, #178673, #0a4b41);
  box-shadow: 0 18px 30px -16px rgba(10, 75, 65, 0.7);
}

.reminder-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--brand-glow);
  border-radius: 50%;
  animation: orb-ring 3.2s ease-out infinite;
}

.reminder-ring-two {
  animation-delay: 1.6s;
}

@keyframes orb-ring {
  0% { transform: scale(0.8); opacity: 0; }
  25% { opacity: 0.8; }
  100% { transform: scale(1.45); opacity: 0; }
}

.reminder-pill {
  position: relative;
  z-index: 1;
  display: inline-flex;
  color: #fff;
}

.reminder-pill .icon-slot {
  width: 30px;
  height: 30px;
}

.reminder-dialog .dialog-kicker {
  color: var(--brand);
}

.reminder-dialog h2 {
  margin-top: 3px;
  font-family: var(--font-serif);
  font-size: 31px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.reminder-dose {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}

.reminder-time {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.reminder-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 22px;
}

.reminder-actions .text-btn {
  align-self: center;
  margin-top: 3px;
}

.reminder-hint {
  margin-top: 16px;
  color: var(--muted-2);
  font-size: 10.5px;
}

.reminder-close {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Confirm dialog */

.confirm-dialog {
  width: min(400px, calc(100vw - 30px));
  padding: 26px 26px 22px;
  text-align: center;
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 13px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-icon .icon-slot,
.confirm-icon svg {
  width: 21px;
  height: 21px;
}

.confirm-dialog h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.confirm-dialog p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 20px;
}

.confirm-actions .btn {
  height: 38px;
  font-size: 12.5px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: min(440px, calc(100vw - 28px));
  padding: 11px 14px;
  border-radius: 13px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: 0 20px 44px -18px rgba(8, 32, 27, 0.55);
  font-size: 12.5px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast-icon {
  display: inline-flex;
  flex: none;
  color: var(--brand-2);
}

.toast-icon .icon-slot {
  width: 17px;
  height: 17px;
}

.toast-message {
  min-width: 0;
}

.toast-action {
  flex: none;
  padding: 3px 2px;
  border: 0;
  background: none;
  color: var(--accent-2);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

[data-theme="dark"] .toast {
  background: #e8f2ec;
  color: #11241f;
}

[data-theme="dark"] .toast-action {
  color: #a9492f;
}

[data-theme="dark"] .toast-icon {
  color: #0f6b5c;
}

/* ---------- Responsive ---------- */

@media (max-width: 1060px) {
  .topbar-inner {
    gap: 14px;
  }

  .tab {
    padding: 7px 13px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    gap: 34px;
  }

  .add-btn {
    padding: 0 15px;
  }
}

@media (max-width: 900px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .tabs {
    order: 3;
    width: 100%;
    margin: 0;
  }

  .tab {
    flex: 1;
    justify-content: center;
    padding: 8px 12px;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-top: 44px;
  }

  .hero-copy {
    max-width: 680px;
  }

  .hero-panel {
    max-width: 680px;
  }

  .next-card {
    min-height: 238px;
  }

  .history-top {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 0 18px;
  }

  .topbar-inner {
    padding-left: 18px;
    padding-right: 18px;
  }

  .add-label {
    display: none;
  }

  .add-btn {
    width: 42px;
    padding: 0;
  }

  .add-btn .icon-slot {
    width: 19px;
    height: 19px;
  }

  .brand-word {
    font-size: 15.5px;
  }

  .hero {
    padding-top: 34px;
    padding-bottom: 36px;
  }

  .hero h1 {
    font-size: clamp(43px, 12vw, 58px);
  }

  .lede {
    margin-top: 20px;
    font-size: 14.5px;
  }

  .reminder-status {
    margin-top: 20px;
    font-size: 11.5px;
  }

  .mini-card {
    min-height: 120px;
    padding: 15px;
  }

  .mini-value {
    font-size: 22px;
  }

  .section-head {
    align-items: flex-start;
    margin-top: 28px;
  }

  .section-head .btn {
    flex: none;
    margin-top: 4px;
  }

  .section-sub {
    max-width: 320px;
  }

  .dose-row {
    grid-template-columns: 64px 20px minmax(0, 1fr);
    gap: 0 10px;
    padding: 18px 15px;
  }

  .time-main {
    font-size: 16.5px;
  }

  .dose-title h3 {
    font-size: 15px;
  }

  .dose-meta {
    white-space: normal;
  }

  .dose-actions {
    gap: 5px;
  }

  .mini-btn {
    height: 29px;
    padding: 0 9px;
    font-size: 10.5px;
  }

  .lookahead-day {
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 10px;
  }

  .lookahead-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .meds-grid {
    grid-template-columns: 1fr;
  }

  .chart-card {
    padding: 18px 14px 16px;
  }

  .chart {
    gap: 5px;
  }

  .chart-track {
    height: 92px;
  }

  .legend {
    gap: 8px;
  }

  .history-score {
    gap: 16px;
    padding: 19px;
  }

  .score-ring {
    width: 78px;
    height: 78px;
  }

  .score-ring strong {
    font-size: 18px;
  }

  .history-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .hstat {
    padding: 14px 11px;
  }

  .hstat strong {
    font-size: 21px;
  }

  .activity-head {
    padding: 15px 16px;
  }

  .activity-list {
    padding: 0 16px 6px;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }

  .time-control {
    max-width: none;
  }

  .dialog-head {
    padding: 18px 18px 10px;
  }

  .dialog .dialog-body {
    padding: 4px 18px 18px;
  }

  .form-error {
    margin: 0 18px 10px;
  }

  .dialog-foot {
    padding: 12px 18px;
  }

  .reminder-dialog {
    padding: 28px 22px 22px;
  }

  .footer-inner {
    padding: 28px 18px 34px;
  }
}

@media (max-width: 480px) {
  .brand-word {
    display: none;
  }

  .topbar-actions {
    gap: 4px;
  }

  .icon-btn {
    width: 35px;
    height: 35px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .eyebrow {
    font-size: 9.5px;
    letter-spacing: 0.1em;
    gap: 6px;
  }

  .section-head {
    flex-direction: column;
    gap: 10px;
  }

  .section-head .btn {
    margin-top: 0;
  }

  .mini-grid {
    gap: 8px;
  }

  .install-banner {
    display: grid;
    grid-template-columns: 39px minmax(0, 1fr) 32px;
    gap: 10px;
    align-items: center;
  }

  .install-icon {
    grid-column: 1;
    grid-row: 1;
  }

  .install-copy {
    grid-column: 2;
    grid-row: 1;
  }

  .install-dismiss {
    grid-column: 3;
    grid-row: 1;
  }

  .install-action {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 2px;
  }

  .mini-card {
    padding: 13px;
    min-height: 110px;
  }

  .mini-sub {
    font-size: 10.5px;
  }

  .next-card {
    padding: 22px;
    min-height: 225px;
  }

  .next-card h2 {
    font-size: 25px;
  }

  .next-bottom {
    gap: 10px;
  }

  .next-countdown {
    font-size: 23px;
  }

  .next-cta {
    height: 34px;
    padding: 0 11px;
    font-size: 11px;
  }

  .next-cta .icon-slot {
    width: 13px;
    height: 13px;
  }

  .dose-row {
    grid-template-columns: 56px 14px minmax(0, 1fr);
    gap: 0 8px;
    padding: 16px 12px;
  }

  .time-main {
    font-size: 15px;
  }

  .dose-dot {
    width: 9px;
    height: 9px;
  }

  .dose-title {
    gap: 6px;
  }

  .dose-title h3 {
    font-size: 14.5px;
  }

  .chip {
    font-size: 8.5px;
    padding: 3px 6px;
  }

  .dose-meta,
  .dose-status {
    font-size: 11px;
  }

  .dose-actions {
    margin-top: 9px;
  }

  .mini-btn {
    height: 28px;
    padding: 0 8px;
    font-size: 10px;
  }

  .empty-state {
    padding: 36px 18px;
  }

  .empty-actions .btn {
    width: 100%;
  }

  .score-copy h3 {
    font-size: 19px;
  }

  .score-totals {
    gap: 12px;
  }

  .filters {
    width: 100%;
    justify-content: space-between;
  }

  .filter-btn {
    flex: 1;
    padding: 0 6px;
  }

  .activity-item {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .activity-item .chip {
    display: none;
  }
}

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