/* Archon's palette (archonstl.org: --archon-green #005c00, --archon-register
   #ffb100 on #1b1b1b). Light by default, like the con's site and its bright
   halls; a dark green-black for phones set to dark mode. */
:root {
  --brand: #005c00;
  --brand-ink: #ffffff;
  --brand-text: #005c00;
  --gold: #ffb100;
  --on-gold: #1b1b1b;
  --gold-wash: rgba(255, 177, 0, 0.16);
  --star: #b87400;
  --picked-line: rgba(184, 116, 0, 0.5);
  --bg: #f3f5f1;
  --panel: #ffffff;
  --panel-2: #eaefe8;
  --ink: #17201a;
  --ink-dim: #56645a;
  --line: #d3dbd2;
  --tab-bg: #ffffff;
  --toast-bg: #17201a;
  --toast-ink: #ffffff;
  --open: #1b7f2a;
  --danger: #c62828;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --radius: 12px;
  --tab-height: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --day-bar-h: 66px;
  font-size: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-text: #7fcf8a;
    --star: #ffb100;
    --picked-line: rgba(255, 177, 0, 0.45);
    --bg: #0d1310;
    --panel: #151e18;
    --panel-2: #1d2921;
    --ink: #e6ede7;
    --ink-dim: #9aab9f;
    --line: #2a382f;
    --tab-bg: #111a14;
    --toast-bg: #263329;
    --toast-ink: #e6ede7;
    --open: #6fd37f;
    --danger: #ef6b6b;
  }
}

* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom));
}

body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: var(--safe-top); background: var(--brand);
}

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: baseline; gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--brand);
  color: var(--brand-ink);
}

.app-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--brand-ink);
}

.app-tagline {
  color: rgba(255, 255, 255, 0.72); font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
}

.party-bar { display: flex; gap: 8px; margin-left: auto; align-self: center; }
.party-bar:empty { display: none; }

.header-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold);
  font-size: 0.85rem; font-weight: 700;
  color: var(--on-gold);
  text-decoration: none;
}
.header-chip svg { color: inherit; }

/* ---------- offline banner ---------- */
.offline-banner {
  padding: 6px 12px;
  font-size: 0.82rem;
  text-align: center;
  background: var(--gold-wash);
  color: var(--ink);
  border-bottom: 1px solid var(--gold);
}
.offline-banner[hidden] { display: none; }

/* ---------- main view ---------- */
.view { padding: 12px 12px 24px; max-width: 720px; margin: 0 auto; }
.loading { color: var(--ink-dim); text-align: center; padding: 40px 0; }
.error-note { color: var(--danger); text-align: center; padding: 40px 12px; }
.map-prompt { margin: 18px 4px 0; color: var(--ink-dim); font-size: 0.95rem; text-align: center; }
.room-head {
  margin: 22px 0 4px;
  font-family: var(--display); font-size: 1.4rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--brand-text);
}
.empty-note { color: var(--ink-dim); text-align: center; padding: 30px 10px; }

/* ---------- bottom tab bar ---------- */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--tab-bg);
  border-top: 1px solid var(--line);
  z-index: 50;
}

.tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-dim);
  font-size: 0.68rem;
}

.tab-bar a.active { color: var(--brand-text); }
.tab-icon { font-size: 1.15rem; line-height: 1; margin-bottom: 2px; }
.chip svg, .header-chip svg { margin-right: 6px; }
.chip.active .fa-solid { color: inherit; }

/* ---------- chips ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-dim);
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 0.85rem;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 0.78rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.inline-form { display: flex; gap: 8px; }
.text-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem; /* 16px keeps iOS from zooming on focus */
}

/* ---------- segmented controls ---------- */
.segmented {
  display: flex; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.segment {
  flex: 1; min-width: 0; min-height: 40px; padding: 4px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-dim);
  font: inherit; font-size: 0.88rem; font-weight: 600; line-height: 1.15; cursor: pointer;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}
.segment-label { font-family: var(--display); font-size: 1rem; font-weight: 600; letter-spacing: 0.02em; }
.segment-sub { font-size: 0.7rem; font-weight: 500; opacity: 0.85; }
.segment.active { background: var(--brand); color: var(--brand-ink); }
.segment:focus-visible, .icon-btn:focus-visible, .pick-toggle:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }

.day-bar {
  position: sticky; top: var(--safe-top); z-index: 6;
  height: var(--day-bar-h); margin: -12px -12px 0; padding: 10px 12px 8px;
  background: var(--bg);
}
.kind-row { display: flex; gap: 8px; margin: 6px 0 10px; }
.kind-row .segmented { flex: 1; }
.building-picker { margin-bottom: 4px; }

.icon-btn {
  position: relative; flex: none; width: 48px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--ink); font-size: 1rem; cursor: pointer;
}
.icon-btn[aria-expanded="true"] { border-color: var(--brand-text); color: var(--brand-text); }
.icon-btn .count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--gold); color: var(--on-gold); font-size: 0.7rem; font-weight: 700;
}
.icon-btn .count[hidden] { display: none; }

.filter-panel {
  margin: 0 0 12px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.filter-panel[hidden] { display: none; }
.filter-panel .chip-row { flex-wrap: wrap; overflow: visible; padding: 0; }
.filter-panel .chip:not(.active) { background: var(--panel-2); }
.filter-summary {
  display: flex; align-items: center; gap: 10px; margin: -2px 0 10px;
  color: var(--ink-dim); font-size: 0.82rem;
}
.filter-summary[hidden] { display: none; }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--brand-text); font: inherit; font-weight: 600; cursor: pointer; }

/* ---------- event cards ---------- */
.event-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}

.event-card.picked { border-color: var(--picked-line); }

.event-meta {
  display: flex;
  flex-wrap: wrap;
  column-gap: 8px; row-gap: 1px;
  align-items: baseline;
  color: var(--ink-dim);
  font-size: 0.78rem;
  margin-bottom: 4px;
}
.event-meta .time { color: var(--ink); font-weight: 600; white-space: nowrap; }
.table-code {
  padding: 0 6px; border-radius: 5px;
  background: var(--panel-2); color: var(--ink);
  font-family: var(--display); font-weight: 700; letter-spacing: 0.03em;
}
.room-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.room-link svg { font-size: 0.7rem; opacity: 0.7; }
.room-link:hover, .room-link:focus-visible { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

.event-head { display: flex; gap: 6px; align-items: flex-start; }
.event-main { flex: 1; min-width: 0; }
.pick-toggle {
  flex: none; width: 44px; height: 44px; margin: -10px -10px 0 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--ink-dim); font-size: 1.15rem; cursor: pointer;
}
.pick-toggle.is-picked { color: var(--star); }
.pick-toggle.just-picked svg { animation: star-pop 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes star-pop { from { transform: scale(0.55) rotate(-18deg); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .pick-toggle.just-picked svg { animation: none; } }
.event-title { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; line-height: 1.25; }
.event-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.event-tags .tag {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-dim);
}
.event-tags .tag { display: inline-flex; align-items: center; }
.event-tags .tag .dot, .chip .dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex: none; }
.event-tags .tag.tournament { border-color: var(--gold); background: var(--gold-wash); color: var(--ink); font-weight: 600; }
.event-people { color: var(--ink-dim); font-size: 0.82rem; margin: 0 0 8px; }

.event-detail { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.event-detail p { margin: 0 0 10px; font-size: 0.9rem; line-height: 1.45; white-space: pre-line; }
.detail-label {
  color: var(--ink-dim); font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.08em; margin: 10px 0 4px;
}
.source-link { color: var(--brand-text); font-size: 0.85rem; font-weight: 600; }

/* ---------- section headers ---------- */
.section-head {
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 20px 0 8px;
  letter-spacing: 0.02em;
}

.time-head { position: sticky; top: calc(var(--safe-top) + var(--day-bar-h)); z-index: 5; margin: 14px -12px 8px; padding: 6px 12px; background: var(--bg); color: var(--brand-text); font-family: var(--display); font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em; }
.text-input.search { display: block; width: 100%; margin: 0 0 10px; }

/* ---------- rooms with opening hours ---------- */
.hours-row {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  padding: 8px 12px; font-size: 0.85rem; border-bottom: 1px solid var(--line);
}
.hours-row:last-child { border-bottom: none; }
.hours-row.open .hours-name::after { content: ' · open now'; color: var(--open); font-weight: 600; }
.hours-name { font-weight: 600; }
.hours-room { flex: 1; color: var(--ink-dim); font-size: 0.78rem; }
.hours-time { color: var(--ink-dim); white-space: nowrap; }

/* ---------- passed / ended events ---------- */
.passed-group { margin: 12px 0; }
.passed-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink-dim);
  font-size: 0.85rem;
}
.passed-group > summary::-webkit-details-marker { display: none; }
.passed-group > summary::before {
  content: '▸';
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}
.passed-group[open] > summary::before { transform: rotate(90deg); }
.passed-group[open] > summary { margin-bottom: 4px; }
/* Ended items read as muted history, not live options. */
.passed-group .agenda-item, .passed-group .event-card { opacity: 0.6; }
.passed-group .section-head:first-of-type { margin-top: 10px; }

/* ---------- my plan (agenda) ---------- */
.plan-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.plan-note { color: var(--ink-dim); font-size: 0.82rem; }
.agenda-item {
  display: flex; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.agenda-item.conflict { border-color: var(--danger); }
.agenda-time { flex: none; width: 72px; font-weight: 600; font-size: 0.85rem; }
.agenda-body { flex: 1; min-width: 0; }
.agenda-item .pick-toggle { margin: -10px -10px -10px 0; }
.agenda-title { font-weight: 600; font-size: 0.92rem; margin: 0 0 2px; }
.agenda-room { color: var(--ink-dim); font-size: 0.78rem; }
.conflict-note { color: var(--danger); font-size: 0.78rem; font-weight: 600; margin-top: 4px; }

/* ---------- maps ---------- */
.floor-map { display: block; width: 100%; max-width: 420px; height: auto; margin: 8px auto 0; }
.floor-map .room { fill: var(--panel-2); stroke: var(--ink-dim); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.floor-map .room.highlight { fill: var(--gold); }
.floor-map .room.tappable { cursor: pointer; }
.floor-map text { fill: var(--ink); font-size: 7.5px; font-family: var(--display); font-weight: 600; pointer-events: none; }
.floor-map text.big { font-size: 10px; font-weight: 600; }
.floor-map text.small { font-size: 5.5px; }
.floor-map text.sub { font-size: 5px; fill: var(--ink-dim); }
.floor-map text.landmark-label { font-size: 5.5px; fill: var(--ink-dim); }
.floor-map text.anchor { font-size: 6px; font-weight: 700; letter-spacing: 0.04em; fill: var(--brand-text); }
.floor-map .landmark { color: var(--ink-dim); }
/* The Gateway plan is wide: pan it on phones instead of shrinking it to nothing. */
.map-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 0 12px; }
.map-scroll .floor-map.landscape { min-width: 720px; max-width: none; }
.mini-map .floor-map.landscape text:not(.big):not(.anchor) { display: none; }
.floor-map .room.highlight + text { fill: var(--on-gold); font-weight: 700; }
.floor-map .room.highlight + text + text.sub { fill: var(--on-gold); }
.floor-map .arrowhead { fill: var(--brand-text); }
.floor-map .route { fill: none; stroke: var(--brand-text); vector-effect: non-scaling-stroke; }
.floor-map .landmark { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.map-caption { color: var(--ink-dim); font-size: 0.82rem; margin: 6px 0 0; }
.map-note {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink-dim); font-size: 0.8rem;
}
.mini-map { margin-top: 10px; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.panel.welcome { margin-top: 24px; }
.panel-title { margin: 0 0 6px; font-size: 1.05rem; }
.panel-text { margin: 0 0 12px; color: var(--ink-dim); font-size: 0.88rem; line-height: 1.5; }

.back-link {
  display: block;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 0;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 100;
  animation: toast-in 0.2s ease-out;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
}
.toast-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-action { flex: none; border: 0; background: none; padding: 2px 0; color: var(--gold); font: inherit; font-weight: 700; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (min-width: 720px) {
  .app-title { font-size: 1.6rem; }
}
