/* ------------------------------------------------------------------ *
   Heartline — design system
   ------------------------------------------------------------------ */

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

:root {
  --font-ui: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;

  --bg: #f4f1e9;
  --bg-deep: #ebe5d9;
  --surface: #fffdf8;
  --surface-2: #faf7f0;
  --surface-3: #f2ece0;
  --ink: #1c2a30;
  --ink-2: #405158;
  --muted: #79868b;
  --line: #e5ded1;
  --line-strong: #d7cebe;

  --coral: #cf5b4e;
  --coral-dark: #b2473c;
  --coral-soft: #f8e5e0;
  --teal: #2f7f79;
  --teal-dark: #22625e;
  --teal-soft: #e2f1ee;
  --amber: #a97520;
  --amber-soft: #f8ecd5;
  --blue: #466f8e;
  --blue-soft: #e6eef5;
  --green: #4d7858;
  --green-soft: #e7f0e7;
  --red: #b33a32;
  --red-soft: #f8e3e0;

  --shadow-sm: 0 1px 2px rgba(28, 42, 48, 0.05);
  --shadow: 0 1px 2px rgba(28, 42, 48, 0.04), 0 14px 36px rgba(28, 42, 48, 0.06);
  --shadow-lg: 0 24px 70px rgba(20, 30, 34, 0.18);

  --radius: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #10171a;
  --bg-deep: #0c1214;
  --surface: #192226;
  --surface-2: #202b30;
  --surface-3: #263238;
  --ink: #edf3f2;
  --ink-2: #c6d2d0;
  --muted: #92a2a1;
  --line: #2b393e;
  --line-strong: #3a4b50;

  --coral: #e37b6e;
  --coral-dark: #f09487;
  --coral-soft: #3a2624;
  --teal: #62b6b0;
  --teal-dark: #83cbc6;
  --teal-soft: #1d3332;
  --amber: #e0ad5d;
  --amber-soft: #392e1d;
  --blue: #82aac9;
  --blue-soft: #1d2b36;
  --green: #83b491;
  --green-soft: #1e3024;
  --red: #ef877e;
  --red-soft: #3a2322;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 16px 40px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 10% -10%, rgba(207, 91, 78, 0.075), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, rgba(47, 127, 121, 0.06), transparent 58%),
    var(--bg);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

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

svg {
  display: block;
}

::selection {
  background: var(--coral-soft);
  color: var(--coral-dark);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--coral) 45%, transparent);
  outline-offset: 2px;
}

.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;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 500;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 14px;
}

/* ------------------------------------------------------------------ *
   Boot + app frame
   ------------------------------------------------------------------ */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.boot-card {
  width: 100%;
  max-width: 440px;
  padding: 38px 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.boot-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--coral);
  color: #fffaf3;
  box-shadow: 0 14px 30px rgba(207, 91, 78, 0.25);
  animation: bootPulse 1.8s ease-in-out infinite;
}

.boot-mark svg {
  width: 34px;
  height: 34px;
}

.boot p {
  font-size: 13px;
  letter-spacing: 0.02em;
  margin: 0;
}

@keyframes bootPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.04);
    opacity: 0.85;
  }
}

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

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 13px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--coral);
  color: #fffaf3;
  box-shadow: 0 8px 18px rgba(207, 91, 78, 0.22);
}

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

.brand-word {
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 15px;
  height: 15px;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-link.active {
  color: var(--coral-dark);
  background: var(--coral-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

.sync.saving .sync-dot {
  background: var(--amber);
  animation: blink 1s ease-in-out infinite;
}

.sync.offline .sync-dot {
  background: var(--coral);
}

.sync.error .sync-dot {
  background: var(--red);
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 28px 90px;
}

.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 34px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.offline-banner {
  max-width: 1124px;
  margin: 16px auto 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
}

.offline-banner svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ *
   Shared type + controls
   ------------------------------------------------------------------ */

.eyebrow {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.view-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 500;
  color: var(--ink);
}

.view-sub {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 60ch;
}

.head-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

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

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

.btn-primary {
  background: var(--coral);
  color: #fffaf3;
  box-shadow: 0 8px 18px rgba(207, 91, 78, 0.22);
}

.btn-primary:hover {
  background: var(--coral-dark);
}

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

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

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

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

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 22%, transparent);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 11.5px;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 14px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

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

.btn-block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

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

.today-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 26px;
  margin: 4px 0 26px;
}

.today-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(31px, 4vw, 43px);
  line-height: 1.06;
  letter-spacing: -0.03em;
  font-weight: 500;
}

.hero-sub {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.completion-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9px 18px 9px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

.completion-ring {
  position: relative;
  width: 52px;
  height: 52px;
}

.completion-ring svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

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

.completion-ring .ring-fill {
  fill: none;
  stroke: var(--coral);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.completion-ring span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 750;
  color: var(--ink);
}

.completion-copy strong {
  display: block;
  font-size: 12.5px;
  line-height: 1.2;
}

.completion-copy span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.today-grid > div {
  min-width: 0;
}

.span-7 {
  grid-column: span 7;
}

.span-6 {
  grid-column: span 6;
}

.span-5 {
  grid-column: span 5;
}

.span-12 {
  grid-column: span 12;
}

.card {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 23px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.card-title > div {
  min-width: 0;
}

.card-title h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 750;
  letter-spacing: 0.005em;
}

.card-title p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
}

.card-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.card-icon svg {
  width: 18px;
  height: 18px;
}

.card-icon.coral {
  background: var(--coral-soft);
  color: var(--coral);
}

.card-icon.teal {
  background: var(--teal-soft);
  color: var(--teal);
}

.card-icon.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.card-icon.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.card-icon.green {
  background: var(--green-soft);
  color: var(--green);
}

.card-icon.ink {
  background: var(--surface-3);
  color: var(--ink-2);
}

.card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.card-foot svg {
  width: 13px;
  height: 13px;
}

.metric-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.metric-big {
  font-size: 46px;
  line-height: 0.95;
  font-weight: 680;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.metric-unit {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.delta svg {
  width: 11px;
  height: 11px;
}

.delta.up {
  background: var(--amber-soft);
  color: var(--amber);
}

.delta.down {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.delta.flat {
  background: var(--surface-2);
  color: var(--muted);
}

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

.weight-side {
  text-align: right;
  flex: 0 0 auto;
}

.weight-side .label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 3px;
}

.weight-side strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.spark {
  height: 58px;
  margin: 10px -4px 0;
}

.spark svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.weight-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0 2px;
}

.weight-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 38ch;
}

/* BP */

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

.bp-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 13px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bp-row:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.bp-slot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 82px;
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
}

.bp-slot svg {
  width: 14px;
  height: 14px;
}

.bp-reading {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.bp-reading strong {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.bp-reading .bp-pulse {
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.bp-reading .bp-pulse svg {
  width: 11px;
  height: 11px;
}

.bp-placeholder {
  font-size: 12px;
  color: var(--muted);
}

.status-pill {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 7px;
  border-radius: 999px;
}

.status-pill.ok {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.high {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.low {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill.danger {
  background: var(--red-soft);
  color: var(--red);
}

.bp-target {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.bp-add {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--coral);
  white-space: nowrap;
}

.bp-add svg {
  width: 11px;
  height: 11px;
}

/* Fluid */

.fluid-layout {
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  align-items: center;
  gap: 22px;
}

.fluid-ring {
  position: relative;
  width: 172px;
  height: 172px;
  margin: 0 auto;
}

.fluid-ring svg {
  width: 172px;
  height: 172px;
  transform: rotate(-90deg);
}

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

.fluid-ring .ring-target {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 2;
  stroke-dasharray: 2 5;
}

.fluid-ring .ring-fill {
  fill: none;
  stroke: var(--teal);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke 0.25s ease, stroke-dasharray 0.5s ease;
}

.fluid-ring.over-target .ring-fill {
  stroke: var(--amber);
}

.fluid-ring.over-leeway .ring-fill {
  stroke: var(--coral);
}

.fluid-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 2px;
}

.fluid-center strong {
  font-size: 27px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.fluid-center span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 3px;
}

.fluid-center em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  margin-top: 5px;
}

.fluid-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 9px 11px;
  border-radius: 13px;
  border: 1px solid transparent;
  background: var(--teal-soft);
  color: var(--teal-dark);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.quick-btn:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}

.quick-btn:active {
  transform: scale(0.98);
}

.quick-btn strong {
  font-size: 14px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.quick-btn small {
  font-size: 9.5px;
  color: color-mix(in srgb, var(--teal-dark) 72%, var(--muted));
  letter-spacing: 0.02em;
}

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

.quick-btn.custom small {
  color: var(--muted);
}

.fluid-status {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.fluid-status.warn {
  color: var(--amber);
}

.fluid-status.danger {
  color: var(--coral);
}

.fluid-log {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
  align-items: center;
}

.fluid-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.fluid-chip button {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.fluid-chip button:hover {
  background: var(--red-soft);
  color: var(--red);
}

.fluid-chip svg {
  width: 9px;
  height: 9px;
}

.undo-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  padding: 3px 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.undo-link:hover {
  color: var(--coral);
}

/* Symptoms */

.symptom-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.symptom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--surface-2);
}

.symptom-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.sev-pill {
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.sev-1 {
  background: color-mix(in srgb, var(--amber-soft) 80%, var(--surface));
  color: var(--amber);
}

.sev-2 {
  background: color-mix(in srgb, var(--coral-soft) 70%, var(--amber-soft));
  color: color-mix(in srgb, var(--coral) 65%, var(--amber));
}

.sev-3 {
  background: var(--red-soft);
  color: var(--red);
}

.symptom-none {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 13px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12.5px;
  font-weight: 650;
}

.symptom-none svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.symptom-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.symptom-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Sleep */

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

.sleep-big {
  font-size: 36px;
  line-height: 1;
  font-weight: 680;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.sleep-big span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
  margin-left: 4px;
}

.sleep-times {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.meta-pill svg {
  width: 11px;
  height: 11px;
}

.meta-pill.wake {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: transparent;
}

.meta-pill.med {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: transparent;
}

.quality-dots {
  display: inline-flex;
  gap: 3px;
}

.quality-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}

.quality-dots i.on {
  background: var(--amber);
}

/* Activity */

.activity-total {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.activity-total strong {
  font-size: 34px;
  line-height: 1;
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.activity-total span {
  font-size: 11px;
  color: var(--muted);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface-2);
}

.activity-type-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

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

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

.activity-copy strong {
  display: block;
  font-size: 12px;
  line-height: 1.3;
}

.activity-copy span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 1px;
}

.activity-mins {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.worse-chip {
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber);
  background: var(--amber-soft);
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

/* Empty states */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 6px 6px;
}

.empty-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  margin-bottom: 9px;
}

.empty-icon svg {
  width: 19px;
  height: 19px;
}

.empty p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  max-width: 30ch;
}

/* Notices */

.notice {
  display: flex;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 13px;
  font-size: 11.5px;
  line-height: 1.45;
  margin-top: 13px;
}

.notice svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.notice strong {
  font-weight: 750;
}

.notice-amber {
  background: var(--amber-soft);
  color: color-mix(in srgb, var(--amber) 82%, var(--ink));
}

.notice-red {
  background: var(--red-soft);
  color: var(--red);
}

.notice-green {
  background: var(--green-soft);
  color: var(--green);
}

.notice a {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.welcome {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(120deg, var(--surface), var(--coral-soft));
  border: 1px solid color-mix(in srgb, var(--coral) 16%, var(--line));
  margin-bottom: 20px;
}

.welcome-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--coral);
  color: #fffaf3;
  flex: 0 0 auto;
}

.welcome-icon svg {
  width: 18px;
  height: 18px;
}

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

.welcome-copy strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.welcome-copy p {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

.welcome-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px;
  flex: 0 0 auto;
}

.welcome-close svg {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------------ *
   Trends
   ------------------------------------------------------------------ */

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

.range-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.range-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  min-width: 0;
}

.stat-value {
  font-size: 21px;
  line-height: 1.15;
  font-weight: 680;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-value small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
}

.stat-label {
  margin-top: 3px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.chart-card {
  min-width: 0;
}

.chart-card.full {
  grid-column: 1 / -1;
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 210px;
}

.sleep-wake-chart {
  min-height: 108px;
}

.sleep-wake-chart svg {
  height: 108px;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 10px;
  font-size: 10.5px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.legend-line {
  width: 14px;
  height: 0;
  border-top: 2px dashed var(--line-strong);
}

.chart-tip {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 10.5px;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s ease;
  white-space: nowrap;
}

.chart-tip.show {
  opacity: 1;
}

.chart-tip strong {
  display: block;
  font-size: 10px;
  font-weight: 650;
  opacity: 0.7;
  margin-bottom: 2px;
}

.chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

.chart-tip .tip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.chart-data {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.chart-data summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  list-style: none;
}

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

.chart-data summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 5px;
  transition: transform 0.15s ease;
}

.chart-data[open] summary::before {
  transform: rotate(90deg);
}

.chart-data table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.chart-data th,
.chart-data td {
  padding: 4px 5px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.chart-data th {
  color: var(--muted);
  font-weight: 650;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 9.5px;
  color: var(--muted);
}

.heatmap-legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}

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

.history-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.month-head {
  margin: 20px 0 4px 4px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.month-head:first-child {
  margin-top: 4px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.history-row:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.history-date {
  flex: 0 0 auto;
  min-width: 54px;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.history-date strong {
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.history-date span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.history-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip svg {
  width: 10px;
  height: 10px;
}

.chip.coral {
  background: var(--coral-soft);
  color: var(--coral-dark);
  border-color: transparent;
}

.chip.teal {
  background: var(--teal-soft);
  color: var(--teal-dark);
  border-color: transparent;
}

.chip.amber {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: transparent;
}

.chip.red {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}

.chip.green {
  background: var(--green-soft);
  color: var(--green);
  border-color: transparent;
}

.chip.blue {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: transparent;
}

.history-chev {
  flex: 0 0 auto;
  color: var(--muted);
}

.history-chev svg {
  width: 15px;
  height: 15px;
}

/* ------------------------------------------------------------------ *
   Clinic report
   ------------------------------------------------------------------ */

.clinic-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.report-period {
  max-width: 900px;
  margin: 0 auto 20px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.period-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.period-label {
  min-width: 82px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.period-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.period-date .input {
  width: 145px;
  padding: 8px 10px;
  font-size: 12px;
}

.period-visit-row {
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.period-hint {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.report {
  max-width: 900px;
  margin: 0 auto;
  padding: 42px 44px;
  background: #fffdf9;
  color: #1c2a30;
  border: 1px solid #e5ded1;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid #1c2a30;
}

.report-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.report-brand svg {
  width: 21px;
  height: 21px;
  color: #cf5b4e;
}

.report-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.025em;
  font-weight: 500;
}

.report-sub {
  margin: 5px 0 0;
  font-size: 12px;
  color: #5d6b71;
}

.report-meta {
  text-align: right;
  font-size: 11px;
  line-height: 1.6;
  color: #5d6b71;
  flex: 0 0 auto;
}

.report-meta strong {
  display: block;
  color: #1c2a30;
  font-size: 12px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 20px 0 4px;
}

.report-stat {
  padding: 10px 11px;
  border-radius: 11px;
  background: #f5f1e9;
}

.report-stat span {
  display: block;
  font-size: 8.5px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d7a7f;
  margin-bottom: 3px;
}

.report-stat strong {
  display: block;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.report-stat small {
  display: block;
  margin-top: 2px;
  font-size: 9.5px;
  color: #6d7a7f;
  font-weight: 500;
}

.report-section {
  margin-top: 24px;
  break-inside: avoid;
}

.report-section h3 {
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid #ddd5c7;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #405158;
}

.report-section p {
  margin: 0 0 7px;
  font-size: 11.5px;
  line-height: 1.55;
  color: #405158;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.report-table th,
.report-table td {
  padding: 5px 6px;
  text-align: left;
  border-bottom: 1px solid #e9e2d6;
  vertical-align: top;
}

.report-table th {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6d7a7f;
  font-weight: 750;
}

.report-table td.num {
  white-space: nowrap;
}

.report-table .muted-cell {
  color: #879398;
}

.report-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
}

.report-note {
  margin-top: 26px;
  padding-top: 11px;
  border-top: 1px solid #e0d8ca;
  font-size: 9px;
  line-height: 1.5;
  color: #718086;
}

.report-questions {
  margin: 0;
  padding: 0 0 0 17px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #405158;
}

.report-questions li {
  margin-bottom: 3px;
}

.report-questions li.done {
  text-decoration: line-through;
  color: #879398;
}

.report-empty {
  color: #879398;
  font-style: italic;
  font-size: 11px;
}

/* Questions editor */

.questions-card {
  max-width: 900px;
  margin: 20px auto 0;
}

.question-form {
  display: flex;
  gap: 8px;
}

.question-form .input {
  flex: 1;
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.question-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--surface-2);
}

.question-check {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: transparent;
  margin-top: 1px;
}

.question-check svg {
  width: 12px;
  height: 12px;
}

.question-check.done {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.question-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.45;
  padding-top: 1px;
}

.question-text.done {
  text-decoration: line-through;
  color: var(--muted);
}

.question-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px;
  flex: 0 0 auto;
}

.question-del svg {
  width: 13px;
  height: 13px;
}

.question-del:hover {
  color: var(--red);
}

/* ------------------------------------------------------------------ *
   Settings
   ------------------------------------------------------------------ */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 20px;
  align-items: start;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section {
  padding: 22px 23px;
}

.settings-section h2 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 750;
}

.settings-section > p {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.settings-section h3 {
  margin: 20px 0 10px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.settings-section h3:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.settings-actions .saved-note {
  margin-right: auto;
  font-size: 11px;
  color: var(--muted);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}

.danger-zone {
  border-color: color-mix(in srgb, var(--red) 22%, var(--line));
}

.danger-zone h2 {
  color: var(--red);
}

.about-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
}

.about-list li {
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

.about-list li:last-child {
  border-bottom: 0;
}

.about-list strong {
  color: var(--ink-2);
}

/* ------------------------------------------------------------------ *
   Forms
   ------------------------------------------------------------------ */

.field {
  margin-bottom: 15px;
}

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

.field > label,
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
}

.field .label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field .label-row label,
.field .label-row .field-label {
  margin: 0;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 16px;
  line-height: 1.3;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: color-mix(in srgb, var(--line-strong) 60%, var(--muted));
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--coral);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--coral-soft);
}

.input::placeholder,
.textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 75%, transparent);
}

.textarea {
  min-height: 78px;
  resize: vertical;
}

.input-lg {
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.03em;
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.input-wrap {
  position: relative;
}

.input-wrap .input {
  padding-right: 46px;
}

.input-suffix {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
}

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

.field-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.error-text {
  margin: 6px 0 0;
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
}

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

.seg {
  flex: 1;
  position: relative;
  display: block;
  cursor: pointer;
  min-width: 0;
}

.seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.seg span {
  display: block;
  padding: 7px 5px;
  border-radius: 8px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 650;
  color: var(--muted);
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.seg input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--coral);
  outline-offset: 1px;
}

.seg.tone-1 input:checked + span {
  background: var(--amber-soft);
  color: var(--amber);
}

.seg.tone-2 input:checked + span {
  background: color-mix(in srgb, var(--coral-soft) 65%, var(--amber-soft));
  color: color-mix(in srgb, var(--coral) 70%, var(--amber));
}

.seg.tone-3 input:checked + span {
  background: var(--red-soft);
  color: var(--red);
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice {
  position: relative;
  display: block;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.choice span {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.choice input:checked + span {
  background: var(--coral-soft);
  border-color: color-mix(in srgb, var(--coral) 30%, transparent);
  color: var(--coral-dark);
}

.choice input:focus-visible + span {
  outline: 2px solid var(--coral);
  outline-offset: 1px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.step-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.step-btn:hover {
  background: var(--surface);
  border-color: var(--muted);
}

.step-value {
  min-width: 42px;
  text-align: center;
  font-size: 20px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.rating {
  display: flex;
  gap: 5px;
}

.rating-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--line-strong);
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.rating-btn svg {
  width: 19px;
  height: 19px;
}

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

.rating-btn.on {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 25%, transparent);
}

.rating-label {
  margin-left: 7px;
  font-size: 11px;
  color: var(--muted);
  align-self: center;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--coral);
  margin: 0;
}

.modal-safety {
  display: flex;
  gap: 8px;
  padding: 10px 11px;
  border-radius: 11px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 10.5px;
  line-height: 1.5;
  margin-top: 14px;
}

.modal-safety svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.modal-safety strong {
  font-weight: 750;
}

/* ------------------------------------------------------------------ *
   Modal + toast
   ------------------------------------------------------------------ */

.modal-root:empty {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 19, 22, 0.5);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.16s ease;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal.wide {
  max-width: 680px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 21px 23px 0;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 500;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.modal-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.modal-close:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: 18px 23px 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 23px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.modal-foot .left {
  margin-right: auto;
}

.modal-error {
  margin: 10px 0 0;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 11px;
  line-height: 1.45;
  font-weight: 600;
}

.modal-reading {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 16px;
}

.modal-reading strong {
  font-size: 36px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.modal-reading span {
  font-size: 11px;
  color: var(--muted);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
}

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11.5px;
  font-weight: 650;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 100%;
}

.toast svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.toast.error {
  background: var(--red);
  color: #fff;
}

.toast.success svg {
  color: var(--green);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ------------------------------------------------------------------ *
   Day detail
   ------------------------------------------------------------------ */

.detail-section {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:first-child {
  padding-top: 0;
}

.detail-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.detail-head h3 {
  margin: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 750;
}

.detail-value {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

.detail-value strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.detail-value > span {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.detail-value > span > svg {
  display: inline-block;
  vertical-align: -2px;
}

.detail-empty {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 650;
}

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

.mini-btn.danger:hover {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
  background: var(--red-soft);
}

/* ------------------------------------------------------------------ *
   Auth
   ------------------------------------------------------------------ */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
}

.auth-art {
  position: relative;
  overflow: hidden;
  padding: 48px 52px;
  background:
    radial-gradient(900px 700px at -10% 110%, rgba(207, 91, 78, 0.52), transparent 65%),
    radial-gradient(700px 500px at 110% -10%, rgba(47, 127, 121, 0.28), transparent 60%),
    #142126;
  color: #f9f4e9;
  display: flex;
  flex-direction: column;
}

.auth-art::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(249, 244, 233, 0.08);
  border-radius: 50%;
  right: -180px;
  bottom: -180px;
  pointer-events: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: -0.02em;
  margin-bottom: auto;
  position: relative;
  z-index: 1;
}

.auth-brand svg {
  width: 24px;
  height: 24px;
  color: #e37b6e;
}

.auth-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 54px 0 0;
}

.auth-copy h1 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(38px, 4.2vw, 60px);
  line-height: 1.03;
  letter-spacing: -0.035em;
  font-weight: 400;
}

.auth-copy p {
  margin: 0;
  color: rgba(249, 244, 233, 0.64);
  font-size: 14px;
  line-height: 1.6;
  max-width: 42ch;
}

.auth-ekg {
  width: min(520px, 100%);
  height: 120px;
  margin: 34px 0 0;
  color: #e37b6e;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

.auth-ekg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: drawLine 2.6s ease forwards 0.3s;
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

.auth-fine {
  margin: auto 0 0;
  padding-top: 30px;
  color: rgba(249, 244, 233, 0.42);
  font-size: 10.5px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 370px;
}

.auth-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 31px;
  letter-spacing: -0.025em;
  font-weight: 500;
}

.auth-card .auth-sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.auth-card .field {
  margin-bottom: 14px;
}

.auth-submit {
  width: 100%;
  margin-top: 8px;
}

.auth-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
}

.auth-error:empty {
  display: none;
}

.auth-note {
  margin: 18px 0 0;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.55;
}

.password-wrap {
  position: relative;
}

.password-wrap .input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.password-toggle:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.password-toggle svg {
  width: 16px;
  height: 16px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.auth-links a,
.auth-links button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}

.auth-links a:hover,
.auth-links button:hover {
  color: var(--ink);
}

/* ------------------------------------------------------------------ *
   Bottom nav
   ------------------------------------------------------------------ */

.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.bn-item svg {
  width: 20px;
  height: 20px;
}

.bn-item.active {
  color: var(--coral);
  background: var(--coral-soft);
}

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

@media (max-width: 1020px) {
  .nav-links {
    gap: 0;
  }

  .nav-link {
    padding: 8px 9px;
    font-size: 12px;
  }

  .nav-link svg {
    display: none;
  }

  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar-inner {
    padding: 11px 18px;
    gap: 10px;
  }

  .nav-links {
    display: none;
  }

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

  .view {
    padding: 24px 16px 108px;
  }

  .app-footer {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .offline-banner {
    margin: 12px 16px 0;
  }

  .today-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
  }

  .today-hero h1 {
    font-size: 33px;
  }

  .completion-card {
    align-self: stretch;
    justify-content: flex-start;
  }

  .today-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .span-7,
  .span-5,
  .span-6,
  .span-12 {
    grid-column: 1 / -1;
  }

  .card {
    padding: 19px;
    border-radius: 21px;
  }

  .view-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .view-title {
    font-size: 32px;
  }

  .fluid-layout {
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 16px;
  }

  .fluid-ring,
  .fluid-ring svg {
    width: 140px;
    height: 140px;
  }

  .fluid-center strong {
    font-size: 23px;
  }

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

  .report {
    padding: 28px 24px;
    border-radius: 20px;
  }

  .report-period {
    padding: 14px;
  }

  .period-label {
    width: 100%;
  }

  .period-date {
    flex: 1 1 100%;
  }

  .period-date .input {
    flex: 1;
    width: auto;
  }

  .period-row .btn {
    flex: 1 1 auto;
  }

  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    animation: slideUp 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .modal-foot {
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
  }

  .toast-root {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }

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

  .auth-art {
    padding: 28px 26px 24px;
  }

  .auth-copy {
    margin: 30px 0 0;
  }

  .auth-copy h1 {
    font-size: 36px;
  }

  .auth-copy p {
    font-size: 12.5px;
  }

  .auth-ekg {
    height: 62px;
    margin-top: 18px;
  }

  .auth-fine {
    display: none;
  }

  .auth-panel {
    padding: 28px 22px 48px;
    place-items: start center;
  }
}

@media (max-width: 560px) {
  .brand-word {
    font-size: 21px;
  }

  .sync {
    padding: 6px 8px;
    font-size: 9.5px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fluid-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .fluid-ring {
    margin: 0 auto;
  }

  .fluid-quick {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bp-slot {
    width: 70px;
  }

  .bp-target {
    display: none;
  }

  .history-row {
    gap: 11px;
    padding: 12px 13px;
  }

  .history-date strong {
    font-size: 16px;
  }

  .history-chips {
    gap: 4px;
  }

  .chip {
    font-size: 9.5px;
    padding: 3px 7px;
  }

  .report {
    padding: 22px 18px;
    border-radius: 16px;
  }

  .report-head {
    flex-direction: column;
    gap: 12px;
  }

  .report-meta {
    text-align: left;
  }

  .report-title {
    font-size: 24px;
  }

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

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

  .form-grid .full {
    grid-column: auto;
  }

  .field-row,
  .field-row-3 {
    grid-template-columns: 1fr;
  }

  .modal-head {
    padding: 18px 18px 0;
  }

  .modal-body {
    padding: 15px 18px 18px;
  }

  .modal-foot {
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  }

  .view-title {
    font-size: 29px;
  }

  .card {
    padding: 17px;
  }

  .metric-big {
    font-size: 42px;
  }

  .auth-panel {
    padding: 24px 20px 40px;
  }
}

@media (max-width: 380px) {
  .bp-slot {
    width: 62px;
    font-size: 10.5px;
  }

  .bp-reading strong {
    font-size: 17px;
  }

  .status-pill {
    display: none;
  }

  .completion-card {
    padding-right: 12px;
  }
}

/* ------------------------------------------------------------------ *
   Print
   ------------------------------------------------------------------ */

@media print {
  @page {
    size: Letter;
    margin: 13mm;
  }

  body {
    background: #fff !important;
    color: #1c2a30 !important;
    font-size: 10pt;
  }

  .topbar,
  .bottom-nav,
  .app-footer,
  .offline-banner,
  .toast-root,
  .modal-root,
  .no-print,
  .clinic-toolbar,
  .questions-card,
  .report-period,
  .view-head,
  .range-tabs,
  .skip-link,
  .head-meta {
    display: none !important;
  }

  .view {
    max-width: none;
    padding: 0;
  }

  .report {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    color: #1c2a30;
  }

  .report-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .report-cols {
    grid-template-columns: 1fr 1fr !important;
    gap: 24px !important;
  }

  .report-head {
    flex-direction: row !important;
  }

  .report-section {
    break-inside: auto;
  }

  .report-section h3 {
    break-after: avoid;
  }

  .report-table tr {
    break-inside: avoid;
  }

  .report-note {
    break-inside: avoid;
  }

  .report-table {
    font-size: 9pt;
  }

  .report-head {
    border-color: #1c2a30;
  }

  a {
    text-decoration: none;
    color: inherit;
  }
}

@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;
  }
}
