:root {
  --bg: #F1F4F2; --surface: #FFFFFF; --ink: #15282E; --muted: #5A6C70; --line: #D7E0DC;
  --sun: #D98E0B; --bat: #23895C; --load: #2774A6; --grid: #6550CF; --warn: #C2462F;
  --sun-soft: #F7E3BC; --bat-soft: #CDEBDD; --load-soft: #D3E5F2; --grid-soft: #E0DBF7;
  --sky1: #2D6E9E; --sky2: #8CC3E3; --sky-ink: #FFFFFF;
  --display: "Bricolage Grotesque", "Hind Siliguri", system-ui, sans-serif;
  --body: "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-lg: 22px; --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1A1E; --surface: #13252B; --ink: #E4ECEA; --muted: #8FA3A4; --line: #22393F;
    --sun: #F2AE3A; --bat: #3DBA84; --load: #52A6DA; --grid: #9886F2; --warn: #EE7A5F;
    --sun-soft: #3A2E15; --bat-soft: #163829; --load-soft: #15303F; --grid-soft: #27234A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1A1E; --surface: #13252B; --ink: #E4ECEA; --muted: #8FA3A4; --line: #22393F;
  --sun: #F2AE3A; --bat: #3DBA84; --load: #52A6DA; --grid: #9886F2; --warn: #EE7A5F;
  --sun-soft: #3A2E15; --bat-soft: #163829; --load-soft: #15303F; --grid-soft: #27234A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.6 var(--body); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.88rem; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 14px; z-index: 9; border-radius: 8px; }
.skip:focus { left: 8px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- sky hero ---------- */
.sky { position: relative; overflow: hidden; color: var(--sky-ink);
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 100%); transition: background 2s; }
.arc { position: absolute; inset: 70px 0 30px 0; width: 100%; height: calc(100% - 100px); pointer-events: none; }
.arc path { stroke: currentColor; stroke-opacity: .28; stroke-width: 1.5; stroke-dasharray: 3 7; vector-effect: non-scaling-stroke; }
.sun { position: absolute; width: 74px; height: 74px; margin: -37px 0 0 -37px; border-radius: 50%; left: 50%; top: 40%;
  background: radial-gradient(circle, #FFF7DA 0 30%, #FFD36B 46%, rgba(255, 196, 70, .35) 62%, rgba(255, 196, 70, 0) 72%);
  transition: left 1.5s, top 1.5s, opacity 1.5s; }
.sun.moon { background: radial-gradient(circle, #F4F1E6 0 26%, rgba(244, 241, 230, .2) 40%, rgba(244, 241, 230, 0) 60%); }
.top { position: relative; display: flex; justify-content: space-between; align-items: center; padding-top: 18px; padding-bottom: 18px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 600 1.05rem var(--display); min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; flex: none; background: url(/icon.svg) center/cover; }
.tools { display: flex; gap: 8px; flex: none; }
.chip { border: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 35%, transparent);
  background: color-mix(in srgb, currentColor 8%, transparent); border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: .92rem; line-height: 1.4; }
.chip.icon { padding: 5px 11px; }
.chip:hover { background: color-mix(in srgb, currentColor 16%, transparent); }
.hero { position: relative; padding-top: 4vh; padding-bottom: 96px; }
.place { margin: 0 0 10px; opacity: .85; font-size: .98rem; }
.status { font-size: clamp(2rem, 5.4vw, 3.9rem); font-weight: 800; max-width: 17ch; letter-spacing: -0.025em; text-wrap: balance; }
.sub { margin: 14px 0 0; font-size: 1.08rem; max-width: 52ch; opacity: .92; }
.now { display: flex; flex-wrap: wrap; gap: 14px 44px; margin: 36px 0 0; }
.now div { min-width: 0; }
.now dt { font-size: .9rem; opacity: .82; }
.now dd { margin: 0; font: 600 clamp(1.5rem, 3vw, 2.1rem)/1.1 var(--display); font-variant-numeric: tabular-nums; }
.sky.dim .sun { opacity: .9; }
.ground { position: absolute; left: -10%; right: -10%; bottom: -1px; height: 64px; background: var(--bg);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0; }

/* ---------- blocks ---------- */
main { padding-bottom: 40px; }
.block { padding: 34px 0; border-top: 1px solid var(--line); }
.block:first-child { border-top: 0; padding-top: 6px; }
.block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 10px 20px; margin-bottom: 20px; }
.block .chip { color: var(--ink); }

/* flow diagram */
.flow { background: var(--surface); border-radius: var(--r-lg); padding: 10px; }
#flowSvg { display: block; width: 100%; height: auto; max-height: 420px; }
.wires path { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; }
.pulse { fill: none; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 22; opacity: 0; transition: opacity .6s; }
.pulse.on { opacity: 1; animation: flow var(--dur, 2s) linear infinite; }
.pulse.rev { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -24; } }
.sun-c { stroke: var(--sun); color: var(--sun); } .bat-c { stroke: var(--bat); color: var(--bat); }
.load-c { stroke: var(--load); color: var(--load); } .grid-c { stroke: var(--grid); color: var(--grid); }
.ring { fill: var(--bg); stroke: var(--line); stroke-width: 2; }
.sun-r { fill: var(--sun-soft); stroke: none; } .bat-r { fill: var(--bat-soft); stroke: none; }
.load-r { fill: var(--load-soft); stroke: none; } .grid-r { fill: var(--grid-soft); stroke: none; }
.glyph { fill: currentColor; stroke: none; }
.glyph .thin { fill: none; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.glyph rect.thin { fill: none; }
.node text { text-anchor: middle; fill: var(--ink); }
.lbl { font: 500 15px var(--body); fill: var(--muted) !important; }
.val { font: 600 20px var(--display); font-variant-numeric: tabular-nums; }
.hub-t { font: 800 17px var(--display); letter-spacing: .06em; }
.hub-s { font: 500 13px var(--body); fill: var(--muted) !important; }
.node.off .ring { opacity: .45; } .node.off .glyph { opacity: .35; }

/* today */
.today { display: grid; grid-template-columns: 190px 1fr; gap: 28px; align-items: center; }
.ring-box { position: relative; width: 170px; height: 170px; }
.ss-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ss-ring circle { fill: none; stroke-width: 11; }
.ss-ring .track { stroke: var(--line); }
.ss-ring .fill { stroke: var(--bat); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 1.2s; }
.ring-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.2; }
.ring-txt b { font: 800 2.3rem var(--display); }
.ring-txt span { font-size: .85rem; color: var(--muted); }
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 28px; margin: 0; }
.figures.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; }
.figures dt { color: var(--muted); font-size: .92rem; }
.figures dd { margin: 2px 0 0; font: 600 1.6rem/1.15 var(--display); font-variant-numeric: tabular-nums; }
.figures small { display: block; color: var(--muted); font-size: .85rem; }
.up { color: var(--bat); } .down { color: var(--warn); }

/* charts */
.day-pick { display: flex; gap: 6px; align-items: center; }
.day-pick input { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -6px 0 12px; font-size: .9rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.chart { position: relative; width: 100%; }
.chart.tall { height: 300px; } .chart.short { height: 130px; margin-top: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 4px 13px; border-radius: 999px; cursor: pointer; font-size: .92rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* grid timeline */
.timeline { position: relative; height: 34px; border-radius: 8px; background: repeating-linear-gradient(90deg, var(--line) 0 2px, transparent 2px 8px); overflow: hidden; }
.timeline span { position: absolute; top: 0; bottom: 0; }
.timeline .ok { background: var(--grid-soft); }
.timeline .cut { background: var(--warn); }
.timeline .nowline { width: 2px; background: var(--ink); }
.tl-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* impact */
.impact-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 26px; align-items: end; }
.impact-grid .n { font: 800 clamp(2rem, 4vw, 2.9rem)/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.impact-grid .big .n { font-size: clamp(3.2rem, 8vw, 5.6rem); color: var(--sun); }
.impact-grid .u { margin-left: 6px; color: var(--muted); font-weight: 500; }
.impact-grid p { margin: 6px 0 0; color: var(--muted); font-size: .95rem; max-width: 26ch; }
.records { list-style: none; padding: 0; margin: 30px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.records li { background: var(--surface); border-radius: 999px; padding: 6px 16px; font-size: .93rem; }
.records b { font-weight: 600; }

/* weather */
.wx { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.wx-day { background: var(--surface); border-radius: var(--r-lg); padding: 18px 20px; }
.wx-day h3 { font-size: 1.05rem; display: flex; justify-content: space-between; gap: 8px; }
.wx-day .ico { font-size: 1.6rem; line-height: 1; }
.wx-day .est { font: 800 2rem/1.1 var(--display); color: var(--sun); margin-top: 12px; font-variant-numeric: tabular-nums; }
.wx-day .est small { font: 500 .9rem var(--body); color: var(--muted); margin-left: 4px; }
.wx-day p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.sunbar { position: relative; height: 6px; border-radius: 3px; background: var(--line); margin-top: 14px; }
.sunbar i { position: absolute; top: -4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--sun); }
.sunbar b { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--sun-soft); }
.sun-times { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* specs + about */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.two h2 { margin-bottom: 16px; }
.specs { margin: 0; }
.specs div { display: grid; grid-template-columns: 11rem 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }
.about { margin: 0 0 14px; max-width: 60ch; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 20px; padding-top: 22px; padding-bottom: 40px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }
.foot-links { display: flex; gap: 18px; }
.hide { display: none !important; }

/* stale data */
body.stale .now dd, body.stale .val { opacity: .6; }

/* wall display */
body.tv .block:not(.flow-block), body.tv .foot, body.tv .tools { display: none; }
body.tv .hero { padding-bottom: 70px; }
body.tv .status { font-size: clamp(2.4rem, 6vw, 5rem); }

@media (max-width: 860px) {
  .today { grid-template-columns: 1fr; justify-items: start; }
  .figures, .figures.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .impact-grid { grid-template-columns: 1fr 1fr; }
  .impact-grid .big { grid-column: 1 / -1; }
  .wx { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .specs div { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .hero { padding-bottom: 80px; }
  .now { gap: 12px 28px; }
  .chart.tall { height: 250px; }
  .block-head { margin-bottom: 14px; }
  .val { font-size: 30px; transform: translateY(12px); } .lbl { font-size: 24px; } .hub-s { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse.on { animation: none; stroke-dasharray: none; opacity: .75; }
  .sky, .sun, .ss-ring .fill { transition: none; }
}
.hero { text-shadow: 0 1px 14px rgba(10, 30, 50, .22); }
@media (max-width: 520px) {
  .arc { inset: 56px 0 auto 0; height: 46%; }
  .sun { width: 50px; height: 50px; margin: -25px 0 0 -25px; opacity: .8; }
}
