:root {
  --bg: #0f1226;
  --bg2: #171a33;
  --card: #1d2140;
  --card2: #252a52;
  --line: #2f3566;
  --text: #eef0ff;
  --muted: #a3a8d1;
  --night: #6f7dff;
  --nap: #b58cff;
  --wake: #ffcf70;
  --plan: #7fe0c4;
  --danger: #ff7a8a;
  --ok: #6fdc9b;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
body { padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom)); min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -200px, #23285a 0%, var(--bg) 60%) fixed; }
main { max-width: 560px; margin: 0 auto; padding: 12px 16px 24px; }
h1 { font-size: 22px; margin: 6px 0 2px; }
h2 { font-size: 17px; margin: 22px 0 10px; color: var(--muted); font-weight: 600; letter-spacing: .2px; }
h3 { font-size: 16px; margin: 0 0 6px; }
p { margin: 6px 0; }
a { color: var(--plan); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 40px 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { height: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }
.card.warn { border-color: #6b4a2a; background: #2b2234; }
.card.alert { border-color: #7a2d3c; background: #33202e; }
.card.info { border-color: #2c5f57; background: #18303a; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px;
  background: var(--card2); color: var(--text); font-size: 16px; font-weight: 600; padding: 14px 16px; cursor: pointer;
  min-height: 48px; width: 100%; }
.btn:active { transform: scale(.98); }
.btn.big { min-height: 64px; font-size: 18px; border-radius: 18px; }
.btn.night { background: linear-gradient(135deg, #4b55d6, #6f7dff); }
.btn.nap { background: linear-gradient(135deg, #8a5ae0, #b58cff); }
.btn.wake { background: linear-gradient(135deg, #e0a53a, #ffcf70); color: #2a1d00; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: #5a2333; color: #ffd6dc; }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; width: auto; }
.btn:disabled { opacity: .5; }
.btns { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin: 12px 0; }
.btns.one { grid-template-columns: 1fr; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 999px; padding: 7px 12px;
  font-size: 14px; cursor: pointer; }
.chip.on { background: var(--plan); color: #072a22; border-color: var(--plan); font-weight: 700; }

/* clock */
.clockwrap { position: relative; width: min(84vw, 330px); margin: 6px auto 0; aspect-ratio: 1; }
.clockwrap svg { width: 100%; height: 100%; display: block; }
.clockcenter { position: absolute; inset: 22%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; }
.clockcenter .big { font-size: 30px; font-weight: 800; letter-spacing: .3px; }
.clockcenter .lbl { font-size: 13px; color: var(--muted); }
.clockcenter .next { margin-top: 6px; font-size: 14px; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.night { background: var(--night); } .dot.nap { background: var(--nap); } .dot.plan { background: var(--plan); }

/* plan list */
.plan { list-style: none; margin: 0; padding: 0; }
.plan li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan li:last-child { border-bottom: 0; }
.plan .ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--bg2); }
.plan .t { font-weight: 700; font-size: 18px; }
.plan .w { font-size: 13px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--bg2); border-radius: 14px; padding: 10px; text-align: center; }
.tile .v { font-weight: 800; font-size: 17px; }
.tile .k { font-size: 12px; color: var(--muted); }

/* history */
.day { margin-top: 16px; }
.dayhead { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.entry { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; margin: 6px 0; cursor: pointer; width: 100%; color: var(--text); text-align: left; font: inherit; }
.entry .ic { font-size: 20px; }
.entry .main { flex: 1; }
.entry .when { font-weight: 700; }
.entry .meta { font-size: 13px; color: var(--muted); }

/* forms */
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 16px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--plan); border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5, 6, 20, .65); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--bg2); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

/* tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(15, 18, 38, .96);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; backdrop-filter: blur(8px); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 9px 0 10px; font-size: 12px; display: flex;
  flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button .ti { font-size: 20px; }
.tabs button.active { color: var(--text); }

.banner { position: sticky; top: 0; background: #5a4520; color: #ffe7b5; text-align: center; padding: 8px 12px; font-size: 14px; z-index: 15; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #2b315f;
  color: var(--text); padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { background: #6a2232; }

.codes { display: grid; grid-template-columns: 1fr; gap: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 15px; margin: 12px 0; }
.codes div { background: var(--bg); padding: 8px; border-radius: 8px; text-align: center; }

.chart svg { width: 100%; height: auto; display: block; }
.logo { font-size: 46px; text-align: center; margin-top: 30px; }
details summary { cursor: pointer; font-weight: 600; }
details ul { padding-left: 18px; }
.a-night { stroke: var(--night); } .a-nap { stroke: var(--nap); } .a-wake { stroke: var(--wake); } .a-plan { stroke: var(--plan); opacity: .85; }
