:root {
  --bg-base: #141414;
  --bg-surface: #1c1c1c;
  --bg-card: #242424;
  --bg-card-hover: #2b2b2b;
  --border-subtle: #2d2d2d;
  --border-active: #404040;
  --text-main: #ededed;
  --text-muted: #9e9e9e;
  --text-dim: #6c6c6c;
  --accent-primary: #ededed;
  --accent-text: #141414;
  --accent-hover: #ffffff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-icon {
  width: 24px;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon svg {
  width: 13px;
  height: 13px;
  fill: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.badge-pill.active {
  border-color: var(--border-active);
  color: var(--text-main);
}

.badge-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.code-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.05em;
}

/* Buttons & Inputs */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--accent-text);
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-primary);
}

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

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.btn-danger {
  background: transparent;
  border: 1px solid #4a2525;
  color: #f87171;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: #3b1818;
  color: #fff;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

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

/* Modal Styles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Lobby View */
#view-lobby {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
  z-index: 10;
}

.lobby-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2.25rem;
  width: 100%;
  max-width: 420px;
}

.lobby-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.lobby-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.lobby-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-code {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 1.05rem;
  font-weight: 600;
}

.input-pin {
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  font-size: 1.05rem;
  font-weight: 600;
}

/* Watch Room Layout */
#view-room {
  flex: 1;
  display: none;
  padding: 1.25rem;
  gap: 1.25rem;
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 10;
}

.room-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
  width: 100%;
}

@media (max-width: 1024px) {
  .room-grid {
    grid-template-columns: 1fr;
  }
}

/* Player Container */
.player-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.player-viewport {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.player-iframe-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#ytplayer {
  width: 100%;
  height: 100%;
}

.player-overlay-empty {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.player-overlay-empty svg {
  width: 56px;
  height: 56px;
  color: var(--text-dim);
}

/* Player Custom Controls */
.control-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.seek-bar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.time-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 95px;
  text-align: right;
}

.scrub-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

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

.controls-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-circle:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.btn-play-pause {
  width: 40px;
  height: 40px;
  background: var(--accent-primary);
  color: var(--accent-text);
  border: 1px solid var(--accent-primary);
}

.btn-play-pause:hover {
  background: var(--accent-hover);
}

.local-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.volume-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 120px;
}

.volume-group input[type="range"] {
  height: 4px;
}

/* Video Details Card */
.video-info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.video-meta h2 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.video-meta p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Queue Sidebar */
.queue-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  position: sticky;
  top: 80px;
  overflow: hidden;
}

.queue-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.queue-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.add-video-form {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.add-video-row {
  display: flex;
  gap: 0.5rem;
}

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.queue-empty-msg {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.queue-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.queue-thumb {
  width: 72px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  background: #000;
  flex-shrink: 0;
}

.queue-item-details {
  flex: 1;
  min-width: 0;
}

.queue-item-title {
  font-size: 0.825rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
  margin-bottom: 0.15rem;
}

.queue-item-author {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex-shrink: 0;
}

.btn-action-tiny {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.2rem;
  border-radius: 3px;
  cursor: pointer;
}

.btn-action-tiny:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.btn-action-tiny.delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  color: var(--text-main);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
