/* Sparsh Home: tokens, chrome, shared components */
:root {
  --bg:#0c0c0e; --panel:#17171a; --panel-2:#202024; --border:#2c2c31;
  --text:#f4f4f6; --text-dim:#a2a2ab; --text-faint:#6e6e77;
  --accent:#d09e52; --on-accent:#2f2410; --danger:#c06a3e; --sage:#b9b98f;
  --radius:14px; --radius-lg:18px;
  --curve:cubic-bezier(0.32,0.72,0,1);
  --tabbar-h:72px; --bottom-chrome:calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  --font:-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --pad:20px;
}

*, *::before, *::after { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
[hidden] { display:none !important; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); }
html { color-scheme:dark; -webkit-text-size-adjust:100%; }
body {
  font:15px/1.4 var(--font);
  -webkit-font-smoothing:antialiased;
  overflow:hidden; overscroll-behavior:none;
  -webkit-user-select:none; user-select:none;
  -webkit-touch-callout:none;
}
body.scroll-lock .screen { overflow:hidden; }
button { font:inherit; color:inherit; background:none; border:0; padding:0; cursor:pointer; }
input, textarea, select { font:inherit; font-size:16px; color:var(--text); -webkit-user-select:text; user-select:text; }
h1, h2, h3, p { margin:0; }

/* Screens */
.app { position:fixed; inset:0; }
.screen {
  position:absolute; inset:0; overflow-x:hidden; overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:none; touch-action:pan-y;
  padding:calc(env(safe-area-inset-top) + 12px) var(--pad) calc(var(--bottom-chrome) + 16px);
}
.screen-body { position:relative; will-change:transform; }
.large-title { font-size:28px; font-weight:700; letter-spacing:-0.02em; line-height:1.15; margin:8px 0 16px; }
.section-label { font-size:13px; font-weight:600; letter-spacing:0.02em; color:var(--text-dim); margin:22px 4px 8px; text-transform:none; }
.hint { color:var(--text-dim); font-size:14px; text-align:center; padding:24px 12px; }
.dim { color:var(--text-dim); }
.faint { color:var(--text-faint); }

/* Press feedback */
.pressable { transition:transform 160ms ease-out, background-color 160ms ease-out, opacity 160ms ease-out; }
.pressable:active { transform:scale(.97); transition:transform 160ms ease-out; }

/* Card + row */
.card { background:var(--panel); border-radius:var(--radius-lg); padding:16px; border:1px solid rgba(255,255,255,0.03); }
.card + .card { margin-top:12px; }
.card.flush { padding:0; overflow:hidden; }
.row {
  display:flex; align-items:center; gap:12px; min-height:48px; padding:10px 16px;
  width:100%; text-align:left;
}
.row + .row { border-top:1px solid var(--border); }
.row .label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.row .value { color:var(--text-dim); margin-left:auto; flex:none; max-width:55%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.row .chev { flex:none; width:8px; height:14px; color:var(--text-faint); }
.row .chev::before { content:""; display:block; width:8px; height:8px; margin-top:3px; border-right:2px solid currentColor; border-top:2px solid currentColor; transform:rotate(45deg); }
button.row:active { background:var(--panel-2); }

/* Tile */
.tile-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.tile {
  position:relative; min-height:96px; padding:14px; border-radius:var(--radius-lg);
  background:var(--panel); border:1px solid rgba(255,255,255,0.03);
  display:flex; flex-direction:column; justify-content:space-between; text-align:left;
  min-width:0;
}

/* Switch */
.switch {
  position:relative; flex:none; width:51px; height:31px; border-radius:16px;
  background:var(--panel-2); border:1px solid var(--border);
  transition:background-color 200ms var(--curve), border-color 200ms var(--curve);
  cursor:pointer; padding:0; display:inline-block;
}
.switch::before { content:""; position:absolute; inset:-7px -3px; } /* 44px target */
.switch::after {
  content:""; position:absolute; top:1px; left:1px; width:27px; height:27px; border-radius:50%;
  background:#fff; box-shadow:0 2px 5px rgba(0,0,0,0.4);
  transition:transform 200ms var(--curve);
}
.switch.on, .switch[aria-checked="true"] { background:var(--accent); border-color:var(--accent); }
.switch.on::after, .switch[aria-checked="true"]::after { transform:translateX(20px); }
.switch:active::after { width:31px; }
.switch.on:active::after, .switch[aria-checked="true"]:active::after { transform:translateX(16px); }

/* Vertical brightness slider shell */
.slider-v {
  position:relative; width:88px; height:280px; border-radius:28px; overflow:hidden;
  background:var(--panel-2); touch-action:none; cursor:pointer;
}
.slider-v .fill { position:absolute; left:0; right:0; bottom:0; height:50%; background:var(--text); }
.slider-v .pct { position:absolute; left:0; right:0; bottom:14px; text-align:center; font-weight:600; color:var(--on-accent); mix-blend-mode:normal; }

/* Pill buttons */
.pill-btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  min-height:48px; padding:0 22px; border-radius:24px; font-weight:600; font-size:16px;
  background:var(--panel-2); color:var(--text); border:1px solid var(--border);
}
.pill-btn-accent { background:var(--accent); color:var(--on-accent); border-color:transparent; }
.pill-btn.danger { color:var(--danger); }
.pill-btn.block { display:flex; width:100%; }

/* Segmented control */
.seg { display:flex; padding:3px; gap:2px; background:var(--panel-2); border-radius:12px; }
.seg button {
  flex:1; min-height:38px; border-radius:9px; font-weight:600; font-size:14px; color:var(--text-dim);
  transition:background-color 200ms var(--curve), color 200ms var(--curve);
}
.seg button.active { background:var(--panel); color:var(--text); box-shadow:0 1px 3px rgba(0,0,0,0.4); }

/* Text input (R10: >= 16px, quiet) */
.input {
  width:100%; min-height:48px; padding:0 14px; font-size:16px; border-radius:var(--radius);
  background:var(--panel-2); border:1px solid var(--border); outline:none; color:var(--text);
  transition:border-color 160ms ease-out;
}
.input:focus { border-color:var(--accent); }
.input::placeholder { color:var(--text-faint); }

/* Tab bar */
.tabbar {
  position:fixed; z-index:30; left:50%; transform:translateX(-50%);
  bottom:calc(env(safe-area-inset-bottom) + 10px);
  display:flex; gap:4px; padding:6px; width:min(calc(100% - 40px), 360px);
  background:rgba(23,23,26,0.72); border:1px solid rgba(255,255,255,0.08); border-radius:34px;
  -webkit-backdrop-filter:blur(20px) saturate(1.4); backdrop-filter:blur(20px) saturate(1.4);
  box-shadow:0 10px 30px rgba(0,0,0,0.45);
}
.tab {
  flex:1; min-height:52px; border-radius:28px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px;
  color:var(--text-dim); font-size:11px; font-weight:600; letter-spacing:0.01em;
  transition:background-color 220ms var(--curve), color 220ms var(--curve), transform 160ms ease-out;
}
.tab.active { background:var(--accent); color:var(--on-accent); }

/* Pull to refresh */
.ptr-spinner {
  position:absolute; top:calc(env(safe-area-inset-top) + 6px); left:50%; width:32px; height:32px; margin-left:-16px;
  opacity:0; pointer-events:none; z-index:2; transform:scale(.8);
}
.ptr-spinner svg { display:block; width:32px; height:32px; transform:rotate(-90deg); }
.ptr-spinner circle { fill:none; stroke-width:2.5; stroke-linecap:round; }
.ptr-spinner .trk { stroke:var(--border); }
.ptr-spinner .arc { stroke:var(--accent); }
.ptr-spinner.spinning svg { animation:sh-spin 800ms linear infinite; }
@keyframes sh-spin { to { transform:rotate(270deg); } }
.ptr-spinner.settle { transition:opacity 260ms var(--curve), transform 260ms var(--curve); }
.screen-body.settle { transition:transform 320ms var(--curve); }

/* Sheets */
.sheet-root { position:fixed; inset:0; z-index:50; pointer-events:none; }
.sheet-scrim {
  position:absolute; inset:0; background:rgba(0,0,0,0.55); opacity:0; pointer-events:auto;
  transition:opacity 200ms var(--curve);
  -webkit-backdrop-filter:blur(2px); backdrop-filter:blur(2px);
}
.sheet-scrim.in { opacity:1; }
.sheet {
  position:absolute; left:0; right:0; bottom:0; pointer-events:auto;
  height:calc(100vh - env(safe-area-inset-top) - 12px);
  height:calc(100dvh - env(safe-area-inset-top) - 12px);
  background:var(--bg); border-radius:24px 24px 0 0; border:1px solid var(--border); border-bottom:0;
  box-shadow:0 -10px 40px rgba(0,0,0,0.5);
  transform:translateY(100%); transition:transform 200ms var(--curve);
  display:flex; flex-direction:column; overflow:hidden;
}
@supports (height:-webkit-fill-available) and (not (height:100dvh)) {
  .sheet { height:calc(-webkit-fill-available - env(safe-area-inset-top) - 12px); }
}
.sheet.in { transform:translateY(0); }
.sheet.dragging { transition:none; }
.sheet-grab { flex:none; width:36px; height:5px; border-radius:3px; background:var(--border); margin:8px auto 0; }
.sheet-head { flex:none; display:flex; align-items:center; gap:12px; padding:10px 20px 8px; min-height:56px; }
.sheet-title { flex:1; min-width:0; font-size:20px; font-weight:700; letter-spacing:-0.02em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sheet-close {
  flex:none; width:44px; height:44px; border-radius:22px; background:var(--panel-2); color:var(--text-dim);
  display:flex; align-items:center; justify-content:center;
}
.sheet-close svg { width:16px; height:16px; }
.sheet-content {
  flex:1; min-height:0; overflow-y:auto; overscroll-behavior-y:contain; -webkit-overflow-scrolling:touch;
  padding:8px 20px calc(env(safe-area-inset-bottom) + 24px);
}

/* Toast */
.toast-root {
  position:fixed; left:0; right:0; z-index:60; pointer-events:none; display:flex; justify-content:center;
  bottom:calc(var(--bottom-chrome) + 14px);
}
.toast {
  max-width:calc(100% - 40px); padding:11px 18px; border-radius:22px; font-size:14px; font-weight:500;
  background:rgba(32,32,36,0.92); border:1px solid rgba(255,255,255,0.08); color:var(--text);
  -webkit-backdrop-filter:blur(20px); backdrop-filter:blur(20px);
  box-shadow:0 8px 24px rgba(0,0,0,0.4);
  opacity:0; transform:translateY(8px) scale(.98);
  transition:opacity 200ms var(--curve), transform 200ms var(--curve);
}
.toast.in { opacity:1; transform:none; }

/* Gate */
.gate {
  position:fixed; inset:0; z-index:100; background:var(--bg);
  display:flex; align-items:center; justify-content:center;
  padding:calc(env(safe-area-inset-top) + 24px) 28px calc(env(safe-area-inset-bottom) + 24px);
  background-image:radial-gradient(120% 60% at 50% 0%, rgba(208,158,82,0.12), transparent 70%);
  overflow-y:auto;
}
.gate-inner { width:100%; max-width:340px; display:flex; flex-direction:column; align-items:stretch; gap:12px; text-align:center; }
.gate-mark {
  width:84px; height:84px; margin:0 auto 12px; border-radius:24px; background:var(--panel); color:var(--accent);
  display:flex; align-items:center; justify-content:center; border:1px solid var(--border);
  box-shadow:0 12px 34px rgba(208,158,82,0.12);
}
.gate-title { font-size:28px; font-weight:700; letter-spacing:-0.02em; }
.gate-sub { color:var(--text-dim); margin:0 0 12px; }
.gate-or { display:flex; align-items:center; gap:12px; color:var(--text-faint); font-size:13px; margin:6px 0 2px; }
.gate-or::before, .gate-or::after { content:""; flex:1; height:1px; background:var(--border); }
.gate-input {
  width:100%; min-height:48px; padding:0 14px; font-size:16px; border-radius:var(--radius);
  background:var(--panel); border:1px solid var(--border); outline:none; color:var(--text); text-align:center;
}
.gate-input:focus { border-color:var(--accent); }
.gate-input::placeholder { color:var(--text-faint); }
.gate-err { min-height:20px; font-size:14px; color:var(--danger); }
.gate-fade { animation:sh-fade 260ms var(--curve); }
@keyframes sh-fade { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

@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; }
  .pressable:active { transform:none; }
  .ptr-spinner.spinning svg { animation:sh-spin 1.2s linear infinite !important; animation-duration:1.2s !important; animation-iteration-count:infinite !important; }
}
