/* ==========================================================================
   DEF CON schedule — visual language borrowed from the hardware on the floor:
   an OSH Park purple board, silkscreen-white type, ENIG gold for anything the
   attendee themselves marked. Times are always set in mono because they are
   data you scan down a column, not prose you read across.
   ========================================================================== */

:root {
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: 4.25rem;
  --topbar-h: 6.75rem;
  --radius: 0.625rem;
  --radius-sm: 0.375rem;
  --tap: 2.75rem;

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* --- Dark: the board ----------------------------------------------------- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --board:    #150C22;
  --board-2:  #1C1130;
  --board-3:  #26173F;
  --board-4:  #33205260;
  --edge:     #362350;
  --edge-2:   #4A3168;
  --silk:     #EFE9F7;
  --silk-2:   #B4A6CC;
  --silk-3:   #8878A4;
  --gold:     #F0B429;
  --gold-ink: #150C22;
  --gold-soft: rgba(240,180,41,.16);
  --danger:   #FF7A8A;
  --shadow:   0 1.25rem 3rem -1rem rgba(0,0,0,.7);

  /* Saturation/lightness for the generated per-village hues. */
  --vs: 62%;
  --vl: 71%;

  --c-official: #6FD3FF;
  --c-demolab:  #74E0A8;
  --c-workshop: #C4A6FF;
  --c-training: #FF9EC0;
  --c-village:  #8FB0FF;
  --c-contest:  #FFA85C;
  --c-party:    #FF7B9C;
  --c-social:   #9FA9BE;
}

/* --- Light: the silkscreen ----------------------------------------------- */
:root[data-theme="light"] {
  color-scheme: light;
  --board:    #F6F3FB;
  --board-2:  #FFFFFF;
  --board-3:  #EFE8F9;
  --board-4:  #E7DEF6;
  --edge:     #DED3EF;
  --edge-2:   #C7B6E0;
  --silk:     #22103A;
  --silk-2:   #5A4779;
  --silk-3:   #7C6C99;
  --gold:     #8A5B00;
  --gold-ink: #FFFFFF;
  --gold-soft: rgba(138,91,0,.12);
  --danger:   #C4283C;
  --shadow:   0 1.25rem 3rem -1.25rem rgba(40,16,70,.28);

  --vs: 58%;
  --vl: 34%;

  --c-official: #0A6EA1;
  --c-demolab:  #0E7A4C;
  --c-workshop: #6435C9;
  --c-training: #B01F63;
  --c-village:  #2B4FB8;
  --c-contest:  #A55200;
  --c-party:    #B32347;
  --c-social:   #4C5567;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --board:    #F6F3FB;
    --board-2:  #FFFFFF;
    --board-3:  #EFE8F9;
    --board-4:  #E7DEF6;
    --edge:     #DED3EF;
    --edge-2:   #C7B6E0;
    --silk:     #22103A;
    --silk-2:   #5A4779;
    --silk-3:   #7C6C99;
    --gold:     #8A5B00;
    --gold-ink: #FFFFFF;
    --gold-soft: rgba(138,91,0,.12);
    --danger:   #C4283C;
    --shadow:   0 1.25rem 3rem -1.25rem rgba(40,16,70,.28);

    --vs: 58%;
    --vl: 34%;

    --c-official: #0A6EA1;
    --c-demolab:  #0E7A4C;
    --c-workshop: #6435C9;
    --c-training: #B01F63;
    --c-village:  #2B4FB8;
    --c-contest:  #A55200;
    --c-party:    #B32347;
    --c-social:   #4C5567;
  }
}

/* ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--silk);
  background: var(--board);
  overflow-wrap: break-word;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--gold); text-underline-offset: .15em; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: fixed; top: .5rem; left: .5rem; z-index: 100;
  padding: .5rem .875rem; border-radius: var(--radius-sm);
  background: var(--gold); color: var(--gold-ink); font-weight: 650;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* !important because these utilities have to beat component rules such as
   .icon-btn { display: grid } that are declared later in the file. */
.mobile-only { display: none !important; }

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--board) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--edge);
  padding-top: env(safe-area-inset-top);
}

.topbar-row {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .875rem;
  max-width: 90rem; margin-inline: auto;
}

.brand {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: 0; padding: .25rem; cursor: pointer;
  color: inherit; flex-shrink: 0;
}
.brand-mark {
  width: 1.75rem; height: 1.75rem; border-radius: .3125rem;
  background:
    radial-gradient(circle at 30% 30%, var(--gold) 0 18%, transparent 19%),
    radial-gradient(circle at 70% 70%, var(--gold) 0 18%, transparent 19%),
    linear-gradient(140deg, var(--board-3), var(--board-2));
  border: 1px solid var(--edge-2);
  box-shadow: inset 0 0 0 1px rgba(240,180,41,.12);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.brand-name { font-family: var(--font-mono); font-weight: 700; font-size: .9375rem; letter-spacing: .02em; }
.brand-sub  { font-size: .625rem; color: var(--silk-3); letter-spacing: .09em; text-transform: uppercase; }

.search { position: relative; flex: 1; min-width: 0; }
.search-icon {
  position: absolute; left: .6875rem; top: 50%; transform: translateY(-50%);
  color: var(--silk-3); pointer-events: none; width: 1.0625rem; height: 1.0625rem;
}
#q {
  width: 100%; height: var(--tap);
  padding: 0 2.25rem 0 2.25rem;
  background: var(--board-2);
  border: 1px solid var(--edge);
  border-radius: 1.375rem;
  color: var(--silk);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
#q::placeholder { color: var(--silk-3); }
#q:focus { border-color: var(--edge-2); background: var(--board-3); outline: none; }
#q:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
#q::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute; right: .375rem; top: 50%; transform: translateY(-50%);
  width: 2rem; height: 2rem; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; cursor: pointer; color: var(--silk-2);
}
.search-clear:hover { background: var(--board-3); color: var(--silk); }

.icon-btn {
  width: var(--tap); height: var(--tap); flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--board-2); border: 1px solid var(--edge);
  border-radius: 50%; cursor: pointer; color: var(--silk-2);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--board-3); color: var(--silk); }

/* --- Day rail ------------------------------------------------------------ */

.daybar {
  display: flex; gap: .375rem; overflow-x: auto; scrollbar-width: none;
  padding: 0 .875rem .625rem;
  max-width: 90rem; margin-inline: auto;
}
.daybar::-webkit-scrollbar { display: none; }

.day {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  gap: .0625rem; min-width: 3.75rem; padding: .375rem .625rem;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--silk-2);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.day:hover { background: var(--board-2); color: var(--silk); }
.day-name { font-family: var(--font-mono); font-size: .8125rem; font-weight: 650; letter-spacing: .02em; }
.day-num  { font-size: .625rem; color: var(--silk-3); font-variant-numeric: tabular-nums; }
.day[aria-pressed="true"] {
  background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 45%, transparent); color: var(--silk);
}
.day[aria-pressed="true"] .day-num { color: var(--gold); }
.day.is-today::after {
  content: ""; width: .25rem; height: .25rem; border-radius: 50%;
  background: var(--gold); margin-top: .0625rem;
}

/* --- Active filter chips ------------------------------------------------- */

.chipbar {
  display: flex; flex-wrap: wrap; gap: .375rem;
  padding: 0 .875rem .625rem; max-width: 90rem; margin-inline: auto;
}
.chip {
  display: inline-flex; align-items: center; gap: .3125rem;
  padding: .1875rem .5rem .1875rem .625rem;
  background: var(--board-3); border: 1px solid var(--edge);
  border-radius: 1rem; font-size: .75rem; color: var(--silk);
  cursor: pointer;
}
.chip:hover { border-color: var(--edge-2); }
.chip svg { width: .8125rem; height: .8125rem; color: var(--silk-3); }
.chip.chip-clear { background: none; color: var(--silk-2); }

/* --- Layout -------------------------------------------------------------- */

.layout {
  display: grid; grid-template-columns: 17.5rem minmax(0, 1fr);
  gap: 1.5rem; max-width: 90rem; margin-inline: auto;
  padding: 0 .875rem 6rem;
  align-items: start;
}

body.no-filters .layout { grid-template-columns: minmax(0, 1fr); }
body.no-filters .sidebar { display: none; }
body.no-filters #openFilters { display: none !important; }

.sidebar {
  position: sticky; top: calc(var(--topbar-h) + .75rem);
  max-height: calc(100vh - var(--topbar-h) - 2rem);
  display: flex; flex-direction: column;
  background: var(--board-2); border: 1px solid var(--edge);
  border-radius: var(--radius); overflow: hidden;
  margin-top: 1rem;
}
.sidebar-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem .875rem; border-bottom: 1px solid var(--edge);
}
.sidebar-head h2 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .09em; color: var(--silk-3); flex: 1; }
.sidebar-body { overflow-y: auto; overscroll-behavior: contain; padding: .25rem 0 .75rem; flex: 1; }
.sidebar-foot { padding: .75rem; border-top: 1px solid var(--edge); }

.text-btn {
  background: none; border: 0; padding: .25rem .375rem; cursor: pointer;
  color: var(--silk-2); font-size: .75rem; border-radius: var(--radius-sm);
}
.text-btn:hover { color: var(--gold); background: var(--gold-soft); }

/* --- Facets -------------------------------------------------------------- */

.facet { border-bottom: 1px solid var(--edge); }
.facet:last-child { border-bottom: 0; }

.facet-head {
  width: 100%; display: flex; align-items: center; gap: .5rem;
  padding: .6875rem .875rem; background: none; border: 0; cursor: pointer;
  text-align: left; color: var(--silk);
}
.facet-head:hover { background: var(--board-3); }
.facet-title { flex: 1; font-size: .8125rem; font-weight: 650; }
.facet-count {
  font-family: var(--font-mono); font-size: .6875rem; color: var(--gold);
  background: var(--gold-soft); padding: .0625rem .375rem; border-radius: .625rem;
}
/* The chevron starts pointing left; -90deg turns it downward for "open". */
.facet-caret { color: var(--silk-3); transition: transform .18s var(--ease); width: 1rem; height: 1rem; transform: rotate(-90deg); }
.facet[data-open="false"] .facet-caret { transform: rotate(0deg); }
.facet[data-open="false"] .facet-body { display: none; }

.facet-body { padding: 0 .5rem .625rem; }
.facet-search {
  width: calc(100% - .75rem); margin: 0 .375rem .375rem; height: 2rem;
  padding: 0 .5rem; font-size: .8125rem;
  background: var(--board); border: 1px solid var(--edge); border-radius: var(--radius-sm);
}
.facet-list { max-height: 15rem; overflow-y: auto; overscroll-behavior: contain; }

.opt {
  display: flex; align-items: center; gap: .5rem;
  padding: .375rem .375rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .8125rem; line-height: 1.3;
}
.opt:hover { background: var(--board-3); }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt-box {
  width: 1rem; height: 1rem; flex-shrink: 0; border-radius: .25rem;
  border: 1.5px solid var(--edge-2); display: grid; place-items: center;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.opt input:checked + .opt-box { background: var(--gold); border-color: var(--gold); }
.opt input:checked + .opt-box::after {
  content: ""; width: .5rem; height: .28rem; margin-top: -.12rem;
  border-left: 2px solid var(--gold-ink); border-bottom: 2px solid var(--gold-ink);
  transform: rotate(-45deg);
}
.opt input:focus-visible + .opt-box { outline: 2px solid var(--gold); outline-offset: 2px; }
.opt-label { flex: 1; min-width: 0; }
.opt-n { font-family: var(--font-mono); font-size: .6875rem; color: var(--silk-3); font-variant-numeric: tabular-nums; }
.opt-swatch { width: .5rem; height: .5rem; border-radius: .125rem; background: var(--c, var(--silk-3)); flex-shrink: 0; }

.switch-row {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem .375rem; cursor: pointer; font-size: .8125rem; border-radius: var(--radius-sm);
}
.switch-row:hover { background: var(--board-3); }
.switch-row input { position: absolute; opacity: 0; }
.switch {
  width: 2rem; height: 1.125rem; border-radius: .5625rem; flex-shrink: 0;
  background: var(--board-4); border: 1px solid var(--edge-2); position: relative;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: .0625rem; left: .0625rem;
  width: .875rem; height: .875rem; border-radius: 50%; background: var(--silk-3);
  transition: transform .15s var(--ease), background .15s var(--ease);
}
.switch-row input:checked + .switch { background: var(--gold); border-color: var(--gold); }
.switch-row input:checked + .switch::after { transform: translateX(.875rem); background: var(--gold-ink); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- Toolbar ------------------------------------------------------------- */

.toolbar {
  display: flex; align-items: center; gap: .625rem; flex-wrap: wrap;
  padding: 1rem 0 .625rem;
}
.result-count { flex: 1; font-size: .8125rem; color: var(--silk-2); font-variant-numeric: tabular-nums; }
.result-count b { color: var(--silk); font-family: var(--font-mono); font-weight: 650; }
.toolbar-actions { display: flex; gap: .375rem; }

.pill {
  display: inline-flex; align-items: center; gap: .375rem; position: relative;
  height: 2.125rem; padding: 0 .75rem;
  background: var(--board-2); border: 1px solid var(--edge); border-radius: 1.0625rem;
  cursor: pointer; font-size: .8125rem; color: var(--silk-2);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.pill:hover { background: var(--board-3); color: var(--silk); }
.pill svg { width: .9375rem; height: .9375rem; }
.pill[aria-pressed="true"] { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 45%, transparent); color: var(--silk); }
.pill-badge, .tab-badge {
  min-width: 1.125rem; height: 1.125rem; padding: 0 .25rem;
  display: grid; place-items: center; border-radius: .5625rem;
  background: var(--gold); color: var(--gold-ink);
  font-family: var(--font-mono); font-size: .625rem; font-weight: 700;
}
.swatch-mini {
  width: .75rem; height: .75rem; border-radius: .1875rem;
  background: linear-gradient(135deg, var(--c-official) 0 33%, var(--c-contest) 33% 66%, var(--c-workshop) 66%);
}

/* --- Results: the time ruler -------------------------------------------- */

.results { display: flex; flex-direction: column; }

.day-heading {
  position: sticky; top: calc(var(--topbar-h) - .0625rem); z-index: 20;
  display: flex; align-items: baseline; gap: .625rem;
  margin: 1.25rem 0 .25rem; padding: .4375rem .625rem;
  background: color-mix(in srgb, var(--board) 92%, transparent);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  font-size: .8125rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--silk-2);
}
.day-heading:first-child { margin-top: .25rem; }
.day-heading .n { margin-left: auto; font-family: var(--font-mono); font-size: .6875rem; color: var(--silk-3); letter-spacing: 0; text-transform: none; }

/* Each slot is a rung on the ruler: mono time in the gutter, events to the right. */
.slot { display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); align-items: start; }

.slot-time {
  position: relative;
  padding: .8125rem .625rem 0 0;
  text-align: right;
  font-family: var(--font-mono); font-size: .8125rem; font-weight: 650;
  color: var(--silk-2); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.slot-time::after {
  content: ""; position: absolute; right: 0; top: 1.375rem; bottom: 0;
  width: 1px; background: var(--edge);
}
.slot:last-child .slot-time::after { display: none; }
.slot-time .meridiem { font-size: .625rem; color: var(--silk-3); margin-left: .0625rem; }

.slot-events { display: flex; flex-direction: column; gap: .375rem; padding: .375rem 0 .625rem .75rem; min-width: 0; }

/* --- Event card ---------------------------------------------------------- */

.ev {
  position: relative; display: flex; align-items: stretch;
  background: var(--board-2);
  border: 1px solid var(--edge);
  border-left: 3px solid var(--c, var(--silk-3));
  border-radius: var(--radius);
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease);
}
.ev:hover { background: var(--board-3); }
.ev:has(.ev-main:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

.ev-main {
  flex: 1; min-width: 0; text-align: left; cursor: pointer;
  background: none; border: 0; padding: .625rem .5rem .625rem .75rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.ev-main:focus-visible { outline: none; }

.ev-title { font-size: .9375rem; line-height: 1.3; font-weight: 620; }

.ev-meta {
  display: flex; align-items: center; gap: .375rem; flex-wrap: wrap;
  font-size: .75rem; color: var(--silk-2);
}
.ev-dot { width: .4375rem; height: .4375rem; border-radius: 50%; background: var(--c, var(--silk-3)); flex-shrink: 0; }
.ev-village { color: var(--c, var(--silk-2)); font-weight: 600; }
.ev-room { color: var(--silk-3); }
.ev-room::before { content: "· "; }
.ev-dur { font-family: var(--font-mono); font-size: .6875rem; color: var(--silk-3); font-variant-numeric: tabular-nums; }

.ev-people { font-size: .75rem; color: var(--silk-2); }
.ev-people::before { content: "by "; color: var(--silk-3); }

.ev-tags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .0625rem; }
.tag {
  font-family: var(--font-mono); font-size: .625rem; letter-spacing: .01em;
  padding: .0625rem .375rem; border-radius: .25rem;
  background: var(--board-4); color: var(--silk-2); border: 1px solid transparent;
}
.tag.tag-audience { color: var(--gold); background: var(--gold-soft); }

.ev-actions { display: flex; flex-direction: column; justify-content: flex-start; gap: .125rem; padding: .375rem .375rem .375rem 0; }
.act {
  width: 2rem; height: 2rem; display: grid; place-items: center;
  background: none; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--silk-3);
  transition: color .12s var(--ease), background .12s var(--ease);
}
.act:hover { background: var(--board-4); color: var(--silk); }
.act svg { width: 1.0625rem; height: 1.0625rem; }
.act[aria-pressed="true"] { color: var(--gold); }
.act-star[aria-pressed="true"] svg { fill: var(--gold); }

/* State: starred, hidden, past */
.ev.is-starred { border-color: color-mix(in srgb, var(--gold) 42%, var(--edge)); background: color-mix(in srgb, var(--gold) 5%, var(--board-2)); }
.ev.is-hidden { opacity: .42; }
.ev.is-hidden .ev-title { text-decoration: line-through; text-decoration-color: var(--silk-3); }
.ev.is-past { opacity: .5; }
.ev.is-live { border-color: color-mix(in srgb, var(--gold) 55%, var(--edge)); }
.ev-live-flag {
  display: inline-flex; align-items: center; gap: .25rem;
  font-family: var(--font-mono); font-size: .625rem; font-weight: 700;
  color: var(--gold); letter-spacing: .06em;
}
.ev-live-flag::before {
  content: ""; width: .375rem; height: .375rem; border-radius: 50%;
  background: var(--gold); animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* The now rail — the signature device. */
.nowline {
  display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr);
  align-items: center; margin: .375rem 0; scroll-margin-top: calc(var(--topbar-h) + 3rem);
}
.nowline-label {
  font-family: var(--font-mono); font-size: .6875rem; font-weight: 700;
  color: var(--gold); text-align: right; padding-right: .625rem; letter-spacing: .04em;
}
.nowline-rule { position: relative; height: 1px; background: var(--gold); opacity: .75; margin-left: .75rem; }
.nowline-rule::before {
  content: ""; position: absolute; left: -.1875rem; top: 50%; transform: translateY(-50%);
  width: .4375rem; height: .4375rem; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 .25rem var(--gold-soft);
}

/* --- Conflict seam (My Schedule) ----------------------------------------- */

.conflict-note {
  display: flex; align-items: center; gap: .5rem;
  margin: .25rem 0 .375rem .75rem; padding: .375rem .625rem;
  border-left: 3px solid var(--danger); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  font-size: .75rem; color: var(--silk);
}
.conflict-note svg { width: .9375rem; height: .9375rem; color: var(--danger); flex-shrink: 0; }
.ev.is-conflict { border-color: color-mix(in srgb, var(--danger) 45%, var(--edge)); }
.ev-clash {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .6875rem; font-weight: 600; color: var(--danger);
}
.ev-clash svg { width: .8125rem; height: .8125rem; }

/* --- Empty / summary panels ---------------------------------------------- */

.section-note {
  margin: -.125rem 0 .5rem; padding: 0 .625rem;
  font-size: .75rem; color: var(--silk-3);
}

.empty {
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
  padding: 4rem 1.5rem; text-align: center; color: var(--silk-2);
}
.empty h3 { font-size: 1.0625rem; color: var(--silk); }
.empty p { margin: 0; font-size: .875rem; max-width: 26rem; }

.panel {
  background: var(--board-2); border: 1px solid var(--edge);
  border-radius: var(--radius); padding: 1rem 1.125rem; margin-bottom: .75rem;
}
.panel h3 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .09em; color: var(--silk-3); margin-bottom: .625rem; }

.countdown {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  font-family: var(--font-mono);
}
.countdown b { font-size: 2rem; font-weight: 700; color: var(--gold); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.countdown span { font-size: .8125rem; color: var(--silk-2); }

/* --- Village directory --------------------------------------------------- */

.village-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .625rem; }
.village-card {
  display: flex; flex-direction: column; gap: .375rem; text-align: left;
  background: var(--board-2); border: 1px solid var(--edge);
  border-left: 3px solid var(--c, var(--silk-3));
  border-radius: var(--radius); padding: .75rem .875rem; cursor: pointer;
}
.village-card:hover { background: var(--board-3); }
.village-card h3 { font-size: .9375rem; }
.village-card .vc-meta { font-size: .75rem; color: var(--silk-3); display: flex; gap: .375rem; flex-wrap: wrap; align-items: baseline; }
.village-card .vc-n { font-family: var(--font-mono); color: var(--c, var(--silk-2)); font-weight: 650; white-space: nowrap; }
.village-card p { margin: 0; font-size: .75rem; color: var(--silk-2); display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* --- Detail sheet -------------------------------------------------------- */

.sheet {
  padding: 0; border: 0; background: transparent;
  max-width: 44rem; width: calc(100% - 2rem); max-height: 88vh;
  margin: auto; overflow: visible;
}
.sheet::backdrop { background: rgba(8,4,16,.72); backdrop-filter: blur(3px); }

.sheet-inner {
  background: var(--board-2); border: 1px solid var(--edge);
  border-top: 3px solid var(--c, var(--gold));
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
}

.sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; gap: .75rem;
  padding: 1rem 1.125rem .75rem;
  background: color-mix(in srgb, var(--board-2) 94%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--edge);
}
.sheet-head h2 { font-size: 1.125rem; line-height: 1.28; flex: 1; }
.sheet-body { padding: 1rem 1.125rem 1.5rem; }

.d-when {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: .8125rem; color: var(--silk);
  padding: .5rem .625rem; background: var(--board); border-radius: var(--radius-sm);
  margin-bottom: .625rem;
}
.d-when .d-gold { color: var(--gold); }

.d-rows { display: grid; gap: .375rem; margin-bottom: 1rem; }
.d-row { display: grid; grid-template-columns: 5.25rem minmax(0,1fr); gap: .625rem; font-size: .8125rem; align-items: baseline; }
.d-row dt { color: var(--silk-3); font-size: .6875rem; text-transform: uppercase; letter-spacing: .07em; }
.d-row dd { margin: 0; color: var(--silk); }

.d-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.125rem; }
.btn {
  display: inline-flex; align-items: center; gap: .4375rem;
  height: var(--tap); padding: 0 1rem;
  background: var(--board-3); border: 1px solid var(--edge); border-radius: var(--radius-sm);
  cursor: pointer; font-size: .875rem; font-weight: 600; color: var(--silk);
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { background: var(--board-4); border-color: var(--edge-2); }
.btn svg { width: 1rem; height: 1rem; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); width: 100%; justify-content: center; }
.btn-primary:hover { background: color-mix(in srgb, var(--gold) 85%, var(--silk)); }
.btn-starred { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 45%, transparent); color: var(--gold); }
.btn-starred svg { fill: currentColor; }

.d-section { margin-bottom: 1.25rem; }
.d-section > h3 {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--silk-3); margin-bottom: .5rem;
  padding-bottom: .3125rem; border-bottom: 1px solid var(--edge);
}
.prose { font-size: .9375rem; line-height: 1.62; color: var(--silk); }
.prose p { margin: 0 0 .75rem; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 .75rem; padding-left: 1.25rem; }
.prose li { margin-bottom: .25rem; }
.prose a { color: var(--gold); }
.prose code { font-family: var(--font-mono); font-size: .875em; background: var(--board); padding: .0625rem .25rem; border-radius: .1875rem; }
.prose blockquote { margin: 0 0 .75rem; padding-left: .75rem; border-left: 2px solid var(--edge-2); color: var(--silk-2); }

.speaker { margin-bottom: .875rem; }
.speaker:last-child { margin-bottom: 0; }
.speaker h4 { font-size: .875rem; margin-bottom: .1875rem; }
.speaker .prose { font-size: .875rem; color: var(--silk-2); }

.linkchips { display: flex; flex-wrap: wrap; gap: .375rem; }
.linkchip {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .3125rem .625rem; border-radius: 1rem;
  background: var(--board); border: 1px solid var(--edge);
  font-size: .75rem; color: var(--silk); text-decoration: none;
  font-family: var(--font-mono);
}
.linkchip:hover { border-color: var(--gold); color: var(--gold); }
.linkchip svg { width: .8125rem; height: .8125rem; }

.d-related { display: flex; flex-direction: column; gap: .375rem; }

.map-ref {
  font-family: var(--font-mono); font-size: .8125em;
  color: var(--silk-2); text-decoration: none;
  border-bottom: 1px dashed var(--edge-2); cursor: default;
}

/* --- Settings ------------------------------------------------------------ */

.seg { display: inline-flex; background: var(--board); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: .125rem; gap: .125rem; }
.seg button {
  padding: .375rem .75rem; background: none; border: 0; border-radius: .25rem;
  cursor: pointer; font-size: .8125rem; color: var(--silk-2);
}
.seg button[aria-pressed="true"] { background: var(--board-3); color: var(--silk); box-shadow: inset 0 0 0 1px var(--edge); }

.set-row { display: flex; align-items: center; gap: 1rem; padding: .625rem 0; border-bottom: 1px solid var(--edge); }
.set-row:last-child { border-bottom: 0; }
.set-row .set-label { flex: 1; }
.set-row .set-label b { display: block; font-size: .875rem; font-weight: 620; }
.set-row .set-label span { font-size: .75rem; color: var(--silk-3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); gap: .625rem; }
.stat { background: var(--board); border-radius: var(--radius-sm); padding: .625rem .75rem; }
.stat b { display: block; font-family: var(--font-mono); font-size: 1.25rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.stat span { font-size: .6875rem; color: var(--silk-3); text-transform: uppercase; letter-spacing: .07em; }

/* --- View switch (desktop) ----------------------------------------------- */

.viewswitch {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 35;
  display: flex; gap: .125rem; padding: .1875rem;
  background: color-mix(in srgb, var(--board-2) 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid var(--edge); border-radius: 1.5rem;
  box-shadow: var(--shadow);
}
.viewswitch button {
  display: inline-flex; align-items: center; gap: .375rem;
  height: 2.25rem; padding: 0 .875rem; border: 0; border-radius: 1.125rem;
  background: none; cursor: pointer; font-size: .8125rem; color: var(--silk-2);
}
.viewswitch button:hover { color: var(--silk); background: var(--board-3); }
.viewswitch button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); font-weight: 650; }
.viewswitch button[aria-pressed="true"] svg { stroke-width: 2; }
.viewswitch svg { width: .9375rem; height: .9375rem; }
.viewswitch .tab-badge { background: var(--board-4); color: var(--silk); }
.viewswitch button[aria-pressed="true"] .tab-badge { background: rgba(0,0,0,.22); color: var(--gold-ink); }

/* --- Misc ---------------------------------------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(8,4,16,.6); }

.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%);
  z-index: 60; padding: .625rem 1rem; border-radius: 1.375rem;
  background: var(--silk); color: var(--board); font-size: .8125rem; font-weight: 600;
  box-shadow: var(--shadow); animation: toast-in .2s var(--ease);
  max-width: calc(100% - 2rem);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, .5rem); } }

.sentinel { height: 1px; }
.loading-more { padding: 1.5rem; text-align: center; color: var(--silk-3); font-size: .8125rem; }

.tabbar { display: none; }

/* ==========================================================================
   Mobile — the hallway case: one thumb, bright room, low patience.
   ========================================================================== */

@media (max-width: 900px) {
  :root { --gutter: 3.25rem; --topbar-h: 6.5rem; }

  .mobile-only { display: block !important; }
  .icon-btn.mobile-only, .tab.mobile-only { display: grid !important; }
  .pill.mobile-only, .btn.mobile-only { display: inline-flex !important; }
  .tabbar.mobile-only { display: grid !important; }
  .desktop-only { display: none !important; }

  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 .625rem 5.5rem; gap: 0; }

  .sidebar {
    position: fixed; inset: auto 0 0 0; z-index: 50;
    margin: 0; max-height: 82vh; border-radius: 1rem 1rem 0 0;
    border-bottom: 0; transform: translateY(101%);
    transition: transform .28s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-head { padding-top: 1rem; }
  .sidebar-head::before {
    content: ""; position: absolute; top: .375rem; left: 50%; transform: translateX(-50%);
    width: 2.25rem; height: .1875rem; border-radius: .125rem; background: var(--edge-2);
  }
  .facet-list { max-height: 12rem; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 44;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--board) 94%, transparent);
    backdrop-filter: blur(16px) saturate(1.5);
    border-top: 1px solid var(--edge);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: .1875rem;
    padding: .5rem .25rem .5625rem; background: none; border: 0; cursor: pointer;
    color: var(--silk-3); font-size: .625rem; letter-spacing: .01em;
    min-height: 3.25rem;
  }
  .tab svg { width: 1.25rem; height: 1.25rem; }
  .tab[aria-pressed="true"] { color: var(--gold); }
  .tab[aria-pressed="true"] svg { stroke-width: 2.1; }
  .tab-badge { position: absolute; top: .1875rem; right: 50%; margin-right: -1.375rem; }

  .toolbar { padding: .75rem 0 .5rem; }
  .day-heading { top: calc(var(--topbar-h) - .0625rem); }

  .sheet {
    width: 100%; max-width: none; max-height: 100%;
    margin: 0; margin-top: auto; align-self: flex-end;
  }
  .sheet-inner { border-radius: 1rem 1rem 0 0; max-height: 92vh; border-left: 0; border-right: 0; border-bottom: 0; }
  .sheet-body { padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }

  .toast { bottom: 4.75rem; }

  .ev-actions { padding-right: .1875rem; }
  .act { width: 2.375rem; height: 2.375rem; }
  .ev-title { font-size: .9375rem; }
}

@media (max-width: 400px) {
  :root { --gutter: 2.875rem; }
  .slot-events { padding-left: .5rem; }
  .ev-main { padding-left: .625rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .topbar, .sidebar, .tabbar, .viewswitch, .toolbar, .ev-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .ev { break-inside: avoid; border-color: #ccc; }
}
