:root {
  --bg: #eceff5; --surface: #fff; --ink: #151b2c; --muted: #55607a; --line: #d3dae6;
  --on: #ffd04d; --off: #26304a; --maybe: #8d93a6; --now: #d1242f; --accent: #2352c4; --warn-bg: #fff1c9; --warn-ink: #5b4100;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c101a; --surface: #161c2a; --ink: #eef1f8; --muted: #a0abc2; --line: #2b3448;
    --on: #e8b440; --off: #35405e; --maybe: #8a8270; --now: #ff6b6b; --accent: #9dbbff; --warn-bg: #3a2e10; --warn-ink: #ffe3a0;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0 auto; max-width: 920px; padding: 16px 16px 40px; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .875rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.top h1 { font-size: 1.35rem; letter-spacing: -.01em; }
.pickers { display: flex; gap: 8px; flex: 1 1 300px; max-width: 440px; }
.pickers label { flex: 2; min-width: 0; }
.pickers label + label { flex: 1; }
.pickers span { display: block; font-size: .75rem; color: var(--muted); }
select, button { font: inherit; color: inherit; }
select { width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

section { background: var(--surface); border-radius: var(--r); padding: 18px; margin-bottom: 12px; }
.alert { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r); padding: 12px 18px; margin-bottom: 12px; }

/* Стан: вікно, у якому горить або не горить світло */
.status { display: flex; gap: 18px; align-items: center; }
.lamp { flex: none; width: 56px; height: 68px; border-radius: 8px; border: 3px solid var(--off);
  background: linear-gradient(var(--off), var(--off)) center / 3px 100% no-repeat, linear-gradient(var(--off), var(--off)) center / 100% 3px no-repeat, var(--surface); }
.status[data-state="0"] .lamp { background-color: var(--on); }
.status[data-state="1"] .lamp { background-color: var(--off); background-image: linear-gradient(var(--surface), var(--surface)), linear-gradient(var(--surface), var(--surface)); }
.status[data-state="2"] .lamp { background-image: repeating-linear-gradient(135deg, var(--on) 0 6px, var(--off) 6px 12px); background-size: auto; }
.state { font-size: clamp(1.45rem, 6vw, 2rem); font-weight: 700; line-height: 1.15; letter-spacing: -.015em; }
.next { margin-top: 4px; font-size: 1.05rem; }

.mine { display: grid; gap: 22px; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-bottom: 8px; }
.spans { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.spans li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; }
.spans li small { font-weight: 400; color: var(--muted); font-size: .875rem; }
.spans li.past { opacity: .75; text-decoration: line-through; text-decoration-thickness: 1px; }
.spans li.current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* Смуга доби */
.bar { position: relative; display: block; height: 40px; }
/* позиція точно за часом; проміжок 2px — рамка кольору поверхні всередині сегмента */
.seg { position: absolute; top: 0; bottom: 0; border-radius: 5px; border: 0 solid transparent; border-width: 0 1px; background: var(--on); background-clip: padding-box !important; }
.seg.off { background: var(--off); }
.seg.maybe { background: repeating-linear-gradient(135deg, var(--on) 0 4px, var(--off) 4px 8px); }
.nowline { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--now); pointer-events: none; box-shadow: 0 0 0 1.5px var(--surface); }
.axis { position: relative; height: 1.2em; margin-top: 4px; font-size: .75rem; color: var(--muted); }
.axis span { position: absolute; transform: translateX(-50%); }
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }

.news li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.news li:first-child { border: 0; }

.all-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.tabs { display: flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--bg); }
.tabs button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0 / .18); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0; font-size: .875rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.k { width: 16px; height: 12px; border-radius: 3px; background: var(--on); }
.k.off { background: var(--off); }
.k.maybe { background: repeating-linear-gradient(135deg, var(--on) 0 3px, var(--off) 3px 6px); }

.matrix { --lab: 46px; }
.row { display: grid; grid-template-columns: var(--lab) 1fr; align-items: center; width: 100%; min-height: 32px; padding: 3px 8px 3px 0; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.row b { padding-left: 8px; font-weight: 500; }
.row .bar { height: 22px; }
.row .nowline { top: -5px; bottom: -5px; }
.row:hover { background: var(--bg); }
.row[aria-pressed="true"] { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.row[aria-pressed="true"] b { font-weight: 700; }
.matrix .axis { margin: 4px 8px 0 var(--lab); }

.tip { position: fixed; z-index: 2; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: .875rem; pointer-events: none; white-space: nowrap; }
.center { padding: 48px 16px; text-align: center; }
.center button { margin-top: 12px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--accent); color: var(--surface); cursor: pointer; }
footer { padding: 6px 18px; }
.support { margin-top: 20px; text-align: center; font-size: .875rem; color: var(--muted); }
.support a { color: var(--accent); font-weight: 600; }
@media (max-width: 480px) { body { padding: 12px 12px 32px; } section { padding: 14px; } .matrix { --lab: 40px; } }
@media (forced-colors: active) { .seg, .k, .lamp, .nowline { forced-color-adjust: none; } }
