/* ==========================================================================
   TeleFlix — glass UI
   Visual layer only. Every class name, id and CSS variable that app.js /
   index.html rely on is preserved.
   ========================================================================== */

:root {
  /* Legacy tokens (kept: app.js and inline styles reference some of these) */
  --bg-primary: #05060a;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-modal: rgba(28, 30, 40, 0.72);
  --text-primary: #f5f5f7;
  --text-secondary: rgba(235, 235, 245, 0.62);
  --text-muted: rgba(235, 235, 245, 0.38);
  --accent-red: #e50914;
  --accent-red-hover: #f40612;
  --accent-green: #30d158;
  --accent-amber: #ffb340;
  --accent-blue: #0a84ff;
  --border-color: rgba(255, 255, 255, 0.10);
  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Glass system */
  --glass-bg: linear-gradient(145deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.035));
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: blur(28px) saturate(180%);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --radius-lg: 24px;
  --radius-md: 16px;
}

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

html {
  background: #05060a;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient aurora behind the glass (static, own compositor layer = smooth scrolling) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transform: translateZ(0);
  background:
    radial-gradient(40% 35% at 14% 10%, rgba(10, 132, 255, 0.30), transparent 70%),
    radial-gradient(34% 30% at 86% 14%, rgba(191, 90, 242, 0.24), transparent 70%),
    radial-gradient(40% 34% at 72% 92%, rgba(229, 9, 20, 0.15), transparent 70%),
    radial-gradient(34% 30% at 8% 88%, rgba(48, 209, 88, 0.09), transparent 70%);
}

::selection {
  background: rgba(10, 132, 255, 0.45);
}

/* Slim translucent scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shared glass surface ----------
   Large scrolling surfaces use translucent fills (cheap to scroll);
   only the small sticky navbar re-blurs what is behind it. */
.navbar,
.stat-box,
.table-container,
.player-details {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight), 0 14px 30px -18px rgba(0, 0, 0, 0.7);
}

.navbar {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.035)),
    rgba(14, 16, 24, 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
}

.table-container {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(14, 16, 24, 0.55);
}

/* ---------- Navbar (floating glass bar) ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  width: 92%;
  max-width: 1400px;
  margin: 14px auto 0;
  padding: 0.75rem 1.1rem 0.75rem 1.4rem;
  border-radius: 22px;
  position: sticky;
  top: 14px;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand .logo-red {
  color: var(--accent-red);
  text-shadow: 0 0 22px rgba(229, 9, 20, 0.55);
}

.brand .badge-saas {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
}

.nav-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

/* ---------- Buttons ---------- */
button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-radius: 999px;
  transition:
    transform 0.25s var(--ease-ios),
    background-color 0.25s var(--ease-ios),
    border-color 0.25s var(--ease-ios),
    color 0.25s var(--ease-ios),
    box-shadow 0.25s var(--ease-ios),
    opacity 0.25s var(--ease-ios);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  -webkit-tap-highlight-color: transparent;
}

button:active:not(:disabled),
a.btn-primary:active {
  transform: scale(0.96);
}

button:focus-visible,
a.btn-primary:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #3d9bff 0%, #0a84ff 100%);
  color: #fff;
  padding: 0.58rem 1.15rem;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 6px 18px -6px rgba(10, 132, 255, 0.7);
}

a.btn-primary, .play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.25s var(--ease-ios), box-shadow 0.25s var(--ease-ios), filter 0.25s var(--ease-ios);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #55a8ff 0%, #1a8dff 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 8px 24px -6px rgba(10, 132, 255, 0.85);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.58rem 1.15rem;
  font-size: 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon-action {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 0.34rem 0.8rem;
  font-size: 0.78rem;
  border-radius: 999px;
  white-space: nowrap;
}

.btn-icon-action:hover:not(:disabled) {
  background: rgba(10, 132, 255, 0.16);
  border-color: rgba(10, 132, 255, 0.5);
  color: #64b0ff;
}

.btn-delete {
  background: rgba(255, 69, 58, 0.12);
  color: #ff6961;
  border: 1px solid rgba(255, 69, 58, 0.28);
  padding: 0.34rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 999px;
}

.btn-delete:hover:not(:disabled) {
  background: #ff453a;
  border-color: #ff453a;
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(255, 69, 58, 0.8);
}

.btn-cancel {
  background: rgba(255, 179, 64, 0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(255, 179, 64, 0.3);
  padding: 0.34rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 999px;
}

.btn-cancel:hover:not(:disabled) {
  background: var(--accent-amber);
  border-color: var(--accent-amber);
  color: #1c1300;
  box-shadow: 0 6px 18px -6px rgba(255, 179, 64, 0.8);
}

/* Play button inside the table matches the other row actions in size */
.play-btn {
  padding: 0.34rem 0.95rem;
  font-size: 0.8rem;
}

/* ---------- Stats ribbon ---------- */
.stats-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 1400px;
  width: 92%;
  margin: 1.4rem auto 0;
}

.stat-box {
  padding: 1.2rem 1.4rem 1.3rem;
  border-radius: var(--radius-lg);
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.035em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ---------- Player (kept for compatibility) ---------- */
.player-container {
  max-width: 1100px;
  width: 92%;
  margin: 1.5rem auto;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.9);
  display: none;
}

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-wrapper .plyr,
.player-wrapper .plyr__video-wrapper,
.player-wrapper video {
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}

.player-wrapper .plyr__controls {
  z-index: 10;
}

.player-details {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0;
  border-width: 1px 0 0;
}

.cache-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.08);
}

.cache-badge.hit {
  background: rgba(48, 209, 88, 0.15);
  color: var(--accent-green);
  border-color: rgba(48, 209, 88, 0.4);
}

.cache-badge.miss {
  background: rgba(229, 9, 20, 0.15);
  color: #ff6961;
  border-color: rgba(229, 9, 20, 0.4);
}

/* ---------- Dashboard section ---------- */
.content-section {
  max-width: 1400px;
  width: 92%;
  margin: 1.5rem auto 3rem;
  flex: 1;
}

.dashboard-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  flex: 1 1 260px;
  max-width: 360px;
}

.search-box input[type="text"] {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.55rem;
  background-color: rgba(255, 255, 255, 0.07);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-opacity='0.5' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.9rem center;
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff;
  border-radius: 999px;
  font-size: 0.92rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---------- Table ---------- */
.table-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.95rem 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  letter-spacing: 0;
  white-space: nowrap;
}

td {
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.045);
}

/* Poster preview */
.poster-thumb {
  width: 90px;
  height: 54px;
  aspect-ratio: 5 / 3;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.8);
  display: block;
}

.thumb-fallback {
  width: 90px;
  height: 54px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-muted);
}

/* Video info cell */
.video-title-cell {
  max-width: 300px;
}

.video-title {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.015em;
  color: #fff;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-id-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
}

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.26rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-ready {
  background: rgba(48, 209, 88, 0.14);
  color: var(--accent-green);
  border: 1px solid rgba(48, 209, 88, 0.32);
}

.status-processing {
  background: rgba(255, 179, 64, 0.14);
  color: var(--accent-amber);
  border: 1px solid rgba(255, 179, 64, 0.32);
}

.status-failed {
  background: rgba(255, 69, 58, 0.14);
  color: #ff6961;
  border: 1px solid rgba(255, 69, 58, 0.32);
}

.status-deleting {
  background: rgba(124, 122, 255, 0.16);
  color: #a5a3ff;
  border: 1px solid rgba(124, 122, 255, 0.34);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

/* Pipeline stage pills */
.status-queued {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.status-validating {
  background: rgba(100, 210, 255, 0.14);
  color: #64d2ff;
  border: 1px solid rgba(100, 210, 255, 0.32);
}

.status-downloading {
  background: rgba(10, 132, 255, 0.16);
  color: #4da3ff;
  border: 1px solid rgba(10, 132, 255, 0.38);
}

.status-uploading {
  background: rgba(191, 90, 242, 0.16);
  color: #d08cff;
  border: 1px solid rgba(191, 90, 242, 0.38);
}

/* Progress bar under the pill (downloading / uploading) */
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-width: 92px;
}

.progress-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s var(--ease-ios);
}

.progress-fill.status-downloading {
  background: linear-gradient(90deg, #0a84ff, #64d2ff);
  border: none;
}

.progress-fill.status-uploading {
  background: linear-gradient(90deg, #bf5af2, #ff6bd6);
  border: none;
}

.progress-pct {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 2.2em;
  text-align: right;
}

/* Stream link cell / actions */
.copy-group {
  display: flex;
  gap: 0.4rem;
}

.action-group {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Modals (sheet-style glass) ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
  animation: overlay-in 0.35s var(--ease-ios) both;
}

.modal-overlay.active .modal {
  animation: sheet-in 0.5s var(--ease-ios) both;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.modal {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    var(--bg-modal);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  border-radius: 28px;
  padding: 1.75rem 1.75rem 1.9rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 40px 90px -20px rgba(0, 0, 0, 0.85);
}

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

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.close-btn {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

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

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 500;
  padding-left: 0.2rem;
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  padding: 0.78rem 1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: border-color 0.25s var(--ease-ios), box-shadow 0.25s var(--ease-ios), background-color 0.25s var(--ease-ios);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-ios);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tab-btn.active {
  background: rgba(10, 132, 255, 0.25);
  color: #fff;
  border-color: rgba(10, 132, 255, 0.7);
  box-shadow: 0 0 14px rgba(10, 132, 255, 0.3);
}

input::placeholder {
  color: var(--text-muted);
}

input:focus {
  outline: none;
  border-color: rgba(10, 132, 255, 0.85);
  background-color: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.22);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  padding-left: 0.2rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  word-break: break-word;
}

.alert-success {
  background: rgba(48, 209, 88, 0.14);
  color: var(--accent-green);
  border: 1px solid rgba(48, 209, 88, 0.4);
}

.alert-error {
  background: rgba(255, 69, 58, 0.14);
  color: #ff6961;
  border: 1px solid rgba(255, 69, 58, 0.4);
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 4.5rem 1rem;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

/* ---------- Pagination ---------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

.pagination-btn {
  padding: 0.45rem 1.05rem;
  font-size: 0.85rem;
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 120px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  body { font-size: 14px; }

  .navbar {
    padding: 0.7rem 0.9rem;
    border-radius: 20px;
  }

  .brand { font-size: 1.15rem; }
  .brand .badge-saas { display: none; }

  .stat-value { font-size: 1.6rem; }

  .search-box { max-width: none; flex-basis: 100%; }

  /* Modals become bottom sheets, like iOS */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    border-radius: 28px 28px 0 0;
    max-height: 92vh;
  }
  @keyframes sheet-in {
    from { opacity: 0.6; transform: translateY(100%); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- Table fit: no horizontal scrollbar, no squeezed buttons ---------- */
button,
a.btn-primary,
.status-pill {
  white-space: nowrap;
}

/* Wide screens: fixed column grid, title column flexes and truncates */
table {
  table-layout: fixed;
}

th:nth-child(1) { width: 44px; }
th:nth-child(2) { width: 90px; }
th:nth-child(4) { width: 112px; }
th:nth-child(5) { width: 118px; }
th:nth-child(6) { width: 112px; }
th:nth-child(7) { width: 232px; }
th:nth-child(8) { width: 252px; }

th, td {
  padding-left: 1rem;
  padding-right: 1rem;
}

th:first-child, td:first-child { padding-left: 1.25rem; }
th:last-child,  td:last-child  { padding-right: 1.25rem; }

.video-title-cell {
  max-width: none;
  min-width: 0;
}

td:nth-child(n+3):nth-child(-n+5) {
  white-space: nowrap;
}

.copy-group {
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-icon-action {
  padding: 0.32rem 0.7rem;
  font-size: 0.76rem;
}

.action-group {
  flex-wrap: wrap;
}

/* Mid-size windows: keep the single-row table, just tighter */
@media (max-width: 1279px) {
  th:nth-child(1) { width: 40px; }
  th:nth-child(2) { width: 76px; }
  th:nth-child(4) { width: 98px; }
  th:nth-child(5) { width: 108px; }
  th:nth-child(6) { width: 104px; }
  th:nth-child(7) { width: 208px; }
  th:nth-child(8) { width: 228px; }

  th, td { padding-left: 0.65rem; padding-right: 0.65rem; }
  th:first-child, td:first-child { padding-left: 1rem; }
  th:last-child,  td:last-child  { padding-right: 1rem; }

  .poster-thumb, .thumb-fallback { width: 68px; height: 41px; border-radius: 8px; }
  .btn-icon-action { padding: 0.3rem 0.62rem; font-size: 0.74rem; }
  .play-btn, .btn-delete, .btn-cancel { padding: 0.32rem 0.8rem; }
}

/* Tablets / small laptops (≤1150px): each video becomes a tidy glass card.
   The desktop table needs ~860px of fixed columns + ~200px for the title,
   so below that the single-row grid squeezes the button columns and
   stacks actions vertically. Cards avoid that squeeze entirely.
   8 cells: 1 checkbox (overlay) · 2 poster · 3 title · 4 status · 5 size · 6 chunks
   7 copy-group (full width) · 8 action-group (full width) */
@media (max-width: 1150px) {
  table, thead, tbody { display: block; }
  thead { display: none; }

  tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto;
    column-gap: 1rem;
    row-gap: 0.6rem;
    align-items: start;
    padding: 1rem 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    transition: background-color 0.25s var(--ease-ios);
  }

  tbody tr:last-child { border-bottom: none; }
  tbody tr:hover { background: rgba(255, 255, 255, 0.045); }

  tbody td,
  tbody tr:hover td {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    min-width: 0;
  }

  tbody td:first-child,
  tbody td:last-child { padding: 0; }

  /* Checkbox overlays the poster corner instead of taking a column */
  tbody td:nth-child(1) {
    position: absolute;
    top: 0.8rem;
    left: 0.85rem;
    z-index: 3;
    margin: 0;
    padding: 0.15rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 7px;
    background: rgba(18, 20, 30, 0.85);
    line-height: 0;
  }
  tbody td:nth-child(1) .row-checkbox { width: 16px; height: 16px; margin: 0; }

  /* Header block: poster spans two rows; title/status/size/chunks fill the rest */
  tbody td:nth-child(2) { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  tbody td:nth-child(3) { grid-column: 2; grid-row: 1; }
  tbody td:nth-child(3) > div { min-width: 0; flex: 1; }
  tbody td:nth-child(3) .video-title { min-width: 0; flex: 1; }
  tbody td:nth-child(4) { grid-column: 3; grid-row: 1; justify-self: end; }
  tbody td:nth-child(5) { grid-column: 3; grid-row: 2; justify-self: end; text-align: right; }
  tbody td:nth-child(6) { grid-column: 2; grid-row: 2; }

  /* Button rows are always full-width so the groups wrap evenly */
  tbody td:nth-child(7) { grid-column: 1 / -1; grid-row: 3; }
  tbody td:nth-child(8) { grid-column: 1 / -1; grid-row: 4; }
  tbody td[colspan]     { grid-column: 1 / -1; grid-row: auto; }

  .copy-group,
  .action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .copy-group > button,
  .action-group > button,
  .copy-group > a,
  .action-group > a {
    flex: 0 1 auto;
    min-height: 40px;
    justify-content: center;
    text-align: center;
  }
}

/* Phones: same card, tighter spacing, buttons fill the row */
@media (max-width: 699px) {
  tbody tr {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    column-gap: 0.8rem;
    row-gap: 0.55rem;
    padding: 0.9rem 0.9rem;
  }
  tbody td:nth-child(1) { top: 0.7rem; left: 0.75rem; }
  tbody td:nth-child(2) { grid-column: 1; grid-row: 1 / span 2; }
  tbody td:nth-child(3) { grid-column: 2; grid-row: 1; }
  tbody td:nth-child(4) { grid-column: 3; grid-row: 1; justify-self: end; }
  tbody td:nth-child(5) { grid-column: 3; grid-row: 2; justify-self: end; text-align: right; }
  tbody td:nth-child(6) { grid-column: 2; grid-row: 2; }
  tbody td:nth-child(7) { grid-column: 1 / -1; grid-row: 3; }
  tbody td:nth-child(8) { grid-column: 1 / -1; grid-row: 4; }

  .copy-group > button,
  .action-group > button,
  .copy-group > a,
  .action-group > a {
    flex: 1 1 auto;
  }

  .video-id-sub { overflow-wrap: anywhere; }
  .status-pill { font-size: 0.72rem; padding: 0.25rem 0.6rem; }
}

/* ---------- Fallbacks ---------- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .navbar, .stat-box, .table-container, .player-details { background: rgba(24, 26, 36, 0.92); }
  .modal { background: rgb(28, 30, 40); }
  .modal-overlay { background: rgba(0, 0, 0, 0.7); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Folder strip (above the video table) ---------- */
.folder-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.folder-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-ios), border-color 0.2s var(--ease-ios), color 0.2s var(--ease-ios);
}

.folder-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.folder-chip.active,
.folder-item.active .folder-chip {
  background: rgba(229, 9, 20, 0.16);
  border-color: rgba(229, 9, 20, 0.55);
  color: var(--text-primary);
}

.folder-chip-count {
  font-size: 0.74rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-secondary);
}

.folder-item.active .folder-chip-count {
  background: rgba(229, 9, 20, 0.28);
  color: #fff;
}

.folder-chip-new {
  border-style: dashed;
  color: var(--text-muted);
}

.folder-chip-new:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.3);
}

.folder-mini-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.25rem 0.3rem;
  border-radius: 8px;
}

.folder-mini-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.folder-mini-btn.danger:hover {
  color: var(--accent-red);
}

.video-folder-tag {
  color: var(--text-muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

/* Actions cell wraps once 📁 Move joins Play / Delete */
td .action-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- Move to folder modal ---------- */
.folder-move-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
}

.folder-move-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}

.folder-move-option:hover {
  background: var(--bg-hover);
}

.folder-move-option.current {
  border-color: rgba(229, 9, 20, 0.55);
}

/* ---------- Batch Selection & Action Bar ---------- */
.batch-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  background: rgba(24, 24, 27, 0.90);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 4px solid var(--accent-blue);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: batchSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes batchSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.batch-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.batch-count {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.btn-text:hover {
  color: var(--text-primary);
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.4rem 0.75rem !important;
  font-size: 0.82rem !important;
  border-radius: 8px !important;
}

.row-select-cell {
  width: 44px;
  text-align: center;
}

.row-checkbox, #selectAllCheckbox {
  cursor: pointer;
  width: 17px;
  height: 17px;
  accent-color: var(--accent-blue);
  vertical-align: middle;
}

tr.row-selected {
  background: rgba(59, 130, 246, 0.08) !important;
}

tr.row-selected:hover {
  background: rgba(59, 130, 246, 0.13) !important;
}

/* ---------- Status Filter Tabs ---------- */
.status-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.status-tab {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 9999px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.status-tab:hover {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-primary);
}

.status-tab.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* ---------- Sort Select Dropdown ---------- */
.sort-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.sort-select:hover, .sort-select:focus {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.sort-select option {
  background: #18181b;
  color: #f4f4f5;
}

/* ---------- Drag and Drop Folder Move ---------- */
tr.draggable-row {
  cursor: grab;
}

tr.draggable-row:active {
  cursor: grabbing;
}

tr.dragging {
  opacity: 0.35;
  background: rgba(59, 130, 246, 0.15) !important;
  outline: 2px dashed var(--accent-blue);
}

.folder-item.drag-over {
  background: rgba(59, 130, 246, 0.25) !important;
  border-color: var(--accent-blue) !important;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.45);
  transition: all 0.15s ease;
}

.poster-cell-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.poster-cell-container:hover .poster-edit-overlay {
  opacity: 1;
}

.poster-edit-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}



/* ==========================================================================
   PROGRESS TOAST — Floating HUD Bottom-Right
   ========================================================================== */

#progressToast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 310px;
  max-width: calc(100vw - 3rem);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 9999;
  pointer-events: none;
}

.progress-toast-card {
  pointer-events: auto;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(14, 16, 24, 0.92);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 16px 36px -10px rgba(0, 0, 0, 0.85);
  animation: toast-slide-in 0.3s var(--ease-ios) both;
}

.progress-toast-card.toast-done {
  animation: toast-slide-out 0.3s var(--ease-ios) forwards;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-slide-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(12px) scale(0.95); }
}

.ptc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.ptc-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.ptc-stage {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.ptc-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.ptc-close:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.14);
}

.ptc-close:active {
  transform: scale(0.90);
}

.ptc-bar-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.ptc-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}

.ptc-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s var(--ease-ios);
  background: linear-gradient(90deg, #bf5af2, #ff6bd6);
}

.ptc-fill.downloading {
  background: linear-gradient(90deg, #0a84ff, #64d2ff);
}

.ptc-fill.processing {
  width: 50% !important;
  background: linear-gradient(90deg, #ffb340, #ff9f0a);
  animation: ptc-indeterminate 1.6s ease-in-out infinite alternate;
}

@keyframes ptc-indeterminate {
  from { margin-left: 0%;  width: 35%; }
  to   { margin-left: 65%; width: 35%; }
}

.ptc-pct {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 2.4em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   KEYBOARD SHORTCUTS MODAL GRID
   ========================================================================== */

#shortcutsModal .shortcuts-grid {
  display: grid;
  grid-template-columns: 48px 1fr;
  row-gap: 0.75rem;
  column-gap: 1.1rem;
  align-items: center;
  margin-top: 1rem;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.85rem;
  padding: 0 0.45rem;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.shortcut-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   GLOBAL FLOATING POSTER HOVER PREVIEW CARD
   ========================================================================== */

.poster-hover-card {
  position: fixed;
  width: 260px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05)),
    rgba(14, 16, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 24px 60px -16px rgba(0, 0, 0, 0.95),
    0 6px 20px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.18s ease, transform 0.18s var(--ease-ios);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  backdrop-filter: blur(32px) saturate(180%);
}

.poster-hover-card.visible {
  opacity: 1;
  transform: scale(1);
}

.poster-hover-card .phc-img {
  width: 100%;
  height: 146px;
  object-fit: cover;
  display: block;
  background: #000;
}

.poster-hover-card .phc-fallback {
  width: 100%;
  height: 146px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
}

.poster-hover-card .phc-body {
  padding: 0.7rem 0.85rem 0.75rem;
}

.poster-hover-card .phc-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.35rem;
}

.poster-hover-card .phc-meta {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.poster-hover-card .phc-meta-sep {
  color: var(--text-muted);
  font-size: 0.65rem;
}

/* ==========================================================================
   RESPONSIVE — SMALL-SCREEN IMPROVEMENTS
   Appended last so it wins the cascade. Desktop (>1024px) untouched.
   ≤1024 tighten · ≤860 nav/stats · ≤700 phones · ≤430 tiny phones
   ========================================================================== */

/* Never let any decorative element push the page sideways */
html, body { overflow-x: hidden; overflow-x: clip; }
img, video { max-width: 100%; height: auto; }
/* .poster-thumb keeps its fixed, dimensioned box (width/height attrs +
   aspect-ratio reserve space before the lazy image loads, so no CLS).
   It must not be forced to height:auto here. */

/* ---------- ≤1024px: tighten the desktop frame ---------- */
@media (max-width: 1024px) {
  .navbar { width: 94%; padding: 0.7rem 0.9rem 0.7rem 1.1rem; }
  .brand { font-size: 1.22rem; }
  .stats-ribbon { width: 94%; }
  .stat-value { font-size: 1.75rem; }
  .content-section { width: 94%; }
  .player-container { width: 94%; }
}

/* ---------- ≤860px: navbar wraps, stats go 2-col ---------- */
@media (max-width: 860px) {
  .navbar { flex-wrap: wrap; }
  .nav-actions { flex-wrap: wrap; }
  .nav-actions .btn-primary,
  .nav-actions .btn-secondary {
    min-height: 40px;
    padding: 0.5rem 0.95rem;
    font-size: 0.82rem;
  }
  .stats-ribbon { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* ---------- ≤700px: phones / small tablets ---------- */
@media (max-width: 700px) {
  /* Navbar: brand on one row, actions stretch on the next */
  .navbar {
    width: 94%;
    margin-top: 10px;
    padding: 0.65rem 0.8rem;
    border-radius: 18px;
    gap: 0.65rem;
  }
  .brand { font-size: 1.15rem; }
  .nav-actions { width: 100%; gap: 0.5rem; }
  .nav-actions .btn-primary,
  .nav-actions .btn-secondary {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 42px;
    font-size: 0.8rem;
    padding: 0.5rem 0.7rem;
  }

  /* Stats: 2 compact columns instead of one tall column */
  .stats-ribbon {
    width: 94%;
    margin-top: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
  .stat-box { padding: 0.9rem 1rem; border-radius: 18px; }
  .stat-label { font-size: 0.72rem; margin-bottom: 0.3rem; }
  .stat-value { font-size: 1.45rem; }

  /* Content width + breathing room */
  .content-section { width: 94%; margin: 1rem auto 2.5rem; }
  .table-container { border-radius: 18px; }

  /* Toolbar stacks: search full-width, then sort + refresh share a row */
  .dashboard-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .search-box { max-width: none; width: 100%; flex: none; }
  .search-box input[type="text"] { font-size: 16px; min-height: 44px; }
  .dashboard-toolbar > div[style] { width: 100% !important; }
  .sort-select, #refreshCatalogBtn {
    flex: 1 1 auto;
    min-height: 42px;
    font-size: 0.85rem;
    justify-content: center;
  }
  .sort-select { font-size: 16px; /* stops iOS zoom-on-focus */ }

  /* Filter tabs: swipeable strip, no wrap, no visible scrollbar */
  .status-filter-bar {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-inline: -0.2rem;
    padding-inline: 0.2rem;
  }
  .status-filter-bar::-webkit-scrollbar { display: none; }
  .status-tab { flex-shrink: 0; min-height: 38px; }

  /* Folders: swipeable strip instead of stacking tall */
  .folder-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0.5rem;
    margin-bottom: 0.7rem;
  }
  .folder-strip::-webkit-scrollbar { display: none; }
  .folder-item { flex-shrink: 0; }
  .folder-chip { flex-shrink: 0; min-height: 38px; }

  /* Batch bar stacks; actions go full-width rows */
  .batch-action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
  }
  .batch-actions { flex-wrap: wrap; }
  .batch-actions .btn-sm { flex: 1 1 auto; min-height: 42px; justify-content: center; }

  /* Video cards: full-width button rows, bigger touch targets */
  .copy-group, .action-group { flex-wrap: wrap; gap: 0.45rem; }
  td .copy-group { flex-wrap: wrap; }
  td .action-group { flex-wrap: wrap; }
  .copy-group > button,
  .action-group > button,
  .copy-group > a,
  .action-group > a {
    flex: 1 1 auto;
    min-height: 40px;
    justify-content: center;
    text-align: center;
  }
  .btn-icon-action, .play-btn, .btn-delete, .btn-cancel {
    min-height: 38px;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
  }
  .poster-thumb, .thumb-fallback { width: 72px; height: 44px; }

  /* Modals: full-width bottom sheet with safe-area padding */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    width: 100%;
    max-width: none !important; /* beat the inline 440px on the shortcuts modal */
    border-radius: 24px 24px 0 0;
    padding: 1.35rem 1.1rem calc(1.35rem + env(safe-area-inset-bottom));
    max-height: 94vh;
    max-height: 94dvh;
  }
  .modal-header h2 { font-size: 1.12rem; }
  .close-btn { width: 40px; height: 40px; }
  /* Inline flex rows inside modals must not overflow */
  .modal div[style] { flex-wrap: wrap; }
  .ingest-tabs .tab-btn { min-height: 42px; }
  .modal button.btn-primary, .modal button.btn-secondary { min-height: 44px; }

  /* Forms: 16px stops iOS input zoom; comfortable targets */
  input[type="text"], input[type="password"], input[type="url"],
  textarea, .sort-select { font-size: 16px; }
  input[type="text"], input[type="password"], input[type="url"], textarea {
    min-height: 44px;
  }

  /* Pagination hugs the screen */
  .pagination-bar { gap: 0.6rem; flex-wrap: wrap; }
  .pagination-btn { min-height: 40px; padding: 0.45rem 0.85rem; }
  .pagination-info { min-width: 0; font-size: 0.8rem; }

  /* Empty state shouldn't eat the whole viewport */
  .empty-state { padding: 2.5rem 1rem; }

  /* Toasts span the bottom instead of clipping at the edge */
  #progressToast {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  /* Touch targets everywhere (small icon buttons stay compact) */
  button:not(.ptc-close):not(.folder-mini-btn),
  a.btn-primary { min-height: 40px; }
  .status-tab, .folder-chip { -webkit-tap-highlight-color: transparent; }
}

/* ---------- ≤480px: tiny phones (320–380px) ---------- */
@media (max-width: 480px) {
  /* Shortcuts are a keyboard feature — hide the button on touch phones */
  #openShortcutsBtn { display: none; }
  .nav-actions .btn-primary,
  .nav-actions .btn-secondary { font-size: 0.78rem; padding: 0.5rem 0.55rem; }

  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: 0.68rem; }

  /* Card rows get tighter — keep the 3-column card grid */
  tbody tr {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    column-gap: 0.65rem;
    row-gap: 0.5rem;
    padding: 0.85rem 0.8rem;
  }
  tbody td:nth-child(1) { top: 0.6rem; left: 0.65rem; }
  .poster-thumb, .thumb-fallback { width: 64px; height: 39px; }
  .video-title { font-size: 0.88rem; }
  .video-id-sub { font-size: 0.68rem; word-break: break-all; }
  .status-pill { font-size: 0.68rem; padding: 0.22rem 0.55rem; }
  /* Play is the primary action — give it the full row on tiny phones */
  .action-group .play-btn { flex: 1 1 100%; min-height: 42px; }
  .copy-group > .btn-icon-action { font-size: 0.76rem; padding-left: 0.55rem; padding-right: 0.55rem; }

  .batch-actions .btn-sm { font-size: 0.78rem !important; }

  .shortcuts-grid { grid-template-columns: auto 1fr; gap: 0.5rem 0.8rem; }
  .shortcut-desc { font-size: 0.82rem; }
}

/* ---------- Touch devices: no hover affordances ---------- */
@media (hover: none) {
  .poster-hover-card { display: none !important; }
  tbody tr:hover td, tr:hover td { background: transparent; }
  button:hover, .status-tab:hover, .folder-chip:hover {
    background: revert;
    color: revert;
  }
}

/* ---------- Very small landscape (short screens) ---------- */
@media (max-height: 500px) and (max-width: 900px) {
  .modal { max-height: 96vh; max-height: 96dvh; }
}

/* ==========================================================================
   Watch / Detail, Retry, Playlists, Storage (feature additions)
   ========================================================================== */

.stat-box-clickable { cursor: pointer; transition: transform .2s var(--ease-ios), border-color .2s var(--ease-ios); }
.stat-box-clickable:hover { transform: translateY(-2px); border-color: rgba(10, 132, 255, .45); }
.stat-box-clickable:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 3px; }
.stat-link-hint { font-size: .68rem; color: var(--accent-blue); font-weight: 500; margin-left: .35rem; opacity: .9; }

.watch-modal { max-width: 1040px; padding: 1.35rem 1.35rem 1.5rem; }
.watch-header { margin-bottom: .9rem; align-items: flex-start; }
.watch-subtitle { font-size: .72rem; color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; margin-top: .2rem; word-break: break-all; }
.watch-player-shell { margin-bottom: 1rem; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--glass-border); background: #000; }
.watch-player-shell .player-wrapper { aspect-ratio: 16 / 9; }
.watch-player-shell video { object-fit: contain; background: #000; }
.watch-player-notice { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; text-align: center; padding: 1.25rem; background: radial-gradient(circle at 50% 40%, rgba(10, 132, 255, .12), rgba(0, 0, 0, .82)); color: #fff; z-index: 2; }
.watch-player-notice strong { font-size: 1rem; }
.watch-player-notice span { font-size: .8rem; color: var(--text-secondary); max-width: 34rem; }
.watch-body { display: flex; flex-direction: column; gap: .9rem; }
.watch-title-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.watch-title-row h3 { font-size: 1.15rem; font-weight: 650; letter-spacing: -.02em; word-break: break-word; }
.watch-meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.watch-meta-item { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; padding: .55rem .7rem; min-width: 0; }
.watch-meta-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .2rem; }
.watch-meta-value { font-size: .82rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.watch-actions .btn-secondary, .watch-actions .btn-primary { text-decoration: none; }
.watch-playlist-row { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; padding-top: .15rem; }
.watch-playlist-label { font-size: .72rem; color: var(--text-muted); }
.playlist-chip { background: rgba(10, 132, 255, .16); color: #cfe6ff; border: 1px solid rgba(10, 132, 255, .4); border-radius: 999px; padding: .35rem .7rem; font-size: .75rem; cursor: pointer; }
.playlist-chip:hover { background: rgba(10, 132, 255, .28); color: #fff; }
.watch-nav { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: .25rem; }
.watch-queue-info { font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.duplicate-warning { margin-top: .55rem; padding: .7rem .8rem; border-radius: 12px; border: 1px solid rgba(255, 179, 64, .45); background: rgba(255, 179, 64, .10); font-size: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.duplicate-warning-title { font-weight: 600; color: var(--accent-amber); }
.duplicate-warning-item { display: flex; justify-content: space-between; gap: .5rem; align-items: center; color: var(--text-secondary); }
.duplicate-warning .btn-secondary.acknowledged { border-color: rgba(48, 209, 88, .6); color: var(--accent-green); }

.retry-modal { max-width: 780px; }
.retry-list { display: flex; flex-direction: column; gap: .6rem; max-height: 50vh; overflow-y: auto; margin: .75rem 0 1rem; padding-right: .15rem; }
.retry-loading { padding: 1rem; color: var(--text-muted); font-size: .85rem; }
.retry-row { display: flex; gap: .7rem; padding: .7rem; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .09); background: rgba(255, 255, 255, .04); }
.retry-check { padding-top: .2rem; }
.retry-check input { width: 18px; height: 18px; accent-color: var(--accent-blue); cursor: pointer; }
.retry-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.retry-title { font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.retry-sub { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .7rem; color: var(--text-muted); }
.retry-id { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.retry-url { width: 100%; padding: .5rem .65rem !important; font-size: .78rem !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }

.playlists-modal { max-width: 1040px; }
.playlists-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1rem; min-height: 380px; }
.playlists-sidebar { display: flex; flex-direction: column; gap: .7rem; border-right: 1px solid rgba(255, 255, 255, .08); padding-right: 1rem; }
.playlist-create-form { display: flex; gap: .4rem; }
.playlist-create-form input { flex: 1; padding: .55rem .7rem; font-size: .82rem; }
.playlist-create-form button { flex: 0 0 auto; min-width: 42px; }
.playlists-list { display: flex; flex-direction: column; gap: .35rem; overflow-y: auto; max-height: 55vh; }
.playlist-list-item { text-align: left; background: transparent; border: 1px solid transparent; border-radius: 12px; padding: .55rem .65rem; display: flex; flex-direction: column; gap: .2rem; cursor: pointer; color: var(--text-secondary); }
.playlist-list-item:hover { background: rgba(255, 255, 255, .06); }
.playlist-list-item.active { background: rgba(10, 132, 255, .16); border-color: rgba(10, 132, 255, .45); color: #fff; }
.playlist-list-name { font-size: .83rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-list-meta { font-size: .68rem; color: var(--text-muted); }
.playlist-detail { min-width: 0; display: flex; flex-direction: column; }
.playlist-empty { padding: 1.2rem; color: var(--text-muted); font-size: .85rem; border: 1px dashed rgba(255, 255, 255, .14); border-radius: 14px; text-align: center; }
.playlist-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.playlist-detail-header h3 { font-size: 1.1rem; font-weight: 650; }
.playlist-detail-meta { font-size: .72rem; color: var(--text-muted); margin-top: .2rem; }
.playlist-detail-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.playlist-items { display: flex; flex-direction: column; gap: .4rem; overflow-y: auto; max-height: 52vh; padding-right: .15rem; }
.playlist-item { display: flex; align-items: center; gap: .65rem; padding: .45rem .55rem; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .07); }
.playlist-item-order { width: 1.3rem; text-align: center; font-size: .72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.playlist-item-poster { width: 72px; height: 42px; border-radius: 8px; overflow: hidden; background: #111; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.playlist-item-poster img { width: 100%; height: 100%; object-fit: cover; }
.playlist-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.playlist-item-title { font-size: .84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-item-sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .68rem; color: var(--text-muted); }
.playlist-item-actions { display: flex; gap: .25rem; flex: 0 0 auto; }
.playlist-item-actions .btn-icon-action { padding: .3rem .45rem; font-size: .75rem; }
.btn-danger-text { color: #ff8a80 !important; }

.storage-modal { max-width: 820px; }
.storage-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.storage-total-card { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; padding: .7rem .8rem; }
.storage-total-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: .25rem; }
.storage-total-value { font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.storage-section-title { font-size: .9rem; font-weight: 650; margin: 1rem 0 .55rem; }
.storage-bots { display: flex; flex-direction: column; gap: .65rem; }
.storage-bot-row { padding: .65rem .75rem; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); }
.storage-bot-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.storage-bot-name { font-size: .84rem; font-weight: 600; }
.storage-bot-mask { font-size: .68rem; color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.storage-bot-meta { font-size: .7rem; color: var(--text-muted); }
.storage-bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.storage-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #0a84ff, #30d158); transition: width .35s var(--ease-ios); }
.storage-bot-share { font-size: .66rem; color: var(--text-muted); margin-top: .3rem; }
.storage-largest { display: flex; flex-direction: column; gap: .4rem; }
.storage-largest-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .7rem; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .07); }
.storage-largest-main { min-width: 0; }
.storage-largest-title { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-largest-sub { font-size: .68rem; color: var(--text-muted); }

.stale-tag { display: inline-block; margin-left: .25rem; padding: .12rem .38rem; border-radius: 999px; font-size: .62rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #ffcf70; background: rgba(255, 179, 64, .14); border: 1px solid rgba(255, 179, 64, .4); vertical-align: middle; }
.video-title-link { cursor: pointer; }
.video-title-link:hover { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

@media (max-width: 860px) {
  .watch-modal { padding: 1rem; }
  .watch-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .playlists-layout { grid-template-columns: 1fr; min-height: 0; }
  .playlists-sidebar { border-right: none; border-bottom: 1px solid rgba(255, 255, 255, .08); padding-right: 0; padding-bottom: .8rem; }
  .playlists-list { max-height: 180px; }
  .playlist-items { max-height: none; }
  .storage-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .watch-meta-grid { grid-template-columns: 1fr; }
  .watch-actions .btn-secondary, .watch-actions .btn-primary, .watch-actions a { flex: 1 1 auto; justify-content: center; text-align: center; }
  .watch-title-row h3 { font-size: 1rem; }
  .storage-totals { grid-template-columns: 1fr; }
  .playlist-detail-actions { width: 100%; }
  .playlist-detail-actions .btn-secondary, .playlist-detail-actions .btn-primary { flex: 1 1 auto; justify-content: center; }
  .retry-row { gap: .5rem; }
  .modal-actions .btn-secondary, .modal-actions .btn-primary { flex: 1 1 auto; justify-content: center; }
}
