/* Glass UI — tokens and components.
   Layout: one full-screen stage; pages are transparent stacks of glass modules
   over a shared, static backdrop; a floating glass tab bar sits above them. */

:root {
  --bg: #e7edf0;
  --ink: #13202a;
  --ink-2: rgba(19, 32, 42, 0.64);
  --ink-3: rgba(19, 32, 42, 0.42);
  --tint: rgba(255, 255, 255, 0.5);
  --tint-strong: rgba(255, 255, 255, 0.66);
  --tint-press: rgba(255, 255, 255, 0.32);
  --tint-solid: rgba(247, 249, 250, 0.96);
  --hi: rgba(255, 255, 255, 0.9);
  --edge: rgba(19, 32, 42, 0.07);
  --well: rgba(19, 32, 42, 0.06);
  --accent: #0c8a7f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(12, 138, 127, 0.14);
  --warn: #c8472f;
  --blob-1: #ff9f7a;
  --blob-2: #58c9b6;
  --blob-3: #ffd073;
  --blob-4: #86b6ff;
  --shadow: 0 14px 34px -16px rgba(18, 44, 60, 0.35), 0 2px 8px -3px rgba(18, 44, 60, 0.14);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --r-card: 22px;
  --r-ctl: 12px;
  --gap: 12px;
  --tabbar-h: 62px;
  --tabbar-space: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1016;
    --ink: #e8f1f4;
    --ink-2: rgba(232, 241, 244, 0.66);
    --ink-3: rgba(232, 241, 244, 0.42);
    --tint: rgba(26, 36, 46, 0.46);
    --tint-strong: rgba(30, 40, 52, 0.62);
    --tint-press: rgba(26, 36, 46, 0.28);
    --tint-solid: rgba(20, 28, 36, 0.97);
    --hi: rgba(255, 255, 255, 0.14);
    --edge: rgba(255, 255, 255, 0.07);
    --well: rgba(255, 255, 255, 0.07);
    --accent: #4fd6c6;
    --accent-ink: #062521;
    --accent-soft: rgba(79, 214, 198, 0.16);
    --warn: #ff8a70;
    --blob-1: #b8452c;
    --blob-2: #137a6e;
    --blob-3: #8a6516;
    --blob-4: #29508f;
    --shadow: 0 16px 38px -16px rgba(0, 0, 0, 0.7), 0 2px 8px -3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1016;
  --ink: #e8f1f4;
  --ink-2: rgba(232, 241, 244, 0.66);
  --ink-3: rgba(232, 241, 244, 0.42);
  --tint: rgba(26, 36, 46, 0.46);
  --tint-strong: rgba(30, 40, 52, 0.62);
  --tint-press: rgba(26, 36, 46, 0.28);
  --tint-solid: rgba(20, 28, 36, 0.97);
  --hi: rgba(255, 255, 255, 0.14);
  --edge: rgba(255, 255, 255, 0.07);
  --well: rgba(255, 255, 255, 0.07);
  --accent: #4fd6c6;
  --accent-ink: #062521;
  --accent-soft: rgba(79, 214, 198, 0.16);
  --warn: #ff8a70;
  --blob-1: #b8452c;
  --blob-2: #137a6e;
  --blob-3: #8a6516;
  --blob-4: #29508f;
  --shadow: 0 16px 38px -16px rgba(0, 0, 0, 0.7), 0 2px 8px -3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* ---------- stage ---------- */

.gx-app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.gx-app input, .gx-app textarea { user-select: text; -webkit-user-select: text; }

.backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(38% 30% at 12% 18%, var(--blob-1), transparent 72%),
    radial-gradient(42% 34% at 88% 22%, var(--blob-4), transparent 72%),
    radial-gradient(48% 38% at 26% 78%, var(--blob-2), transparent 72%),
    radial-gradient(40% 32% at 82% 88%, var(--blob-3), transparent 72%),
    var(--bg);
}
/* Crisp shapes behind the glass so the blur has something to refract. */
.backdrop i {
  position: absolute;
  border-radius: 50%;
  opacity: 0.85;
}
.backdrop i:nth-child(1) { width: 46vmin; height: 46vmin; left: -8vmin; top: 22%; background: linear-gradient(135deg, var(--blob-1), var(--blob-3)); }
.backdrop i:nth-child(2) { width: 30vmin; height: 30vmin; right: 6vmin; top: 8%; background: linear-gradient(160deg, var(--blob-4), var(--blob-2)); }
.backdrop i:nth-child(3) { width: 56vmin; height: 56vmin; right: -14vmin; bottom: 10%; background: linear-gradient(200deg, var(--blob-2), var(--blob-4)); }
.backdrop i:nth-child(4) { width: 18vmin; height: 18vmin; left: 30%; bottom: 30%; border-radius: 28%; transform: rotate(18deg); background: linear-gradient(120deg, var(--blob-3), var(--blob-1)); }

.layers, .tab-layer, .page { position: absolute; inset: 0; }
.page-scroll {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.page-scroll::-webkit-scrollbar { display: none; }
.page-body, .page-top > *, .page-bottom > * { max-width: 560px; margin-inline: auto; }
.page-body { display: flex; flex-direction: column; gap: var(--gap); padding-inline: 14px; }
.page-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0; pointer-events: none; }
.page-bottom { position: absolute; left: 0; right: 0; bottom: calc(var(--tabbar-space) + 10px); padding-inline: 12px; pointer-events: none; }
.page[data-hide-tabbar] .page-bottom { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
.page-top > *, .page-bottom > * { pointer-events: auto; }
.inert, .inert * { pointer-events: none !important; }
.safe-probe { position: absolute; left: 0; top: 0; width: 0; height: env(safe-area-inset-bottom, 0px); visibility: hidden; }

/* ---------- glass ---------- */

.glass {
  position: relative;
  background: var(--tint);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  border-radius: var(--r-card);
  box-shadow: inset 0 1px 0 var(--hi), inset 0 0 0 1px var(--edge), var(--shadow);
}
.glass.strong {
  background: var(--tint-strong);
  -webkit-backdrop-filter: blur(36px) saturate(1.9);
  backdrop-filter: blur(36px) saturate(1.9);
}
.no-blur .glass, .no-blur .glass.strong {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--tint-solid);
}
[data-bind] { will-change: transform, opacity; transform-origin: 50% 50%; }
.mod { padding: 16px; }
.tap { cursor: pointer; transition: background-color 0.15s; }
.tap:active { background: var(--tint-press); }

/* Binding/effect label shown on every module in the demo. */
.tag {
  position: absolute;
  top: -8px;
  right: 16px;
  z-index: 1;
  font: 500 10px/1.5 var(--font);
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: var(--tint-solid);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), inset 0 0 0 1px var(--edge);
  padding: 0 7px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}
.no-tags .tag { display: none; }

/* ---------- header module ---------- */

.head { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; min-height: 44px; }
.head .t { min-width: 0; flex: 1; }
.head h1 { margin: 0; font-size: 17px; font-weight: 650; line-height: 1.25; text-wrap: balance; }
.head .path { font: 11px/1.4 var(--mono); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head.root { padding: 14px 18px 14px; flex-direction: column; align-items: flex-start; gap: 2px; }
.head.root h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.head.root .sub { color: var(--ink-2); font-size: 13px; }
.back {
  flex: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--well);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.back:active { background: var(--tint-press); }
.back svg { width: 20px; height: 20px; }

/* ---------- content ---------- */

.eyebrow { font-size: 12px; color: var(--ink-2); letter-spacing: 0.04em; }
.title { font-size: 17px; font-weight: 650; margin: 2px 0 0; }
.big { font-size: 56px; line-height: 1; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chev { color: var(--ink-3); flex: none; }
.chev svg { width: 18px; height: 18px; display: block; }
.list { display: flex; flex-direction: column; }
.list > * { padding: 11px 0; border-top: 1px solid var(--edge); }
.list > *:first-child { border-top: 0; padding-top: 4px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.stat { background: var(--well); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-2); }
.meter { height: 6px; border-radius: 3px; background: var(--well); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
p { margin: 0; }
.prose p + p { margin-top: 10px; }
.prose { font-size: 16px; line-height: 1.7; }

.hscroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  touch-action: auto;
  scrollbar-width: none;
  margin-inline: -16px;
  padding-inline: 16px;
  scroll-snap-type: x proximity;
}
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { flex: none; scroll-snap-align: start; }
.hour { width: 56px; text-align: center; background: var(--well); border-radius: 14px; padding: 8px 0; font-variant-numeric: tabular-nums; }
.hour b { display: block; font-size: 16px; font-weight: 600; }
.hour span { font-size: 11px; color: var(--ink-2); }
.tile { border-radius: 14px; aspect-ratio: 1; max-width: 100%; }
.slide-card { width: 200px; height: 120px; border-radius: 16px; padding: 12px; display: flex; align-items: flex-end; color: #fff; font-weight: 600; }

/* ---------- controls ---------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font: 600 15px/1.2 var(--font);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.btn:active { filter: brightness(0.92); }
.btn.ghost { background: var(--well); color: var(--ink); }
.btn.warn { background: var(--warn); color: #fff; }
.btn.block { width: 100%; }
.bar { display: flex; gap: 8px; padding: 8px; border-radius: 999px; }
.bar .btn { flex: 1; }
button:focus-visible, input:focus-visible, .tap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 12px; color: var(--ink-2); }
.field input {
  font: 16px var(--font);
  color: var(--ink);
  background: var(--well);
  border: 0;
  border-radius: var(--r-ctl);
  padding: 11px 12px;
}

.ctl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.ctl span { font-size: 14px; }
.ctl output { font: 12px var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 4px 0 2px; }
.ctl small { grid-column: 1 / -1; color: var(--ink-3); font-size: 12px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch {
  flex: none;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  border: 0;
  padding: 0;
  background: var(--well);
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.seg { display: flex; background: var(--well); border-radius: 10px; padding: 2px; }
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 13px var(--font);
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--tint-strong); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }

/* ---------- tab bar ---------- */

.tabbar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  max-width: 420px;
  margin-inline: auto;
  height: var(--tabbar-h);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px;
  border-radius: 26px;
  z-index: 50;
  will-change: transform, opacity;
}
.tabbar button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: 500 11px var(--font);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--accent); background: var(--accent-soft); }

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  z-index: 60;
  right: 8px;
  top: calc(env(safe-area-inset-top, 0px) + 74px);
  width: 148px;
  padding: 7px 10px 4px;
  border-radius: 14px;
  font: 10px/1.45 var(--mono);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  color: var(--ink);
}
.hud .k { color: var(--ink-3); }
.hud .st { font-weight: 700; }
.hud .axis { position: relative; height: 24px; margin-top: 4px; }
.hud .axis .line { position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: var(--well); border-radius: 1px; }
.hud .axis .band { position: absolute; top: 7px; height: 4px; background: var(--accent-soft); border-radius: 2px; }
.hud .axis .tick { position: absolute; top: 4px; width: 1px; height: 10px; background: var(--ink-3); }
.hud .axis .tick b { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); font-weight: 400; font-size: 9px; color: var(--ink-3); }
.hud .axis .mk { position: absolute; top: 4px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--tint-strong); }
.hud .axis .tg { position: absolute; top: -3px; width: 0; height: 0; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--warn); }
.hud[hidden] { display: none; }
