:root {
  /* Dark is the default for everyone; light tokens kept below for an opt-in toggle later. */
  --bg: #141413;
  --surface: #1c1c1a;
  --surface-2: #252523;
  --text: #ecebe6;
  --muted: #9c9a92;
  --line: #33322f;
  --accent: #ff7a45;       /* orange: today, selected, focus, links */
  --accent-ink: #141413;   /* text on orange */
  --toggle-on: #3d3c38;    /* selected state for quiet toggles (Week/Day) */
  --today: var(--accent);
  --k-event: #8b9bb0;      /* grey-blue */
  --k-event-bg: #1e232a;
  --k-exhibition: #d9b945; /* yellow */
  --k-exhibition-bg: #2b2716;
  --k-film: #a57b56;       /* brown */
  --k-film-bg: #2a211a;
  --radius: 0;
  --font: ui-monospace, "SF Mono", Menlo, Consolas, "Cascadia Mono", "Liberation Mono", monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f2f1ed;
  --text: #1c1c1a;
  --muted: #6b6a64;
  --line: #e3e1da;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --toggle-on: #dddbd3;
  --k-event: #5a6b82;
  --k-event-bg: #e9edf2;
  --k-exhibition: #a88a12;
  --k-exhibition-bg: #f6f0d6;
  --k-film: #7d5634;
  --k-film-bg: #f1e9e1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; gap: 10px 16px;
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--accent); line-height: 1; }
.nav { display: flex; align-items: center; gap: 12px; }

.seg, .stepper { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button, .stepper button {
  border: 0; background: transparent; padding: 5px 11px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button + button, .stepper button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--toggle-on); color: var(--text); }
.stepper button:disabled { opacity: .35; cursor: default; }
.seg button:hover:not([aria-pressed="true"]), .stepper button:hover:not(:disabled) { background: var(--surface-2); }

.filters { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.filters select, .filters input {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 5px 9px;
}
.filters input { width: 190px; }
/* Prev/next arrows: same 10×6 triangle as the dropdown caret, turned sideways. */
.tri { display: inline-block; width: 0; height: 0; vertical-align: middle;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.tri-left { border-right: 6px solid var(--muted); }
.tri-right { border-left: 6px solid var(--muted); }
.stepper #prev, .stepper #next { padding-left: 12px; padding-right: 12px; }

/* Own caret so it can sit further from the right edge than the native one. */
.filters select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%239c9a92'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}


main { padding: 16px 20px 40px; }
.status { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- Week view ---------- */
.week { --cols: 7; }
.week-head, .spans, .week-body {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 0 8px;
}
.week-head { position: sticky; top: var(--topbar-h, 58px); z-index: 3; background: var(--bg); padding-bottom: 6px; }
.day-head {
  display: flex; align-items: baseline; gap: 6px; padding: 6px 2px;
  border-bottom: 2px solid var(--line); cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; text-align: left;
}
.day-head .dow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.day-head .num { font-size: 18px; font-weight: 600; }
.day-head .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.day-head.is-today { border-bottom-color: var(--today); }
.day-head.is-today .num { color: var(--today); }
.day-head.is-past, .col.is-past { opacity: .45; }
.day-head:hover .num { text-decoration: underline; }

.spans-wrap { margin: 8px 0 10px; }
.spans-title { font-size: 12px; color: var(--muted); margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.spans { grid-auto-flow: row dense; gap: 4px 8px; }
.bar {
  min-width: 0; border: 0; text-align: left; cursor: pointer;
  padding: 3px 8px; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid var(--kc); background: var(--kbg);
}
.bar.cont-right::after { content: " →"; color: var(--muted); }
.bar.group { font-weight: 400; }
.bar strong { font-weight: 600; }
.bar.group.cont-right::after { content: none; }
.bar.group[aria-expanded="true"] { filter: brightness(0.96); }
.bar.member { margin-left: 12px; opacity: .92; }
.linkish { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 12px; }

.week-body { align-items: start; }
.col { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 4px; }
.card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-left: 3px solid var(--kc);
  background: var(--surface); padding: 6px 8px; min-width: 0;
}
.card:hover { background: var(--surface-2); }
.card .t { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card .title { font-weight: 600; font-size: 13px; line-height: 1.25; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .t + .sub { color: var(--text); margin-top: 0; }   /* inside a group: title is the main line */
/* Venue groups: several events at one venue on one day */
.group-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.group .acts { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row.group .acts { font-size: 13px; -webkit-line-clamp: 2; }
.group .caret, .group .count { color: var(--muted); font-weight: 400; }
.group-wrap.is-open > .group { background: var(--surface-2); }
.group-wrap.is-open .acts { display: none; }
.group-items { display: flex; flex-direction: column; gap: 4px; padding-left: 10px; border-left: 2px solid var(--line); margin-left: 4px; }
.group-items .row, .group-wrap > .row { margin-bottom: 0; }
.day .group-wrap { margin-bottom: 6px; }
.empty { color: var(--muted); font-size: 12px; padding: 6px 2px; }

[data-kind="event"] { --kc: var(--k-event); --kbg: var(--k-event-bg); }
[data-kind="exhibition"] { --kc: var(--k-exhibition); --kbg: var(--k-exhibition-bg); }
[data-kind="film"] { --kc: var(--k-film); --kbg: var(--k-film-bg); }

/* ---------- Day view & mobile agenda ---------- */
.day { max-width: 760px; margin: 0 auto; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.row {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--kc); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 6px;
}
.row:hover { background: var(--surface-2); }
.row.span { grid-template-columns: 1fr; }
.spans-wrap .row.span .desc { display: none; }
.row .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.row .title { font-weight: 600; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .title .count { color: var(--muted); font-weight: 400; }
.row .sub { color: var(--muted); font-size: 13px; }
.group-items .row .sub { color: var(--text); }
.row .desc { color: var(--muted); font-size: 13px; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agenda-day { margin-bottom: 8px; }
.agenda-day h3 { font-size: 15px; margin: 18px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.agenda-day h3 .is-today { color: var(--today); font-size: 12px; font-weight: 600; }

/* ---------- Detail dialog ---------- */
dialog {
  border: 1px solid var(--line); padding: 22px 24px; max-width: 520px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .close {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 0; background: var(--surface);
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--muted);
}
dialog .close:hover { color: var(--text); border-color: var(--muted); }
.d-figure { margin: -22px -24px 16px; background: var(--surface-2); overflow: hidden; }
.d-figure img { display: block; width: 100%; max-height: 360px; object-fit: contain; }
dialog h3 { margin: 2px 0 8px; font-size: 19px; line-height: 1.25; padding-right: 20px; }
.d-kind { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--kc); font-weight: 600; }
.d-when, .d-where { margin: 4px 0; }
.d-where { color: var(--muted); }
.d-desc { margin: 12px 0; line-height: 1.5; }
.d-desc:empty { display: none; }
#d-link { color: var(--accent); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .filters { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr; padding: 10px 16px; position: static; }
  .nav { flex-wrap: wrap; }
  .filters { flex-wrap: wrap; justify-content: flex-start; }
  .filters input { flex: 1 1 140px; width: auto; }
  main { padding: 8px 16px 32px; }
  .row { grid-template-columns: 58px 1fr; padding: 9px 10px; }
}

/* Selection / focus use the accent orange. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters select:focus, .filters input:focus { border-color: var(--accent); outline: none; }
.linkish { color: var(--accent); }

.site-footer { padding: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.site-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--accent); }
@media (max-width: 760px) { .site-footer { padding: 16px; } }

/* Day view breadcrumb back to its week. */
.crumb { display: flex; align-items: center; gap: 8px; margin: 4px 0 4px; font-size: 13px; color: var(--text); }
.crumb button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0;
  color: var(--muted); cursor: pointer; }
.crumb button:hover { color: var(--text); }
.crumb button:hover .tri-left { border-right-color: var(--text); }
.crumb .sep { color: var(--muted); opacity: .5; }
