/* Loop - design system: light (white + purple) and dark (grays + fuchsia) */

:root {
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --transition: .2s ease;

  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #ede9fe;
  --accent: #8b5cf6;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --success: #10b981;
  --success-soft: #d1fae5;
}

[data-theme="dark"] {
  --bg: #111827;
  --surface: #1f2937;
  --surface-2: #374151;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --border: #374151;
  --primary: #d946ef;
  --primary-hover: #c026d3;
  --primary-soft: #4a044e;
  --accent: #e879f9;
  --danger: #f87171;
  --danger-soft: #450a0a;
  --success: #34d399;
  --success-soft: #064e3b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

[x-cloak] { display: none !important; }

/* utilities */
.desktop-only { display: block; }
.mobile-only { display: none; }
.muted { color: var(--text-muted); font-size: .85rem; }

@media (max-width: 768px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; }
}

/* LOGIN */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 10% 20%, color-mix(in srgb, var(--primary) 12%, transparent) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, color-mix(in srgb, var(--accent) 10%, transparent) 0%, transparent 40%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
}

.brand { display: flex; align-items: center; justify-content: center; gap: .75rem; margin-bottom: 1rem; }
.logo-img {
  width: 40px; height: 40px; border-radius: 10px;
  object-fit: contain; display: block;
}
.brand h1 { margin: 0; font-size: 1.75rem; }
.login-lead { color: var(--text-muted); margin-bottom: 2rem; line-height: 1.5; }

.google-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: .75rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.google-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.google-btn svg { width: 20px; height: 20px; }

.theme-toggle {
  position: absolute; top: 1rem; right: 1rem;
  background: transparent; border: 1px solid var(--border);
  border-radius: 999px; width: 36px; height: 36px; cursor: pointer;
  display: grid; place-items: center; font-size: 1rem;
}

.login-footer {
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  display: flex; justify-content: center; gap: .5rem;
}
.login-footer a { color: var(--text-muted); text-decoration: none; }
.login-footer a:hover { color: var(--primary); }

.login-actions {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  margin-top: 1rem;
}

/* LANDING PAGE */
.landing-view {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 10% 10%, color-mix(in srgb, var(--primary) 10%, transparent) 0%, transparent 45%),
    radial-gradient(circle at 90% 30%, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 45%),
    var(--bg);
}

.landing-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.landing-header .brand { margin: 0; text-decoration: none; color: var(--text); justify-content: flex-start; }
.landing-header .logo-img { width: 34px; height: 34px; }
.landing-header .app-name { font-size: 1.15rem; }

.landing-actions {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap;
}
.landing-actions .theme-toggle {
  position: static;
  width: 34px; height: 34px;
}

.hero {
  flex: 1;
  display: grid; place-items: center;
  padding: 3rem 1.5rem;
  text-align: center;
}
.hero-content { max-width: 720px; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  margin: 0 0 1rem;
  letter-spacing: -.02em;
}
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 2rem;
}
.google-btn.large {
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  width: auto;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  padding: 4rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.feature-icon {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid; place-items: center;
  margin-bottom: 1rem;
}
.feature h3 { margin: 0 0 .5rem; font-size: 1.15rem; }
.feature p { margin: 0; color: var(--text-muted); line-height: 1.5; }

.how-it-works {
  padding: 3rem 1.5rem 5rem;
  text-align: center;
}
.how-it-works h2 { font-size: 1.75rem; margin-bottom: 2rem; }
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.step-number {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
}
.steps p { margin: 0; color: var(--text-muted); line-height: 1.45; }

.landing-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}
.landing-footer p { margin: 0 0 .5rem; }
.landing-footer a { color: var(--text-muted); text-decoration: none; }
.landing-footer a:hover { color: var(--primary); }

/* REACTIONS */
.reactions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.reactions h3 {
  margin: 0 0 .75rem;
  font-size: 1rem;
  color: var(--text-muted);
}
.reaction-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.reaction-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.reaction-btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.reaction-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.reaction-emoji {
  font-size: 1.15rem;
  line-height: 1;
}
.reaction-count {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .35rem;
  font-size: .75rem;
  color: var(--text-muted);
}
.reaction-btn.active .reaction-count {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* COOKIE BANNER */
.cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  box-shadow: 0 -4px 20px rgba(0,0,0,.1);
}
.cookie-banner-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.cookie-banner p {
  margin: 0;
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
}
.cookie-banner a { color: var(--primary); text-decoration: none; }
.cookie-banner a:hover { text-decoration: underline; }
.cookie-banner button {
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: none;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.cookie-banner button:hover { background: var(--primary-hover); }

@media (max-width: 768px) {
  .cookie-banner-content { flex-direction: column; align-items: flex-start; }
  .cookie-banner button { width: 100%; }
}

/* LANDING PROCESS ANIMATION */
.process-animation {
  max-width: 720px;
  width: 100%;
  height: auto;
  margin: 2.5rem auto;
  overflow: visible;
}
.process-step {
  opacity: .25;
  animation: stepGlow 4.5s ease-in-out infinite;
}
.process-step.step-1 { animation-delay: 0s; }
.process-step.step-2 { animation-delay: 1.1s; }
.process-step.step-3 { animation-delay: 2.2s; }
.process-step.step-4 { animation-delay: 3.3s; }

@keyframes stepGlow {
  0%, 100% { opacity: .25; }
  8% { opacity: 1; }
  30% { opacity: 1; }
  40% { opacity: .25; }
}

.record-dot {
  animation: pulseRecord 1.2s ease-in-out infinite;
}
@keyframes pulseRecord {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.process-arrow {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-dasharray: 8 6;
  opacity: .25;
  animation: flowArrow 1.2s linear infinite;
}
.process-arrow.arrow-1 { animation-delay: .3s; }
.process-arrow.arrow-2 { animation-delay: 1.4s; }
.process-arrow.arrow-3 { animation-delay: 2.5s; }

@keyframes flowArrow {
  0% { stroke-dashoffset: 14; opacity: .25; }
  50% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: .25; }
}

@media (max-width: 768px) {
  .landing-header { padding: .75rem 1rem; }
  .landing-header .app-name { display: none; }
  .landing-actions .primary-btn { padding: .6rem .9rem; font-size: .85rem; }
  .hero { padding: 2rem 1rem; }
  .features { padding: 2rem 1rem; }
  .how-it-works { padding: 2rem 1rem 3rem; }
}

/* DASHBOARD SHELL */
.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

.dashboard.collapsed {
  grid-template-columns: 80px 1fr;
}

@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "topbar"
      "main"
      "appbar";
    padding-bottom: 72px;
  }
  .dashboard.collapsed {
    grid-template-columns: 1fr;
  }
}

/* TOPBAR */
.topbar {
  grid-area: topbar;
  position: sticky; top: 0; z-index: 30;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand { display: flex; align-items: center; gap: .75rem; }
.topbar-brand .logo-img { width: 32px; height: 32px; border-radius: 8px; }
.app-name { font-weight: 700; font-size: 1.25rem; }

.topbar-user { display: flex; align-items: center; gap: .75rem; }

/* user dropdown */
.user-menu { position: relative; }
.avatar-btn {
  display: flex; align-items: center; gap: .35rem;
  background: transparent; border: none; cursor: pointer; padding: .25rem;
  border-radius: var(--radius);
}
.avatar-btn:hover { background: var(--surface-2); }
.avatar-btn .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.avatar-btn .caret { color: var(--text-muted); }

.dropdown {
  position: absolute; right: 0; top: calc(100% + .5rem);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .5rem;
  z-index: 60;
}
.dropdown-user {
  padding: .75rem .5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}
.dropdown-user strong {
  display: block; font-size: .9rem; margin-bottom: .15rem;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropdown-user .muted { display: block; font-size: .8rem; }
.dropdown-item {
  width: 100%; text-align: left;
  background: transparent; border: none; border-radius: var(--radius-sm);
  padding: .65rem .5rem; color: var(--text);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: .75rem; }
.user-name { font-weight: 600; font-size: .9rem; }
.logout-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); padding: .35rem .75rem;
  border-radius: var(--radius-sm); font-size: .85rem; cursor: pointer;
}
.logout-btn:hover { border-color: var(--primary); color: var(--primary); }
.logout-btn.full { width: 100%; margin-top: 1rem; }

.icon-btn {
  background: transparent; border: none; color: var(--text);
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-sm); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.menu-btn { display: none; }
.collapse-btn { display: none; }
.topbar .collapse-btn.desktop-only { display: grid; }

@media (max-width: 768px) {
  .menu-btn { display: grid; }
  .topbar .collapse-btn.desktop-only { display: none; }
}

/* SIDEBAR */
.sidebar {
  grid-area: sidebar;
  position: sticky; top: 64px; height: calc(100vh - 64px);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex; flex-direction: column;
  background: var(--surface);
  transition: padding var(--transition);
}

.dashboard.collapsed .sidebar { padding: 1rem .5rem; }

.nav-item {
  width: 100%; display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-radius: var(--radius);
  border: none; background: transparent; color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer;
  margin-bottom: .35rem;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item.record { color: var(--danger); }
.nav-item.record:hover { background: var(--danger-soft); }
.nav-item svg { flex-shrink: 0; }

.dashboard.collapsed .sidebar .nav-item { justify-content: center; padding: .75rem .25rem; }
.dashboard.collapsed .sidebar .nav-item span { display: none; }
.dashboard.collapsed .sidebar .sidebar-footer span { display: none; }
.dashboard.collapsed .sidebar .sidebar-footer::after { content: 'Lv0.1'; color: var(--text-muted); font-size: .7rem; }

.sidebar-footer { margin-top: auto; text-align: center; padding: 1rem 0; }

/* MOBILE MENU */
.mobile-menu {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.4);
  display: none;
  justify-content: flex-start;
}
.mobile-menu-panel {
  width: 280px; max-width: 80%;
  background: var(--surface);
  height: 100%;
  padding: 1rem;
  display: flex; flex-direction: column;
}
.mobile-menu-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.mobile-menu-user {
  display: flex; align-items: center; gap: .75rem;
  margin-top: auto; padding: 1rem 0; border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .mobile-menu { display: flex; }
}

/* MAIN */
.main-content {
  grid-area: main;
  padding: 1.5rem;
  overflow-y: auto;
}

.home-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}
.home-header h2 { margin: 0; font-size: 1.5rem; }
.home-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.primary-btn {
  background: var(--primary); color: #fff; border: none;
  padding: .65rem 1.25rem; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .5rem;
  transition: background var(--transition), transform var(--transition);
}
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.primary-btn.small { padding: .45rem .9rem; font-size: .85rem; }
.primary-btn.full { width: 100%; justify-content: center; }
.primary-btn:disabled { opacity: .7; cursor: not-allowed; transform: none; }

.danger-btn {
  background: var(--danger); color: #fff; border: none;
  padding: .65rem 1.25rem; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .5rem;
  transition: background var(--transition), transform var(--transition);
}
.danger-btn:hover { background: #dc2626; transform: translateY(-1px); }
.danger-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.secondary-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: .65rem 1.25rem; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.secondary-btn:hover { background: var(--surface); }
.secondary-btn.full { width: 100%; }

.empty-state {
  text-align: center; padding: 4rem 1rem; color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; }

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.video-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.video-card.selected { outline: 2px solid var(--primary); outline-offset: -2px; }

.thumb {
  aspect-ratio: 16/9;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.thumb-placeholder {
  display: grid; place-items: center;
  width: 100%; height: 100%;
}

.play-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(0,0,0,.12);
  border: none; cursor: pointer; opacity: 0;
  transition: opacity var(--transition);
}
.video-card:hover .play-overlay { opacity: 1; }
.play-overlay svg { filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }

.edit-badge, .delete-badge {
  position: absolute; top: .5rem;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.9); color: var(--text);
  border: none; display: grid; place-items: center; cursor: pointer;
  opacity: 0; transition: opacity var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.edit-badge { right: .5rem; }
.delete-badge { right: 2.75rem; }
[data-theme="dark"] .edit-badge, [data-theme="dark"] .delete-badge { background: rgba(31,41,55,.9); color: var(--text); }
.video-card:hover .edit-badge, .video-card:hover .delete-badge { opacity: 1; }
.edit-badge:hover { color: var(--primary); }
.delete-badge:hover { color: var(--danger); }

.card-select {
  position: absolute; top: .5rem; left: .5rem; z-index: 5;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,.9);
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
[data-theme="dark"] .card-select { background: rgba(31,41,55,.9); }
.card-select input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

.card-body { padding: 1rem; }
.card-body h3 { margin: 0 0 .5rem; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.badge {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: .2rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
}
.st-READY .badge { background: var(--success-soft); color: var(--success); }
.st-FAILED .badge { background: var(--danger-soft); color: var(--danger); }
.st-DRIVE_UPLOADING .badge { background: var(--primary-soft); color: var(--primary); }
.st-UPLOADING .badge { background: #fef3c7; color: #b45309; }

.actions { display: flex; gap: .5rem; }
.icon-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.icon-action:hover { background: var(--primary-soft); color: var(--primary); transform: translateY(-1px); }
.icon-action.retry:hover, .icon-action.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-action svg { pointer-events: none; }

/* DRAWER */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.35);
}
.right-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 41;
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.right-drawer.open { transform: translateX(0); }

.drawer-header {
  height: 64px; padding: 0 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.drawer-header h2 { margin: 0; font-size: 1.1rem; }

.drawer-body { padding: 1.25rem; overflow-y: auto; flex: 1; }

.preview-wrap {
  background: #000; border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 1rem;
  aspect-ratio: 16/9;
  display: grid; place-items: center;
}
.preview-wrap canvas { width: 100%; height: 100%; object-fit: contain; }
.preview-placeholder {
  color: var(--text-muted); text-align: center; padding: 1rem;
}

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--primary-soft); color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem;
}

.error { color: var(--danger); font-weight: 600; margin-bottom: 1rem; }
.notice { color: var(--success); font-weight: 600; margin-bottom: 1rem; }

.recording-title-input {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.recording-title-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.options-panel {
  display: flex; flex-direction: column; gap: 1rem;
  margin-bottom: 1rem;
}
.option-group { display: flex; flex-direction: column; gap: .5rem; }
.option-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.toggle-row { display: flex; flex-wrap: wrap; gap: .5rem; }

.chip-check, .chip-radio {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .75rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font: inherit; font-size: .9rem; cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.chip-check:has(input:checked), .chip-radio:has(input:checked) {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary);
}
.chip-check input, .chip-radio input { display: none; }

.local-result {
  display: flex; flex-direction: column; gap: .75rem;
  margin-bottom: 1rem;
}
.local-result p { margin: 0; color: var(--text-muted); }

.recorder-controls {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;
}
.record-btn, .stop-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  border: none; border-radius: var(--radius);
  padding: .75rem 1.25rem; font: inherit; font-weight: 700; cursor: pointer;
  color: #fff;
}
.record-btn { background: var(--danger); }
.record-btn:hover { background: #dc2626; }
.stop-btn { background: #374151; }
.stop-btn:hover { background: #1f2937; }
.record-btn .dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.stop-btn .square { width: 10px; height: 10px; background: #fff; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }

.progress-wrap { margin-bottom: 1rem; }
progress { width: 100%; height: 6px; border-radius: 999px; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--primary); }

/* MOBILE APP BAR */
.mobile-appbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 64px; background: var(--surface);
  border-top: 1px solid var(--border);
  justify-content: space-around; align-items: center;
  z-index: 30; padding-bottom: env(safe-area-inset-bottom);
}
.appbar-item {
  flex: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem; background: transparent; border: none; color: var(--text-muted);
  font: inherit; font-size: .7rem; cursor: pointer;
}
.appbar-item.active { color: var(--primary); }
.appbar-item.record { color: var(--danger); }

@media (max-width: 768px) {
  .mobile-appbar { display: flex; }
  .main-content { padding-bottom: 1rem; }
  .home-header { flex-direction: column; align-items: flex-start; }
  .video-grid { grid-template-columns: 1fr; }
  .right-drawer { width: 100vw; }
  .play-overlay, .edit-badge { opacity: 1; }
}

/* MODALS */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.55);
  display: grid; place-items: center;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(640px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.modal-header {
  height: 56px; padding: 0 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1.25rem; overflow-y: auto; }

.video-modal {
  width: min(960px, 100%);
}
.video-modal .modal-body {
  padding: 0;
  background: #000;
  display: grid; place-items: center;
}
.video-modal .modal-body > .plyr,
.video-modal .modal-body > video {
  width: 100%; max-height: 70vh;
  display: block;
}

/* force Plyr to fill its container */
.plyr {
  width: 100%;
  height: 100%;
}
.plyr__video-wrapper,
.plyr__video-embed,
.plyr video,
.plyr__poster {
  width: 100%;
  height: 100%;
}

.edit-modal .field {
  display: flex; flex-direction: column; gap: .4rem;
  margin-bottom: 1rem;
}
.edit-modal .field span { font-size: .9rem; font-weight: 600; }
.edit-modal input[type="text"],
.edit-modal input[type="file"] {
  width: 100%; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit;
}
.edit-modal input[type="text"]:focus {
  outline: 2px solid var(--primary-soft); border-color: var(--primary);
}
.cover-preview {
  aspect-ratio: 16/9; border-radius: var(--radius);
  overflow: hidden; background: var(--surface-2); margin-bottom: 1rem;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: .75rem;
}

/* WATCH PAGE */
.watch-page {
  min-height: 100vh;
  background: var(--bg);
}
.watch-topbar {
  height: 64px; padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.watch-topbar .brand { display: flex; align-items: center; gap: .75rem; margin: 0; color: var(--text); text-decoration: none; }
.watch-topbar .logo-img { width: 32px; height: 32px; border-radius: 8px; }
.watch-topbar .app-name { font-weight: 700; font-size: 1.25rem; }
.watch-topbar .topbar-user { gap: .75rem; }
.watch-topbar .theme-toggle { position: relative; top: auto; right: auto; }

.watch-container {
  max-width: 1100px; margin: 0 auto; padding: 2rem 1rem;
}
.watch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.watch-video-wrap {
  background: #000;
  aspect-ratio: 16/9;
  display: grid; place-items: center;
}
.watch-video-wrap video {
  width: 100%; height: 100%;
  max-height: 70vh;
  object-fit: contain;
}
.watch-info { padding: 1.5rem; }
.watch-info h1 { margin: 0 0 .5rem; font-size: 1.5rem; }
.watch-meta { color: var(--text-muted); font-size: .9rem; margin-bottom: 1rem; }
.watch-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.password-gate {
  max-width: 420px; margin: 6rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.password-gate .logo-img { width: 64px; height: 64px; margin: 0 auto 1rem; }
.password-gate h2 { margin: 0 0 .5rem; }
.password-gate p { color: var(--text-muted); margin-bottom: 1.5rem; }
.password-gate input {
  width: 100%; padding: .75rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit;
  margin-bottom: 1rem;
}
.password-gate input:focus {
  outline: 2px solid var(--primary-soft); border-color: var(--primary);
}
.password-gate .error { margin-bottom: 1rem; }

.not-found {
  text-align: center; padding: 6rem 1rem; color: var(--text-muted);
}
.not-found h2 { color: var(--text); margin-bottom: .5rem; }

/* LEGAL PAGES */
.legal-container { padding-bottom: 3rem; }
.legal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.legal-card h1 { margin-top: 0; font-size: 1.75rem; }
.legal-card h2 { margin-top: 1.75rem; font-size: 1.15rem; color: var(--primary); }
.legal-card p { line-height: 1.6; }
.legal-card ul { padding-left: 1.25rem; line-height: 1.6; }
.legal-card a { color: var(--primary); }

.lang-switch {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: .2rem;
  gap: .2rem;
}
.lang-switch button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  padding: .35rem .6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.lang-switch button.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.version-badge {
  display: inline-flex; align-items: center;
  font-size: .7rem; font-weight: 700; letter-spacing: .02em;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--border);
  line-height: 1;
  white-space: nowrap;
}

/* FOOTER LINKS */
.app-footer {
  grid-area: main;
  align-self: end;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
}
.app-footer a { color: var(--text-muted); margin: 0 .5rem; text-decoration: none; }
.app-footer a:hover { color: var(--primary); }

@media (max-width: 768px) {
  .legal-card { padding: 1.25rem; }
}
