:root {
  --bg: #f4f7f2;
  --surface: #ffffff;
  --text: #1a2e1a;
  --text-muted: #5a6b5a;
  --border: #d4dfd0;
  --accent: #2d6a4f;
  --accent-light: #40916c;
  --star: #d4a017;
  --star-empty: #b8c4b0;
  --shadow: 0 1px 2px rgba(26, 46, 26, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --font: "DM Sans", system-ui, sans-serif;
  --font-display: "Playfair Display", Georgia, serif;
  --chrome-h: 11rem;
  --touch: 44px;

  --turnstone: #2a9d8f;
  --curlew: #8b6914;
  --avocet: #457b9d;
  --osprey: #588157;
  --plover: #bc6c25;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--chrome-h) + 0.5rem);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-x: hidden;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.label-short { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Sticky chrome — header + filters stick together */
.site-chrome {
  position: sticky;
  top: 0;
  z-index: 200;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  box-shadow: var(--shadow);
}

/* Header */
.header {
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 60%, #40916c 100%);
  color: #fff;
  padding: 0.65rem max(0.75rem, env(safe-area-inset-right)) 0.75rem max(0.75rem, env(safe-area-inset-left));
  box-shadow: none;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 0.6rem;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  grid-row: 1;
}

.header-titles {
  min-width: 0;
}

.header-titles h1,
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 0.6875rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-toggle {
  display: flex;
  width: 100%;
  grid-row: 2;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.view-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  min-height: var(--touch);
  flex: 1;
  min-width: 0;
  padding: 0 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.view-btn.active {
  background: #fff;
  color: var(--accent);
}

.starred-count {
  background: var(--star);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  min-width: 1.125rem;
  height: 1.125rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}

.view-btn.active .starred-count {
  background: var(--accent);
}

.view-link {
  text-decoration: none;
}

.view-link.active {
  background: #fff;
  color: var(--accent);
}

/* Now banner */
.now-banner {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: #e8f5e9;
  border: 1px solid #c5e1a5;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.now-banner-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.now-banner-clock {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.now-banner-hint {
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.35;
}

/* Main */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 1.5rem max(0.75rem, env(safe-area-inset-left));
}

/* Filters */
.filters {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
  margin-bottom: 0;
}

.filter-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.5rem;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

#search {
  width: 100%;
  height: var(--touch);
  padding: 0 0.75rem 0 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

#search:focus {
  outline: none;
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.2);
}

.filter-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-toggle.is-open,
.filter-toggle[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-toggle-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 700;
}

.filter-toggle.is-open .filter-toggle-badge,
.filter-toggle[aria-expanded="true"] .filter-toggle-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.filter-panel {
  border-top: 1px solid var(--border);
  padding: 0.5rem;
}

.filter-panel[hidden] {
  display: none;
}

.filter-row {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-group label,
.filter-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.filter-group select {
  width: 100%;
  height: var(--touch);
  padding: 0 2rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.stage-chips-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0 -0.25rem;
  padding: 0.15rem 0.25rem 0.35rem;
  scrollbar-width: none;
}

.stage-chips-scroll::-webkit-scrollbar {
  display: none;
}

.stage-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  width: max-content;
  min-width: 100%;
}

.stage-chip {
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  min-height: var(--touch);
  padding: 0 0.875rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.stage-chip.active {
  background: var(--chip-color, var(--accent));
  border-color: var(--chip-color, var(--accent));
  color: #fff;
}

.clear-btn {
  width: 100%;
  min-height: var(--touch);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.results-meta {
  margin-bottom: 0.4rem;
}

.results-meta p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Schedule */
.schedule {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.day-section h2 {
  position: sticky;
  top: calc(var(--chrome-h) + 0.25rem);
  z-index: 100;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.event-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.time-block {
  border-bottom: 1px solid var(--border);
}

.time-block:last-child {
  border-bottom: none;
}

.time-block--next {
  background: #f0faf4;
}

.time-col {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.time-block--next .time-col {
  background: #e0f2e9;
}

.time-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.time-label-badge {
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.events-col {
  min-width: 0;
}

.event-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.event-row:last-child {
  border-bottom: none;
}

.event-row.is-starred {
  background: #fffdf5;
}

.event-row--next {
  background: rgba(64, 145, 108, 0.08);
  box-shadow: inset 3px 0 0 var(--accent-light);
}

.event-row-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.event-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.event-title {
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.3;
}

.event-speaker {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.event-relative {
  margin-left: auto;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent-light);
  white-space: nowrap;
}

.star-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  min-width: var(--touch);
  min-height: var(--touch);
  margin: -0.35rem -0.5rem -0.35rem auto;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--star-empty);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.star-btn.starred { color: var(--star); }

.stage-badge {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  color: #fff;
  line-height: 1.2;
}

.stage-badge[data-stage="Turnstone Stage"] { background: var(--turnstone); }
.stage-badge[data-stage="Curlew Stage"] { background: var(--curlew); }
.stage-badge[data-stage="Avocet Stage"] { background: var(--avocet); }
.stage-badge[data-stage="Osprey Stage"] { background: var(--osprey); }
.stage-badge[data-stage="Plover Stage"] { background: var(--plover); }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

@media (max-width: 380px) {
  .label-long { display: none; }
  .label-short { display: inline; }

  .view-btn {
    padding: 0 0.35rem;
    font-size: 0.75rem;
  }

  .brand h1 { font-size: 1rem; }
  .header-titles h1 { font-size: 1rem; }
}

@media (min-width: 768px) {
  :root {
    --chrome-h: 7rem;
  }

  body { font-size: 0.875rem; }

  .filters {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 0.5rem;
  }

  .filter-toggle { display: none; }

  .filter-panel {
    display: block !important;
    border-top: none;
    padding: 0 0.65rem 0.65rem;
  }

  .filter-panel[hidden] {
    display: block !important;
  }

  .filter-toolbar {
    padding-bottom: 0;
  }

  .filter-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
  }

  .filter-group {
    flex-direction: row;
    align-items: center;
  }

  .filter-group select {
    width: auto;
    height: auto;
    font-size: 0.75rem;
    padding: 0.25rem 1.5rem 0.25rem 0.45rem;
  }

  #search {
    height: auto;
    font-size: 0.8125rem;
    padding: 0.35rem 0.5rem 0.35rem 1.75rem;
  }

  .stage-chips {
    flex-wrap: wrap;
    width: auto;
  }

  .stage-chip {
    min-height: auto;
    font-size: 0.6875rem;
    padding: 0.15rem 0.45rem;
  }

  .clear-btn {
    width: auto;
    min-height: auto;
    font-size: 0.6875rem;
    padding: 0.2rem 0.5rem;
  }

  .now-banner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.75rem;
  }

  .now-banner-clock { font-size: inherit; }

  .now-banner-hint {
    flex: 1;
    text-align: right;
  }

  .time-block {
    display: grid;
    grid-template-columns: 3.25rem 1fr;
  }

  .time-col {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0.35rem 0.25rem;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }

  .time-val { font-size: 0.75rem; text-align: center; }

  .time-label-badge {
    font-size: 0.55rem;
    border-radius: 3px;
    padding: 0.1rem 0.25rem;
  }

  .event-row {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.45rem;
    min-height: 1.75rem;
  }

  .event-row--next {
    box-shadow: none;
  }

  .event-row-meta {
    display: contents;
  }

  .event-row .stage-badge { order: 1; }

  .event-main {
    flex: 1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.4rem;
    order: 2;
  }

  .event-speaker::before {
    content: "·";
    margin-right: 0.4rem;
    color: var(--border);
  }

  .event-relative { order: 3; margin-left: 0; }

  .event-row .star-btn {
    order: 4;
    min-width: auto;
    min-height: auto;
    margin: 0;
    font-size: 0.95rem;
  }

  .event-title { font-size: 0.8125rem; }
  .event-speaker { font-size: 0.75rem; }

  .stage-badge {
    width: 4.5rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.6rem;
    padding: 0.1rem 0.35rem;
  }
}

@media (min-width: 1024px) {
  .header-inner {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
    align-items: center;
  }

  .header-title-row {
    grid-row: 1;
    grid-column: 1;
  }

  .view-toggle {
    grid-row: 1;
    grid-column: 2;
    width: auto;
  }

  .header-titles h1 { font-size: 1.1rem; }
  .subtitle { font-size: 0.7rem; }

  .view-btn {
    flex: none;
    min-height: 2rem;
    min-width: 0;
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
  }
}
