@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter.woff2") format("woff2");
}

:root {
  /* Monochrome periwinkle palette on deep night */
  --bg-0: #06070f;
  --bg-1: #10122a;
  --ink: #f4f4fb;
  --ink-2: #b6b8d6;
  --ink-3: #74769c;
  --line: rgba(150, 160, 220, 0.10);

  --accent: #aab2ff;
  --accent-deep: #7b7ffb;
  --accent-dim: rgba(139, 146, 240, 0.5);

  /* Single-hue charts */
  --chart-1: #8b92f0;
  --chart-2: #8b92f0;
  --chart-3: #8b92f0;

  --glow: 0 20px 55px -22px rgba(123, 127, 251, 0.5);
  --card: rgba(255, 255, 255, 0.04);
  --card-brd: rgba(255, 255, 255, 0.075);
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 15px;
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

/* Minimal line icons */
.icn { width: 1em; height: 1em; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  /* One soft top glow that fades fully to transparent — no seams */
  background:
    radial-gradient(135% 90% at 50% -25%, rgba(123, 127, 251, 0.16), rgba(123, 127, 251, 0) 62%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 55%, #040509 100%);
  background-attachment: fixed;
  letter-spacing: -0.011em;
}

#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#stars i { position: absolute; border-radius: 50%; background: #fff; animation: tw 5s ease-in-out infinite; }
@keyframes tw { 0%, 100% { opacity: 0.12 } 50% { opacity: 0.7 } }

main {
  position: relative; z-index: 1;
  max-width: 500px; margin: 0 auto;
  padding: 26px 20px calc(104px + env(safe-area-inset-bottom));
}
.connection-status {
  position: sticky; top: 0; z-index: 8; max-width: 500px; max-height: 48px; margin: 0 auto;
  padding: 8px 20px; overflow: hidden; text-align: center; font-size: .78rem;
  color: #17182b; background: var(--accent);
  transition: max-height .3s ease, padding .3s ease, opacity .2s ease;
}
.connection-status.online { background: rgba(28, 31, 58, .94); color: var(--ink-2); }
.connection-status.offline { background: #6b3440; color: #fff; }
.connection-status.hidden { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .connection-status { transition: none; }
}

h1 { font-size: 1.55rem; font-weight: 650; letter-spacing: -0.02em; }
h2 {
  font-size: 0.72rem; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.16em; margin: 26px 4px 12px;
}

/* ---- Top bar ---- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.topbar .avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  color: var(--accent); font-size: 1.35rem;
  background: radial-gradient(circle at 35% 30%, #22244a, #14152e);
  border: 1px solid var(--card-brd); flex: none; cursor: pointer;
}
.topbar .meta { line-height: 1.15; }
.topbar .greet { color: var(--ink-3); font-size: 0.8rem; }
.topbar .age { margin-left: auto; color: var(--ink-3); font-size: 0.82rem; text-align: right; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---- Hero pressure card ---- */
.hero-card {
  background: linear-gradient(180deg, rgba(139,146,240,.09), rgba(139,146,240,.02));
  border: 1px solid var(--card-brd); border-radius: var(--r-lg);
  padding: 20px 18px 10px; margin-bottom: 14px;
}
.hero-top { text-align: center; }
.hero-top .kicker { color: var(--ink-2); font-size: 0.95rem; font-weight: 500; }
.hero-top .big {
  font-size: 3.1rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.03em;
  margin: 2px 0; font-variant-numeric: tabular-nums;
}
.hero-top .sub { color: var(--ink-3); font-size: 0.84rem; }
.wave-hero { margin: 14px 0 6px; }
.wave-hero svg { width: 100%; height: auto; display: block; overflow: visible; }
.now-pulse { animation: pulse 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.35 } }
.pressure-foot {
  display: flex; align-items: center; gap: 8px; padding: 10px 2px 4px;
  border-top: 1px solid var(--line); font-size: 0.9rem;
}
.pressure-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.pressure-foot .title { font-weight: 600; }
.pressure-foot .read { margin-left: auto; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---- Insight notes ---- */
.note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--card-brd); border-radius: var(--r-md);
  padding: 13px 15px; margin-bottom: 12px; font-size: 0.86rem; color: var(--ink-2); line-height: 1.45;
}
.note .note-ic { color: var(--accent); font-size: 1.1rem; flex: none; margin-top: 1px; line-height: 1; }
.note strong { color: var(--ink); font-weight: 600; }
.note-x {
  flex: none; border: 0; background: none; cursor: pointer; padding: 2px; margin: -2px -4px 0 auto;
  color: var(--ink-3); font-size: 0.95rem; line-height: 1;
}
.note-x:hover { color: var(--ink); }

/* ---- Primary action ---- */
.action-row { margin: 4px 0 2px; }
.big-btn {
  width: 100%; border: 0; cursor: pointer; border-radius: var(--r-md);
  padding: 18px; font: inherit; font-size: 1.05rem; font-weight: 650; color: #0b0c1a;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: var(--glow);
  transition: transform 0.12s ease;
}
.big-btn .ico { font-size: 1.3rem; }
.big-btn:active { transform: scale(0.98); }
.big-btn.stop {
  color: var(--ink);
  background: linear-gradient(135deg, #3a2140 0%, #52243c 100%);
  box-shadow: 0 18px 50px -22px rgba(210, 90, 90, 0.5);
}
.big-btn .elapsed { font-weight: 500; opacity: 0.8; font-variant-numeric: tabular-nums; }

/* ---- Schedule list ---- */
.sched { list-style: none; }
.sched li {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 2px; border-bottom: 1px solid var(--line); font-size: 0.98rem;
}
.sched li:last-child { border-bottom: 0; }
.sched .ic {
  width: 34px; height: 34px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: rgba(139, 146, 240, 0.10); color: var(--accent); font-size: 1.1rem;
}
.sched .t { margin-left: auto; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sched .predicted { opacity: 0.6; }
.badge {
  font-size: 0.62rem; padding: 3px 9px; border-radius: 20px; letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.06); color: var(--ink-2);
}
.badge.live { background: rgba(139, 146, 240, 0.18); color: var(--accent); }

/* ---- Forms ---- */
form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
form.grid > * { min-width: 0; }
form.grid .full { grid-column: 1 / -1; }
label.f { display: block; font-size: 0.72rem; color: var(--ink-3); margin-bottom: 5px; }
input, select {
  width: 100%; min-width: 0; max-width: 100%; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--card-brd); background: rgba(255, 255, 255, 0.04);
  color: var(--ink); font: inherit; color-scheme: dark;
}
input[type="date"], input[type="time"] { display: block; -webkit-appearance: none; appearance: none; }
input:focus, select:focus { outline: none; border-color: var(--accent-deep); }
.btn {
  border: 0; border-radius: 16px; padding: 14px; font: inherit; font-weight: 650; cursor: pointer; width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #0b0c1a;
}
.btn.ghost { background: rgba(255, 255, 255, 0.05); color: var(--ink); }
button:disabled, input:disabled, select:disabled { opacity: .48; cursor: not-allowed; }
.form-error { color: #ffabb8; font-size: .8rem; line-height: 1.4; margin-top: 10px; }
.data-actions { display: grid; gap: 10px; }
.file-label { display: block; color: var(--ink-3); font-size: .72rem; margin-bottom: 5px; }
.auth-shell { padding-top: min(14vh, 90px); }
.auth-shell .welcome { margin-bottom: 26px; }
.account-login { color: var(--ink-2); font-size: .84rem; margin-bottom: 14px; overflow-wrap: anywhere; }
.auth-switch { display: block; margin: 14px auto 0; padding: 8px; border: 0; background: none; color: var(--accent); font: inherit; font-size: .84rem; cursor: pointer; }
.sync-review p { color: var(--ink-2); font-size: .82rem; line-height: 1.45; margin: 7px 0 14px; }

@media (max-width: 420px) {
  form.grid { gap: 10px; }
  form.grid input { padding-inline: 8px; }
}

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

/* ---- Log ---- */
.log-item { display: grid; grid-template-columns: 34px auto 1fr auto; align-items: center; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: 0; }
.log-item .ic { width: 34px; height: 34px; flex: none; border-radius: 11px; display: grid; place-items: center; background: rgba(139,146,240,.10); color: var(--accent); font-size: 1.1rem; }
.log-item .t { margin-left: auto; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.log-item .edit-event { width: 44px; height: 44px; border: 0; border-radius: 14px; background: none; color: var(--ink-3); font-size: 1.05rem; cursor: pointer; display: grid; place-items: center; }
.log-item .edit-event:hover, .log-item .edit-event:focus-visible { color: var(--ink); background: rgba(255,255,255,.05); }
.day-nav { display: grid; grid-template-columns: 44px auto 44px; align-items: center; justify-content: center; column-gap: 4px; margin: 18px 0 12px; color: var(--ink-2); text-align: center; font-size: .88rem; font-weight: 600; }
.day-nav span { min-width: 142px; }
.day-nav button { width: 44px; height: 44px; border: 0; border-radius: 14px; background: none; color: var(--accent); font: inherit; font-size: 1.2rem; cursor: pointer; display: grid; place-items: center; }
.day-nav button:hover, .day-nav button:focus-visible { background: rgba(255,255,255,.05); }
.log-empty { padding: 8px 4px; color: var(--ink-3); font-size: .86rem; }

dialog#edit-event-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); margin: auto; border: 1px solid var(--card-brd); border-radius: var(--r-lg); background: #111329; color: var(--ink); box-shadow: 0 28px 90px rgba(0,0,0,.6); overflow: hidden; }
dialog#edit-event-dialog::backdrop { background: rgba(3,4,10,.74); backdrop-filter: blur(5px); }
.edit-dialog header { display: flex; align-items: flex-start; gap: 16px; padding: 20px 20px 10px; }
.edit-dialog header p { color: var(--ink-3); font-size: .8rem; margin-top: 4px; }
.dialog-close { width: 44px; height: 44px; margin: -8px -8px 0 auto; flex: none; border: 0; border-radius: 14px; background: none; color: var(--ink-3); cursor: pointer; font-size: 1.05rem; }
.dialog-close:hover, .dialog-close:focus-visible { color: var(--ink); background: rgba(255,255,255,.05); }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 10px 20px 20px; overflow-y: auto; }
.edit-fields .full { grid-column: 1 / -1; }
.edit-fields .ongoing { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .84rem; }
.edit-fields .ongoing input { width: auto; }
.edit-dialog footer { display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(5,6,15,.35); }
.dialog-action { min-height: 48px; border: 0; border-radius: 16px; font: inherit; font-weight: 650; cursor: pointer; }
.dialog-action.primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #0b0c1a; }
.dialog-action.danger { background: rgba(167,72,91,.14); color: #ffabb8; }
.delete-confirm { padding: 12px 14px; border: 1px solid rgba(255,171,184,.22); border-radius: 14px; background: rgba(167,72,91,.08); color: #ffd9df; font-size: .84rem; line-height: 1.4; }

@media (max-width: 420px) {
  dialog#edit-event-dialog { width: 100%; max-width: none; max-height: calc(100dvh - 20px); margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .edit-fields { gap: 10px; }
  .edit-fields input { padding-inline: 8px; }
}

/* ---- Trends ---- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.tile { background: var(--card); border: 1px solid var(--card-brd); border-radius: var(--r-md); padding: 15px 10px; text-align: center; }
.tile .v { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.tile .k { font-size: 0.66rem; color: var(--ink-3); margin-top: 4px; line-height: 1.3; }
.chart-card .avg { font-size: 0.78rem; color: var(--ink-2); margin-bottom: 10px; }
.section-title { display: flex; align-items: center; gap: 8px; }
.beta-badge { font-size: .58rem; line-height: 1; padding: 4px 8px; border: 1px solid rgba(139,146,240,.24); border-radius: 20px; background: rgba(139,146,240,.10); color: var(--accent); letter-spacing: .06em; text-transform: uppercase; }
.accuracy-card .avg { font-size: .88rem; color: var(--ink-2); }
.accuracy-card p { color: var(--ink-3); font-size: .78rem; line-height: 1.45; margin-top: 8px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-card details { margin-top: 10px; font-size: 0.8rem; color: var(--ink-2); }
.chart-card summary { cursor: pointer; color: var(--ink-3); }
.chart-card table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.chart-card td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.axis { font-size: 10px; fill: var(--ink-3); }
.grid-line { stroke: var(--line); stroke-dasharray: 2 5; }

/* ---- Tabs ---- */
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-around;
  max-width: 500px; margin: 0 auto;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: rgba(11, 12, 26, 0.72);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
#tabs[hidden] { display: none; }
#tabs button {
  border: 0; background: none; color: var(--ink-3); font: inherit; font-size: 0.66rem; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  padding: 5px 16px; border-radius: 14px; transition: color 0.15s ease;
}
#tabs button .icn { font-size: 1.4rem; opacity: 0.85; }
#tabs button.active { color: var(--accent); }

/* ---- Toast & tooltip ---- */
#toast {
  position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%);
  background: rgba(30, 32, 60, 0.95); color: var(--ink); padding: 12px 20px;
  border-radius: 16px; z-index: 10; font-size: 0.9rem; border: 1px solid var(--card-brd);
  box-shadow: var(--glow); animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px) } }
#tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: rgba(38, 40, 74, 0.97); color: var(--ink); font-size: 0.78rem;
  padding: 7px 11px; border-radius: 11px; border: 1px solid var(--card-brd);
  white-space: nowrap;
}

/* ---- Onboarding ---- */
.welcome { text-align: center; margin: 52px 0 30px; }
.welcome .logo { margin: 0 auto; width: 84px; height: 84px; color: var(--accent); filter: drop-shadow(0 10px 34px rgba(123, 127, 251, 0.5)); }
.welcome h1 { margin-top: 14px; font-size: 1.9rem; }
.welcome p { color: var(--ink-2); margin-top: 10px; font-size: 0.98rem; line-height: 1.5; }
