:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --text: #121826;
  --muted: #6b7385;
  --line: #e4e8f0;
  --blue: #377dff;
  --on: #1f9d55;
  --on-bg: #e7f6ed;
  --off: #e5484d;
  --off-bg: #fdecec;
  --unk: #c9cfdb;
  --ring-on: #7cc576;
  --ring-off: #ef6461;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #182030;
    --text: #eef1f7;
    --muted: #9aa3b5;
    --line: #2a3446;
    --on-bg: #143524;
    --off-bg: #3a1b1d;
    --unk: #3a4558;
    --ring-on: #3f8f4c;
    --ring-off: #c9474a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* Our own pull-to-refresh replaces the browser's. */
html, body { overscroll-behavior-y: contain; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue); }
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 17px; margin: 0; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Pull-to-refresh indicator: hidden above the screen, follows the finger, spins while loading. */
.ptr {
  position: fixed; z-index: 10; top: max(8px, env(safe-area-inset-top)); left: 50%;
  width: 36px; height: 36px; margin-left: -18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.12);
  font-size: 18px; color: var(--muted);
  transform: translateY(-80px); transition: transform .2s ease;
  pointer-events: none;
}
.ptr.dragging { transition: none; }
.ptr-icon { display: inline-block; line-height: 1; transition: transform .15s ease; }
.ptr.ready .ptr-icon { transform: rotate(180deg); color: var(--blue); }
.ptr.loading { transform: translateY(0); }
.ptr.loading .ptr-icon { animation: spin .9s linear infinite; color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.picker-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 13px; }
.queues { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.q {
  padding: 10px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.q[aria-checked="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
@media (max-width: 360px) { .queues { grid-template-columns: repeat(4, 1fr); } }

.status { padding: 10px 12px; }
.status.on { background: var(--on-bg); border-color: transparent; }
.status.off { background: var(--off-bg); border-color: transparent; }
.st-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.st-q {
  flex: none;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 3px 7px; border-radius: 7px; background: var(--blue); color: #fff;
}
.st-main { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.status.on .st-main { color: var(--on); }
.status.off .st-main { color: var(--off); }
.st-badge {
  flex: none;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); color: var(--muted);
}
.st-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.days { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 1 0 auto;
  min-width: 84px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center;
}
.day small { color: var(--muted); font-size: 12px; }
.day.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.day.active small { color: inherit; opacity: .7; }

.radial { margin-top: 14px; }
.radial svg { display: block; width: 100%; max-width: 340px; margin: 0 auto; }
.w-on { fill: var(--ring-on); }
.w-off { fill: var(--ring-off); }
.w-unk { fill: var(--unk); }
.w-past { fill: var(--surface); opacity: .35; }
.w-gap { stroke: var(--surface); stroke-width: 3; }
.w-bulb path { fill: none; stroke: #fff; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.w-now { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.w-label { fill: var(--surface); }
.w-num { fill: var(--text); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.w-center { fill: var(--surface); }
.w-date { fill: var(--text); font-size: 22px; }
.w-queue { fill: var(--text); font-size: 64px; font-weight: 700; letter-spacing: -1px; }
.w-caption { fill: var(--muted); font-size: 13px; letter-spacing: .06em; }


.sched-title { margin-bottom: 4px; }

.pill { font-size: 13px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--line); }
.pill:empty { display: none; }

.timeline, .ov-bar {
  position: relative;
  height: 28px;
  border-radius: 8px;
  background: var(--on-bg);
  overflow: hidden;
}
.timeline i, .ov-bar i { position: absolute; top: 0; bottom: 0; }
.offseg { background: var(--off); }
.unk { background: repeating-linear-gradient(45deg, var(--unk) 0 4px, transparent 4px 8px); }
.timeline b, .ov-bar b { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); }
.hours { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 4px 0 8px; }

.intervals { list-style: none; margin: 0; padding: 0; }
.intervals li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.intervals li:first-child { border-top: 0; }
.intervals .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.intervals .dur { margin-left: auto; color: var(--muted); font-size: 14px; }
.intervals li.past { opacity: .45; }
.intervals li.live strong { color: var(--off); }
.intervals li.muted { color: var(--muted); }

.overview h2 { margin-bottom: 10px; }
.ov { display: flex; flex-direction: column; gap: 6px; }
.ov-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px; margin: 0 -4px;
  border: 0; border-radius: 10px; background: none;
  text-align: left;
}
.ov-row.sel { background: var(--bg); }
.ov-q { width: 30px; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.ov-row.sel .ov-q { color: var(--blue); }
.ov-bar { flex: 1; height: 16px; border-radius: 5px; }

.stats-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 600; }
.stats-go { font-size: 13px; font-weight: 400; color: var(--muted); }

.install h2 { margin-bottom: 6px; }
.install-lead { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.install-btn {
  width: 100%; margin-bottom: 12px; padding: 12px; border: 0; border-radius: 12px;
  background: var(--blue); color: #fff; font-weight: 600;
}
.install-os { border-radius: 12px; }
.install-os.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--blue) 18%, transparent); } 100% { background: transparent; } }
.install-os h3 { font-size: 15px; margin: 0 0 6px; }
.install-os ol { margin: 0; padding-left: 20px; font-size: 14px; }
.install-os li { margin: 4px 0; }
.install-ico { display: inline-flex; vertical-align: -3px; color: var(--blue); }

.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 8px 0; }
