@import url("/fonts.css");

/*
  PillCheck design system.
  Modelled on the patterns shared by the best-rated medication and habit apps
  (Apple Health Medications, Medisafe, MyTherapy, Streaks, Duolingo):
  grouped grey canvas with white rounded cards, large titles, time-grouped
  dose lists with round check circles, colored pill icons, a bottom tab bar
  with a prominent scan action, and tactile buttons with a raised bottom edge.
  Colors follow iOS semantic colors so light and dark both feel native.
*/
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f7f7fa;
  --fill: #e9e9ef;
  --fill-2: #dedee6;
  --line: #e3e3e8;
  --text: #111114;
  --text-2: #5b5b66;
  --text-3: #8e8e96;
  --accent: #0a6cff;
  --accent-dark: #0052cc;
  --accent-soft: #e6f0ff;
  --accent-on: #ffffff;
  --green: #1f9d4c;
  --green-dark: #167a3a;
  --green-soft: #e3f6e9;
  --orange: #c2610c;
  --orange-soft: #fff1e0;
  --red: #d92d20;
  --red-soft: #fdecea;
  --sheet-shadow: 0 -10px 40px rgb(0 0 0 / 0.12);
  --card-shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 1px 3px rgb(16 24 40 / 0.06);
  --bar: rgb(249 249 252 / 0.86);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "DM Sans", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "DM Sans", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #232326;
    --fill: #2c2c2e;
    --fill-2: #3a3a3c;
    --line: #2f2f33;
    --text: #f5f5f7;
    --text-2: #aeaeb5;
    --text-3: #7c7c84;
    --accent: #3d8bff;
    --accent-dark: #1f63cc;
    --accent-soft: #10264a;
    --green: #30d158;
    --green-dark: #1f9d42;
    --green-soft: #0f2e18;
    --orange: #ff9f0a;
    --orange-soft: #33230a;
    --red: #ff453a;
    --red-soft: #3a1513;
    --card-shadow: none;
    --sheet-shadow: 0 -10px 40px rgb(0 0 0 / 0.6);
    --bar: rgb(22 22 24 / 0.86);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #232326;
  --fill: #2c2c2e;
  --fill-2: #3a3a3c;
  --line: #2f2f33;
  --text: #f5f5f7;
  --text-2: #aeaeb5;
  --text-3: #7c7c84;
  --accent: #3d8bff;
  --accent-dark: #1f63cc;
  --accent-soft: #10264a;
  --green: #30d158;
  --green-dark: #1f9d42;
  --green-soft: #0f2e18;
  --orange: #ff9f0a;
  --orange-soft: #33230a;
  --red: #ff453a;
  --red-soft: #3a1513;
  --card-shadow: none;
  --sheet-shadow: 0 -10px 40px rgb(0 0 0 / 0.6);
  --bar: rgb(22 22 24 / 0.86);
  color-scheme: dark;
}

/* ---------- Base ---------- */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
html.large-text {
  font-size: 19px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
label,
input,
select {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
svg {
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 999;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-on);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus {
  top: 12px;
}
.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}
.small {
  font-size: 0.875rem;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
}

/* ---------- App shell ---------- */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  display: none;
}
.main {
  flex: 1;
  min-width: 0;
}
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px calc(112px + env(safe-area-inset-bottom));
  animation: enter 0.25s ease both;
}
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 14px;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 2.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.topbar .sub {
  color: var(--text-2);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  color: var(--accent);
  font-weight: 600;
  margin: 6px 0 -8px -4px;
}
.round-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--card-shadow);
}
.round-btn svg {
  width: 22px;
  height: 22px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7aa7ff, #0a6cff);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.avatar.sm {
  width: 34px;
  height: 34px;
  font-size: 0.8rem;
}

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--bar);
  border-top: 0.5px solid var(--line);
  backdrop-filter: saturate(1.8) blur(20px);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
}
.tabbar button {
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 52px;
  padding-top: 4px;
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 600;
}
.tabbar button svg {
  width: 26px;
  height: 26px;
}
.tabbar button.active {
  color: var(--accent);
}
.tabbar .scan-tab svg {
  width: 60px;
  height: 60px;
  padding: 16px;
  margin-top: -26px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--accent-dark), 0 10px 22px -6px rgb(10 108 255 / 0.55);
}
.tabbar .scan-tab {
  color: var(--text);
}

/* Desktop sidebar (iPad / Mac app style) */
@media (min-width: 900px) {
  .tabbar {
    display: none;
  }
  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 260px;
    height: 100vh;
    padding: 22px 14px;
    background: var(--card);
    border-right: 0.5px solid var(--line);
  }
  .page {
    padding: 20px 32px 64px;
  }
  .topbar h1 {
    font-size: 2.4rem;
  }
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  text-align: left;
}
.side-link svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}
.side-link:hover {
  background: var(--fill);
}
.side-link.active {
  background: var(--accent);
  color: #fff;
}
.side-link.active svg {
  color: #fff;
}
.side-scan {
  margin: 10px 0;
}
.side-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: var(--fill);
  text-align: left;
  width: 100%;
}
.profile-chip b {
  display: block;
  font-size: 0.95rem;
}
.profile-chip small {
  color: var(--text-2);
}

/* ---------- Buttons (tactile, Duolingo-style raised edge) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  background: var(--card);
  color: var(--accent);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 var(--line);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 transparent;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--accent-dark);
}
.btn.success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 4px 0 var(--green-dark);
}
.btn.danger {
  color: var(--red);
}
.btn.block {
  width: 100%;
}
.btn.sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.9rem;
  border-radius: 12px;
}
.link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}
.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Cards, sections, grouped lists ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 18px;
}
.section {
  margin-top: 26px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 4px 8px;
}
.section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-head h2 svg {
  color: var(--orange);
}
.caption {
  margin: 8px 6px 0;
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.45;
}
.list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  text-align: left;
  position: relative;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 68px;
  border-top: 0.5px solid var(--line);
}
.row.plain + .row.plain::before {
  left: 16px;
}
button.row:hover,
label.row:hover {
  background: var(--card-2);
}
.row .grow {
  flex: 1;
  min-width: 0;
}
.row-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}
.row-sub {
  color: var(--text-2);
  font-size: 0.9rem;
}
.chev {
  color: var(--text-3);
}
.row-value {
  color: var(--text-2);
  font-size: 0.95rem;
}
.ico-tile {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #fff;
  flex-shrink: 0;
}
.ico-tile svg {
  width: 21px;
  height: 21px;
}
.t-blue {
  background: #0a84ff;
}
.t-green {
  background: #30b158;
}
.t-orange {
  background: #ff9500;
}
.t-red {
  background: #ff3b30;
}
.t-purple {
  background: #8e5cf6;
}
.t-gray {
  background: #8e8e93;
}
.t-teal {
  background: #12a4b8;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.tag.green {
  background: var(--green-soft);
  color: var(--green);
}
.tag.orange {
  background: var(--orange-soft);
  color: var(--orange);
}
.tag.red {
  background: var(--red-soft);
  color: var(--red);
}
.tag.blue {
  background: var(--accent-soft);
  color: var(--accent);
}
.tag svg {
  width: 13px;
  height: 13px;
}
.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--card-shadow);
}
.notice .ico-tile {
  width: 32px;
  height: 32px;
}
.notice b {
  display: block;
}
.notice p {
  color: var(--text-2);
  font-size: 0.92rem;
}
.notice.orange {
  background: var(--orange-soft);
}
.notice.blue {
  background: var(--accent-soft);
}

/* ---------- Pill icons (Apple Health style) ---------- */
.pill-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  flex-shrink: 0;
}
.pill-ico svg {
  width: 30px;
  height: 30px;
}
.pill-ico.lg {
  width: 56px;
  height: 56px;
}
.pill-ico.lg svg {
  width: 38px;
  height: 38px;
}
.pill-stack {
  display: flex;
}
.pill-stack .pill-ico {
  width: 34px;
  height: 34px;
  border: 2px solid var(--card);
  margin-left: -10px;
}
.pill-stack .pill-ico:first-child {
  margin-left: 0;
}
.pill-stack .pill-ico svg {
  width: 22px;
  height: 22px;
}

/* ---------- Today ---------- */
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 10px 6px;
}
.day {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 6px 0;
  border-radius: 14px;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.day .ring {
  width: 38px;
  height: 38px;
}
.day .num {
  font-size: 0.95rem;
  color: var(--text);
  text-transform: none;
}
.day.selected {
  background: var(--accent-soft);
  color: var(--accent);
}
.day.today .num {
  color: var(--accent);
}
.day.future {
  opacity: 0.5;
}
.ring-wrap {
  position: relative;
  display: grid;
  place-items: center;
}
.ring-wrap .ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.summary {
  display: flex;
  align-items: center;
  gap: 18px;
}
.summary .ring {
  width: 92px;
  height: 92px;
}
.summary .ring-label {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.summary h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.summary p {
  color: var(--text-2);
  font-size: 0.95rem;
  margin: 2px 0 12px;
}
.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--orange);
  font-weight: 800;
  font-size: 0.9rem;
}
.dose-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 4px 8px;
}
.dose-group-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
}
.slot-sun {
  color: #ff9500;
}
.slot-moon {
  color: #5e5ce6;
}
.check-circle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2.5px solid var(--fill-2);
  color: transparent;
  flex-shrink: 0;
}
.check-circle.done {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.check-circle svg {
  width: 20px;
  height: 20px;
  stroke-width: 3;
}
.taken-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
  font-size: 0.9rem;
}
.slot-cta {
  padding: 12px 16px 16px;
}

/* ---------- Welcome (onboarding) ---------- */
.welcome {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
}
.welcome-inner {
  width: 100%;
  max-width: 460px;
  display: grid;
  gap: 26px;
}
.welcome-hero {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 12px;
}
.welcome-hero img {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  box-shadow: 0 14px 30px -10px rgb(10 108 255 / 0.55);
}
.welcome-hero h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.welcome-hero p {
  color: var(--text-2);
  font-size: 1.05rem;
}
.feature {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.feature .ico-tile {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}
.feature .ico-tile svg {
  width: 26px;
  height: 26px;
}
.feature b {
  display: block;
  font-size: 1.02rem;
}
.feature p {
  color: var(--text-2);
  font-size: 0.95rem;
}
.welcome-actions {
  display: grid;
  gap: 12px;
}
.fine {
  text-align: center;
  color: var(--text-3);
  font-size: 0.8rem;
}

/* ---------- Scan ---------- */
.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--fill);
}
.segmented button {
  flex: 1;
  min-height: 38px;
  border-radius: 9px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
}
.segmented button[aria-pressed="true"] {
  background: var(--card);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.14);
}
.viewfinder {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #2a2d36, #121318);
  color: #fff;
  text-align: center;
}
.viewfinder img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.viewfinder.camera-live {
  background: #000;
}
.camera-live video,
.camera-live #camera-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.camera-live video {
  background: #000;
}
.camera-live #camera-overlay {
  pointer-events: none;
}
.camera-status {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  max-width: calc(100% - 28px);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.72);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 650;
}
.camera-mode {
  margin-top: 14px;
}
.viewfinder .corners {
  position: absolute;
  inset: 22px;
  pointer-events: none;
  background:
    linear-gradient(#fff, #fff) top left / 34px 4px,
    linear-gradient(#fff, #fff) top left / 4px 34px,
    linear-gradient(#fff, #fff) top right / 34px 4px,
    linear-gradient(#fff, #fff) top right / 4px 34px,
    linear-gradient(#fff, #fff) bottom left / 34px 4px,
    linear-gradient(#fff, #fff) bottom left / 4px 34px,
    linear-gradient(#fff, #fff) bottom right / 34px 4px,
    linear-gradient(#fff, #fff) bottom right / 4px 34px;
  background-repeat: no-repeat;
  border-radius: 6px;
  opacity: 0.9;
}
.viewfinder .hint {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 20px;
}
.viewfinder .hint svg {
  width: 44px;
  height: 44px;
  opacity: 0.9;
}
.viewfinder .hint b {
  font-size: 1.1rem;
}
.viewfinder .hint span {
  font-size: 0.9rem;
  opacity: 0.75;
}
.viewfinder.busy::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  height: 3px;
  border-radius: 3px;
  background: #4da3ff;
  box-shadow: 0 0 18px 4px rgb(77 163 255 / 0.7);
  animation: sweep 1.4s ease-in-out infinite alternate;
}
@keyframes sweep {
  from {
    top: 26px;
  }
  to {
    top: calc(100% - 28px);
  }
}
.shutter-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.shutter {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 5px solid var(--card);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent), 0 10px 24px -8px rgb(10 108 255 / 0.6);
  cursor: pointer;
}
.shutter svg {
  width: 32px;
  height: 32px;
}
.shutter:active {
  transform: scale(0.95);
}
.side-action {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
.side-action span.ico {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--card-shadow);
}
.steps {
  display: grid;
  gap: 2px;
}
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-3);
  font-weight: 600;
}
.step .dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2.5px solid var(--fill-2);
  flex-shrink: 0;
}
.step .dot svg {
  width: 15px;
  height: 15px;
  stroke-width: 3;
}
.step.done {
  color: var(--text);
}
.step.done .dot {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.step.now {
  color: var(--text);
}
.step.now .dot {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.result {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
  padding: 26px 20px 20px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  animation: enter 0.3s ease both;
}
.result .big-ico {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.result .big-ico svg {
  width: 38px;
  height: 38px;
  stroke-width: 2.4;
}
.result h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.result p {
  color: var(--text-2);
  max-width: 440px;
}
.result .actions {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
}
.result.good .big-ico {
  background: var(--green);
  color: #fff;
}
.result.warn .big-ico {
  background: var(--orange-soft);
  color: var(--orange);
}
.result.bad .big-ico {
  background: var(--red-soft);
  color: var(--red);
}
.found-thumb {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  background: #000;
  flex-shrink: 0;
}
details.found summary {
  list-style: none;
  cursor: pointer;
}
details.found summary::-webkit-details-marker {
  display: none;
}
details.found[open] .chev {
  transform: rotate(90deg);
}
.alt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 82px;
}
.ref-tile {
  display: block;
  width: 160px;
  height: 80px;
  border-radius: 10px;
  background-color: #000;
  flex-shrink: 0;
  zoom: 0.55;
}
.ref-tile.full {
  zoom: 1;
}
.meter {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: var(--fill);
  overflow: hidden;
  margin-top: 5px;
  max-width: 180px;
}
.meter i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}
.ai-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Stats (Streaks style) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  padding: 16px 14px;
  text-align: center;
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.stat span {
  display: block;
  color: var(--text-3);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 150px;
}
.bar {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 6px;
  height: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
}
.bar .track {
  width: 100%;
  max-width: 34px;
  height: 100%;
  border-radius: 9px;
  background: var(--fill);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.bar .fill {
  width: 100%;
  border-radius: 9px;
  background: var(--green);
}

/* ---------- Organizer ---------- */
.org {
  overflow-x: auto;
}
.org-grid {
  display: grid;
  grid-template-columns: 84px repeat(7, minmax(70px, 1fr));
  gap: 6px;
  min-width: 620px;
}
.org-label {
  align-self: center;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-2);
  text-transform: uppercase;
}
.org-cell {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: center;
  min-height: 84px;
  padding: 8px 2px;
  border-radius: 14px;
  background: var(--card-2);
  border: 2px solid var(--line);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-2);
}
.org-cell.checked {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}
.org-cell.concern {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}
.org-cell.empty {
  opacity: 0.45;
}
.org-cell .pill-stack .pill-ico {
  width: 24px;
  height: 24px;
  margin-left: -8px;
}
.org-cell .pill-stack .pill-ico:first-child {
  margin-left: 0;
}
.org-cell .pill-stack svg {
  width: 16px;
  height: 16px;
}

/* ---------- Forms ---------- */
input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card-2);
  font-size: 1rem;
  font-weight: 400;
}
textarea {
  min-height: 84px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
}
input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 0;
  accent-color: var(--accent);
}
input[type="file"] {
  display: none;
}
.search {
  position: relative;
}
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
}
.search input {
  padding-left: 40px;
  background: var(--fill);
  border-color: transparent;
  min-height: 44px;
}
.field-group {
  display: grid;
  gap: 6px;
  font-weight: 650;
  font-size: 0.92rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.full {
  grid-column: 1 / -1;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font-weight: 650;
  cursor: pointer;
}
.checks label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 51px !important;
  height: 31px !important;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 99px;
  background: var(--fill-2);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.25);
  transition: transform 0.2s;
}
.switch:checked {
  background: #34c759;
}
.switch:checked::after {
  transform: translateX(20px);
}
.error {
  color: var(--red);
  font-weight: 600;
  min-height: 1em;
  margin-top: 10px;
}
.row select {
  width: auto;
  min-height: 40px;
  padding: 6px 10px;
  background: var(--fill);
  border: 0;
}

/* ---------- Sheets (dialogs) ---------- */
dialog {
  width: min(560px, 100vw);
  max-width: 100vw;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--sheet-shadow);
}
dialog::before {
  content: "";
  display: block;
  width: 38px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 99px;
  background: var(--fill-2);
}
dialog[open] {
  animation: sheet 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes sheet {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}
@media (min-width: 700px) {
  dialog {
    margin: auto;
    border-radius: 22px;
    padding-bottom: 22px;
  }
  dialog::before {
    display: none;
  }
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}
.dialog-head h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 99px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 1.2rem;
  line-height: 1;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.lookup-results {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
}
.lookup-result {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card);
  text-align: left;
}
.lookup-result:hover {
  outline: 2px solid var(--accent);
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}
.note {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text-2);
  font-size: 0.92rem;
}
.note.amber {
  background: var(--orange-soft);
  color: var(--orange);
}
.note strong {
  display: block;
  color: var(--text);
}

/* ---------- Toast, misc ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 300;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: rgb(30 30 34 / 0.94);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (min-width: 900px) {
  #toast {
    bottom: 28px;
    left: calc(50% + 130px);
  }
}
.footer {
  margin: 34px 6px 0;
  color: var(--text-3);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.metric {
  padding: 16px;
}
.metric b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.metric span {
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 600;
}
.metric small {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-weight: 800;
  font-size: 0.78rem;
}
.report-only {
  display: none;
}
@media (max-width: 560px) {
  .form-grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .stat b {
    font-size: 1.6rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
@media print {
  body > *:not(#print-report) {
    display: none !important;
  }
  #print-report {
    display: block !important;
    color: #000;
    font-family: system-ui, sans-serif;
  }
  #print-report table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0 20px;
  }
  #print-report th,
  #print-report td {
    border: 1px solid #999;
    padding: 6px;
    text-align: left;
    font-size: 12px;
  }
}

/* ---------- Content used inside sheets ---------- */
.stack {
  display: grid;
  gap: 10px;
}
.section-gap {
  margin-top: 16px;
}
.dose-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
}
.dose-row h3 {
  font-size: 1rem;
}
.dose-desc {
  color: var(--text-2);
  font-size: 0.9rem;
}
.pill-wrap {
  display: contents;
}
