:root{
  --bg:#0b0f1a;
  --panel:rgba(255,255,255,.05);
  --panel-2:rgba(255,255,255,.09);
  --line:rgba(205,218,245,.14);
  --line-2:rgba(205,218,245,.30);
  --text:#eef1f8;
  --text-2:#aab4c8;
  --text-3:#7f8aa3;
  --text-4:#525c74;
  --accent:#8fb4e8;
  --accent-2:#5f8fd1;
  --gold:#e8c468;
  --moon:#efeadb;
  --shadow:#12182a;
  --slate:#060912;
  --sans:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  --serif:'Instrument Serif',Georgia,'Times New Roman',serif;
  --mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
*{margin:0;padding:0;box-sizing:border-box}
[hidden]{display:none !important}
body.boot *{transition:none !important; animation:none !important}
html,body{height:100%}
body{
  background:var(--bg); color:var(--text); font-family:var(--sans);
  -webkit-font-smoothing:antialiased;
  background-image:radial-gradient(130% 95% at 50% -10%, #141c33 0%, #0e1322 50%, #07090f 100%);
  background-attachment:fixed;
}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px}
button{font-family:inherit; color:inherit; background:none; border:none}
input{font-family:inherit; color:inherit}

.page{display:flex; flex-direction:column; min-height:100vh}

/* ---------- top bar ---------- */
.bar{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:max(14px, env(safe-area-inset-top)) 20px 0; flex:none;
}
.home,.icon{
  display:inline-flex; align-items:center; gap:7px; height:38px;
  color:var(--text); text-decoration:none; font:500 14px/1 var(--sans);
  background:var(--panel); border:1px solid var(--line); border-radius:999px;
  cursor:pointer; transition:background .15s, border-color .15s;
}
.home{padding:0 14px 0 10px}
.home span{font-family:var(--serif); font-size:18px; letter-spacing:.01em}
.icon{width:38px; justify-content:center; padding:0}
.home:hover,.icon:hover{background:var(--panel-2); border-color:var(--line-2)}

/* ---------- layout ---------- */
main{
  flex:1; display:grid; grid-template-columns:minmax(0,1fr) 316px;
  gap:24px; padding:10px 20px max(22px, env(safe-area-inset-bottom));
  align-items:start; align-content:start;
  width:100%; max-width:1148px; margin:0 auto;
}
.stage{display:flex; flex-direction:column; gap:14px; min-width:0}
.titleblock{max-width:680px; padding:6px 2px 2px}
.kicker{font-size:11.5px; font-weight:600; letter-spacing:.15em; text-transform:uppercase; color:var(--text-3)}
h1{
  font-family:var(--serif); font-weight:400; font-size:clamp(34px, 4.4vw, 58px);
  line-height:.98; letter-spacing:-.01em; margin:4px 0 8px;
}
.sub{font-size:14.5px; line-height:1.55; color:var(--text-2); max-width:64ch}
.sub em{color:var(--text); font-style:italic; font-family:var(--serif); font-size:17.5px}
.sub b{font-weight:600; color:var(--text)}
.lbl{font-size:11px; font-weight:600; letter-spacing:.12em; text-transform:uppercase; color:var(--text-3)}

/* ---------- composer ---------- */
.composer{display:flex; flex-direction:column; gap:10px}
.chips{display:flex; flex-wrap:wrap; gap:7px}
.chip{
  padding:6px 12px; border-radius:999px; background:var(--panel); border:1px solid var(--line);
  font:600 12.5px/1 var(--sans); color:var(--text-2); cursor:pointer;
  transition:background .14s, border-color .14s, color .14s;
}
.chip:hover{background:var(--panel-2); border-color:var(--line-2); color:var(--text)}
.chip.active{background:rgba(143,180,232,.18); border-color:rgba(143,180,232,.55); color:var(--accent)}

.controlsRow{display:flex; flex-wrap:wrap; align-items:end; gap:8px}
.field{display:flex; flex-direction:column; gap:5px; flex:1 1 150px; min-width:0}
.field.narrow{flex:0 1 108px}
.flbl{font-size:10.5px; font-weight:600; letter-spacing:.1em; text-transform:uppercase; color:var(--text-3)}
.field input{
  height:42px; padding:0 12px; border-radius:11px;
  background:var(--panel); border:1px solid var(--line); color:var(--text);
  font:500 14.5px/1 var(--mono); width:100%;
}
.field input:focus{border-color:var(--accent-2)}
.field input::-webkit-calendar-picker-indicator{filter:invert(.8)}

.btn{
  display:flex; align-items:center; justify-content:center; text-align:center; gap:8px;
  padding:0 14px; height:42px; border-radius:11px; cursor:pointer; flex:none;
  background:var(--panel-2); border:1px solid var(--line);
  font:600 13px/1 var(--sans); color:var(--text-2); white-space:nowrap;
  transition:background .14s, border-color .14s, transform .08s, color .14s;
}
.btn:hover{background:rgba(255,255,255,.14); border-color:var(--line-2); color:var(--text)}
.btn:active{transform:translateY(1px)}
.btn.primary{background:var(--accent-2); border-color:var(--accent-2); color:#081021}
.btn.primary:hover{background:var(--accent); border-color:var(--accent)}
.status{font-size:11.5px; line-height:1.5; color:var(--text-3); min-height:1.3em; max-width:60ch}

/* ---------- chart ---------- */
.slate{
  position:relative; width:100%; overflow:hidden; border-radius:14px;
  background:var(--slate); border:1px solid var(--line);
  box-shadow:0 22px 46px -30px #000, 0 1px 0 rgba(255,255,255,.04) inset;
}
#chart{display:block; width:100%; height:300px; cursor:pointer; touch-action:manipulation}
#chart:focus-visible{outline:2px solid var(--gold); outline-offset:3px}
.caption{font-size:12px; color:var(--text-3); display:flex; align-items:center; gap:14px; flex-wrap:wrap}
.dot{display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:5px; vertical-align:middle}
.dot.rise{background:var(--accent)}
.dot.gap{background:none; border:1.5px dashed var(--text-4)}
.dot.twice{background:var(--gold)}

/* ---------- panel ---------- */
.panel{
  display:flex; flex-direction:column; gap:14px; position:sticky; top:12px;
  background:var(--panel); border:1px solid var(--line); border-radius:16px;
  padding:14px 15px 13px;
}
.readout{
  border-radius:11px; padding:12px 13px; border:1px solid var(--line);
  background:var(--panel-2);
}
.rdate{display:block; font:400 21px/1.15 var(--serif); color:var(--text); margin-bottom:9px}
.rgrid{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:10px}
.rlbl{font-size:10.5px; font-weight:600; letter-spacing:.1em; text-transform:uppercase; color:var(--text-3); margin-bottom:2px}
.rval{font:600 16px/1.2 var(--mono); color:var(--text)}
.rphase{display:flex; align-items:center; gap:9px; padding-top:9px; border-top:1px solid var(--line); font-size:12.5px; color:var(--text-2)}
#phaseIcon{flex:none; border-radius:50%}

.grp{display:flex; flex-direction:column; gap:8px}
.daylist{display:flex; flex-direction:column; gap:2px; max-height:300px; overflow-y:auto; border-radius:9px}
.dayrow{
  display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:8px;
  cursor:pointer; text-align:left; font-size:12.5px; color:var(--text-2);
  border:1px solid transparent; transition:background .12s, border-color .12s;
}
.dayrow:hover{background:var(--panel-2)}
.dayrow.sel{background:rgba(143,180,232,.14); border-color:rgba(143,180,232,.45); color:var(--text)}
.dayrow .dname{flex:1 1 auto; font-family:var(--mono)}
.dayrow .dtime{font-family:var(--mono); color:var(--text-3); white-space:nowrap}
.dayrow.sel .dtime{color:var(--accent)}
.dayrow .dmini{width:13px; height:13px; border-radius:50%; flex:none}
.dayrow.none .dtime{color:var(--text-4); font-style:italic}

.foot{font-size:11.5px; line-height:1.6; color:var(--text-3); border-top:1px solid var(--line); padding-top:12px}
.link{color:var(--accent); cursor:pointer; font:inherit; font-weight:600; text-align:left; text-decoration:underline; text-underline-offset:2px}
.link:hover{color:#b6d0f3}

/* ---------- about ---------- */
dialog{border:none; padding:0; background:transparent; max-width:min(700px, 92vw); max-height:86vh; margin:auto}
dialog::backdrop{background:rgba(5,7,12,.7); backdrop-filter:blur(3px)}
.about{
  position:relative; background:#10151f; border:1px solid var(--line);
  border-radius:18px; padding:26px 28px 24px; overflow-y:auto; max-height:86vh;
  box-shadow:0 30px 60px -28px #000;
}
.about h2{font-family:var(--serif); font-weight:400; font-size:30px; line-height:1.08; margin:4px 0 14px; color:var(--text)}
.about h3{font-family:var(--serif); font-weight:400; font-size:20px; line-height:1.1; margin:20px 0 10px; color:var(--text)}
.about p{font-size:14.5px; line-height:1.68; color:var(--text-2); margin-bottom:12px}
.about p b{color:var(--text); font-weight:600}
.about p i{font-style:italic; color:var(--text)}
.about .fine{font-size:12.5px; color:var(--text-3); border-top:1px solid var(--line); padding-top:12px; margin-top:4px; margin-bottom:0}
.x{
  position:absolute; top:14px; right:14px; width:32px; height:32px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; color:var(--text-3);
  background:var(--panel-2); border:1px solid var(--line); border-radius:999px;
}
.x:hover{color:var(--text); border-color:var(--line-2)}

/* ---------- narrow ---------- */
@media (max-width:920px){
  main{grid-template-columns:minmax(0,1fr); gap:16px; padding:8px 14px max(20px, env(safe-area-inset-bottom))}
  .panel{position:static}
  h1{font-size:clamp(28px, 7.6vw, 40px)}
  .sub{font-size:14px}
  #chart{height:230px}
  .daylist{max-height:220px}
  .about{padding:22px 20px 20px; border-radius:15px}
  .about h2{font-size:25px}
  .about h3{font-size:18px}
}
@media (max-width:420px){
  .controlsRow{flex-direction:column; align-items:stretch}
  .field,.field.narrow{flex:none}
  .btn.primary{width:100%}
}
@media (prefers-reduced-motion: reduce){
  *{transition:none !important; animation:none !important}
}
