/* ===== WatchBuddy — Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* Accent */
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, .35);
  --gradient: linear-gradient(135deg, #7c3aed, #2563eb);
  --gradient-hover: linear-gradient(135deg, #6d28d9, #1d4ed8);

  /* Dark (default) */
  --bg: #0a0a12;
  --bg-card: rgba(22, 22, 40, .75);
  --bg-card-solid: #16162a;
  --bg-input: rgba(30, 30, 55, .8);
  --bg-overlay: rgba(0, 0, 0, .6);
  --text: #eee;
  --text-muted: #9ca3af;
  --border: rgba(255, 255, 255, .08);
  --border-hover: rgba(255, 255, 255, .15);
  --shadow: 0 8px 32px rgba(0, 0, 0, .4);
  --glass: blur(18px);
}

/* ===== Light theme ===== */
[data-theme="light"] {
  --bg: #f0f2f5;
  --bg-card: rgba(255, 255, 255, .85);
  --bg-card-solid: #fff;
  --bg-input: rgba(0, 0, 0, .05);
  --bg-overlay: rgba(255, 255, 255, .6);
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: rgba(0, 0, 0, .08);
  --border-hover: rgba(0, 0, 0, .15);
  --shadow: 0 8px 32px rgba(0, 0, 0, .1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .4s, color .4s;
  overflow-x: hidden;
  line-height: 1.6;
}

a { color: var(--accent-light); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

/* ===== Utility ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .25s;
  border: none;
  font-size: .95rem;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--bg-card);
}

.btn-sm { padding: 8px 16px; font-size: .85rem; border-radius: 8px; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--bg-input);
  border: 1px solid var(--border); cursor: pointer; transition: all .2s;
}
.btn-icon:hover { border-color: var(--accent); background: var(--bg-card); }

.glass {
  background: var(--bg-card);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-field::placeholder { color: var(--text-muted); }

/* ===== Navbar ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  padding: 12px 0;
  background: var(--bg-card);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--border);
  transition: background .4s;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.3rem; color: var(--text);
}
.navbar-brand svg { width: 32px; height: 32px; }
.navbar-actions { display: flex; align-items: center; gap: 10px; }

/* Theme toggle */
.theme-toggle {
  width: 44px; height: 24px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background .3s;
}
.theme-toggle::after {
  content: '🌙';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .3s;
}
[data-theme="light"] .theme-toggle::after {
  content: '☀️';
  transform: translateX(20px);
}

/* ===== Landing Page ===== */
.hero {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  top: -100px; left: 50%;
  transform: translateX(-50%);
  animation: pulse 6s infinite alternate;
  pointer-events: none;
}
@keyframes pulse {
  0% { opacity: .4; transform: translateX(-50%) scale(1); }
  100% { opacity: .7; transform: translateX(-50%) scale(1.2); }
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 20px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 40px;
}
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* Feature cards */
.features {
  padding: 80px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.feature-card {
  padding: 32px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: transform .3s, border-color .3s, box-shadow .3s;
}
.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 40px var(--accent-glow);
}
.feature-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: var(--gradient);
  font-size: 1.5rem;
  margin-bottom: 18px;
}
.feature-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); font-size: .92rem; }

/* Footer */
.footer {
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}

/* ===== Player Page ===== */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100vh;
  padding-top: 60px;
}

/* Video area */
.player-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
  position: relative;
}

.video-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  cursor: pointer;
  overflow: hidden;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* YouTube player container */
#ytPlayerDiv,
#ytPlayerDiv iframe {
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  inset: 0;
  z-index: 5;
  border: none;
}

.video-container .yt-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .85);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  gap: 12px;
  animation: fadeIn .3s;
}

.yt-loading-overlay .yt-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ytSpin 1s linear infinite;
}

@keyframes ytSpin {
  to { transform: rotate(360deg); }
}

/* Subtitle overlay */
.subtitle-overlay {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 10;
  max-width: 80%;
  transition: all .3s;
}
.subtitle-text {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: 500;
  color: #fff;
  background: rgba(0, 0, 0, .7);
  text-shadow: 1px 1px 3px rgba(0,0,0,.8);
  line-height: 1.5;
}
.subtitle-text:empty { display: none; }

.sync-status {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  z-index: 12;
  transition: opacity .2s, transform .2s;
}

.sync-status.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Video Controls Bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card-solid);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.controls-bar button {
  background: none; border: none; color: var(--text);
  cursor: pointer; font-size: 1.2rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: background .2s;
}
.controls-bar button:hover { background: var(--bg-input); }

.mobile-seek-btn {
  display: none !important;
  font-size: .85rem !important;
  font-weight: 800;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 3px;
  width: 0;
  transition: width .1s;
}

.time-display {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}

.volume-slider {
  width: 80px;
  accent-color: var(--accent);
}

.speed-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text);
  font-size: .8rem;
  cursor: pointer;
}

/* Source input bar */
.source-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card-solid);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.source-bar .input-field { flex: 1; padding: 10px 14px; font-size: .9rem; }

/* ===== Sidebar ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-card-solid);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: all .2s;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  background: none;
}
.sidebar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.sidebar-tab:hover { color: var(--text); }

/* Tab panels */
.tab-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-panel.active { display: flex; }

/* Room panel */
.room-panel { padding: 16px; gap: 14px; }
.room-info {
  padding: 14px;
  background: var(--bg-input);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.room-info label {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.room-link-box {
  display: flex;
  gap: 6px;
}
.room-link-box .input-field {
  flex: 1;
  font-size: .8rem;
  padding: 8px 12px;
}
.user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
}
.user-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: .88rem;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name { flex: 1; }
.user-badge {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Chat panel */
.chat-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-msg {
  display: flex;
  gap: 10px;
  animation: fadeIn .3s;
  max-width: 86%;
  align-self: flex-start;
}
.chat-msg.own {
  align-self: flex-end;
  justify-content: flex-end;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.chat-msg.own .chat-msg-body {
  align-items: flex-end;
}
.chat-msg-name {
  font-weight: 600;
  font-size: .8rem;
  margin-bottom: 2px;
  color: var(--accent-light);
}
.chat-msg-text { font-size: .88rem; word-wrap: break-word; }
.chat-message-item {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--bg-input);
}
.chat-msg.own .chat-message-item {
  background: rgba(124, 58, 237, .22);
  border: 1px solid rgba(167, 139, 250, .18);
}
.chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  justify-content: flex-start;
}
.chat-msg.own .chat-msg-meta {
  justify-content: flex-end;
}
.chat-msg-time { font-size: .7rem; color: var(--text-muted); }
.chat-reply-action {
  opacity: 0;
  font-size: .7rem;
  color: var(--accent-light);
  cursor: pointer;
  border: none;
  background: none;
  transition: opacity .2s;
}
.chat-message-item:hover .chat-reply-action,
.chat-reply-action:focus {
  opacity: 1;
}
.chat-reply-quote,
.reply-preview {
  border-left: 3px solid var(--accent);
  background: var(--bg-input);
  border-radius: 8px;
}
.chat-reply-quote {
  max-width: 220px;
  padding: 6px 8px;
  margin-bottom: 4px;
}
.chat-reply-name,
.reply-preview-name {
  font-size: .72rem;
  font-weight: 700;
  color: var(--accent-light);
}
.chat-reply-text,
.reply-preview-text {
  font-size: .76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-preview {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 14px;
  padding: 8px 10px;
}
.reply-preview button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}
.reply-preview button:hover { background: var(--border); color: var(--text); }
.chat-image-link {
  display: block;
  width: fit-content;
  max-width: 100%;
}
.chat-image {
  display: block;
  max-width: min(220px, 100%);
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #000;
}
.chat-msg.system {
  justify-content: center;
  padding: 4px 0;
}
.chat-msg.system .chat-msg-text {
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}

/* Chat input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.chat-input-area .input-field { flex: 1; padding: 10px 14px; font-size: .88rem; }
.emoji-btn {
  font-size: 1.3rem;
  cursor: pointer;
  background: none; border: none;
  transition: transform .2s;
}
.emoji-btn:hover { transform: scale(1.2); }
.chat-image-btn {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.chat-image-btn:hover {
  border-color: var(--accent);
  background: var(--bg-card);
}

/* Emoji picker */
.emoji-picker {
  display: none;
  position: absolute;
  bottom: 60px;
  right: 14px;
  width: 280px;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
}
.emoji-picker.open { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-picker span {
  font-size: 1.4rem;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background .15s;
}
.emoji-picker span:hover { background: var(--bg-input); }

/* Subtitle settings panel */
.subtitle-panel { padding: 16px; gap: 14px; overflow-y: auto; }
.settings-group {
  padding: 14px;
  background: var(--bg-input);
  border-radius: 10px;
  margin-bottom: 12px;
}
.settings-group h4 {
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-row label {
  font-size: .82rem;
  color: var(--text-muted);
}
.setting-row input[type="range"] { width: 120px; accent-color: var(--accent); }
.setting-row input[type="color"] {
  width: 36px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: none;
}
.setting-row select {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text);
  font-size: .82rem;
}

.toggle-switch {
  position: relative;
  width: 42px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: background .3s;
}
.toggle-switch.active { background: var(--accent); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .3s;
}
.toggle-switch.active::after { transform: translateX(20px); }

/* Subtitle file upload */
.subtitle-upload {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.subtitle-upload:hover,
.subtitle-upload.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.subtitle-upload p { font-size: .85rem; color: var(--text-muted); margin-top: 8px; }
.subtitle-upload .upload-icon { font-size: 2rem; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow);
  animation: modalIn .3s;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 6px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal p { color: var(--text-muted); font-size: .9rem; margin-bottom: 20px; }
.modal-field { margin-bottom: 16px; }
.modal-field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 24px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 3000;
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1);
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh 1fr;
  }
  .sidebar { border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1rem; }
  .features { grid-template-columns: 1fr; }
  .controls-bar { gap: 6px; padding: 8px 10px; }
  .volume-slider { width: 50px; }
  .subtitle-text { font-size: 1rem; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Fullscreen overrides ===== */
.app-layout:fullscreen {
  padding-top: 0;
  background: var(--bg);
}
.app-layout:fullscreen ~ .navbar,
:fullscreen .navbar { display: none; }
.app-layout:fullscreen .controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: rgba(22, 22, 40, .92);
}
.app-layout:fullscreen .source-bar { display: none; }
.app-layout:fullscreen .subtitle-overlay { bottom: 60px; }
.app-layout:fullscreen .sidebar {
  position: relative;
  z-index: 10;
}

/* ===== Capacitor / Mobile App ===== */
/* Safe area for notched devices */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Prevent text selection on UI elements (native feel) */
.btn, .sidebar-tab, .controls-bar button, .toggle-switch, .emoji-btn, .chat-image-btn, .chat-reply-action {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Minimum touch target sizes (44px) */
.controls-bar button {
  min-width: 44px;
  min-height: 44px;
}

/* Mobile: hide scrollbars for cleaner look */
@media (max-width: 600px) {
  .chat-messages::-webkit-scrollbar { display: none; }
  .chat-messages { -ms-overflow-style: none; scrollbar-width: none; }
  
  /* Larger controls on mobile */
  .controls-bar { gap: 4px; padding: 8px 8px; }
  .controls-bar button { font-size: 1.1rem; }
  .controls-bar .mobile-seek-btn { display: flex !important; }
  .chat-reply-action { opacity: 1; }
  .time-display { font-size: .7rem; min-width: 70px; }
  .speed-select { font-size: .75rem; padding: 2px 4px; }
  
  /* Stack source bar input */
  .source-bar { padding: 8px 10px; }
  .source-bar .input-field { font-size: .82rem; padding: 8px 10px; }
}
