:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --ink: #1b1b1f;
  --ink-2: #5b5b66;
  --ink-3: #8a8a95;
  --line: #dddad3;
  --accent: #e0452b;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.06);
  --shadow-lg: -12px 0 40px rgba(0,0,0,.18);
  --label-w: 168px;
  --axis-h: 38px;
  --lane-h: 120px;
  --footer-h: 40px;
  --scrub-h: 40px;
  --chrome-h: calc(var(--footer-h) + var(--scrub-h));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141417;
    --surface: #1e1e23;
    --surface-2: #26262c;
    --ink: #ececf1;
    --ink-2: #a9a9b4;
    --ink-3: #75757f;
    --line: #34343b;
    --accent: #ff6a4d;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
    --shadow-lg: -12px 0 40px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.brand h1 span { color: var(--accent); }
.meta { margin: 2px 0 0; color: var(--ink-3); font-size: 12px; }
.days { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 10px; }
.days button {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 6px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
}
.days button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-left: auto; }
.controls input[type="search"] {
  width: 260px; max-width: 100%;
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit;
}
.ctl { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12px; }
.ctl select {
  font: inherit; font-size: 13px; padding: 5px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: progress; }

/* ---------- Legend / filters ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="false"] { opacity: .45; }
.chip[aria-pressed="false"] .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.chip .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Gantt ---------- */
.gantt-wrap { flex: 1; overflow: auto; position: relative; }
.gantt { position: relative; min-width: 100%; }

.axis {
  position: sticky; top: 0; z-index: 5;
  display: flex; height: var(--axis-h);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.axis-corner {
  position: sticky; left: 0; z-index: 6; flex: 0 0 var(--label-w);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 12px;
  font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em;
}
.axis-track { position: relative; flex: none; }
.tick {
  position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line);
  padding: 10px 0 0 6px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.tick.half { color: var(--ink-3); font-size: 11px; }

.row { display: flex; border-bottom: 1px solid var(--line); }
.row-label {
  position: sticky; left: 0; z-index: 4; flex: 0 0 var(--label-w);
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 12px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.row-label strong { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.row-label strong::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--stage); flex: none;
}
.row-label small { color: var(--ink-3); font-size: 11px; padding-left: 18px; }

.row-track { position: relative; flex: none; }
.gridline { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--line); opacity: .7; }
.gridline.hour { border-left-style: solid; }

/* The path: one line per stage, sessions sit on it */
.path {
  position: absolute; left: 0; right: 0; height: 3px; margin-top: -1.5px;
  background: var(--stage); opacity: .55; border-radius: 3px;
}

.session {
  position: absolute; height: calc(var(--lane-h) - 16px); margin-top: calc((var(--lane-h) - 16px) / -2);
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
  padding: 6px 8px 6px 10px; text-align: left;
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line));
  border-left: 5px solid var(--c);
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  color: var(--ink); font: inherit; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, opacity .15s ease;
}
.session:hover, .session:focus-visible {
  z-index: 3; transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  outline: none;
}
.session:focus-visible { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.session.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); z-index: 3; }
.session.dim { opacity: .18; }
.session.match { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.s-time { font-size: 10.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.s-title {
  font-weight: 650; font-size: 12.5px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.s-people {
  font-size: 11px; color: var(--ink-2); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.s-people b { color: var(--ink); font-weight: 600; }

.now-line {
  position: absolute; top: var(--axis-h); bottom: 0; width: 2px; margin-left: -1px;
  background: var(--accent); z-index: 3; pointer-events: none;
}
.now-line[hidden] { display: none; }
.now-line::before {
  content: "now"; position: absolute; top: 2px; left: 4px;
  font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase;
}

.empty { padding: 40px; color: var(--ink-2); }

/* ---------- Side panel ---------- */
.scrim { position: fixed; inset: 0 0 var(--chrome-h) 0; background: rgba(0,0,0,.18); z-index: 20; }
.panel {
  position: fixed; top: 0; right: 0; bottom: var(--chrome-h); z-index: 21;
  width: 33.333vw; min-width: 380px; max-width: 100vw;
  background: var(--surface); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.panel.open { transform: translateX(0); }
.panel-close {
  position: absolute; top: 10px; right: 12px; z-index: 1;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer;
}
.panel-close:hover { background: var(--surface-2); }
.panel-body { overflow-y: auto; padding: 22px 24px 32px; }
.panel-band { height: 6px; border-radius: 3px; background: var(--c); margin: 0 48px 16px 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line));
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.panel h2 { font-size: 22px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -.01em; }
.when { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 20px; font-size: 13px; }
.when dt { color: var(--ink-3); }
.when dd { margin: 0; font-weight: 500; }
.panel h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3);
  margin: 22px 0 10px;
}
.speakers { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.speaker { display: flex; gap: 12px; align-items: center; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--surface-2); display: grid; place-items: center;
  font-weight: 700; color: var(--ink-2);
}
.speaker .name { font-weight: 650; }
.speaker .role { font-size: 12.5px; color: var(--ink-2); }
.speaker .company { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.desc p { margin: 0 0 10px; color: var(--ink); line-height: 1.55; }
.panel-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 24px; }
.panel-link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 13px; }
.panel-link:hover { text-decoration: underline; }

.filters-toggle { display: none; }
.footer .short { display: none; }

@media (max-width: 720px) {
  :root { --label-w: 92px; --lane-h: 112px; --footer-h: 34px; --scrub-h: 36px; }
  .panel { width: 100vw; min-width: 0; }

  /* Compact header: title + day tabs + filters toggle on two short lines */
  .topbar { gap: 8px; padding: 8px 12px; }
  .brand { flex: 1 1 100%; }
  .brand h1 { font-size: 16px; }
  .meta { display: none; }
  .days button { padding: 5px 10px; font-size: 13px; }
  .filters-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
  .filters-toggle .caret { transition: transform .15s ease; }
  .badge {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
    display: inline-grid; place-items: center;
  }
  .badge[hidden] { display: none; }

  /* Accordion: filters hidden until opened, and never taller than ~half the screen */
  .controls, .legend { display: none; }
  body.filters-open .filters-toggle .caret { transform: rotate(180deg); }
  body.filters-open .controls { display: flex; margin-left: 0; width: 100%; gap: 8px 12px; }
  body.filters-open .legend { display: flex; max-height: 30vh; overflow-y: auto; padding: 8px 12px; }
  .controls input[type="search"] { flex: 1 1 100%; width: auto; }
  .ctl input[type="range"] { width: 110px; }

  .row-label { padding: 8px; }
  .row-label strong { font-size: 12px; gap: 6px; }
  .row-label small { padding-left: 16px; }
  .axis-corner { padding: 0 8px; }

  .scrub { padding: 0 10px; }
  .scrub-tick.alt span { display: none; }

  .footer { font-size: 11.5px; gap: 2px 12px; }
  .footer .long { display: none; }
  .footer .short { display: inline; }
}

/* ---------- Day scrubber (above the footer) ---------- */
.scrub {
  flex: 0 0 var(--scrub-h);
  position: relative; z-index: 23;
  display: flex; align-items: center;
  padding: 0 14px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.scrub[hidden] { display: none; }
.scrub-track {
  position: relative; flex: 1; height: 100%;
  cursor: pointer; touch-action: none; outline: none;
}
.scrub-rail {
  position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px;
  border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line);
}
.scrub-tick { position: absolute; top: 7px; bottom: 7px; border-left: 1px solid var(--line); }
.scrub-tick span {
  position: absolute; left: 4px; top: -2px; font-size: 10px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.scrub-now {
  position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px;
  background: var(--accent); border-radius: 1px; opacity: .8;
}
.scrub-now[hidden] { display: none; }
.scrub-cursor {
  position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px;
  background: var(--ink); border-radius: 1px;
}
.scrub-cursor::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ink); box-shadow: var(--shadow);
}
.scrub-time {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  padding: 3px 8px; border-radius: 6px; background: var(--ink); color: var(--surface);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
  opacity: 0; transition: opacity .12s ease; pointer-events: none;
}
.scrub.dragging .scrub-time,
.scrub-track:hover .scrub-time,
.scrub-track:focus-visible .scrub-time { opacity: 1; }
.scrub-track:focus-visible .scrub-cursor::after { border-color: var(--accent); }

/* ---------- Footer (always visible) ---------- */
.footer {
  flex: 0 0 var(--footer-h);
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 20px;
  padding: 0 16px; font-size: 13px;
  background: var(--surface); border-top: 1px solid var(--line); color: var(--ink-2);
  position: relative; z-index: 22;
}
.footer strong { color: var(--ink); }
.footer a { color: var(--ink-2); text-decoration: none; }
.footer a:hover { color: var(--accent); text-decoration: underline; }
