:root {
  --bg: #08090c;
  --surface: #111318;
  --surface-2: #181b22;
  --border: #262a33;
  --text: #e8eaed;
  --text-dim: #8b90a0;
  --accent: #4fd1c5;
  --accent-2: #f6ad55;
  --danger: #f56565;
  --radius: 8px;
  --gap: 4px;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.app-shell {
  display: flex;
  height: 100%;
}

/* ---- Sidebar (menú separado del wall) ----------------------------------- */

:root {
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.18s ease;
}

.sidebar.is-collapsed {
  width: var(--sidebar-w-collapsed);
  padding: 12px 8px;
}

.sidebar.is-collapsed .sidebar-label,
.sidebar.is-collapsed .add-form,
.sidebar.is-collapsed .sidebar-status #role-badge,
.sidebar.is-collapsed .brand { display: none; }

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-toggle {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }

.brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  color: var(--accent);
  white-space: nowrap;
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.8rem;
  outline: none;
  width: 100%;
}

.add-form input:focus {
  border-color: var(--accent);
}

.add-form button {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.add-form button:hover { filter: brightness(1.1); }

.sidebar-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.75rem;
  white-space: nowrap;
}

.sidebar-actions,
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.sidebar-actions button,
.sidebar-footer button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}
.sidebar-actions button:hover,
.sidebar-footer button:hover { border-color: var(--accent); color: var(--accent); }
.sidebar-actions button.is-active { background: var(--accent); color: #06110f; border-color: var(--accent); }

.sidebar.is-collapsed .sidebar-actions button,
.sidebar.is-collapsed .sidebar-footer button {
  justify-content: center;
  padding: 8px 0;
}

#clear-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ---- Wall area (separado del menú) --------------------------------------- */

.wall-area {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* Bento grid: fixed columns + fixed row height so tile col/row/colSpan/
   rowSpan (explicit position, free-drag-with-snap — see wireDragMove in
   app.js) map to whole grid cells. Always 6 columns regardless of viewport
   — explicit per-tile grid-column/row placement assumes a fixed column
   count (the same one screen.js's crop math and the Pantallas físicas
   region picker assume), so this grid deliberately does NOT reflow to
   fewer columns on narrow viewports like a typical responsive grid would. */
.wall {
  height: 100%;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 160px; /* keep in sync with ROW_HEIGHT_PX in app.js */
  gap: var(--gap);
  padding: var(--gap);
  background: #000;
  overflow-y: auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-align: center;
  pointer-events: none;
  gap: 6px;
  padding: 0 24px;
}

.empty-state .hint { font-size: 0.75rem; max-width: 520px; }
.wall:not(:empty) ~ .empty-state,
.wall.has-tiles ~ .empty-state { display: none; }

.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tile-media {
  flex: 1;
  position: relative;
  background: #000;
  min-height: 0;
}

.tile-media iframe,
.tile-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

.tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.manual-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  z-index: 4;
  background: rgba(17, 19, 24, 0.85);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.manual-play:hover { background: var(--accent); color: #06110f; }

.tile-placeholder .icon { font-size: 1.6rem; }
.tile-placeholder .icon.spin { animation: spin 1.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tile-placeholder .err-msg { color: var(--danger); }

.tile-placeholder .retry-ingest {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #06110f;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.75rem;
}
.tile-placeholder code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-2);
  word-break: break-all;
}

.tile-overlay-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  display: flex;
  gap: 4px;
}

.tile-overlay-controls button {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(17, 19, 24, 0.85);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  backdrop-filter: blur(2px);
}

.tile-overlay-controls .tile-fs:hover {
  background: var(--accent);
  color: #06110f;
  border-color: var(--accent);
}

.tile-overlay-controls .tile-remove:hover {
  background: var(--danger);
  color: #1a0505;
  border-color: var(--danger);
}

.tile-overlay-controls .tile-audio.is-soloed {
  background: var(--accent);
  color: #06110f;
  border-color: var(--accent);
}

.tile-overlay-controls .tile-audio:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tile-resize-handle {
  position: absolute;
  right: 4px;
  bottom: 32px;
  width: 14px;
  height: 14px;
  z-index: 6;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.15s;
  background: linear-gradient(135deg, transparent 50%, var(--accent) 50%);
  border-radius: 2px;
}

.tile:hover .tile-resize-handle { opacity: 0.85; }

/* Iframes/videos swallow mouse events, which stalls drag listeners the
   instant the cursor crosses one mid-drag. Kill pointer-events on all tile
   media while a resize or reorder drag is in progress (app.js toggles this
   on <body>) so the drag never "freezes". */
body.is-interacting { user-select: none; }
body.is-interacting .tile-media iframe,
body.is-interacting .tile-media video { pointer-events: none; }

.tile.is-dragging { z-index: 10; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); outline: 2px solid var(--accent); outline-offset: -2px; }

/* Viewers can watch and solo audio but not restructure the wall. */
body.is-viewer .tile-resize-handle,
body.is-viewer .tile-remove,
body.is-viewer .tile-playlist,
body.is-viewer .tile-record,
body.is-viewer .add-form,
body.is-viewer #clear-btn,
body.is-viewer #arrange-btn { display: none; }
body.is-viewer .tile-bar { cursor: default; }

.tile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  height: 26px;
  flex-shrink: 0;
  cursor: grab;
}
.tile-bar:active { cursor: grabbing; }

.tile-badge {
  background: var(--accent);
  color: #06110f;
  font-weight: 800;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.tile-badge.badge-srt { background: var(--danger); }
.tile-badge.badge-rtmp { background: var(--danger); }
.tile-badge.badge-youtube { background: #ff4d4d; }
.tile-badge.badge-mdstrm { background: var(--accent-2); }

.tile-label {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tile-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tile-controls button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}

.tile-controls button:hover {
  color: var(--text);
  background: var(--border);
}

.tile.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  border-radius: 0;
}

.role-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: uppercase;
}
.role-badge.role-admin { border-color: var(--accent); color: var(--accent); }
.role-badge.role-viewer { border-color: var(--accent-2); color: var(--accent-2); }

#notify-toggle.is-active { background: var(--accent); color: #06110f; border-color: var(--accent); }

/* Down-source alert: a tile whose media element hit a fatal error (only
   tracked for hls/video/srt — cross-origin iframes give us no signal). */
.alert-banner {
  background: var(--danger);
  color: #1a0505;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 16px;
  text-align: center;
}

.tile.is-down { border-color: var(--danger); }
.tile.is-down .tile-badge { background: var(--danger); }
.tile-down-flag {
  display: none;
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 5;
  background: var(--danger);
  color: #1a0505;
  font-weight: 800;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.tile.is-down .tile-down-flag { display: block; }

.team-card { width: 380px; align-items: stretch; }

.team-members {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.team-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 0.8rem;
}

.team-member-row .member-email { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.team-member-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 3px 4px;
}

.team-member-row .member-remove {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
}

.invite-form {
  display: flex;
  gap: 8px;
}

.invite-form select {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px;
  font-size: 0.8rem;
}

.invite-form button {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.invite-result {
  display: flex;
  gap: 8px;
}

.invite-result input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 8px;
  font-size: 0.75rem;
}

.invite-result button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.75rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.modal-card h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.auth-body {
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.auth-card {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.auth-card .brand { font-size: 1rem; }

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

.auth-form input:focus { border-color: var(--accent); }

.auth-form button {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.auth-form button:hover { filter: brightness(1.1); }
.auth-form button:disabled { opacity: 0.6; cursor: default; }

.auth-error { color: var(--danger); font-size: 0.78rem; min-height: 1em; margin: 0; }
.auth-message { color: var(--accent); font-size: 0.78rem; margin: 0; }

.auth-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover { color: var(--accent); }

/* ---- Programación (escenas + horarios, fase 3 ítem 7) ------------------ */

.schedule-card { width: 480px; align-items: stretch; max-height: 85vh; overflow-y: auto; }

.schedule-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.schedule-section:first-of-type { border-top: none; padding-top: 0; }

.schedule-section h3 { margin: 0; font-size: 0.85rem; color: var(--text); }

.section-hint { margin: 0; font-size: 0.72rem; color: var(--text-dim); }

.scene-save-form,
.rule-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.scene-save-form input,
.rule-form select,
.rule-form input[type="time"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.8rem;
}

.scene-save-form input { flex: 1; min-width: 160px; }
.rule-form select { width: 100%; }

.scene-save-form button,
.rule-form button {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.rule-days {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.rule-days label {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
}
.rule-days input:checked + span,
.rule-days label:has(input:checked) { color: var(--accent); }
.rule-days label:has(input:checked) { border-color: var(--accent); }

.rule-times {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.scene-list,
.rule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.scene-row,
.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 0.78rem;
}

.scene-row .scene-name,
.rule-row .rule-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rule-row.is-disabled { opacity: 0.5; }

.scene-row button,
.rule-row button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
}
.scene-row button:hover,
.rule-row button:hover { color: var(--text); }
.scene-row .scene-remove:hover,
.rule-row .rule-remove:hover { color: var(--danger); }

/* ---- Playlist por tile (fase 3 ítem 7) ---------------------------------- */

.tile-overlay-controls .tile-playlist.has-playlist {
  background: var(--accent);
  color: #06110f;
  border-color: var(--accent);
}

.playlist-card { width: 420px; align-items: stretch; }

.playlist-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  width: 100%;
}

.playlist-item-row {
  display: flex;
  gap: 6px;
}

.playlist-item-row input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.78rem;
}

.playlist-item-row .item-url { flex: 2; min-width: 0; }
.playlist-item-row .item-label { flex: 1; min-width: 0; }

.playlist-item-row .item-remove {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--danger);
  cursor: pointer;
  padding: 0 10px;
}

.playlist-rotate-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
  align-self: flex-start;
}

.playlist-rotate-label input {
  width: 70px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
}

.playlist-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.playlist-actions button:first-child {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- Grabación (DVR) + clips (fase 3 ítem 8) ---------------------------- */

/* Oculto por pedido explícito del usuario (por ahora), mismo criterio que
   el botón "Grabaciones" del sidebar — backend/wiring en app.js intactos,
   es solo el entry point por tile. */
.tile-overlay-controls .tile-record { display: none; }

.tile-overlay-controls .tile-record:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tile-overlay-controls .tile-record.is-recording {
  background: var(--danger);
  color: #1a0505;
  border-color: var(--danger);
  animation: rec-pulse 1.4s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---- Baja latencia WebRTC/WHEP (fase 4 ítem 9) --------------------------- */

.tile-overlay-controls .tile-webrtc:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tile-overlay-controls .tile-webrtc.is-active {
  background: var(--accent);
  color: #06110f;
  border-color: var(--accent);
}

.recordings-card { width: 520px; align-items: stretch; max-height: 85vh; overflow-y: auto; }

.quota-bar { display: flex; flex-direction: column; gap: 4px; width: 100%; }

.quota-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s;
}

.quota-bar-fill.is-full { background: var(--danger); }

.recording-list { max-height: 200px; }

.recording-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 0.78rem;
  flex-wrap: wrap;
}

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

.recording-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recording-meta { color: var(--text-dim); font-size: 0.7rem; }

.recording-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.recording-actions button,
.recording-actions a {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 3px 8px;
  text-decoration: none;
}

.recording-actions button:hover,
.recording-actions a:hover { color: var(--text); border-color: var(--accent); }
.recording-actions .recording-remove:hover { color: var(--danger); border-color: var(--danger); }

.recording-empty { color: var(--text-dim); font-size: 0.78rem; padding: 6px 8px; }

.clip-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.clip-form input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 0.75rem;
}

.clip-form .clip-start,
.clip-form .clip-end { width: 90px; }
.clip-form .clip-name { flex: 1; min-width: 100px; }

.clip-form button {
  background: var(--accent);
  color: #06110f;
  border: none;
  border-radius: var(--radius);
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
}

/* ---- Pantallas físicas (fase 4 ítem 10) --------------------------------- */

.screen-region-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.screen-region-inputs label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.68rem;
  color: var(--text-dim);
  flex: 1;
  min-width: 80px;
}

.screen-region-inputs input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 0.8rem;
}

/* ---- Organizar automáticamente ------------------------------------------ */

.arrange-card { width: 380px; align-items: stretch; }

.arrange-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.arrange-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
}
.arrange-option:hover { border-color: var(--accent); }

.arrange-option-title { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.arrange-option-desc { font-size: 0.72rem; color: var(--text-dim); }

.screen-row .screen-link {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 3px 8px;
}
.screen-row .screen-link:hover { color: var(--text); border-color: var(--accent); }

/* ---- Importar M3U -------------------------------------------------------- */

.m3u-card { width: 460px; align-items: stretch; }
#m3u-file-input { font-size: 0.75rem; color: var(--text-dim); }
.m3u-textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 8px;
  box-sizing: border-box;
}
.m3u-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.m3u-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.m3u-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

body.is-viewer #m3u-btn { display: none; }

/* ---- Paginación (más de PAGE_SIZE tiles, ver app.js) --------------------- */

.pagination-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 5;
}
.pagination-bar button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
}
.pagination-bar button:hover:not(:disabled) { border-color: var(--accent); }
.pagination-bar button:disabled { opacity: 0.35; cursor: not-allowed; }
.page-indicator { font-size: 0.75rem; color: var(--text-dim); min-width: 90px; text-align: center; }
