/* ── Antaraav — calm dark theme ───────────────────────────── */
:root {
  --bg: #0e1220;
  --bg2: #161b2e;
  --card: #1b2138;
  --card2: #232a45;
  --text: #e8eaf2;
  --muted: #9aa3bd;
  --accent: #8b7cf6;
  --accent2: #5eead4;
  --gold: #f5c26b;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }

/* ── Access gate ───────────────────────────────────────── */
#gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2340 0%, #0e1220 60%);
}
html[data-unlocked] #gate { display: none; }        /* returning visitor: no flash */
body.locked { overflow: hidden; }                    /* block scroll while gated */
.gate-card {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--card); border: 1px solid #2a3252;
  border-radius: var(--radius); padding: 32px 24px 24px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.gate-logo { font-size: 2.6rem; }
.gate-card h1 { font-size: 1.5rem; letter-spacing: .5px; }
.gate-card .muted { font-size: .9rem; line-height: 1.4; }
#gate-input {
  width: 100%; text-align: center; font-size: 1.05rem;
  background: var(--card2); color: var(--text);
  border: 1px solid #343d63; border-radius: 12px; padding: 13px;
}
#gate-input:focus { outline: none; border-color: var(--accent); }
.gate-card .btn { width: 100%; }
.gate-error { color: #f38ba8; font-size: .85rem; min-height: 1em; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2340 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 84px;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 6px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.logo { font-weight: 700; letter-spacing: .5px; font-size: 1.05rem; }
.topright { display: flex; align-items: center; gap: 12px; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; }
.gear { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 2px 4px; line-height: 1; }
.gear:active { color: var(--accent2); }

main { padding: 8px 16px 24px; max-width: 560px; margin: 0 auto; }
h1 { font-size: 1.5rem; margin: 10px 0 4px; }
h2 { font-size: 1.02rem; margin-bottom: 8px; }
.sub { color: var(--muted); margin-bottom: 16px; }
.muted { color: var(--muted); font-size: .88rem; }

.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.card {
  background: var(--card);
  border: 1px solid #2a3153;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.plan-card { background: linear-gradient(135deg, #232a55, #1b2138); }
.plan { list-style: none; counter-reset: n; }
.plan li { counter-increment: n; display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #2a3153; }
.plan li:last-child { border-bottom: 0; }
.plan li::before { content: counter(n); color: var(--accent2); font-weight: 700; min-width: 18px; }
.linklike { background: none; border: 0; color: var(--text); font-size: .98rem; text-align: left; cursor: pointer; padding: 0; }
.linklike:active { color: var(--accent2); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.quick { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); font-size: .95rem; cursor: pointer; padding: 18px 10px; }
.quick .big { font-size: 1.9rem; }
.quick:active { background: var(--card2); }

.btn {
  border: 0; border-radius: 12px; padding: 12px 18px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  color: #101425; background: var(--accent2);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid #343d63; font-weight: 500; }
.btn.wide { width: 100%; margin-bottom: 14px; }
.btn:active { filter: brightness(1.15); }
.btn.danger { background: #e5484d; color: #fff; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid #2a3153; border-radius: var(--radius);
  padding: 14px; cursor: pointer; color: var(--text); text-align: left; width: 100%;
}
.item:active { background: var(--card2); }
.item .emoji { font-size: 1.7rem; }
.item .body { flex: 1; }
.item .title { font-weight: 600; }
.item .sub2 { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.item .chev { color: var(--muted); }
.item.playing { border-color: var(--accent2); }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid #2a3153; background: var(--card); color: var(--muted); font-weight: 600; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* Mala */
.mala-card { text-align: center; }
.mala-bead {
  display: block; margin: 12px auto; width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a3263, #241f45);
  border: 2px solid var(--accent); color: var(--text);
  font-size: 2rem; cursor: pointer; transition: transform .08s;
}
.mala-bead:active { transform: scale(.93); }
.mala-bead span { display: block; font-size: 1.3rem; font-weight: 700; color: var(--gold); }

/* Breath coach modal */
dialog {
  border: 0; border-radius: 20px; background: var(--bg2); color: var(--text);
  width: min(92vw, 480px); padding: 0; margin: auto;
}
dialog::backdrop { background: rgba(5,8,18,.75); backdrop-filter: blur(3px); }
.modal-inner { padding: 22px; }
.modal-inner h2 { font-size: 1.25rem; margin-bottom: 4px; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.steps { margin: 12px 0 12px 18px; display: flex; flex-direction: column; gap: 8px; }
.kv { margin: 10px 0; }
.kv b { color: var(--accent2); }
.devanagari { font-size: 1.35rem; line-height: 1.9; color: var(--gold); margin: 10px 0; }

/* Settings controls */
.sel {
  width: 100%; background: var(--card2); color: var(--text);
  border: 1px solid #343d63; border-radius: 10px; padding: 11px; font-size: 1rem;
  margin: 6px 0 4px; color-scheme: dark;
}
.setlabel { display: block; color: var(--muted); font-size: .9rem; margin: 14px 0 4px; }
.setlabel.row { display: flex; align-items: center; gap: 10px; }
.setlabel.row input { width: 18px; height: 18px; accent-color: var(--accent); }

.breath-stage { text-align: center; padding: 10px 0 4px; }
.breath-circle {
  width: 170px; height: 170px; margin: 18px auto; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #6d5ef0, #2c2670);
  box-shadow: 0 0 60px #6d5ef055;
  transition: transform linear;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 700; color: #fff;
}
.breath-label { font-size: 1.15rem; font-weight: 600; min-height: 1.5em; }
.breath-round { color: var(--muted); margin-top: 6px; }

/* Sequence player */
.seq-pose { text-align: center; padding: 8px 0; }
.seq-pose .emoji { font-size: 3.4rem; display: block; margin-bottom: 6px; }
.seq-timer { font-size: 2.4rem; font-weight: 700; color: var(--accent2); font-variant-numeric: tabular-nums; }
.seq-progress { height: 6px; background: var(--card2); border-radius: 3px; margin: 14px 0; overflow: hidden; }
.seq-progress i { display: block; height: 100%; background: var(--accent2); width: 0%; transition: width .5s linear; }
.player-controls { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

/* Sounds */
.timer-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.timer-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* Sleep form */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .9rem; }
.form input { background: var(--card2); border: 1px solid #343d63; border-radius: 10px; padding: 10px; color: var(--text); font-size: 1rem; color-scheme: dark; }
.stars { display: flex; gap: 4px; }
.stars button { background: none; border: 0; font-size: 1.7rem; color: #3a4166; cursor: pointer; padding: 2px; }
.stars button.on { color: var(--gold); }

/* Chart */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bar i { width: 100%; border-radius: 6px 6px 0 0; background: var(--accent); min-height: 4px; }
.chart .bar.good i { background: var(--accent2); }
.chart .bar.bad i { background: #e5484d; }
.chart .bar small { color: var(--muted); font-size: .68rem; }
.chart .bar b { font-size: .72rem; color: var(--text); }

.tips { margin-left: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: .92rem; }
.tips a { color: var(--accent2); }

.hist-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; border-bottom: 1px dashed #2a3153; font-size: .9rem; }
.hist-row .del { background: none; border: 0; color: #e5484d; cursor: pointer; font-size: 1rem; }

/* Bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: rgba(14,18,32,.92); backdrop-filter: blur(10px);
  border-top: 1px solid #232a45;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.navbtn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 1.25rem; padding: 4px 10px; border-radius: 10px;
}
.navbtn span { font-size: .68rem; font-weight: 600; }
.navbtn.active { color: var(--accent2); }

@media (min-width: 700px) {
  .grid2 { grid-template-columns: repeat(4, 1fr); }
}
