:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #5b9fd4;
  --on-accent: #0f1419;
  --error: #e57373;
  --row-hover: rgba(91, 159, 212, 0.08);
  --row-mine: rgba(91, 159, 212, 0.18);
  --row-mine-hover: rgba(91, 159, 212, 0.26);
  --table-head-bg: rgba(0, 0, 0, 0.15);
  --shadow-elevated: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f0f3f8;
  --surface: #ffffff;
  --border: #c5d0de;
  --text: #1a2332;
  --muted: #5c6b7f;
  --accent: #2d7bb8;
  --on-accent: #ffffff;
  --error: #c62828;
  --row-hover: rgba(45, 123, 184, 0.08);
  --row-mine: rgba(45, 123, 184, 0.14);
  --row-mine-hover: rgba(45, 123, 184, 0.22);
  --table-head-bg: rgba(0, 0, 0, 0.04);
  --shadow-elevated: 0 -4px 24px rgba(26, 35, 50, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

header,
.page-header {
  margin-bottom: 1.5rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
}

.page-header-main {
  flex: 1 1 12rem;
  min-width: 0;
}

.page-header-main h1 {
  margin: 0 0 0.35rem;
}

.page-header-main .subtitle {
  margin: 0;
}

.theme-switch {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.theme-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}

.theme-switch-icon {
  display: block;
  width: 1.125rem;
  height: 1.125rem;
}

.theme-switch-btn:last-child {
  border-right: none;
}

.theme-switch-btn:hover {
  color: var(--text);
  background: var(--row-hover);
}

.theme-switch-btn[aria-pressed="true"] {
  color: var(--text);
  background: var(--row-mine);
  font-weight: 600;
}

.page-header-toolbar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
}

.join-qr-header-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.join-qr-header-btn[hidden] {
  display: none !important;
}

#youtube-queue-open-btn[hidden] {
  display: none !important;
}

.youtube-queue-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.youtube-queue-url-row .search-input {
  flex: 1 1 auto;
  min-width: 0;
}

.youtube-queue-fetch-btn {
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.search-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.search-query-field {
  flex: 1 1 12rem;
  min-width: 0;
}

#search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

#search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.status.loading {
  color: var(--accent);
}

.status.error {
  color: var(--error);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--table-head-bg);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--row-hover);
}

#queue-table tbody tr.queue-row--mine {
  background: var(--row-mine);
}

#queue-table tbody tr.queue-row--mine:hover {
  background: var(--row-mine-hover);
}

#queue-table tbody tr.queue-row--voted {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: -2px;
}

#queue-table tbody tr.queue-row--podium {
  box-shadow: inset 3px 0 0 var(--accent, #3b82f6);
}

#queue-table tbody tr.queue-row--summon {
  outline: 2px solid var(--warning, #d97706);
  outline-offset: -2px;
  animation: summon-row-pulse 1.5s ease-in-out infinite;
}

@keyframes summon-row-pulse {
  0%,
  100% {
    background: var(--row-hover);
  }
  50% {
    background: color-mix(in srgb, var(--warning, #d97706) 12%, var(--surface));
  }
}

.summon-dialog {
  max-width: 26rem;
  width: calc(100% - 2rem);
  padding: 0;
  border: 3px solid var(--warning, #d97706);
  border-radius: 12px;
  background: color-mix(in srgb, var(--warning, #d97706) 8%, var(--surface));
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.summon-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.summon-dialog-body {
  padding: 1.35rem 1.5rem calc(1.35rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
}

.summon-dialog-title {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--warning, #d97706);
}

.summon-banner-message {
  margin: 0 0 1.15rem;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.45;
}

.summon-dialog .summon-ack-btn {
  width: 100%;
  min-height: 2.75rem;
  font-size: 1.05rem;
}

@media (prefers-reduced-motion: no-preference) {
  .summon-dialog[open] {
    animation: summon-dialog-in 0.28s ease-out;
  }

  @keyframes summon-dialog-in {
    from {
      opacity: 0;
      transform: scale(0.92) translateY(-0.5rem);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .summon-dialog[open] {
    animation: none;
  }
}

body.summon-dialog-visible {
  overflow: hidden;
}

#admin-table tbody tr.admin-summon-pending {
  outline: 2px solid var(--warning, #d97706);
  outline-offset: -2px;
}

.admin-call-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: color-mix(in srgb, var(--warning, #d97706) 20%, var(--surface));
  color: var(--text);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  #queue-table tbody tr.queue-row--summon {
    animation: none;
  }
}

.queue-vote-muted {
  font-size: 0.85rem;
  color: var(--muted);
}

.queue-votes-col {
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 3rem;
}

.queue-bids-col {
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 4rem;
}

.queue-bid-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.queue-bid-input {
  width: 5rem;
  min-width: 4rem;
  padding: 0.25rem 0.35rem;
}

.admin-bid-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.admin-bid-input {
  width: 5rem;
  min-width: 4rem;
}

.auction-bid-panel {
  margin-bottom: 1rem;
}

.my-queue-entry-panel {
  margin-bottom: 1rem;
}

.recommend-panel {
  margin-top: 1rem;
  margin-bottom: 0;
  flex-shrink: 0;
}

.recommend-details {
  border: none;
  margin: 0;
  padding: 0;
}

.recommend-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin: 0 0 0.5rem;
}

.recommend-summary::-webkit-details-marker {
  display: none;
}

.recommend-details:not([open]) .recommend-summary {
  margin-bottom: 0;
}

.recommend-disclaimer {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.recommend-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.recommend-status {
  margin: 0;
  flex: 1 1 12rem;
}

td.recommend-reason,
th.col-recommend-reason {
  font-size: 0.9rem;
  max-width: 14rem;
}

.my-queue-entry-song {
  font-weight: 600;
  margin: 0.25rem 0 0.5rem;
}

.my-queue-entry-position {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.my-queue-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.my-queue-swap-hint {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.auction-bid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.auction-bid-input {
  max-width: 8rem;
}

.btn-queue-vote {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

th.col-source,
th.col-duration,
td.source,
td.duration {
  min-width: 4.5rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td.artist {
  width: 38%;
  font-weight: 500;
}

.event-banner-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  text-decoration: none;
}

a.queue-song-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a.queue-song-link:hover {
  text-decoration-thickness: 2px;
}

.queue-song-with-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  vertical-align: baseline;
}

.btn-copy-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0.15rem;
  margin: 0;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.btn-copy-title:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-queue {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  margin-right: 0.25rem;
}

.btn-queue:hover {
  border-color: var(--accent);
}

.btn-queue.btn-muted {
  color: var(--muted);
}

#results-table tbody tr.results-row--taken {
  opacity: 0.72;
}

#results-table tbody tr.results-row--taken:hover {
  opacity: 0.85;
}

.btn-queue.btn-queue-taken {
  cursor: pointer;
}

.btn-queue.btn-queue-taken:hover {
  border-color: var(--error);
  color: var(--error);
}

td.actions {
  white-space: nowrap;
}

.section-heading {
  margin: 2rem 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.admin-settings {
  margin: 1rem 0 1.25rem;
}

.admin-settings-advanced {
  margin-top: 1rem;
}

.admin-settings-advanced-summary {
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.admin-settings-advanced .admin-settings-first-toggle {
  display: flex;
  margin-top: 1rem;
}

.fair-queue-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

.admin-settings-toggle + .admin-settings-desc {
  margin-top: 0.35rem;
}

.admin-settings-desc + .admin-settings-toggle {
  margin-top: 0.85rem;
}

.admin-settings-desc {
  margin: 0.35rem 0 0;
}

.admin-settings-actions {
  margin: 1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-on-behalf-actions {
  margin: 0 0 1rem;
}

.admin-on-behalf-dialog {
  width: min(56rem, calc(100vw - 2rem));
}

.admin-on-behalf-form .search-label {
  display: block;
  margin-top: 0.75rem;
}

.admin-on-behalf-mode {
  border: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.admin-on-behalf-mode-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.admin-on-behalf-results {
  margin-top: 0.5rem;
  max-height: 20rem;
  overflow-y: auto;
  border: 1px solid var(--border-subtle, #ccc);
  border-radius: 0.35rem;
  padding: 0.35rem 0.5rem;
}

.admin-on-behalf-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-on-behalf-results-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface, #fff);
  text-align: left;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle, #ccc);
}

.admin-on-behalf-results-table tbody td {
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}

.admin-on-behalf-results-table tbody tr {
  cursor: pointer;
}

.admin-on-behalf-results-table tbody tr:hover:not(.results-row--taken) {
  background: var(--surface-muted, rgba(127, 127, 127, 0.12));
}

.admin-on-behalf-results-table tbody tr.admin-on-behalf-result-selected {
  background: var(--surface-muted, rgba(127, 127, 127, 0.18));
  font-weight: 600;
}

.admin-on-behalf-results-table tbody tr.results-row--taken {
  opacity: 0.55;
  cursor: not-allowed;
}

.admin-on-behalf-results-table tbody tr.results-row--taken:hover {
  background: transparent;
}

.admin-on-behalf-empty {
  margin: 0.35rem 0;
}

.admin-on-behalf-hint {
  margin: 0.35rem 0 0;
  color: var(--status-warn, #b45309);
}

.admin-on-behalf-error {
  margin: 0.75rem 0 0;
  color: var(--status-error, #b91c1c);
}

.admin-on-behalf-form .search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.admin-on-behalf-form .search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.admin-on-behalf-dedication {
  resize: vertical;
  min-height: 4rem;
}

.admin-on-behalf-youtube-url-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.admin-on-behalf-youtube-url-row .search-input {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}

.admin-on-behalf-youtube-fetch {
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}

.admin-stats-actions-col {
  white-space: nowrap;
  width: 1%;
}

.admin-event-info {
  margin-bottom: 1rem;
}

.admin-event-info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem;
}

.admin-event-info-row:last-child {
  margin-bottom: 0;
}

.admin-event-info-label {
  flex: 0 0 8.5rem;
  font-weight: 500;
}

.admin-event-info-value {
  flex: 1 1 8rem;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  word-break: break-all;
}

.section-desc {
  margin: 0 0 0.75rem;
}

.section-table {
  margin-bottom: 1.5rem;
}

.panel {
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.panel-heading {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.panel-desc {
  margin-bottom: 0.75rem;
}

.field {
  margin-bottom: 0.75rem;
}

.field-inline {
  flex: 1;
  min-width: 10rem;
}

.participant-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.h1-event {
  display: none;
}

body.event-search-active .h1-default {
  display: none;
}

body.event-search-active .h1-event {
  display: inline;
}

body.event-search-active .page-header-main .subtitle {
  display: none;
}

.participant-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.participant-bar .participant-nick-label {
  flex: 0 0 100%;
  margin-bottom: 0;
}

#participant-panel .participant-bar {
  margin-bottom: 0;
}

#participant-panel.panel {
  padding: 0.65rem 0.85rem;
}

#participant-nick-input {
  flex: 1 1 8rem;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

#participant-nick-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pitch-summary {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  white-space: nowrap;
}

.search-chrome {
  flex-shrink: 0;
}

.search-results-scroll {
  min-height: 0;
}

.source-filter-details {
  border: none;
  margin: 0;
  padding: 0;
}

.source-filter-summary {
  display: none;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  padding: 0.35rem 0;
}

.source-filter-summary::-webkit-details-marker {
  display: none;
}

.pitch-dialog {
  max-width: 22rem;
  width: calc(100% - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-elevated);
}

.pitch-dialog.admin-on-behalf-dialog {
  max-width: 56rem;
  width: min(56rem, calc(100vw - 2rem));
}

.pitch-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.pitch-dialog-form {
  padding: 1.15rem 1.25rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
}

.pitch-dialog-form .search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.65rem;
}

.pitch-dialog-form .search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pitch-dialog-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.pitch-dialog-song {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

.pitch-dialog-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pitch-dialog-actions .btn-primary {
  width: 100%;
}

.pitch-dialog-actions .btn-queue {
  width: 100%;
  margin-right: 0;
  padding: 0.5rem 0.75rem;
}

#pitch-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

#pitch-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#dedication-input {
  width: 100%;
  min-height: 4rem;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

#dedication-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.admin-dedication-col {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.admin-page .container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 2rem 1.25rem 3rem;
  overflow-x: hidden;
}

body.admin-page .table-wrap {
  overflow-x: hidden;
}

body.admin-page #admin-table,
body.admin-page #stats-table {
  table-layout: fixed;
  width: 100%;
}

body.admin-page .admin-dedication-col {
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
  width: 18%;
}

body.admin-page .admin-song-col {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
  min-width: 0;
}

body.admin-page #admin-table th:nth-child(1),
body.admin-page #admin-table td:nth-child(1) {
  width: 4.25rem;
}

body.admin-page #admin-table th.col-source,
body.admin-page #admin-table td.source {
  width: 4.5rem;
  min-width: 0;
}

body.admin-page #admin-table th.col-duration,
body.admin-page #admin-table td.duration {
  width: 4.5rem;
  min-width: 0;
}

body.admin-page #admin-table th:nth-child(6),
body.admin-page #admin-table td:nth-child(6) {
  width: 4.5rem;
}

body.admin-page #admin-table th#admin-votes-col-header,
body.admin-page #admin-table td.queue-votes-col {
  width: 3.5rem;
}

body.admin-page td.actions {
  white-space: normal;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: flex-start;
  vertical-align: top;
  width: 11rem;
}

body.admin-page #stats-table th:nth-child(2),
body.admin-page #stats-table td:nth-child(2) {
  width: 6rem;
}

body.admin-page #stats-table th:nth-child(3),
body.admin-page #stats-table td:nth-child(3) {
  width: 40%;
}

.source-filter-field {
  flex: 0 1 11rem;
  min-width: 9rem;
  margin-bottom: 0;
}

.source-filter-field .search-label {
  display: block;
  margin-bottom: 0.35rem;
}

#source-filter {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

#source-filter:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel input[type="text"],
.panel select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.panel input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field-error {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--error);
}

.btn-primary {
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

#search-section.is-locked {
  opacity: 0.45;
  pointer-events: none;
}

body.queue-toast-visible .container {
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

.queue-toast {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
  color: var(--text);
  font-size: 0.95rem;
}

.queue-toast[hidden] {
  display: none;
}

.queue-toast.loading .queue-toast-message {
  color: var(--accent);
}

.queue-toast.error {
  border-color: var(--error);
}

.queue-toast.error .queue-toast-message {
  color: var(--error);
}

.queue-toast-message {
  flex: 1;
  margin: 0;
  line-height: 1.4;
}

.queue-toast-dismiss {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.queue-toast-dismiss:hover {
  border-color: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .queue-toast:not([hidden]) {
    animation: queue-toast-in 0.2s ease-out;
  }
}

@keyframes queue-toast-in {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.btn-queue.btn-queue-success {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-queue.btn-queue-busy {
  opacity: 0.85;
}

@media (max-width: 40rem) {
  body {
    overflow-x: clip;
  }

  body.search-layout-active {
    display: flex;
    flex-direction: column;
    min-height: var(--app-vh, 100dvh);
  }

  body.search-layout-active .container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  body.search-layout-active #search-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  body.search-layout-active .search-chrome {
    flex-shrink: 0;
  }

  body.search-layout-active #recommend-panel.recommend-panel {
    flex-shrink: 0;
  }

  body.search-layout-active #recommend-panel.recommend-panel .recommend-details[open] {
    max-height: min(40vh, 22rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.search-layout-active .search-results-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.search-focused .page-header-main .subtitle,
  body.search-focused .h1-default {
    display: none;
  }

  body.search-focused.event-search-active .h1-event {
    display: inline;
    font-size: 1.1rem;
  }

  body.search-focused .page-header {
    margin-bottom: 0.5rem;
  }

  body.search-focused #participant-panel.panel {
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.5rem;
  }

  body.search-focused .participant-bar .participant-nick-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.search-focused #participant-nick-input {
    padding: 0.4rem 0.55rem;
    font-size: 0.9rem;
  }

  body.search-focused .pitch-summary {
    font-size: 0.75rem;
    padding: 0.25rem 0.4rem;
  }

  body.search-focused .search-chrome .status {
    margin: 0.35rem 0 0.25rem;
    min-height: 1.25rem;
    font-size: 0.8rem;
  }

  body:not(.queue-qr-presenter) #join-qr-panel.join-qr-panel {
    display: none;
  }

  .container {
    margin: 0;
    padding: 1rem 0.75rem 2rem;
    max-width: 100%;
    overflow-x: clip;
  }

  body.admin-page .container {
    padding-inline: 1rem;
    padding-top: 1rem;
    padding-bottom: 2rem;
  }

  body.admin-page .table-wrap {
    overflow-x: hidden;
  }

  #search-section {
    max-width: 100%;
    overflow-x: clip;
  }

  .search-results-scroll {
    max-width: 100%;
    overflow-x: clip;
  }

  h1 {
    font-size: 1.35rem;
  }

  .page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 0.75rem;
    row-gap: 0.5rem;
  }

  .page-header-main {
    grid-column: 1;
    grid-row: 1;
  }

  .page-header .page-header-toolbar {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    width: auto;
  }

  .event-banner-link {
    word-break: break-word;
  }

  .participant-fields {
    flex-direction: column;
  }

  #participant-panel .participant-bar {
    flex-wrap: nowrap;
  }

  #participant-panel .participant-nick-label {
    flex: 0 0 auto;
    width: auto;
    font-size: 0.8rem;
    margin-bottom: 0;
    align-self: center;
  }

  #participant-nick-input {
    flex: 1 1 auto;
  }

  .field-inline {
    min-width: 0;
    width: 100%;
  }

  .source-filter-field {
    display: none !important;
  }

  .table-wrap {
    overflow-x: clip;
    max-width: 100%;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  .queue-toast {
    font-size: 0.9rem;
  }

  /* --- Wyniki wyszukiwania (zapis do kolejki) --- */
  #results-table {
    display: block;
    max-width: 100%;
    overflow-x: clip;
  }

  #results-table thead {
    display: none;
  }

  #results-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 100%;
    overflow-x: clip;
  }

  #results-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.2rem 0.5rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  #results-table tbody tr::before {
    content: "";
    order: 2;
    flex: 1 0 100%;
    width: 0;
    height: 0;
  }

  #results-table tbody tr:has(> td.actions) td.results-title {
    flex: 1 1 0;
  }

  #results-table tbody tr:not(:has(> td.actions)) td.results-title {
    flex: 1 0 100%;
    max-width: 100%;
  }

  #results-table tbody tr:hover {
    background: var(--row-hover);
  }

  #results-table tbody td {
    padding: 0;
    border-bottom: none;
    min-width: 0;
  }

  #results-table tbody td.results-title {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #results-table tbody td.results-title.results-title--truncatable {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
  }

  #results-table tbody td.results-title.results-title--expanded {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
    text-decoration: none;
  }

  #results-table tbody td:nth-child(1):not(.results-title) {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #results-table tbody td.artist {
    order: 3;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #results-table tbody td.source {
    order: 3;
    flex: 0 0 auto;
    align-self: center;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
  }

  #results-table tbody td.source::before {
    content: "·";
    margin-inline: 0.35rem;
  }

  #results-table tbody td.duration {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #results-table tbody td.actions {
    order: 2;
    flex: 0 0 auto;
    width: auto;
    margin-top: 0;
    white-space: nowrap;
    align-self: flex-start;
  }

  #results-table tbody td.actions .btn-queue {
    width: auto;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
    margin-right: 0;
  }

  #results-table tbody td.actions .btn-queue-taken {
    width: auto;
    font-size: 0.75rem;
    padding: 0.3rem 0.45rem;
  }

  .btn-queue.btn-queue-compact .btn-queue-label-long {
    display: none;
  }

  .btn-queue:not(.btn-queue-compact) .btn-queue-label-short {
    display: none;
  }

  /* --- Lista kolejki --- */
  #queue-table {
    display: block;
  }

  #queue-table thead {
    display: none;
  }

  #queue-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  #queue-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.35rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  #queue-table tbody tr:hover {
    background: var(--row-hover);
  }

  #queue-table tbody tr.queue-row--mine {
    background: var(--row-mine);
  }

  #queue-table tbody tr.queue-row--mine:hover {
    background: var(--row-mine-hover);
  }

  #queue-table tbody td {
    padding: 0;
    border-bottom: none;
    min-width: 0;
  }

  #queue-table tbody td:nth-child(1) {
    order: 0;
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--muted);
  }

  #queue-table tbody td:nth-child(2) {
    order: 1;
    flex: 1 1 4rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #queue-table tbody td:nth-child(5) {
    order: 2;
    flex: 0 0 auto;
  }

  #queue-table tbody td:nth-child(3),
  #queue-table tbody td:nth-child(4) {
    order: 3;
    flex: 0 1 auto;
    max-width: 100%;
    font-size: 0.875rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #queue-table tbody td:nth-child(3)::after {
    content: " — ";
  }
}

.join-qr-panel .panel-desc.join-qr-desc {
  margin-bottom: 1rem;
}

.join-qr-heading-desktop {
  display: none;
  margin: 0 0 0.25rem;
}

.join-qr-body {
  padding-top: 0.75rem;
}

@media (min-width: 40.0625rem) {
  #join-qr-open-btn {
    display: none !important;
  }

  .source-filter-summary {
    display: none !important;
  }

  .source-filter-details {
    display: block;
  }

  .source-filter-details .search-label {
    display: block;
  }

  body.search-focused .page-header-main .subtitle,
  body.search-focused .h1-default {
    display: block;
  }

  body.event-search-active.search-focused .h1-default {
    display: none;
  }

  body.event-search-active.search-focused .page-header-main .subtitle {
    display: none;
  }

  .participant-bar .participant-nick-label {
    flex: 0 0 auto;
    width: auto;
    margin-bottom: 0;
    align-self: center;
  }

  #participant-panel .participant-bar {
    flex-wrap: nowrap;
  }

  .join-qr-heading-desktop {
    display: block;
  }

  .join-qr-body {
    padding-top: 0;
  }
}

body.queue-qr-presenter .join-qr-heading-desktop {
  display: block;
}

body.queue-qr-presenter #join-qr-open-btn {
  display: none !important;
}

.join-qr-dialog {
  max-width: 22rem;
  width: calc(100% - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-elevated);
}

.join-qr-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.join-qr-dialog-form {
  padding: 1.15rem 1.25rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
}

.join-qr-dialog-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.join-qr-dialog .join-qr-desc {
  margin-bottom: 1rem;
}

.join-qr-dialog-close {
  width: 100%;
  margin-top: 1rem;
  margin-right: 0;
  padding: 0.5rem 0.75rem;
}

.join-qr-mount {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.join-qr-mount img,
.join-qr-mount canvas {
  display: block;
  border-radius: 6px;
}

.join-qr-code {
  margin: 0 0 0.5rem;
  text-align: center;
  font-size: 1.05rem;
}

.join-qr-code-value {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.join-qr-url {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  word-break: break-all;
}

.join-qr-url a {
  color: var(--accent);
}

body.queue-qr-presenter .container {
  max-width: 42rem;
}

body.queue-qr-presenter #search-link {
  display: none;
}

body.queue-qr-presenter .join-qr-mount img,
body.queue-qr-presenter .join-qr-mount canvas {
  max-width: min(40vw, 360px);
  height: auto;
  width: auto;
}
