:root {
  --bg: #0b1026; --card: #161c3a; --card2: #1d2450; --ink: #e8eaf6;
  --dim: #9aa3c7; --accent: #ffd166; --accent2: #7c8cf8; --danger: #ff6b81;
  --deep: #3a4fb0; --rem: #9b6bf3; --light: #6fc3df; --awake: #ff6b81;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }
body { padding-bottom: 76px; }
.view { max-width: 560px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }
.app-head h1 { margin: 8px 0 2px; font-size: 28px; }
.sub { color: var(--dim); margin: 0 0 12px; font-size: 14px; line-height: 1.4; }
.card { background: var(--card); border-radius: 14px; padding: 16px; margin: 0 0 14px; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.field { display: block; margin: 0 0 14px; font-size: 14px; color: var(--dim); }
.field input, .field select { display: block; width: 100%; margin-top: 6px; padding: 12px;
  font-size: 17px; border-radius: 10px; border: 1px solid #2c3565; background: var(--card2); color: var(--ink); }
.btn { appearance: none; border: 1px solid #2c3565; background: var(--card2); color: var(--ink);
  padding: 12px 18px; border-radius: 12px; font-size: 16px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #231a00; font-weight: 700; }
.btn.big { display: block; width: 100%; margin: 10px 0; padding: 16px; font-size: 18px; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.chip { flex: 1; padding: 12px 6px; font-size: 14px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; }
.hint { color: var(--dim); font-size: 13px; line-height: 1.45; }
.banner { background: #5b2333; color: #ffd9de; padding: 12px 16px; display: flex;
  gap: 10px; align-items: center; justify-content: space-between; font-size: 14px; }
.banner-note { background: #243064; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink); }

/* tab bar */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; z-index: 40;
  background: rgba(13,17,40,.96); border-top: 1px solid #232a52; padding-bottom: env(safe-area-inset-bottom); }
#tabbar .tab { flex: 1; background: none; border: none; color: var(--dim); font-size: 14px; padding: 14px 0; cursor: pointer; }
#tabbar .tab.active { color: var(--accent); font-weight: 700; }

/* night screen: intentionally very dim */
.view.night { min-height: 100vh; max-width: none; background: #04060f; color: #39406b;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.night-clock { font-size: 84px; font-weight: 200; color: #4a548a; letter-spacing: 2px; }
.night-phase { font-size: 18px; color: #556099; }
.night-phase strong { color: #7c8cf8; }
.night-info { font-size: 15px; color: #454e7d; }
.night-info.dim { color: #333b63; font-size: 13px; }
.night-activity { font-size: 22px; color: #2e3862; letter-spacing: 6px; }

/* alarm screen */
.view.alarm { min-height: 100vh; max-width: none; text-align: center; padding-top: 18vh; }
body.alarm-flash { animation: flash 1s steps(2) infinite; }
@keyframes flash { 0% { background: #0b1026; } 50% { background: #3d2f05; } }
.alarm-emoji { font-size: 72px; }
.view.alarm h1 { font-size: 34px; margin: 6px 0; }

/* report */
.score-card { text-align: center; }
.score-num { font-size: 64px; font-weight: 800; color: var(--accent); line-height: 1; }
.score-label { color: var(--dim); font-size: 13px; text-transform: uppercase; letter-spacing: 2px; }
.score-parts { color: var(--dim); font-size: 12px; margin-top: 8px; }
.legend { font-size: 12px; color: var(--dim); margin-top: 8px; }
.legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 3px 0 10px; }
.lg.awake { background: var(--awake); } .lg.light { background: var(--light); }
.lg.deep { background: var(--deep); } .lg.rem { background: var(--rem); } .lg.act { background: var(--accent); }
#rep-chart { width: 100%; height: auto; background: #0d1230; border-radius: 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 15px; }
.stat-grid .k { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.stat-grid .v { font-size: 19px; font-weight: 600; }

/* history */
.hist-item { display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 12px; padding: 12px 14px; margin: 0 0 10px; cursor: pointer; }
.hist-item .grow { flex: 1; }
.hist-item .date { font-weight: 600; }
.hist-item .meta { color: var(--dim); font-size: 13px; }
.hist-item .score { font-size: 22px; font-weight: 800; color: var(--accent); }
.hist-item .del { background: none; border: none; color: var(--danger); font-size: 18px; cursor: pointer; }
.demo-tag { font-size: 11px; background: #243064; color: var(--accent2); border-radius: 6px; padding: 2px 6px; margin-left: 6px; }
