:root {
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --stroke: rgba(30, 50, 80, 0.12);
  --text: #1a2433;
  --muted: #5a6a7e;
  --accent: #2b7cff;
  --danger: #e24b3b;
  --ok: #1a9a55;
  --shadow: 0 8px 32px rgba(20, 40, 70, 0.12);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: var(--font); color: var(--text);
  background: #cfe6f5;
}
#c {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: grab;
}
#c:active { cursor: grabbing; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

#topbar {
  position: fixed; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; z-index: 10;
  flex-wrap: wrap;
}
#topbar .brand {
  font-weight: 700; letter-spacing: -0.02em; white-space: nowrap;
}
#topbar .note {
  font-size: 11px; color: var(--muted); margin-left: 4px;
}
.kpis { display: flex; gap: 10px; flex: 1; justify-content: center; flex-wrap: wrap; }
.kpi {
  min-width: 64px; text-align: center; padding: 2px 8px;
  border-radius: 10px; background: rgba(255,255,255,0.35);
}
.kpi b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.clock {
  font-family: var(--mono); font-size: 18px; font-weight: 600;
  padding: 4px 10px; border-radius: 8px; background: rgba(255,255,255,0.4);
}
.controls { display: flex; gap: 6px; align-items: center; }
.controls button, .dock button, .icon-btn {
  appearance: none; border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.55); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 13px;
  cursor: pointer; min-height: 44px; min-width: 44px;
}
.controls button:hover, .dock button:hover, .icon-btn:hover {
  background: rgba(255,255,255,0.85);
}
.controls button.active {
  background: var(--accent); color: #fff; border-color: transparent;
}

#side {
  position: fixed; top: 78px; left: 12px; bottom: 72px;
  width: min(300px, 34vw); z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px; overflow: hidden;
}
#side input[type="search"] {
  width: 100%; border: 1px solid var(--stroke); border-radius: 10px;
  padding: 10px 12px; font: inherit; background: rgba(255,255,255,0.7);
  min-height: 44px;
}
.tabs { display: flex; gap: 4px; }
.tabs span {
  flex: 1; text-align: center; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); padding: 4px;
}
.lists { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.list-block h3 {
  margin: 0 0 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); font-weight: 600;
}
.list-item {
  width: 100%; display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-auto-rows: auto;
  gap: 2px 8px; align-items: center;
  text-align: left; padding: 8px 10px; margin-bottom: 4px;
  border-radius: 10px; border: 1px solid transparent;
  background: rgba(255,255,255,0.4); cursor: pointer; font: inherit; color: inherit;
  min-height: 44px;
}
.list-item:hover { background: rgba(255,255,255,0.7); }
.list-item.selected {
  border-color: var(--accent); background: rgba(43, 124, 255, 0.12);
}
.list-item .badge {
  width: 8px; height: 8px; border-radius: 50%; grid-row: span 2;
}
.list-item .primary { font-weight: 600; font-size: 13px; }
.list-item .muted { font-size: 11px; color: var(--muted); grid-column: 2; }
.list-item .tag {
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: rgba(30,50,80,0.08); color: var(--muted); justify-self: end;
}
.list-item .delay { color: var(--danger); font-size: 11px; font-weight: 600; justify-self: end; }
.list-item .ontime { color: var(--ok); font-size: 11px; justify-self: end; }

#detail-panel {
  position: fixed; top: 78px; right: 12px; width: min(340px, 36vw);
  z-index: 10; padding: 14px 16px 18px;
  max-height: calc(100vh - 160px); overflow: auto;
  transform: translateX(110%); opacity: 0; pointer-events: none;
  transition: transform 0.35s ease, opacity 0.35s ease;
}
#detail-panel.open {
  transform: translateX(0); opacity: 1; pointer-events: auto;
}
#panel-close {
  position: absolute; top: 8px; right: 8px;
}
.panel-kicker {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 4px;
}
#panel-body h2, #sheet-body h2 {
  margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em;
}
#panel-body h2 .mark, #sheet-body h2 .mark { color: var(--accent); }
#panel-body .sub, #sheet-body .sub {
  margin: 0 0 12px; color: var(--muted); font-size: 13px;
}
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.grid label {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.grid b { font-size: 14px; font-variant-numeric: tabular-nums; }
.grid b.delay { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }

.timeline { margin-top: 14px; }
.timeline-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 6px;
}
.timeline-bar {
  display: flex; gap: 3px; height: 8px; border-radius: 4px; overflow: hidden;
}
.timeline-bar .seg {
  flex: 1; background: rgba(30,50,80,0.12); border-radius: 2px;
}
.timeline-bar .seg.done { background: rgba(43,124,255,0.35); }
.timeline-bar .seg.active { background: var(--accent); }
.timeline-names {
  display: flex; gap: 3px; margin-top: 4px;
  font-size: 8px; color: var(--muted); overflow: hidden;
}
.timeline-names span { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.timeline-names span.on { color: var(--accent); font-weight: 700; }

#dock {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 8px; z-index: 10;
}

#bottom-sheet {
  display: none;
  position: fixed; left: 8px; right: 8px; bottom: 0; z-index: 20;
  border-radius: 16px 16px 0 0; padding: 12px 14px 24px;
  max-height: 45vh; overflow: auto;
  transform: translateY(110%); transition: transform 0.3s ease;
}
#bottom-sheet.open { transform: translateY(0); }
#sheet-close { float: right; }

#no-webgl {
  display: none; position: fixed; inset: 0; z-index: 100;
  align-items: center; justify-content: center;
  background: #1a2433; color: #fff; text-align: center; padding: 24px;
}
#no-webgl.show { display: flex; }

@media (max-width: 720px) {
  #side { display: none; }
  #detail-panel { display: none; }
  #bottom-sheet { display: block; }
  #topbar { padding: 8px 10px; gap: 8px; }
  .kpis .kpi:nth-child(n+3) { display: none; }
  #dock { bottom: auto; top: auto; }
}

@media (prefers-reduced-motion: reduce) {
  #detail-panel, #bottom-sheet { transition: none; }
}
