:root {
  --accent: #22a855;
  --accent-hover: #1a8a43;
}
[data-accent="red"] {
  --accent: #ff4444;
  --accent-hover: #cc0000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0f0f0f;
  color: #fff;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 40px 20px;
}

/* ── Dev banner ── */
#dev-banner {
  align-self: stretch;
  margin: -40px -20px 40px;
  padding: 10px 20px;
  background: #f59e0b;
  color: #000;
  text-align: center;
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── Resizable layout container ── */
.layout {
  position: relative;
  width: 720px;
  max-width: calc(100vw - 40px);
  min-width: 320px;
  container-type: inline-size;
}

@container (max-width: 500px) {
  .queue-btn-label { display: none; }
  button.queue-btn { padding: 7px; }
}

.resize-handle {
  position: absolute;
  right: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 60px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.resize-handle::before {
  content: '';
  display: block;
  width: 5px;
  height: 36px;
  border-left: 2px dotted #444;
  border-right: 2px dotted #444;
  transition: border-color 0.2s;
}

.resize-handle:hover::before { border-color: #888; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
  transition: background 0.3s;
}

.dot.connected    { background: #4caf50; }
.dot.disconnected { background: #f44336; }
.dot.playing      { background: #4caf50; }
.dot.paused       { background: #888; }

.settings-wrapper {
  position: relative;
}

.settings-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.settings-btn:hover { color: #fff; background: #222; }

.settings-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 14px;
  min-width: 220px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.settings-dropdown.open { display: block; }

.settings-label {
  font-size: 0.72rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.settings-name-row {
  display: flex;
  gap: 6px;
}

.settings-name-row input {
  flex: 1;
  padding: 6px 8px;
  background: #111;
  border: 1px solid #333;
  border-radius: 5px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.settings-name-row input:focus { border-color: var(--accent); }

.settings-name-row button {
  padding: 6px 10px;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.settings-name-row button:hover { background: var(--accent-hover); }

.settings-toggle-row {
  display: flex;
  gap: 6px;
}

.settings-toggle-btn {
  flex: 1;
  padding: 6px 10px;
  background: #222;
  border: 1px solid #333;
  border-radius: 5px;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.settings-toggle-btn:hover { background: #2a2a2a; color: #ccc; }
.settings-toggle-btn.active { background: #333; border-color: var(--accent); color: #fff; }

/* ── URL input ── */
.input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 24px;
}

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus { border-color: var(--accent); }

button.load-btn {
  padding: 7px 16px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

button.load-btn:hover { background: var(--accent-hover); }
button.load-btn:disabled { opacity: 0.4; cursor: default; }

.url-preview {
  display: none;
  align-items: center;
  gap: 10px;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: -16px;
  margin-bottom: 12px;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.url-preview:hover {
  border-color: var(--accent);
  background: #161616;
}

.url-preview-thumb-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 45px;
}

.url-preview-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: #222;
  display: block;
}

.url-preview-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.url-preview-title {
  font-size: 0.82rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.url-preview-channel {
  font-size: 0.58rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.error-msg {
  color: #ff6b6b;
  font-size: 0.85rem;
  margin-top: -16px;
  margin-bottom: 16px;
  display: none;
}

/* ── Player area & layouts ── */
.player-area {
  display: flex;
  flex-direction: column;
  width: 100%;
}


.player-wrapper {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.video-clip {
  width: 100%;
  position: relative;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f0f0f;
  overflow: hidden;
  border-radius: 8px;
}

#player { display: block; width: 100%; height: 100%; pointer-events: none; }

.player-thumb-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  background: #000;
  cursor: pointer;
}

.player-thumb-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-thumb-overlay:hover .play-overlay-btn { opacity: 1; }

.play-overlay-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.unmute-banner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.82rem;
  text-align: center;
  padding: 8px;
  cursor: pointer;
  z-index: 11;
  display: none;
  transition: background 0.15s;
}

.unmute-banner:hover { background: rgba(40,40,40,0.9); }

.now-playing-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 6px;
  min-width: 0;
}

.now-playing-title[href]:hover { color: #fff; }

.now-playing-title-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.now-playing-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: #ccc;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
}

.now-playing-channel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.now-playing-channel-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.now-playing-channel-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 0.65rem;
  font-weight: bold;
  color: #fff;
}

.now-playing-subscribers {
  font-size: 0.54rem;
  font-weight: normal;
  color: #aaa;
}

.now-playing-video-meta {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.5rem;
  font-weight: bold;
  color: #aaa;
  background: #272727;
  border-radius: 3px;
  padding: 2px 4px 3px;
  margin-top: 1px;
}

.now-playing-video-meta:empty {
  display: none;
}

.now-playing-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 24px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 0 0 8px 8px;
}

.video-clip.controls-show .controls { opacity: 1; }
.video-clip:not(.controls-show),
.video-clip:not(.controls-show) * { cursor: none !important; }

.video-clip.fs {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-clip.fs .video-container {
  width: min(100%, calc(100vh * 16 / 9));
  height: auto !important;
  aspect-ratio: 16 / 9;
}

.video-clip.fs .controls {
  width: min(100%, calc(100vh * 16 / 9));
  left: 50%;
  transform: translateX(-50%);
}

.progress-row {
  display: flex;
  align-items: center;
  margin: 0;
}

.time-display {
  font-size: 0.78rem;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

.seek-bar-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.seek-bar-wrap input[type="range"] {
  flex: 1;
}

.seek-thumbnail {
  position: absolute;
  bottom: calc(100% + 30px);
  transform: translateX(-50%);
  background: #000;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 3px;
  display: none;
  z-index: 11;
  pointer-events: none;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.seek-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  display: none;
  z-index: 10;
}

input[type="range"] {
  flex: 1;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #333;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

#volume-slider { height: 3px; }
#volume-slider::-webkit-slider-thumb { width: 8px; height: 8px; }

.buttons-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ctrl-btn {
  background: rgba(0,0,0,0.3);
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0;
  width: 28px;
  height: 28px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.2s, background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn:hover { color: var(--accent-hover); background: rgba(255,255,255,0.08); }
.ctrl-btn.active { color: #fff; background: rgba(255,255,255,0.18); }

#play-pause-btn { padding-left: 2px; }

.volume-row {
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.3);
  border-radius: 20px;
  padding: 0;
  transition: background 0.15s, padding 0.2s ease;
}

.volume-row:hover { background: rgba(255,255,255,0.08); padding: 0 12px 0 6px; }

#volume-slider {
  width: 0;
  flex: none;
  opacity: 0;
  pointer-events: none;
  transition: width 0.2s ease, opacity 0.2s ease, margin-left 0.2s ease;
  margin-left: 0;
}

.volume-row:hover #volume-slider {
  width: 80px;
  opacity: 1;
  pointer-events: auto;
  margin-left: 6px;
}

#volume-icon {
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Users panel ── */
.users-panel {
  width: 100%;
  background: #111;
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
  font-size: 0.8rem;
  color: #888;
}

.user-chip {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: #ccc;
}

.user-chip.is-you {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Queue panel ── */
.queue-panel {
  width: 100%;
  background: #111;
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.queue-header {
  padding: 8px 14px;
  height: 36px;
  box-sizing: border-box;
  font-size: 0.78rem;
  font-weight: bold;
  color: #555;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  align-items: center;
  gap: 6px;
}

.queue-clear-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #555;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 2px 6px;
}

.queue-clear-btn:hover {
  color: #c44;
}

.queue-clear-confirm {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #666;
}

.queue-clear-yes,
.queue-clear-no {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  line-height: 1;
}

.queue-clear-yes {
  color: #555;
  font-weight: 600;
}

.queue-clear-yes:hover {
  color: #22a855;
}

.queue-clear-no {
  color: #555;
}

.queue-clear-no:hover {
  color: #c44;
}

#queue-count,
#held-count {
  background: #222;
  color: #888;
  border-radius: 10px;
  padding: 3px 9px;
  font-size: 0.62rem;
}

.queue-empty {
  padding: 14px;
  font-size: 0.8rem;
  color: #444;
  text-align: center;
}

.queue-list {
  display: flex;
  flex-direction: column;
}

.queue-list.scrollable {
  max-height: 580px;
  overflow-y: auto;
}

.queue-list.scrollable::-webkit-scrollbar {
  width: 4px;
}

.queue-list.scrollable::-webkit-scrollbar-track {
  background: transparent;
}

.queue-list.scrollable::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 2px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid #1a1a1a;
  transition: background 0.15s;
}

.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: #1a1a1a; }

.thumb-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 45px;
}

.queue-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: #222;
  display: block;
}

.thumb-duration {
  position: absolute;
  bottom: 2px;
  right: 3px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 2px;
  line-height: 1.4;
  pointer-events: none;
}

.queue-num {
  font-size: 0.75rem;
  color: #555;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.queue-title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.queue-title {
  font-size: 0.78rem;
  color: #bbb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-channel {
  font-size: 0.58rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.queue-item.dragging { opacity: 0.35; }

.queue-item.drag-over {
  border-top: 2px solid var(--accent);
  margin-top: -2px;
}

.queue-drag {
  color: #444;
  cursor: grab;
  font-size: 1rem;
  padding: 0 2px;
  flex-shrink: 0;
  letter-spacing: -2px;
  user-select: none;
}

.queue-drag:active { cursor: grabbing; }

.queue-link-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  text-decoration: none;
  line-height: 1;
}

.queue-link-btn:hover { color: #fff; background: #1e1e1e; }

.queue-play-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.queue-play-btn:hover { color: #fff; background: #22a855; }

.held-timestamp {
  font-size: 0.72rem;
  color: #555;
  flex-shrink: 0;
  margin-left: auto;
}

.queue-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.queue-remove:hover { color: #c44; background: #1e1e1e; }

button.queue-btn {
  padding: 7px 12px;
  background: #222;
  border: 1px solid #333;
  border-radius: 6px;
  color: #ccc;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

button.queue-btn:hover { background: #2a2a2a; color: #fff; }
button.queue-btn:disabled { opacity: 0.4; cursor: default; }

/* ── History panel ── */
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid #1a1a1a;
  transition: background 0.15s;
}

.history-item:last-child { border-bottom: none; }
.history-item:hover { background: #1a1a1a; }

.history-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  background: #222;
  display: block;
}

.history-title {
  flex: 1;
  font-size: 0.78rem;
  color: #bbb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.history-add-btn {
  background: #2a2a2a;
  border: none;
  border-radius: 4px;
  color: #aaa;
  font-size: 0.72rem;
  padding: 4px 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.history-add-btn:hover { background: var(--accent); color: #fff; }

/* ── Group Toke ── */
.toke-panel {
  width: 100%;
  background: #111;
  border: 1px solid #2a4a2a;
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.toke-header {
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: bold;
  color: #4caf50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e1e1e;
}

.toke-cancel-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.toke-cancel-btn:hover { color: #c44; }

.toke-participants {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toke-actions {
  padding: 8px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toke-hint {
  font-size: 0.72rem;
  color: #555;
}

.toke-hint strong {
  color: #888;
}

.toke-start-btn {
  padding: 8px 20px;
  background: #4caf50;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.toke-start-btn:hover { background: #388e3c; }

/* ── Cheers overlay ── */
.cheers-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  font-weight: bold;
  color: #4caf50;
  text-shadow: 0 0 40px rgba(76, 175, 80, 0.6), 0 0 80px rgba(76, 175, 80, 0.3);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
}

.cheers-overlay.cheers-animate {
  animation: cheersFlash 3s ease-out forwards;
}

@keyframes cheersFlash {
  0%   { opacity: 0; transform: scale(0.5); }
  15%  { opacity: 1; transform: scale(1.2); }
  30%  { transform: scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
