/* rpgplayer styles */

/* ── Layer cascade (modern CSS) ──────────────────────────────
   Order: resets → base → components → utilities → overrides
   New styles go in their respective layers; existing styles
   remain unlayered (highest priority) so nothing breaks. ────── */
@layer resets, base, components, utilities, overrides;

@import url("./css/tokens.css");
@import url("./css/00-reset.css");
@import url("./css/sortable.css");
@import url("./css/mood-background.css");
@import url("./css/admin.css");


/* ── Base reset ────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background:
    radial-gradient(circle at top left, rgba(126, 184, 218, 0.08), transparent 34rem),
    var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  position: relative;
}
/* Library */
.library {
  background: #16213e;
  border-radius: 8px;
  padding: 16px;
}

.library h2 {
  font-size: 1em;
  margin-bottom: 8px;
}

.upload-area {
  border: 2px dashed #333;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: #888;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.upload-area.dragover {
  border-color: #7eb8da;
}

.upload-label {
  color: #7eb8da;
  cursor: pointer;
  text-decoration: underline;
}

.upload-label input {
  display: none;
}

.upload-accepted {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}



/* Listen page */
.listen-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.listen-container {
  position: relative;
  z-index: 1;
  text-align: center;
  background: #16213e;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 28px;
  width: min(720px, 100%);
  min-width: 320px;
}

.listen-disconnected .listen-container {
  border-color: rgba(244, 67, 54, 0.85);
  box-shadow: 0 0 0 1px rgba(244, 67, 54, 0.25);
}

.listen-minimize-btn,
.listen-expand-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #31446f;
  border-radius: 6px;
  background: #0f3460;
  color: #dbe8f4;
  cursor: pointer;
  line-height: 1;
}

.listen-minimize-btn {
  position: absolute;
  top: 10px;
  right: 10px;
}

.listen-expand-btn {
  display: none;
  flex-shrink: 0;
}

.listen-minimized {
  align-items: stretch;
  padding: 0;
}

.listen-minimized .listen-container {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  padding: 0;
  border-color: transparent;
  background: transparent;
  backdrop-filter: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: none;
}

.listen-minimized #joinArea {
  display: block;
  pointer-events: auto;
  padding-top: 8vh;
}

.listen-minimized .listen-status,
.listen-minimized .now-playing,
.listen-minimized .playback-indicator,
.listen-minimized .chat-panel,
.listen-minimized section.files-panel,
.listen-minimized .listen-minimize-btn {
  display: none;
}

.listen-minimized #playingArea {
  display: none;
}

.listen-minimized .volume-group {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 10;
  width: min(680px, calc(100vw - 28px));
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(126, 184, 218, 0.35);
  border-radius: 8px;
  background: rgba(15, 24, 45, 0.3);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  pointer-events: auto;
}

.listen-minimized.listen-disconnected .volume-group {
  border-color: rgba(244, 67, 54, 0.9);
  box-shadow: 0 0 0 1px rgba(244, 67, 54, 0.25);
}

.listen-minimized .listen-expand-btn {
  display: block;
  position: absolute;
  right: 10px;
  top: -42px;
}

/* Join button — superseded by .btn-primary */
.join-btn {
  /* Use .btn.btn-primary instead */
}

.listen-status {
  margin-bottom: 16px;
}

.status-connected {
  color: #4caf50;
}
.status-disconnected {
  color: #f44336;
}

.now-playing h2 {
  font-size: 1.2em;
  margin-bottom: 4px;
}
.now-playing p {
  color: #aaa;
}

.playback-indicator {
  margin-top: 16px;
  color: #7eb8da;
}

.chat-panel {
  margin-top: 24px;
  text-align: left;
  border-top: 1px solid #263456;
  padding-top: 18px;
}

.chat-header {
  display: grid;
  grid-template-columns: auto minmax(140px, 220px);
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.chat-header h2 {
  font-size: 1em;
}

.chat-header input,
.chat-compose input {
  width: 100%;
  background: #0f3460;
  color: #fff;
  border: 1px solid #33476f;
  border-radius: 4px;
  padding: 9px 10px;
  font: inherit;
}

.chat-header input:focus,
.chat-compose input:focus {
  outline: 2px solid #7eb8da;
  outline-offset: 1px;
}

.chat-messages {
  height: 260px;
  overflow-y: auto;
  background: #111a31;
  border: 1px solid #263456;
  border-radius: 4px;
  padding: 10px;
}

.chat-message {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-message:last-child {
  margin-bottom: 0;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  color: #101626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78em;
  border: 2px solid #0a1020;
  box-shadow: 3px 3px 0 #050812;
}

.chat-message-body {
  min-width: 0;
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-message-name {
  color: #fff;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chat-message-meta time {
  color: #8795b5;
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
}

.chat-message-text {
  color: #d8deec;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-message-roll .chat-message-text {
  color: #f4d47c;
  font-weight: 600;
}

.chat-message-system .chat-message-text {
  color: #ff9aa8;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

/* Chat compose — uses .btn-primary from button system */
.chat-compose .btn-primary {
  padding: 0 var(--space-lg);
  font: inherit;
}

@media (max-width: 520px) {
  .listen-container {
    padding: 20px;
  }

  .listen-minimized .listen-container {
    padding: 0;
  }

  .chat-header {
    grid-template-columns: 1fr;
  }

  .listen-minimized .volume-group {
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

/* Volume control */
.volume-group {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #aaa;
}

.volume-label {
  min-width: 48px;
  font-size: 0.85em;
  color: #888;
}

.volume-control label,
.volume-control .mute-toggle {
  font-size: 1.2em;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  line-height: 1;
  transition: opacity 0.15s;
}

.volume-control .mute-toggle:hover {
  opacity: 0.7;
}

.volume-control .mute-toggle:active {
  opacity: 0.4;
}

.volume-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  max-width: 140px;
  height: 6px;
  background: #0f3460;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #7eb8da;
  border-radius: 50%;
  cursor: pointer;
}

.volume-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #7eb8da;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.volume-control #volumeValue,
.volume-control #sfxVolumeValue {
  min-width: 36px;
  font-size: 0.85em;
  color: #7eb8da;
  text-align: right;
}

/* Files panel (admin) */
.files-panel {
  background: #16213e;
  border-radius: 8px;
  padding: 20px;
}

.files-panel h2 {
  font-size: 1em;
}

.files-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.files-dropzone {
  border: 2px dashed #333;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: #888;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.files-dropzone.dragover {
  border-color: #7eb8da;
}

#filesUploadProgress {
  margin-bottom: 12px;
}

.files-upload-entry {
  margin-bottom: 8px;
  font-size: 0.86em;
  color: var(--text-secondary);
}

.files-upload-entry.success {
  color: #9ad39d;
}

.files-upload-entry.error {
  color: #ff9aa8;
}

.files-upload-status {
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 0.86em;
}

.files-upload-status.success {
  background: #1a3a2a;
  color: #9ad39d;
}

.files-upload-status.error {
  background: #3a1e28;
  color: #ff9aa8;
}

.files-upload-status ul {
  margin: 6px 0 0 18px;
}

.files-list {
  max-height: 400px;
  overflow-y: auto;
}

.files-panel-actions,
.file-folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.file-folders-list {
  display: flex;
  flex-direction: column;
}

.file-folder-section {
  border-bottom: 1px solid #222;
}

.file-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 8px;
  background: #11182d;
}

.file-folder-header h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.95em;
  overflow-wrap: anywhere;
}

.file-folder-count {
  min-width: 24px;
  color: #888;
  font-size: 0.78em;
  text-align: right;
}

.file-folder-files.collapsed {
  display: none;
}

.file-folder-empty {
  padding: 10px 48px;
  border-bottom: 1px solid #222;
}

/* File folder controls — uses .drag-handle and .btn-icon from button system */
.file-folder-spacer {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.file-folder-toggle {
  /* inherits .btn-icon defaults */
}
.file-folder-actions .btn-icon {
  min-width: 28px;
  height: 28px;
  padding: 0;
  padding-inline: var(--space-sm);
  /* inherits .btn-icon defaults */
}

.file-folder-drag-handle {
  /* inherits .drag-handle defaults */
}

.file-folder-toggle-static {
  display: inline-block;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #222;
  font-size: 0.9em;
}

.file-item:last-child {
  border-bottom: none;
}

.file-item:hover {
  background: #1a1a3e;
}

/* File drag handle — uses .drag-handle from button system */
.file-drag-handle {
  /* inherits .drag-handle defaults */
}

.file-icon {
  font-size: 1.5em;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-badge {
  font-size: 0.75em;
  padding: 2px 6px;
  border-radius: 3px;
  background: #0f3460;
  color: #ccc;
  white-space: nowrap;
}

.file-badge-shared {
  background: #1a3a2a;
  color: #4caf50;
}

.file-badge-background {
  background: #443616;
  color: #f4d47c;
}

.file-meta {
  color: #888;
  font-size: 0.8em;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.file-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* File actions — uses .btn-sm from button system */
.file-actions .btn-sm {
  /* inherits .btn-sm defaults */
}

.file-actions .btn-sm.btn-danger {
  /* inherits .btn-danger styles */
}

.file-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}

.file-preview-modal.open {
  display: block;
}

.file-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 14, 0.78);
}

.file-preview-dialog {
  position: absolute;
  inset: 4vh 4vw;
  display: flex;
  flex-direction: column;
  background: #111a31;
  border: 1px solid #33405f;
  border-radius: 6px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.file-preview-header,
.file-preview-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #16213e;
}

.file-preview-header {
  justify-content: space-between;
  border-bottom: 1px solid #263456;
}

.file-preview-header h2 {
  margin: 0;
  font-size: 1em;
  overflow-wrap: anywhere;
}

.file-preview-close {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.25em;
  line-height: 1;
}

.file-preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: auto;
  background: #090d18;
}

.file-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 68vh;
  border: 0;
  background: #fff;
}

.file-preview-text {
  width: 100%;
  height: 100%;
  margin: 0;
  color: #d8e2f3;
  font: 0.9em/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.file-preview-message {
  color: #b7c4df;
  margin: 0;
  text-align: center;
}

.file-preview-footer {
  justify-content: flex-end;
  border-top: 1px solid #263456;
}

.file-preview-footer a {
  color: #7eb8da;
}

.file-rename-input {
  background: #0f3460;
  color: #fff;
  border: 1px solid #7eb8da;
  border-radius: 3px;
  padding: 2px 6px;
  font: inherit;
  font-weight: 600;
  width: 200px;
  max-width: 100%;
}

.file-rename-input:focus {
  outline: 2px solid #7eb8da;
  outline-offset: 1px;
}

.files-empty {
  text-align: center;
  color: #666;
  padding: 24px;
}

/* Files panel (listener) */
section.files-panel {
  margin-top: 24px;
  text-align: left;
  border-top: 1px solid #263456;
  padding-top: 18px;
}

.files-header {
  margin-bottom: 12px;
}

.files-header h2 {
  font-size: 1em;
}

.shared-files-list {
  max-height: 200px;
  overflow-y: auto;
  background: #111a31;
  border: 1px solid #263456;
  border-radius: 4px;
  padding: 10px;
}

.shared-file-folder {
  border-bottom: 1px solid #1a2744;
}

.shared-file-folder:last-child {
  border-bottom: none;
}

.shared-file-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 7px 4px;
  border: 0;
  background: transparent;
  color: #dbe8f4;
  font-size: 0.9em;
  text-align: left;
  cursor: pointer;
}

.shared-file-folder-header:hover {
  background: #16213e;
}

.shared-file-folder-toggle {
  width: 16px;
  flex-shrink: 0;
  text-align: center;
}

.shared-file-folder-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.shared-file-folder-count {
  color: #8fa3c7;
  font-size: 0.85em;
}

.shared-file-folder-files.collapsed {
  display: none;
}

.shared-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid #1a2744;
}

.shared-file-item:last-child {
  border-bottom: none;
}

.shared-file-icon {
  font-size: 1.3em;
  flex-shrink: 0;
  width: 30px;
  text-align: center;
}

.shared-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shared-file-title {
  color: #7eb8da;
  text-decoration: none;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.shared-file-title:hover {
  text-decoration: underline;
}

.shared-file-meta {
  color: #8795b5;
  font-size: 0.78em;
}

.shared-file-preview-btn,
 .shared-file-download-btn {
   flex-shrink: 0;
   text-decoration: none;
}

.shared-file-preview-btn:hover,
.shared-file-download-btn:hover {
  /* inherits .btn hover styles */
}

@media (max-width: 700px) {
  .file-preview-dialog {
    inset: 2vh 2vw;
  }

  .file-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .shared-file-item {
    align-items: flex-start;
  }
}

header,
.playback-bar,
.sidebar,
.content,
.library,
.player-panel,
.sfx-panel,
.files-panel,
.listen-container {
  background: rgba(22, 33, 62, 0.76);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(74, 95, 134, 0.28);
  box-shadow: var(--shadow-card);
}

.playback-bar,
.content,
.library,
.player-panel,
.sfx-panel,
.files-panel,
.listen-container,
.sidebar {
  border-radius: var(--radius-lg);
}

.player-card,
.sfx-track-card,
.player-now,
.chat-messages,
.shared-files-list,
.file-preview-dialog {
  background: var(--bg-input);
  border: 1px solid rgba(74, 95, 134, 0.44);
}

.folder-header,
.playlist-item.active,
.track-item.selected,
.sfx-track-card,
.player-card,
.file-badge {
  background: var(--bg-surface);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)), var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

button:hover,
.btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-light);
  color: #fff;
}

button:active,
.btn:active {
  transform: translateY(1px);
}

button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

button:disabled,
.btn:disabled {
  background: var(--disabled-bg);
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--disabled-text);
  opacity: 1;
  cursor: not-allowed;
  transform: none;
}

.btn-primary,
button.player-play-btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)), var(--accent-primary);
  border-color: rgba(255, 154, 168, 0.55);
  color: #fff;
}

.btn-primary:hover,
button.player-play-btn:hover {
  background-color: var(--accent-primary-hover);
  border-color: rgba(255, 183, 194, 0.78);
}

.btn-success {
  background: rgba(78, 205, 196, 0.14) !important;
  border-color: rgba(78, 205, 196, 0.58) !important;
  color: #8be7df !important;
}

.btn-success:hover {
  background: rgba(78, 205, 196, 0.22) !important;
  border-color: rgba(78, 205, 196, 0.78) !important;
}

.btn-danger,
.danger {
  background: rgba(216, 90, 114, 0.12) !important;
  border-color: rgba(216, 90, 114, 0.58) !important;
  color: #ff9cac !important;
}

.btn-danger:hover,
.danger:hover {
  background: rgba(216, 90, 114, 0.9) !important;
  border-color: rgba(255, 183, 194, 0.72) !important;
  color: #fff !important;
}

.btn-sm,
.track-item button,
.folder-actions button,
.playlist-item button,
.sfx-track-actions button,
.player-card-actions button,
.file-folder-actions .btn-sm,
.file-actions .btn-sm {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.btn-icon,
.folder-actions button,
.playlist-item button,
.file-preview-close,
.listen-minimize-btn,
.listen-expand-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
}

.track-item button,
.folder-actions button,
.playlist-item button,
.file-actions .btn-icon,
.file-folder-actions .btn-icon {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
}

.drag-handle,
.tab,
.mute-toggle,
.shared-file-folder-header,
.file-folder-toggle {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.tab {
  min-height: 38px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-secondary);
}

.tab:hover {
  background: rgba(126, 184, 218, 0.08);
  color: #fff;
}

.tab.active {
  color: #9fd3f1;
  border-bottom-color: #9fd3f1;
}

.mute-toggle {
  border: 0;
  color: var(--text-primary);
}

.drag-handle {
  border-color: transparent;
  color: var(--text-muted);
}

.file-folder-toggle {
  min-width: 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-color: transparent;
  color: var(--text-secondary);
}

.file-folder-toggle:hover,
.drag-handle:hover,
.mute-toggle:hover {
  background: rgba(126, 184, 218, 0.1);
  border-color: rgba(126, 184, 218, 0.24);
  color: #fff;
}

input[type="text"],
input[type="search"],
input:not([type]),
select,
textarea,
.playlist-header input,
.library-filter input,
.chat-header input,
.chat-compose input,
.file-rename-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font: inherit;
  min-height: 36px;
  padding: 8px 10px;
}

select {
  padding-right: 30px;
  max-width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

.tab-bar {
  border-bottom-color: var(--border-color);
}

.folder-header:hover,
.playlist-item:hover,
.track-item:hover,
.file-item:hover,
.shared-file-folder-header:hover {
  background: var(--bg-elevated);
}

.upload-area,
.files-dropzone {
  background: rgba(16, 25, 43, 0.56);
  border-color: rgba(74, 95, 134, 0.72);
}

.upload-area.dragover,
.files-dropzone.dragover {
  border-color: #9fd3f1;
  background: rgba(126, 184, 218, 0.1);
}

.sidebar {
  padding: 14px;
}

.sidebar h2 {
  margin-bottom: 10px;
  color: var(--text-primary);
  letter-spacing: 0;
}

.sidebar-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.folder-section {
  margin-bottom: 8px;
}

.folder-header {
  min-height: 36px;
  padding: 6px;
  border: 1px solid transparent;
}

.folder-header > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.folder-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.folder-header:hover .folder-actions,
.folder-header:focus-within .folder-actions {
  opacity: 1;
  pointer-events: auto;
}

.playlist-drag-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 4px;
}

.playlist-item {
  position: relative;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 7px 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}

.playlist-item.active {
  border-color: rgba(126, 184, 218, 0.38);
  box-shadow: inset 3px 0 0 #9fd3f1;
}

.playlist-item.archived {
  opacity: 0.72;
}

.playlist-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.playlist-item-name {
  color: var(--text-primary);
  font-weight: 650;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-meta {
  min-height: 1em;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.playlist-item:hover .playlist-item-actions,
.playlist-item:focus-within .playlist-item-actions {
  opacity: 1;
  pointer-events: auto;
}

.playlist-item-actions button,
.folder-actions button {
  background: rgba(16, 25, 43, 0.72);
  border-color: rgba(74, 95, 134, 0.52);
  color: var(--text-secondary);
}

.playlist-item-actions button:hover,
.folder-actions button:hover {
  background: var(--bg-surface-hover);
  color: #fff;
}

.playlist-item-actions button:last-child:hover,
.folder-actions button:last-child:hover {
  background: rgba(216, 90, 114, 0.88);
  border-color: rgba(255, 183, 194, 0.72);
  color: #fff;
}

/* Playlist autosave status */
.save-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 60px;
  font-style: italic;
}
.save-status.error {
  color: var(--danger);
  font-weight: bold;
}

/* Files Multi-select */
.file-item.selected {
  background: var(--bg-surface-hover);
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

.files-selection-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1a1a3e;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.files-selection-toolbar .selected-count {
  font-weight: bold;
  font-size: 0.9em;
}

.files-selection-toolbar .toolbar-actions {
  display: flex;
  gap: 8px;
}

.file-folder-header .file-folder-count {
  margin-right: 8px;
}

/* --- Rooms Management Styles --- */
.header-title-area {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.room-selector-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs, 8px);
  background: rgba(22, 33, 62, 0.6);
  border: 1px solid rgba(126, 184, 218, 0.2);
  border-radius: 6px;
  padding: 4px 10px;
}

.room-select-label {
  font-size: 0.85rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.room-select-dropdown {
  background: #16213e;
  border: 1px solid #31446f;
  color: #fff;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  min-width: 140px;
}

.room-select-dropdown:focus {
  border-color: #7eb8da;
}

.rooms-panel {
  background: #16213e;
  border-radius: 8px;
  padding: 20px;
}

.rooms-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 12px;
}

.rooms-panel-header h2 {
  font-size: 1.25rem;
  margin: 0;
}

.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.rooms-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  padding: 30px;
}

.room-card {
  background: #1a1a2e;
  border: 1px solid #31446f;
  border-radius: 8px;
  padding: 16px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.room-card:hover {
  border-color: #7eb8da;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.room-card.active-room {
  border-color: #7eb8da;
  box-shadow: 0 0 10px rgba(126, 184, 218, 0.2);
  background: rgba(26, 26, 46, 0.85);
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.room-card-title {
  font-weight: bold;
  font-size: 1.1rem;
  color: #fff;
  margin: 0;
  flex-grow: 1;
}

.room-card-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.room-card-badge.badge-active {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.room-card-badge.badge-selected {
  background: rgba(126, 184, 218, 0.2);
  color: #7eb8da;
  border: 1px solid rgba(126, 184, 218, 0.3);
}

.room-card-badge.badge-closed {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.room-card-body {
  font-size: 0.85rem;
  color: #aaa;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-card-link {
  color: #7eb8da;
  text-decoration: underline;
  word-break: break-all;
}

.room-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
}

/* ── GM shell ─────────────────────────────────────────────── */
.gm-body {
  min-height: 100vh;
  background: #121629;
}

.gm-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
  position: relative;
  z-index: 1;
}

.gm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gm-header h1 {
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: 6px;
}

.gm-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.gm-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.gm-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  background: rgba(15, 52, 96, 0.8);
}

.gm-nav-link:hover,
.gm-nav-link.active {
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
}

.gm-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.gm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  background: rgba(22, 33, 62, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
}

.gm-create-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gm-input {
  min-width: min(320px, 72vw);
  padding: 9px 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
}

.gm-input:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.gm-status {
  min-height: 20px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

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

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

.gm-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.gm-table-card,
.gm-placeholder {
  background: rgba(22, 33, 62, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.gm-table-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.gm-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gm-card-header h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.gm-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.gm-badge.open {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.16);
}

.gm-badge.closed {
  color: #f44336;
  background: rgba(244, 67, 54, 0.16);
}

.gm-badge.selected {
  color: #7eb8da;
  background: rgba(126, 184, 218, 0.18);
}

.gm-badge.muted {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
}

.gm-badge.active {
  color: #4ecdc4;
  background: rgba(78, 205, 196, 0.16);
}

.gm-card-meta {
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.gm-card-meta div {
  min-width: 0;
}

.gm-card-meta dt {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.gm-card-meta dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.gm-card-meta a {
  color: #7eb8da;
}

.gm-card-actions,
.gm-placeholder-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gm-card-actions {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.gm-empty {
  color: var(--text-secondary);
  padding: 18px;
}

.gm-placeholder {
  padding: 22px;
  max-width: 760px;
}

.gm-placeholder h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.gm-placeholder p {
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.gm-setup-toolbar {
  align-items: flex-start;
}

.gm-setup-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gm-setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.gm-setup-panel {
  min-width: 0;
  padding: 16px;
  background: rgba(22, 33, 62, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.gm-setup-panel-wide {
  grid-column: 1 / -1;
}

.gm-panel-header,
.gm-setup-item,
.gm-file-row,
.gm-file-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gm-panel-header {
  margin-bottom: 12px;
}

.gm-panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.gm-panel-header h2 {
  font-size: 1.08rem;
}

.gm-panel-help {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.gm-panel-count,
.gm-setup-item-main span,
.gm-file-main span,
.gm-file-folder-header p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.gm-setup-list,
.gm-folder-list,
.gm-file-list {
  display: grid;
  gap: 8px;
}

.gm-setup-item,
.gm-file-row {
  min-width: 0;
  padding: 10px;
  background: rgba(15, 52, 96, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
}

.gm-setup-item-main,
.gm-file-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.gm-setup-item-main strong,
.gm-file-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gm-file-folder {
  padding: 12px;
  background: rgba(15, 52, 96, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
}

.gm-file-folder-header {
  align-items: flex-start;
  margin-bottom: 10px;
}

.gm-file-folder-header > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gm-file-folder-header h3 {
  font-size: 1rem;
}

.gm-folder-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* Folder manage buttons (rename, delete) — Library only */
.gm-folder-manage {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gm-folder-manage .btn-icon {
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.gm-file-folder-header:hover .gm-folder-manage .btn-icon {
  opacity: 1;
}

/* Drag handle placeholder — inert when SortableJS not loaded */
.gm-drag-placeholder {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* File selection checkbox */
.gm-file-select-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  min-width: 20px;
  height: 20px;
  margin-right: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.gm-file-row:hover .gm-file-select-check {
  opacity: 0.8;
}

/* Selected file row */
.gm-library-file-row.gm-selected {
  background: rgba(126, 184, 218, 0.12);
}

.gm-library-file-row.gm-selected .gm-file-select-check {
  opacity: 1;
  color: var(--text-primary);
}

/* Drop placeholder for empty folders */
.gm-drop-placeholder {
  /* ensure Sortable can drop into empty lists */
  min-height: 24px;
}

/* Folder create/rename inline inputs */
.gm-folder-create-input,
.gm-folder-rename-input,
.gm-playlist-create-input {
  width: 160px;
  max-width: 100%;
}

/* ── GM: collapsible folders ────────────────────────────────
   Collapse toggle button and hidden file list for folder
   sections across Live, Setup, and Library pages.
   State is persisted in localStorage per page context. ────── */
.gm-collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast),
              background var(--transition-fast);
  flex-shrink: 0;

  &:hover {
    color: var(--text-primary);
    background: rgba(126, 184, 218, 0.1);
  }
}

/* When a folder section is collapsed, hide its file list */
.gm-file-list-collapsed {
  display: none;
}

/* When collapsed, tighten the folder section padding */
.gm-folder-collapsed {
  padding-bottom: 0;
}

/* ── Table setup page: selection feel ────────────────────────
   Slightly deeper panel background so setup reads as an
   active choice surface, distinct from the library. ─────── */
.gm-table-setup-panel {
  border-left: 3px solid rgba(78, 205, 196, 0.3);
}

.gm-tabs {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}

.gm-tab {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  background: rgba(15, 52, 96, 0.8);
  cursor: pointer;
}

.gm-tab:hover,
.gm-tab.active {
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
}

.gm-tab-content {
  display: none;
}

.gm-tab-content.active {
  display: block;
}

.gm-live-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: rgba(22, 33, 62, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.gm-live-now h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.gm-live-now p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.gm-live-now-main {
  min-width: 0;
  flex: 1;
}

.gm-live-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin-top: 10px;
}

.gm-live-progress.disabled {
  opacity: 0.55;
}

.gm-live-select {
  min-width: 150px;
  width: auto;
  max-width: min(260px, 38vw);
  padding: 7px 9px;
}

.gm-live-mode-select {
  min-width: 112px;
}

.gm-live-controls,
.gm-live-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.gm-runtime-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.gm-live-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 2px 0;
}

.gm-live-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 700;
  background: rgba(15, 52, 96, 0.72);
  cursor: pointer;
}

.gm-live-tab span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.gm-live-tab:hover,
.gm-live-tab.active {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
}

.gm-live-tab.live-tab-active {
  border-color: rgba(78, 205, 196, 0.45);
}

.gm-live-tab.live-tab-active span {
  color: var(--accent-success);
  background: rgba(78, 205, 196, 0.12);
}

.gm-live-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.gm-live-tab-panel {
  display: none;
}

.gm-live-tab-panel.active {
  display: grid;
}

.gm-live-active {
  border-color: rgba(78, 205, 196, 0.55);
  background: rgba(78, 205, 196, 0.12);
}

@media (max-width: 720px) {
  .gm-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }

  .gm-header,
  .gm-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .gm-nav {
    justify-content: flex-start;
  }

  .gm-create-form,
  .gm-create-form .btn,
  .gm-input {
    width: 100%;
  }

  .gm-setup-grid {
    grid-template-columns: 1fr;
  }

  .gm-audio-workspace {
    grid-template-columns: 1fr;
  }

  .gm-live-grid {
    grid-template-columns: 1fr;
  }

  .gm-panel-header,
  .gm-setup-item,
  .gm-file-row,
  .gm-file-folder-header,
  .gm-live-now {
    align-items: stretch;
    flex-direction: column;
  }

  .gm-folder-actions,
  .gm-live-controls,
  .gm-live-inline-actions {
    justify-content: flex-start;
  }
}
