:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-muted: #f1f3f0;
  --text: #171917;
  --muted: #6f746f;
  --line: #dfe3de;
  --accent: #b7ed28;
  --danger: #d84e3f;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { color: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell { min-height: 100vh; }
.app-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.app-header h1 { margin: 0; font-size: 1.1rem; letter-spacing: -.02em; }
.brand-block { display: flex; align-items: center; gap: 22px; }
.source-nav {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-muted);
}
.source-nav button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0 12px;
  color: var(--muted);
  font: 650 .62rem var(--mono);
  cursor: pointer;
}
.source-nav button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.refresh-button, .copy-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 0 12px;
  font: 650 .68rem var(--mono);
  cursor: pointer;
}
.refresh-button:hover, .copy-button:hover { border-color: #9ba19a; background: var(--surface-muted); }
.refresh-button:disabled { opacity: .5; cursor: wait; }
.mobile-nav { display: none; }
.to-top-button {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #242824;
  border-radius: 50%;
  background: #242824;
  color: var(--accent);
  box-shadow: 0 8px 24px rgba(23, 25, 23, .18);
  font: 700 1rem var(--mono);
  cursor: pointer;
  animation: floatButtonIn .16s ease-out;
}
.to-top-button:hover { background: #111311; }
.to-top-button[hidden] { display: none; }
@keyframes floatButtonIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, .85fr) minmax(0, 1.15fr);
  max-width: 1600px;
  min-height: calc(100vh - 78px);
  margin: 0 auto;
}
.events-pane, .streams-pane { min-width: 0; padding: 26px clamp(20px, 3vw, 42px) 44px; }
.events-pane { border-right: 1px solid var(--line); }
.streams-pane { background: var(--surface); }
.pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.pane-heading > div { display: flex; align-items: center; }
.pane-heading h2 { margin: 0; font-size: .85rem; letter-spacing: .01em; text-transform: uppercase; }
.pane-heading strong { font: 650 .85rem var(--mono); }
.pane-heading strong small { color: var(--muted); font-size: .64rem; }

.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.search-box > span:first-child { color: var(--muted); font-size: 1.1rem; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: .77rem; }
.filter-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin: 12px 0 16px;
}
.category-filter { display: grid; gap: 5px; }
.category-filter > span { color: var(--muted); font: 650 .53rem var(--mono); text-transform: uppercase; }
.category-filter select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 0 30px 0 9px;
  color: var(--text);
  font-size: .7rem;
  cursor: pointer;
}
.filter-toggle {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font: .66rem var(--mono);
  cursor: pointer;
}
.filter-toggle input { position: absolute; opacity: 0; }
.filter-toggle > span { width: 28px; height: 16px; border-radius: 20px; background: #c8cdc7; padding: 3px; transition: .18s; }
.filter-toggle > span::after { content: ""; display: block; width: 10px; height: 10px; border-radius: 50%; background: white; transition: .18s; }
.filter-toggle input:checked + span { background: #262a26; }
.filter-toggle input:checked + span::after { transform: translateX(12px); background: var(--accent); }

.event-list { display: grid; gap: 7px; max-height: calc(100vh - 245px); overflow: auto; padding-right: 4px; }
.event-card {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 48px minmax(0, 1fr) 20px;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 11px;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.event-card:hover { border-color: #aeb4ad; }
.event-card.active { border-color: #242824; background: #242824; color: white; }
.event-card:disabled { opacity: .5; cursor: not-allowed; }
.event-index, .event-arrow { color: #999e98; font: .59rem var(--mono); }
.event-arrow { text-align: right; font-size: .85rem; color: inherit; }
.team-avatars { position: relative; display: flex; align-items: center; min-width: 45px; }
.team-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: #e8ebe7;
  color: #4a5049;
  font: 650 .54rem var(--mono);
}
.team-avatar + .team-avatar { margin-left: -20px; }
.team-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
  background: #d9ded8;
  box-shadow: inset 0 0 0 1px #c8cec7;
}
.active .team-avatar { border-color: #242824; }
.sport-card .event-copy b { margin: 5px 0 7px; }
.event-copy { min-width: 0; }
.event-copy b, .event-copy small, .team-names { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-copy b { margin: 3px 0; font-size: .78rem; }
.team-names { margin-bottom: 5px; color: #4d524d; font-size: .64rem; font-weight: 600; }
.team-names em { margin: 0 3px; color: #9a9e99; font: .49rem var(--mono); font-style: normal; }
.event-copy small { color: var(--muted); font: .56rem var(--mono); }
.event-copy small > span { margin-right: 5px; color: #5a6950; font-size: .48rem; font-weight: 700; }
.active .team-names, .active .event-copy small { color: #c8ccc7; }
.event-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.event-meta em { color: var(--muted); font: .5rem var(--mono); font-style: normal; text-transform: uppercase; }
.active .event-meta em { color: var(--accent); }
.event-meta i { color: var(--muted); font: .48rem var(--mono); font-style: normal; }
.event-meta i::before { content: "•"; margin-right: 3px; }
.event-meta i.status-live { color: #3f7a32; }
.event-meta i.status-upcoming { color: #56758f; }
.event-meta i.status-started { color: #8a702c; }
.event-meta i.status-ended, .event-meta i.status-unknown { color: #929792; }
.event-meta i.status-hidden { color: #9b7772; }

.select-prompt {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
}
.select-prompt h3 { margin: 15px 0 5px; color: var(--text); font-size: .92rem; }
.select-prompt p { max-width: 390px; margin: 0; font-size: .72rem; line-height: 1.6; }
.select-prompt code { font-size: .65rem; overflow-wrap: anywhere; }
.prompt-orbit { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-muted); }
.prompt-orbit span { color: var(--muted); font: 650 .62rem var(--mono); }
.error-box { display: grid; gap: 4px; margin-bottom: 14px; padding: 11px; border: 1px solid #f0c8c2; border-radius: 7px; background: #fff5f3; }
.error-box[hidden] { display: none; }
.error-box b { color: var(--danger); font-size: .68rem; }
.error-box span { color: #87534c; font-size: .66rem; }

.result-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.result-header small { color: var(--muted); font: .5rem var(--mono); text-transform: uppercase; }
.result-header h3 { margin: 3px 0 0; font-size: .9rem; }
.result-title { min-width: 0; display: flex; align-items: center; gap: 9px; }
.result-title > span { min-width: 0; }
.result-title h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-button {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}
.back-button-wide { width: auto; padding: 0 9px; font: 650 .58rem var(--mono); white-space: nowrap; }
.copy-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.channel-list { display: grid; gap: 7px; }
.channel-card {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 11px 13px;
  text-align: left;
  cursor: pointer;
}
.channel-card:hover { border-color: #aeb4ad; background: #fafbfa; }
.channel-card:disabled { opacity: .5; cursor: not-allowed; }
.channel-logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #d9ded8;
  color: #4a5049;
  font: 650 .52rem var(--mono);
  box-shadow: inset 0 0 0 1px #c8cec7;
}
.channel-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.channel-card > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.channel-card small { color: var(--muted); font: .48rem var(--mono); }
.channel-card b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
.channel-card em { overflow: hidden; color: var(--muted); font-size: .58rem; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.channel-card > i { font-style: normal; text-align: right; }
.stream-list { display: grid; gap: 7px; }
.stream-card { display: grid; grid-template-columns: 38px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 9px; background: var(--surface); overflow: hidden; }
.stream-card.open { border-color: #aeb4ad; }
.stream-number { display: grid; place-items: start center; padding-top: 20px; border-right: 1px solid var(--line); background: var(--surface-muted); color: var(--muted); font: .56rem var(--mono); }
.stream-body { min-width: 0; }
.stream-summary { display: flex; align-items: stretch; min-width: 0; }
.stream-toggle {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: var(--surface);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}
.quick-copy { flex: 0 0 auto; align-self: center; margin-right: 12px; white-space: nowrap; }
.stream-toggle:hover { background: #fafbfa; }
.stream-heading { min-width: 0; display: grid; gap: 7px; }
.stream-heading strong { overflow: hidden; text-overflow: ellipsis; font-size: .76rem; text-transform: uppercase; }
.stream-chevron { flex: 0 0 auto; color: var(--muted); font-size: 1rem; transition: transform .18s; }
.stream-toggle[aria-expanded="true"] .stream-chevron { transform: rotate(180deg); color: var(--text); }
.stream-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.stream-tags span { border-radius: 4px; background: var(--surface-muted); padding: 3px 5px; color: var(--muted); font: .48rem var(--mono); text-transform: uppercase; }
.stream-details { padding: 0 14px 14px; border-top: 1px solid var(--line); animation: dropIn .16s ease-out; }
.stream-details[hidden] { display: none; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0 9px; color: var(--muted); font: .5rem var(--mono); }
.detail-fields { display: grid; gap: 6px; }
.detail-field { min-width: 0; display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px; border-radius: 6px; background: var(--surface-muted); }
.field-label { color: var(--muted); font: 650 .52rem var(--mono); text-transform: uppercase; }
.detail-field code { min-width: 0; overflow: auto; color: #343934; font: .6rem/1.45 var(--mono); white-space: nowrap; }
.detail-field code.multiline { max-height: 220px; white-space: pre-wrap; word-break: break-word; }
.empty-state { min-height: 130px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: .7rem; }
.spinner { width: 14px; height: 14px; border: 2px solid #d1d5d0; border-top-color: #4f544e; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.large { width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #7ea719; outline-offset: 2px; }

@media (max-width: 900px) {
  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 7px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 247, 245, .96);
    backdrop-filter: blur(10px);
  }
  .mobile-nav button {
    min-height: 38px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 650;
    cursor: pointer;
  }
  .mobile-nav button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
  .workspace { grid-template-columns: 1fr; }
  .events-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .event-list { max-height: none; }
  body[data-mobile-view="events"] .streams-pane { display: none; }
  body[data-mobile-view="streams"] .events-pane { display: none; }
  body[data-mobile-view="streams"] .streams-pane { min-height: calc(100vh - 53px); }
}
@media (max-width: 560px) {
  .app-header { padding: 15px 16px; }
  .brand-block { gap: 12px; }
  .source-nav button { padding: 0 9px; }
  .events-pane, .streams-pane { padding: 22px 16px 36px; }
  .filter-controls { grid-template-columns: 1fr; align-items: start; }
  .event-card { grid-template-columns: 20px 42px minmax(0, 1fr) 16px; gap: 6px; padding: 9px 7px; }
  .team-avatar { width: 31px; height: 31px; flex-basis: 31px; }
  .team-avatar + .team-avatar { margin-left: -20px; }
  .result-header { align-items: flex-start; }
  .result-header > .copy-button { min-height: 32px; padding: 0 9px; white-space: nowrap; }
  .back-button-wide { width: 32px; padding: 0; }
  .back-button-wide span { display: none; }
  .stream-card { grid-template-columns: 32px minmax(0, 1fr); }
  .stream-number { padding-top: 18px; }
  .stream-toggle { padding: 11px 10px; }
  .quick-copy { min-width: 34px; margin-right: 7px; padding: 0 8px; }
  .quick-copy span:last-child { display: none; }
  .stream-details { padding: 0 9px 11px; }
  .detail-field { grid-template-columns: 1fr auto; }
  .detail-field code { grid-column: 1 / -1; grid-row: 2; }
  .field-copy { grid-column: 2; grid-row: 1; }
  .to-top-button { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
}
/* BitTV source selector and property browser. */
[hidden] { display: none !important; }
h2 { margin: 0; font-size: .85rem; text-transform: uppercase; }
.app-header h1 { font-size: 1.15rem; }
.app-header h1 span { color: var(--muted); font-weight: 450; }
.brand-note, .details-note { color: var(--muted); font: .65rem var(--mono); }
.source-picker { margin: 0 0 20px; }
.source-nav { flex-shrink: 0; }
.source-nav button { min-height: 34px; font-size: .68rem; }
.source-nav button[aria-pressed="true"], .mobile-nav button[aria-pressed="true"] { background: white; color: var(--text); box-shadow: 0 0 0 1px var(--line); }
#feed-picker { margin-top: 0; }
.category-filter select { height: 40px; font-size: .78rem; }
.catalog-status { margin: 8px 0 0; font-size: .7rem; color: var(--muted); }
.catalog-status:empty { display: none; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.list-toolbar > span { color: var(--muted); font: .62rem var(--mono); }

.event-card { grid-template-columns: 22px 42px minmax(0,1fr) 16px; }
.event-copy b { white-space: normal; line-height: 1.4; font-size: .8rem; }
.event-copy .tagline { white-space: normal; font-size: .68rem; line-height: 1.5; margin: 5px 0; }
.event-copy .schedule { font-size: .6rem; line-height: 1.5; }
.channel-logo { border-radius: 7px; background: #edf0eb; }
.channel-logo img { padding: 0; }
.event-meta { flex-wrap: wrap; }
.result-header h3 { white-space: normal; line-height: 1.4; }
.selection-tagline { color: var(--muted); font-size: .8rem; line-height: 1.6; margin: 0 0 18px; }
.detail-fields { margin-top: 12px; }
.detail-field { grid-template-columns: 115px minmax(0,1fr) auto; }
.detail-field code { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .68rem; max-height: 220px; }
.field-label { font-size: .59rem; line-height: 1.6; }
.field-heading { margin: 22px 0 10px; font: 650 .65rem var(--mono); color: var(--muted); text-transform: uppercase; }
.detail-toolbar { padding: 0; }
.detail-toolbar .copy-button { font-size: .65rem; }
.copy-button:disabled { opacity: .45; cursor: default; }
.page-error { margin: 12px clamp(16px,3vw,48px); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 12px 20px; border-radius: 8px; background: #242824; color: white; font-size: .8rem; box-shadow: 0 6px 25px #0002; z-index: 50; max-width: calc(100vw - 40px); }
button, select { touch-action: manipulation; }
@media (max-width: 900px) { .event-list { max-height: none; } }
@media (max-width: 560px) {
  .brand-note { display: none; }
  .detail-field { grid-template-columns: 1fr auto; }
  .detail-field code { grid-column: 1 / -1; grid-row: 2; }
  .result-header { flex-wrap: wrap; }
  .result-header > .copy-button { margin-left: auto; }
  .select-prompt { min-height: 300px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.raw-details { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.raw-details summary { cursor: pointer; font: .7rem var(--mono); color: var(--muted); }
.raw-details pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 450px; overflow: auto; font: .65rem/1.6 var(--mono); }
/* Minimal browse/copy layout. */
.event-card { grid-template-columns: 42px minmax(0,1fr) 16px; padding: 12px; gap: 12px; }
.event-copy b { margin: 0 0 4px; }
.event-copy .tagline { margin: 0; }
.list-more { margin: 10px 0 14px; text-align: right; }
.list-more > summary { display: inline-block; cursor: pointer; color: var(--muted); font-size: .7rem; padding: 5px; }
.list-more > button { margin-left: 8px; }
.minimal-disclosure { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 16px; }
.minimal-disclosure > summary { cursor: pointer; font-size: .8rem; color: var(--muted); padding: 4px 0; }
.minimal-disclosure[open] > summary { color: var(--text); }
.more-actions, .pair-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pair-actions { justify-content: flex-end; }
.detail-field { padding: 12px; background: #f6f7f5; }
.detail-field code { font-size: .73rem; }
.result-title h3 { margin: 0; }
@media (max-width:560px) { .event-card { grid-template-columns: 38px minmax(0,1fr) 14px; padding: 11px 9px; gap: 9px; } }

/* Keep the catalog controls compact and give the list the remaining viewport. */
@media (min-width: 901px) {
  .app-shell { height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
  .app-header, .page-error { flex-shrink: 0; }
  .workspace { flex: 1; width: 100%; min-height: 0; overflow: hidden; }
  .events-pane, .streams-pane { min-height: 0; padding-bottom: 20px; }
  .events-pane { display: flex; flex-direction: column; }
  .events-pane > :not(.event-list) { flex-shrink: 0; }
  .event-list { flex: 1; min-height: 0; max-height: none; align-content: start; overscroll-behavior: contain; }
  .streams-pane { overflow: auto; }
}
@media (max-width: 560px) {
  .app-header { gap: 8px; flex-wrap: wrap; }
  .brand-block { gap: 10px; }
  .app-header h1 { font-size: 1rem; white-space: nowrap; }
  .source-nav button { padding: 0 8px; font-size: .62rem; }
  .refresh-button { padding: 0 9px; }
}
