/* Stillpoint web. Mirrors the native theme (HypnosisAppCore/UI/Theme.swift): dark only. */
:root {
  --bg: #0E1220;
  --card: #1A2033;
  --card-2: #232a40;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --faint: rgba(255, 255, 255, 0.08);
  --accent: #7C8CF8;
  --warn: #F5C451;
  --ok: #5BD08A;
  --danger: #FF6B6B;
  --orange: #F29B4B;
  --tint: var(--accent);
  --radius: 16px;
  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar: 58px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 40px var(--gutter); color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.caption { font-size: 13px; color: var(--muted); }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
.danger { color: var(--danger); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.screen { min-height: 100dvh; padding: calc(var(--safe-top) + 8px) 0 calc(var(--tabbar) + var(--safe-bottom) + 24px); }
.screen.no-tabs { padding-bottom: calc(var(--safe-bottom) + 24px); }
.page { max-width: 640px; margin: 0 auto; padding: 0 var(--gutter); display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.topbar .back { text-decoration: none; display: inline-flex; align-items: center; gap: 2px; background: none; border: 0; color: var(--accent); padding: 8px 8px 8px 0; font-size: 17px; }
h1.large { font-size: 32px; line-height: 1.15; margin: 6px 0 2px; font-weight: 700; letter-spacing: 0.2px; }
h2 { font-size: 20px; margin: 8px 0 0; }
h3 { font-size: 17px; margin: 0; }
p { margin: 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card > h3 { display: flex; align-items: center; gap: 8px; }
.row { display: flex; align-items: center; gap: 14px; }
.rowcard {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--card);
  border: 0; border-radius: var(--radius); padding: 14px; color: var(--fg); text-decoration: none; cursor: pointer;
}
.rowcard:active, .btn:active { opacity: 0.75; }
.rowcard .grow, .grow { flex: 1; min-width: 0; }
.rowcard .title { font-weight: 600; }
.rowcard .sub { color: var(--muted); font-size: 15px; }
.chev { color: var(--muted); flex: none; }
.icon-tile { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.icon-tile.sm { width: 40px; height: 40px; border-radius: 10px; }
.icon { width: 24px; height: 24px; flex: none; }
.icon.lg { width: 30px; height: 30px; }
.icon.xl { width: 38px; height: 38px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px;
  border: 0; border-radius: 14px; background: var(--tint); color: #fff; font-weight: 600; width: 100%; cursor: pointer;
}
.btn.secondary { background: var(--card-2); }
.btn.ghost { background: transparent; color: var(--accent); min-height: 44px; }
.btn.danger { background: transparent; color: var(--danger); justify-content: flex-start; padding: 0; min-height: 44px; }
.btn.link { background: none; color: var(--accent); padding: 0; min-height: 44px; justify-content: flex-start; width: auto; font-weight: 500; }
.btn[disabled] { opacity: 0.4; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 0; background: var(--faint); color: var(--fg); font-size: 15px; cursor: pointer; }
.pill.on { background: var(--tint); }
.pill.yes.on { background: #2f8a55; }
.pill.no.on { background: #b56a26; }

/* Rescue button */
.rescue { background: linear-gradient(180deg, var(--tint), color-mix(in srgb, var(--tint) 70%, #000)); color: #fff; padding: 16px; }
.rescue .sub { color: rgba(255, 255, 255, 0.85); }

/* Segmented control */
.seg { display: flex; background: var(--faint); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { flex: 1; min-height: 34px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; padding: 4px 2px; }
.seg button.on { background: #5b627a; font-weight: 600; }

/* Toggle */
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track { margin-left: auto; width: 51px; height: 31px; border-radius: 16px; background: #3a3f52; position: relative; flex: none; transition: background 0.15s; }
.toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle input:checked + .track { background: var(--ok); }
.toggle input:checked + .track::after { transform: translateX(20px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Rating */
.rating .nums { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.rating .nums button { min-height: 44px; border: 0; border-radius: 8px; background: var(--faint); font-variant-numeric: tabular-nums; font-size: 15px; padding: 0; }
.rating.compact .nums button { min-height: 36px; }
.rating .nums button.on { background: var(--tint); font-weight: 700; }
.rating .ends { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }

/* Slider */
.vol { display: flex; align-items: center; gap: 12px; }
input[type=range] { flex: 1; accent-color: var(--accent); height: 28px; }

textarea { width: 100%; min-height: 76px; border-radius: 10px; border: 1px solid #3a3f52; background: #10141f; padding: 10px; resize: vertical; }

ul.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.safety { display: flex; flex-direction: column; gap: 14px; }
.safety .item { display: flex; gap: 12px; align-items: flex-start; }
.safety .icon { color: var(--orange); margin-top: 1px; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.note .icon { width: 18px; height: 18px; margin-top: 1px; }
.note.warn { color: var(--warn); }
.note.ok { color: var(--ok); }
.progress { height: 6px; border-radius: 3px; background: var(--faint); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stats .card { align-items: center; gap: 2px; padding: 12px 6px; }
.stats .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  padding: 6px 8px calc(var(--safe-bottom) + 4px); background: rgba(14, 18, 32, 0.92);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 0; min-height: 44px; }
.tabbar a.on { color: var(--accent); }

/* Sheets and the player */
#overlay:empty { display: none; }
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100dvh - var(--safe-top) - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px var(--gutter) calc(var(--safe-bottom) + 20px);
  display: flex; flex-direction: column; gap: 14px; animation: up 0.22s ease-out;
}
.sheet .sheet-head { position: sticky; top: -8px; z-index: 1; background: var(--bg); display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.sheet .sheet-head h2 { margin: 0; font-size: 17px; }
.sheet .sheet-head button { background: none; border: 0; color: var(--accent); font-size: 17px; min-width: 60px; min-height: 44px; }
.sheet .sheet-head button:last-child { text-align: right; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.player {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tint) 28%, var(--bg)) 0%, var(--bg) 50%);
  padding: calc(var(--safe-top) + 12px) 24px calc(var(--safe-bottom) + 20px);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.player .inner { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 18px; min-height: 100%; }
.player .top { width: 100%; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); gap: 8px; }
.player .top .mod { color: var(--tint); display: inline-flex; align-items: center; gap: 4px; }
.player .top span { display: inline-flex; align-items: center; gap: 4px; }
.player .top .icon { width: 16px; height: 16px; }
.ring { position: relative; width: min(280px, 72vw); aspect-ratio: 1; margin-top: 8px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px; gap: 4px; }
.ring .phase { font-size: 19px; font-weight: 500; }
.ring .time { font-size: 42px; font-weight: 300; font-variant-numeric: tabular-nums; }
.player .title { font-size: 24px; font-weight: 700; text-align: center; }
.player .notice { font-size: 14px; text-align: center; color: var(--warn); }
.player .notice.info { color: var(--muted); }
.controls { display: flex; align-items: center; justify-content: center; gap: 44px; margin-top: auto; }
.controls button { border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; cursor: pointer; }
.controls .stop { width: 60px; height: 60px; background: rgba(255, 255, 255, 0.1); }
.controls .play { width: 84px; height: 84px; background: var(--tint); }
.controls .spacer { width: 60px; height: 60px; }
.player .opts { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.player .card { width: 100%; }

.dialog { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; padding: 12px 12px calc(var(--safe-bottom) + 12px); }
.dialog .box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 8px; animation: up 0.18s ease-out; }
.dialog .msg { background: #2a2f42; border-radius: 14px; padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.dialog .msg strong { font-size: 15px; }
.dialog .btn { background: #2a2f42; color: var(--accent); }
.dialog .btn.destructive { color: var(--danger); }
.dialog .btn.cancel { font-weight: 700; }

/* Chart */
.chart svg { width: 100%; height: 180px; display: block; }
.chart .legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.chart .legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart .swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.onboard { display: flex; flex-direction: column; min-height: 100dvh; padding-top: var(--safe-top); }
.onboard .bar { padding: 12px 20px 0; }
.onboard .body { flex: 1; padding: 20px; max-width: 640px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.onboard .foot { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 14px 20px calc(var(--safe-bottom) + 14px); background: linear-gradient(transparent, var(--bg) 30%); max-width: 640px; width: 100%; margin: 0 auto; }
.onboard .foot .btn.ghost { width: auto; }
.hero-icon { color: var(--accent); }
.hero-icon .icon { width: 64px; height: 64px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 700px) { .sheet { border-radius: 18px; margin-bottom: 24px; } .sheet-wrap { align-items: center; } }
.toggle .caption { display: block; line-height: 1.35; margin-top: 2px; }
