:root {
  color-scheme: light dark;
  --border: #d8d8d8;
  --muted: #666;
  --accent: #2a5;

  /* Row colour-coding relative to the Shabbos/Yom Tov window (see legend in the page) */
  --row-buffer-border: #999;
  --row-buffer-bg: rgba(153, 153, 153, 0.10);
  --row-twilight-border: #d1a318;
  --row-twilight-bg: rgba(209, 163, 24, 0.12);
  --row-shabbos-border: #2f6fd1;
  --row-shabbos-bg: rgba(47, 111, 209, 0.10);

  /* Custom player bar: buffered vs played need to be clearly distinguishable at a glance */
  --player-track: color-mix(in srgb, var(--border) 55%, transparent);
  --player-buffered: color-mix(in srgb, var(--muted) 45%, transparent);
  --player-progress: var(--accent);
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  line-height: 1.4;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  margin-bottom: 0.1rem;
  font-size: 1.5rem;
}
.page-header .subtitle {
  margin-top: 0;
  color: var(--muted);
}
.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex: 0 0 auto;
}
.logo-card {
  /* The logo is a full-colour JPG on a white backing (not transparent) — rather than strip
     that background (risky for a multi-colour brand mark's contrast on a dark page), it gets
     a small fixed-white card so it always displays cleanly regardless of site theme. */
  display: inline-flex;
  background: #fff;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  line-height: 0;
}
.header-logo {
  height: 2.2rem;
  width: auto;
  object-fit: contain;
  display: block;
}
.logout-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
}
.logout-link:hover { color: inherit; border-color: var(--muted); }

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1.25rem 0 0.75rem;
  flex-wrap: wrap;
}

.week-nav button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
}
.week-nav button:disabled {
  opacity: 0.4;
  cursor: default;
}

.block-info {
  text-align: center;
  flex: 1;
  min-width: 220px;
}
.block-info .occasion {
  font-weight: 600;
  font-size: 1.1rem;
}
.block-info .times {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
  flex-wrap: wrap;
}
.time-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.time-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.time-big {
  font-size: 1.5rem;
  font-weight: 700;
  color: inherit;
}
.date-small {
  font-size: 0.78rem;
  color: var(--muted);
}
.occasion-icon {
  /* Sized to visually span both lines of .time-stack (the big time + the small date below it) */
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  flex: 0 0 auto;
}
/* These are flat black line-art PNGs with no colour info to adapt automatically like an
   inline SVG using currentColor would — invert them in dark mode so they stay visible
   (black-on-transparent -> white-on-transparent) instead of vanishing into a dark background. */
@media (prefers-color-scheme: dark) {
  .occasion-icon { filter: invert(1); }
}
:root[data-theme="dark"] .occasion-icon { filter: invert(1); }
:root[data-theme="light"] .occasion-icon { filter: none; }
/* Visually hidden but still readable by screen readers — the icons replace this text
   visually (per Stuart: icons instead of the "start"/"end" words), but the meaning still
   needs to be available non-visually. */
.sr-label {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status {
  color: var(--muted);
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
}

.progress-panel {
  position: sticky;
  top: 0;
  z-index: 20;
  background: Canvas;
  margin: 0 0 1rem;
  padding: 0.6rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
}
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.progress-bar {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 16px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
  overflow: visible;
  cursor: pointer;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: var(--accent);
  transition: width 0.2s linear;
  pointer-events: none;
}
.progress-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--muted);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}
.progress-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--muted);
}
.progress-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.master-playbtn {
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: Canvas;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.master-playbtn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.master-speed {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: Canvas;
  color: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.4rem;
  cursor: pointer;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 3px;
}
.swatch-buffer   { background: var(--row-buffer-border); }
.swatch-twilight { background: var(--row-twilight-border); }
.swatch-shabbos  { background: var(--row-shabbos-border); }

.selection-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.selection-bar button {
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}
.selection-bar button:disabled {
  opacity: 0.4;
  cursor: default;
}
.selection-bar #selectionCount {
  color: var(--muted);
}
.route-search {
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: Canvas;
  color: inherit;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  min-width: 200px;
}

.rec-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.rec-table th, .rec-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.35rem;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
}
.rec-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
/* Column widths: everything except the player is kept as narrow as it can comfortably be,
   so the player itself (and its scrubber) gets the lion's share of the row. */
col.col-check { width: 2rem; }
col.col-num   { width: 2.2rem; }
col.col-time  { width: 4.6rem; }
col.col-route { width: 8.5rem; }
col.col-dur   { width: 3rem; }
col.col-play  { width: auto; }

.rec-table .route-cell {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-size: 0.85rem;
}
.rec-table .route-arrow {
  color: var(--muted);
  margin: 0 0.3em;
}

.rec-table .play-cell { padding-right: 0.5rem; }

.player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}
.player-playbtn {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.player-playbtn:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

.player-track {
  position: relative;
  flex: 1 1 auto;
  height: 10px;
  border-radius: 5px;
  background: var(--player-track);
  cursor: pointer;
  overflow: hidden;
  min-width: 60px;
}
.player-buffered {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: var(--player-buffered);
}
.player-progress {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: var(--player-progress);
  pointer-events: none;
}

.player-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.player-dl {
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem;
}
.player-dl:hover { color: var(--accent); }

.rec-table td .secs {
  font-size: 0.75em;
  opacity: 0.7;
}

.rec-table tr.row-buffer   { border-left: 4px solid var(--row-buffer-border);   background: var(--row-buffer-bg); }
.rec-table tr.row-twilight { border-left: 4px solid var(--row-twilight-border); background: var(--row-twilight-bg); }
.rec-table tr.row-shabbos  { border-left: 4px solid var(--row-shabbos-border);  background: var(--row-shabbos-bg); }

/* Synch Bot rows (automated system messages) — bold to stand out, on top of whichever
   Shabbos/buffer colour class the row also has. The player's own time readout is left at
   normal weight so it doesn't compete with the bolded route/time/duration text. */
.rec-table tr.row-synchbot { font-weight: 700; }
.rec-table tr.row-synchbot .player-time { font-weight: 400; }

@media (max-width: 560px) {
  .rec-table thead { display: none; }
  .rec-table, .rec-table tbody, .rec-table tr, .rec-table td {
    display: block;
    width: 100%;
  }
  .rec-table tr {
    border-bottom: 2px solid var(--border);
    padding: 0.5rem 0;
  }
  .rec-table td {
    border-bottom: none;
    padding: 0.15rem 0;
  }
  .player { max-width: 100%; }
}
