:root {
  color-scheme: light dark;
  --bg: #0f0e13;
  --bg-card: #18171e;
  --bg-card-hover: #22202b;
  --bg-subtle: #1e1d25;
  --fg: #f4f3f6;
  --fg-muted: #9592a6;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #ff5a36;
  --accent-hover: #ff724f;
  --accent2: #ff2f7a;
  --brand: #ff5a36;
  --brand-hover: #ff6e4d;
  --brand-glow: rgba(255, 90, 54, 0.28);
  --green: #10b981;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8f7fa;
    --bg-card: #ffffff;
    --bg-card-hover: #f3f2f8;
    --bg-subtle: #eeedf5;
    --fg: #131218;
    --fg-muted: #6e6b7b;
    --line: rgba(0, 0, 0, 0.08);
    --line-strong: rgba(0, 0, 0, 0.15);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------- Top Navbar ---------------- */
.navbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
}

.logo-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffa24a 0%, #ff5a36 50%, #ff2f7a 100%);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(255, 90, 54, 0.35);
}

.logo-badge i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.workspace-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
}

.workspace-badge .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.nav-center {
  flex: 1;
  max-width: 520px;
  margin: 0 32px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-card);
}

.search-box input {
  background: transparent;
  border: 0;
  color: var(--fg);
  font-size: 14px;
  outline: none;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--fg-muted);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--fg);
  text-decoration: none;
  user-select: none;
}

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

.btn.primary {
  background: linear-gradient(135deg, #ff7a3d 0%, #ff5a36 45%, #ff3d77 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 14px var(--brand-glow);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #736ef7 0%, #5b54ea 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 90, 54, 0.4);
}

.btn.accent {
  background: linear-gradient(135deg, #ffa24a 0%, #ff5a36 50%, #ff2f7a 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 14px rgba(255, 90, 54, 0.35);
}

.btn.accent:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c6cf0, #39b5e0);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

/* ---------------- Main Layout ---------------- */
.app-container {
  display: flex;
  flex: 1;
}

.sidebar {
  width: 250px;
  border-right: 1px solid var(--line);
  background: var(--bg-card);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  background: var(--bg-subtle);
  color: var(--fg);
}

.sidebar-link.active {
  background: var(--bg-subtle);
  color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-link .icon {
  font-size: 18px;
  line-height: 1;
}

.sidebar-link .badge {
  margin-left: auto;
  font-size: 12px;
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  color: var(--fg-muted);
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.storage-pill {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.storage-pill strong {
  color: var(--fg);
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

/* ---------------- Content Area ---------------- */
.content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.content-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.page-title p {
  color: var(--fg-muted);
  font-size: 14px;
}

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

.select-pill {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 8px 32px 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.select-pill:focus {
  border-color: var(--brand);
}

/* ---------------- Video Cards Grid ---------------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  color: inherit;
}

.video-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.video-card:hover .card-thumb img {
  transform: scale(1.04);
}

.dur-pill {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

.hover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.video-card:hover .hover-overlay {
  opacity: 1;
}

.play-bubble {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.video-card:hover .play-bubble {
  transform: scale(1);
}

.play-bubble svg {
  margin-left: 3px;
  fill: #131218;
}

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: auto;
}

.meta-owner {
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-owner .avatar.tiny {
  width: 20px;
  height: 20px;
  font-size: 10px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  background: var(--bg-card);
}

.card-act-btn {
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.card-act-btn:hover {
  background: var(--bg-subtle);
  color: var(--fg);
}

/* ---------------- Empty State ---------------- */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  font-size: 32px;
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--fg-muted);
  max-width: 440px;
  font-size: 14px;
  margin-bottom: 24px;
}

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}

.modal-close:hover {
  background: var(--bg-subtle);
  color: var(--fg);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-subtle);
}

/* ---------------- Toast Notification ---------------- */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* account menu */
.account-menu { position: absolute; right: 0; top: 46px; width: 240px; background: var(--bg-card); border: 1px solid var(--line-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 120; padding: 6px; }
.account-menu[hidden] { display: none; }
.account-menu .acct-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.account-menu .acct-head span { color: var(--fg-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.account-menu a, .account-menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 13px; font-weight: 600; border-radius: var(--radius-sm); text-decoration: none; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: var(--bg-subtle); }
.account-menu a[hidden] { display: none; }
