/* ============================================================================
   SYLLOVO STUDIO v8.8 — DEDICATED MOBILE & TABLET RESPONSIVENESS STYLESHEET
   Target Browsers: iOS Safari (iPhone / iPad) & Android Chrome (360px – 1024px)
   Breakpoints:
     • @media (max-width: 1024px) — Tablet & Compact Laptop
     • @media (max-width: 768px)  — Mobile Portrait & Phablet
     • @media (max-width: 480px)  — Narrow Mobile (375px iPhone SE/Mini/Pro, 360px Android)
     • @media (max-height: 540px) and (orientation: landscape) — Mobile Landscape Studio
   ============================================================================ */

/* Global Touch & Overflow Safeguards */
html,
body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Smooth Horizontal Touch Scroll Utility for Pill Strips, Filters & Timelines */
.outline-status-filter-bar,
.outline-subtabs,
.outline-sub-tabs,
.clip-pill-strip,
.studio-bottom-tabs,
.timeline-scroll-area,
.yt-control-bar,
.stage-bottom-bar {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.outline-status-filter-bar::-webkit-scrollbar,
.outline-subtabs::-webkit-scrollbar,
.outline-sub-tabs::-webkit-scrollbar,
.clip-pill-strip::-webkit-scrollbar,
.studio-bottom-tabs::-webkit-scrollbar,
.yt-control-bar::-webkit-scrollbar,
.stage-bottom-bar::-webkit-scrollbar {
  display: none;
}

/* ============================================================================
   1. TABLET & COMPACT WORKSPACE (@media max-width: 1024px)
   ============================================================================ */
@media (max-width: 1024px) {
  .workspace-scroll {
    padding: 16px 16px 96px 16px;
  }

  .top-header,
  .content-header {
    padding: 0 14px;
    gap: 8px;
  }

  .header-course-pill {
    max-width: 200px;
    font-size: 11.5px;
  }

  .studio-main-grid,
  .camtasia-workbench {
    grid-template-columns: 1fr !important;
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Ensure timeline body has generous track scrolling room on tablets */
  .timeline-body-with-meter {
    grid-template-columns: 92px 1fr !important;
  }

  .camtasia-vu-meter {
    display: none !important;
  }
}

/* ============================================================================
   2. MOBILE & PORTRAIT TABLET (@media max-width: 768px)
   ============================================================================ */
@media (max-width: 768px) {
  /* App Shell & Sidebar Hiding */
  .app-sidebar {
    display: none !important;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only-logo {
    display: flex !important;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .mobile-only-inline {
    display: inline-flex !important;
  }

  .workspace-scroll {
    padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 12px)) 12px !important;
    overflow-x: hidden;
  }

  /* --------------------------------------------------------------------------
     1. TOP HEADER BAR (.content-header, .top-header, .header-right-actions)
     Compact horizontal layout with zero overlapping pills or clipped text
     -------------------------------------------------------------------------- */
  .top-header,
  .content-header {
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 10px !important;
    gap: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    overflow: hidden;
  }

  .header-left {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden;
  }

  .page-current-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 150px;
  }

  .header-course-pill {
    display: none !important;
  }

  .header-right,
  .header-right-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    min-width: 0;
  }

  .role-select,
  #role-selector {
    padding: 4px 8px !important;
    font-size: 11.5px !important;
    max-width: 124px;
    height: 32px;
    border-radius: 999px;
    text-overflow: ellipsis;
  }

  #mobile-theme-toggle-btn {
    height: 32px;
    min-width: 32px;
    padding: 4px 7px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Mobile Course Selector Bar */
  #mobile-course-bar {
    display: block !important;
    margin-bottom: 10px !important;
  }

  #mobile-course-selector {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 13px !important;
    padding: 8px 10px !important;
    height: 38px;
  }

  .mobile-clip-card-header,
  .mobile-studio-active-bar {
    display: flex !important;
  }

  /* Guided "Next Step" Banner */
  .guided-banner {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 12px !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
  }

  .guided-banner-left {
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .guided-text-title {
    font-size: 13px !important;
    line-height: 1.35;
  }

  .guided-text-sub {
    font-size: 11.5px !important;
    line-height: 1.4;
    margin-top: 2px;
  }

  .guided-banner .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 38px;
  }

  /* --------------------------------------------------------------------------
     2. COURSE OUTLINE PAGE
     - Status filter pills, Course Time Summary banner & Sub-tabs scroll/wrap
     - Clip rows stack cleanly with full-width tap targets
     -------------------------------------------------------------------------- */
  .approval-bar,
  .course-time-summary,
  .outline-time-summary,
  .time-summary-banner {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 12px !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
  }

  .approval-badges {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 6px !important;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .approval-badges::-webkit-scrollbar {
    display: none;
  }

  .approval-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100%;
  }

  .approval-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 36px;
  }

  /* Status Filter Pills & Outline Sub-Tabs (Video Clips / Full Course Transcript) */
  .outline-status-filter-bar,
  .outline-filter-bar,
  .status-filter-pills,
  .outline-subtabs,
  .outline-sub-tabs {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 6px !important;
    padding: 4px 2px 6px 2px !important;
    margin-bottom: 10px !important;
    width: 100% !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .outline-status-filter-bar > *,
  .outline-subtabs > *,
  .outline-sub-tabs > * {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  /* Outline Clip Rows -> Stacked Native Mobile Cards (Zero Empty/Lone Rows!) */
  .clean-table thead {
    display: none !important;
  }

  .clean-table,
  .clean-table tbody {
    display: block !important;
    width: 100% !important;
  }

  .clean-table tr,
  .clip-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    padding: 12px !important;
    margin-bottom: 10px !important;
    background: var(--bg-surface) !important;
    box-shadow: var(--shadow-xs);
  }

  .clean-table td {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    border-bottom: none !important;
    padding: 2px 0 !important;
    text-align: left !important;
    font-size: 13px !important;
  }

  /* Hide redundant table cells on mobile since .mobile-clip-card-header combines them in 1 line */
  .clean-table td.td-clip-check,
  .clean-table td.td-clip-code,
  .clean-table td.td-clip-ps,
  .clean-table td.td-clip-dur {
    display: none !important;
  }

  .clean-table td.td-clip-title {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 0 0 6px 0 !important;
    border-bottom: 1px solid var(--bg-subtle) !important;
  }

  /* Full-width tap targets for Owner <select>, Status badge, ⬇ MP4 link, and Open Clip -> */
  .clean-table td select,
  .clip-row select,
  .clip-owner-select,
  .owner-select {
    width: 100% !important;
    min-height: 38px !important;
    padding: 6px 10px !important;
    font-size: 12.5px !important;
    border-radius: 8px !important;
  }

  .clean-table td:last-child,
  .clean-table td.td-clip-actions,
  .clip-row-actions,
  .outline-clip-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    padding-top: 6px !important;
    margin-top: 2px;
    border-top: 1px solid var(--border);
  }

  .clean-table td:last-child .btn,
  .clean-table td:last-child a.btn,
  .clip-row .btn,
  .clip-row a.btn {
    flex: 1 1 calc(50% - 4px) !important;
    width: 100% !important;
    min-height: 40px !important;
    justify-content: center !important;
    font-size: 12.5px !important;
    padding: 8px 12px !important;
  }

  /* --------------------------------------------------------------------------
     3. VIDEO STUDIO (.studio-player-shell, .stage-preview-box, .yt-control-bar,
        .stage-bottom-bar, .camtasia-transport-bar, .camtasia-timeline-dock)
     v15.6 Mobile Video Editor:
     - Show ONLY Video Player + CC button by default
     - 1 Button below video to Show/Hide Timeline Editor (.mobile-below-video-editor-toggle-bar)
     - 1 Floating Chat Bot Icon (#mobile-floating-chat-fab) opening #mobile-video-chat-sheet
     -------------------------------------------------------------------------- */
  .studio-main-workbench-layout,
  .studio-main-workbench-layout.with-right-chat-open,
  .studio-main-workbench-layout.right-chat-collapsed {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .studio-hero-stage-grid,
  .studio-center-video-and-timeline-col .studio-hero-stage-grid,
  .studio-center-video-and-timeline-col .studio-hero-stage-grid.with-camtasia-left-dock,
  .studio-center-video-and-timeline-col .studio-hero-stage-grid.left-dock-collapsed {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  /* Hide Desktop Left Callout Library & Desktop Right Chat Column on Mobile Video Editor */
  #camtasia-left-dock,
  .camtasia-left-dock,
  #studio-side-comment-dock,
  .studio-side-comment-dock {
    display: none !important;
  }

  /* Below-Video Mobile Bar: Show/Hide Timeline Editor + CC Live Script Toggle */
  .mobile-below-video-editor-toggle-bar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 2px 0 6px 0 !important;
  }

  /* Hide Timeline Editor on Mobile unless User Taps '🎛️ Show Editor' */
  .studio-timeline-editor-wrapper.mobile-editor-closed {
    display: none !important;
  }

  .studio-timeline-editor-wrapper.mobile-editor-open {
    display: block !important;
    width: 100% !important;
  }

  /* Floating Chat Bot Icon on Mobile Video Editor */
  .mobile-floating-chat-fab {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    position: fixed !important;
    right: 14px !important;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 980 !important;
    background: #09090b !important;
    color: #ffffff !important;
    border: 1.5px solid #ffffff !important;
    border-radius: 999px !important;
    padding: 10px 16px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38) !important;
    cursor: pointer !important;
  }

  /* Hide the generic global AI FAB when on the Video Editor on Mobile so there is only 1 Floating Chat Icon */
  body:has(#mobile-floating-chat-fab) #syllovo-ai-fab {
    display: none !important;
  }

  /* Mobile Video Chat Modal / Bottom Sheet */
  .mobile-video-chat-backdrop {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 9500 !important;
    background: rgba(9, 9, 11, 0.65) !important;
    backdrop-filter: blur(3px) !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  .mobile-video-chat-card {
    width: 100% !important;
    max-width: 540px !important;
    max-height: 82dvh !important;
    background: var(--bg-surface, #ffffff) !important;
    color: var(--text-main, #09090b) !important;
    border-radius: 16px 16px 0 0 !important;
    border-top: 1.5px solid var(--border-strong, #d4d4d8) !important;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.45) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding-bottom: env(safe-area-inset-bottom, 8px) !important;
  }

  .studio-toolbar {
    gap: 8px !important;
    margin-bottom: 10px !important;
  }

  .clip-pill-strip {
    width: 100% !important;
    padding-bottom: 4px !important;
    gap: 6px !important;
  }

  .clip-tab-btn {
    padding: 6px 11px !important;
    font-size: 12px !important;
    min-height: 34px;
  }

  /* Video Stage fits cleanly in mobile portrait (max-height: 34vh) */
  .studio-player-shell {
    border-radius: 12px !important;
    margin-bottom: 10px !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  .stage-preview-box,
  #stage-preview-box {
    max-height: 34vh !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
  }

  /* Compact Top Stage Overlay on Mobile so Slide Content stays 100% legible */
  .stage-top-overlay {
    top: 6px !important;
    left: 6px !important;
    right: 6px !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .stage-top-overlay::-webkit-scrollbar {
    display: none;
  }

  .stage-fullscreen-btn,
  .stage-overlay-pill {
    padding: 4px 8px !important;
    font-size: 10.5px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .stage-live-caption,
  #stage-live-caption-bar {
    bottom: 6px !important;
    left: 6px !important;
    right: 6px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
    max-height: 3.8em;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Interactive Scrub Bar — Larger touch target on mobile */
  .stage-video-scrub-wrap {
    height: 24px !important;
    padding: 0 10px !important;
    touch-action: none;
  }

  .stage-scrub-track {
    height: 6px !important;
  }

  .stage-scrub-thumb {
    width: 16px !important;
    height: 16px !important;
    transform: translate(-50%, -50%) scale(1) !important;
  }

  /* YouTube-Style Bottom Control Bar (.yt-control-bar, .stage-bottom-bar, .camtasia-transport-bar)
     Wraps cleanly so Play/Pause, timecode, 💬 + Comment, CC, ⚙️, Export MP4, and ⛶ Fullscreen
     are all visible and NEVER cut off on the right edge! */
  .yt-control-bar,
  .stage-bottom-bar,
  .camtasia-transport-bar {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px 8px !important;
    padding: 8px 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  .yt-control-bar > div,
  .stage-bottom-bar > div,
  .camtasia-transport-bar > div,
  .yt-left-controls,
  .yt-right-controls {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .transport-btn,
  .yt-btn,
  .yt-control-btn {
    min-width: 30px !important;
    height: 30px !important;
    padding: 0 6px !important;
    font-size: 11.5px !important;
    flex-shrink: 0 !important;
  }

  .transport-btn.play-main,
  .yt-play-btn {
    width: 34px !important;
    height: 34px !important;
    font-size: 14px !important;
  }

  #camtasia-timecode-readout,
  .yt-timecode {
    font-size: 11px !important;
    letter-spacing: -0.02em;
    white-space: nowrap !important;
  }

  .yt-control-bar .btn-sm,
  .stage-bottom-bar .btn-sm,
  .camtasia-transport-bar .btn-sm {
    padding: 4px 8px !important;
    font-size: 11px !important;
    min-height: 30px !important;
    flex-shrink: 0 !important;
  }

  /* --------------------------------------------------------------------------
     FULLSCREEN MODE (#studio-player-shell.stage-fullscreen-active)
     Works smoothly on mobile portrait & landscape with safe-area-inset padding
     and floating comment drawer (#inline-cursor-comment-popover)
     -------------------------------------------------------------------------- */
  #studio-player-shell.stage-fullscreen-active,
  .studio-player-shell:fullscreen,
  .studio-player-shell:-webkit-full-screen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    padding-right: env(safe-area-inset-right, 0px) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    padding-left: env(safe-area-inset-left, 0px) !important;
    background: #000000 !important;
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  #studio-player-shell.stage-fullscreen-active .stage-preview-box,
  .studio-player-shell:fullscreen .stage-preview-box,
  .studio-player-shell:-webkit-full-screen .stage-preview-box {
    max-height: none !important;
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
  }

  /* Floating Comment Drawer inside or below stage (#inline-cursor-comment-popover) */
  #inline-cursor-comment-popover,
  .inline-cursor-comment-popover,
  .fullscreen-comment-drawer {
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
  }

  #studio-player-shell.stage-fullscreen-active #inline-cursor-comment-popover,
  #studio-player-shell.stage-fullscreen-active .inline-cursor-comment-popover {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: calc(64px + env(safe-area-inset-bottom, 8px)) !important;
    width: auto !important;
    max-height: 55dvh !important;
    overflow-y: auto !important;
    z-index: 100001 !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75) !important;
  }

  /* --------------------------------------------------------------------------
     MULTI-TRACK CAMTASIA TIMELINE (.camtasia-timeline-dock)
     Smooth horizontal touch scrolling + compact headers
     -------------------------------------------------------------------------- */
  .camtasia-timeline-dock {
    border-radius: 10px !important;
    margin-bottom: 10px !important;
  }

  .timeline-top-toolbar {
    padding: 6px 8px !important;
    gap: 6px !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .timeline-top-toolbar::-webkit-scrollbar {
    display: none;
  }

  .timeline-top-toolbar > div {
    flex-wrap: nowrap !important;
    flex-shrink: 0 !important;
    gap: 5px !important;
  }

  .tl-tool-btn {
    padding: 4px 8px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .timeline-body-with-meter {
    grid-template-columns: 72px 1fr !important;
    min-height: 196px !important;
  }

  .th-ruler-spacer {
    height: 30px !important;
    padding: 0 6px !important;
    font-size: 9px !important;
  }

  .th-track-label {
    height: 78px !important;
    padding: 6px !important;
    font-size: 11px !important;
  }

  .th-track-sub {
    font-size: 9px !important;
  }

  .timeline-scroll-area {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
  }

  .timeline-ruler {
    height: 30px !important;
  }

  .timeline-track-lane {
    height: 78px !important;
  }

  .tl-chunk {
    top: 6px !important;
    height: 66px !important;
  }

  /* Studio Bottom Segmented Tabs */
  .studio-bottom-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 4px !important;
    padding: 4px !important;
  }

  .studio-bottom-tab,
  .studio-subtab-btn {
    flex: 0 0 auto !important;
    padding: 7px 10px !important;
    font-size: 11.5px !important;
  }

  /* Cards & Grids on Mobile */
  .card {
    padding: 14px !important;
    margin-bottom: 12px !important;
    border-radius: 12px !important;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* --------------------------------------------------------------------------
     4. BOTTOM MOBILE NAVIGATION BAR (.mobile-bottom-nav)
     Clean fixed glass bar with env(safe-area-inset-bottom) padding
     -------------------------------------------------------------------------- */
  .mobile-bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) 6px !important;
    background: rgba(255, 255, 255, 0.88) !important;
    backdrop-filter: blur(16px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
    border-top: 1px solid var(--border) !important;
    z-index: 9000 !important;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06) !important;
  }

  [data-theme="dark"] .mobile-bottom-nav {
    background: rgba(18, 18, 21, 0.88) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.45) !important;
  }

  .mobile-nav-btn {
    min-height: 46px !important;
    border-radius: 10px !important;
    font-size: 10.5px !important;
    gap: 2px !important;
    -webkit-tap-highlight-color: transparent;
  }

  /* Keep Toast Notifications above Bottom Nav Bar */
  .studio-toast-container {
    bottom: calc(68px + env(safe-area-inset-bottom, 8px)) !important;
    left: 12px !important;
    right: 12px !important;
    max-width: none !important;
  }
}

/* ============================================================================
   3. NARROW MOBILE SCREENS (@media max-width: 480px — 375px iPhone / 360px Android)
   ============================================================================ */
@media (max-width: 480px) {
  .top-header,
  .content-header {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 8px !important;
    gap: 4px !important;
  }

  .page-current-title {
    font-size: 13px !important;
    max-width: 118px !important;
  }

  .role-select,
  #role-selector {
    font-size: 11px !important;
    padding: 3px 6px !important;
    max-width: 108px !important;
    height: 28px !important;
  }

  #mobile-theme-toggle-btn {
    height: 28px !important;
    min-width: 28px !important;
    padding: 2px 5px !important;
    font-size: 12px !important;
  }

  .workspace-scroll {
    padding: 10px 8px calc(80px + env(safe-area-inset-bottom, 10px)) 8px !important;
  }

  /* Stack Clip Row Action Buttons Full Width on 375px Screens */
  .clean-table td:last-child .btn,
  .clean-table td:last-child a.btn,
  .clip-row .btn,
  .clip-row a.btn {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  /* Video Stage Portrait Max Height 44vh (unless Fullscreen is active) */
  .stage-preview-box,
  #stage-preview-box {
    max-height: 44vh !important;
  }

  /* Fullscreen Override on Mobile Portrait & Landscape: Full 100vw x 100dvh Stage */
  #studio-player-shell.stage-fullscreen-active,
  .studio-player-shell:fullscreen,
  .studio-player-shell:-webkit-full-screen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    z-index: 99999 !important;
    background: #000000 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
  }

  #studio-player-shell.stage-fullscreen-active .stage-preview-box,
  #studio-player-shell.stage-fullscreen-active #stage-preview-box,
  #studio-player-shell.stage-fullscreen-active .edl-stage-viewport,
  .studio-player-shell:fullscreen .stage-preview-box,
  .studio-player-shell:-webkit-full-screen .stage-preview-box {
    max-height: calc(100dvh - 54px) !important;
    height: calc(100dvh - 54px) !important;
    width: 100vw !important;
    flex: 1 1 auto !important;
  }

  #studio-player-shell.stage-fullscreen-active .edl-stage-img,
  #studio-player-shell.stage-fullscreen-active video {
    width: 100% !important;
    height: 100% !important;
    max-height: calc(100dvh - 54px) !important;
    object-fit: contain !important;
  }

  #studio-player-shell.stage-fullscreen-active.mobile-zoom-fill .edl-stage-img,
  #studio-player-shell.stage-fullscreen-active.mobile-zoom-fill video {
    object-fit: cover !important;
  }

  /* Hide non-essential secondary timing badge inside transport bar on 375px so buttons never clip */
  .camtasia-transport-bar .pill-emerald,
  .yt-control-bar .pill-emerald,
  .stage-bottom-bar .pill-emerald {
    display: none !important;
  }

  .yt-control-bar,
  .stage-bottom-bar,
  .camtasia-transport-bar {
    padding: 6px 8px !important;
    gap: 5px !important;
  }

  .yt-control-bar .btn-sm,
  .stage-bottom-bar .btn-sm,
  .camtasia-transport-bar .btn-sm {
    flex: 1 1 auto !important;
    justify-content: center !important;
    font-size: 10.5px !important;
    padding: 4px 6px !important;
  }

  .timeline-body-with-meter {
    grid-template-columns: 62px 1fr !important;
  }

  .th-track-label {
    font-size: 10px !important;
    padding: 4px !important;
  }

  /* v15.6 Mobile Video Studio Stack: Only Video Player on Top + 1 Button for Timeline Editor + 1 Floating Chat Icon */
  .studio-hero-stage-grid,
  .studio-hero-stage-grid.with-camtasia-left-dock {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  #studio-player-shell {
    order: 1 !important;
    width: 100% !important;
  }

  #camtasia-left-dock,
  #studio-side-comment-dock,
  .studio-side-comment-dock {
    display: none !important;
  }

  .mobile-studio-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
}

/* ============================================================================
   4. MOBILE LANDSCAPE MODE (@media max-height: 540px and orientation: landscape)
   Video Stage fits cleanly at max-height: 78vh with unobtrusive controls
   ============================================================================ */
@media (max-height: 540px) and (orientation: landscape) {
  .top-header,
  .content-header {
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 12px !important;
  }

  .stage-preview-box,
  #stage-preview-box {
    max-height: 78vh !important;
    width: 100% !important;
  }

  #studio-player-shell.stage-fullscreen-active .stage-preview-box,
  .studio-player-shell:fullscreen .stage-preview-box,
  .studio-player-shell:-webkit-full-screen .stage-preview-box {
    max-height: calc(100dvh - 48px) !important;
    height: calc(100dvh - 48px) !important;
  }

  .mobile-bottom-nav {
    height: calc(48px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-nav-btn {
    flex-direction: row !important;
    gap: 5px !important;
    font-size: 11px !important;
    min-height: 38px !important;
  }
}

/* ============================================================================
   5. v16.2 YOUTUBE-STYLE MOBILE MP4 VIDEO PLAYER + INLINE LIVE FIX & BUG CHAT
   Zero desktop toolbar clutter, zero fixed-height stretch, zero iOS zoom glitch
   ============================================================================ */
@media (max-width: 768px) {
  /* Eliminate duplicate + New button & Back/Fwd arrows in mobile top bar so #top-page-title never truncates */
  #mobile-header-new-btn,
  #header-nav-back-btn,
  #header-nav-fwd-btn {
    display: none !important;
  }

  .page-current-title {
    max-width: 195px !important;
    min-width: 60px !important;
    flex: 1 1 auto !important;
  }

  /* Fix Mobile More Sheet 2-column grid button overflow on 360px-390px phones */
  #mobile-menu-sheet .mobile-sheet-card > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #mobile-menu-sheet .mobile-sheet-card .btn {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    height: auto !important;
    min-height: 40px !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere !important;
  }

  /* Wrap secondary page flex headers & toolbars on <=768px so zero controls extend offscreen */
  .card-header,
  .card-header > div,
  #official-html-outline-section .card-header,
  #official-html-outline-section .card-header > div,
  #page-view-container div[style*="display:flex"]:not(.mobile-yt-title-row):not(.mobile-yt-action-strip):not(.mobile-yt-composer-footer):not(.mobile-yt-chat-header):not(.timeline-track-row),
  #page-view-container div[style*="display: flex"]:not(.mobile-yt-title-row):not(.mobile-yt-action-strip):not(.mobile-yt-composer-footer):not(.mobile-yt-chat-header):not(.timeline-track-row) {
    flex-wrap: wrap !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Enforce >=32px touch target height across mobile controls */
  #mobile-theme-toggle-btn,
  .status-filter-pill,
  .tl-tool-btn,
  .btn-sm {
    min-height: 32px !important;
    min-width: 32px !important;
  }

  /* Guarantee workbench height never locks or stretches vertically on mobile */
  .studio-main-workbench-layout,
  .studio-center-video-and-timeline-col,
  .studio-center-video-and-timeline-col .studio-hero-stage-grid {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }

  /* Hide floating FABs and top course bar whenever the Mobile YouTube Studio view is active so the 16:9 MP4 player sits right at the top */
  body:has(#mobile-yt-studio-root) #mobile-course-bar,
  body:has(#mobile-yt-studio-root) #syllovo-ai-fab,
  body:has(#mobile-yt-studio-root) #mobile-floating-chat-fab {
    display: none !important;
  }

  .mobile-yt-studio-root {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    padding-bottom: 12px;
    box-sizing: border-box;
  }

  .mobile-yt-player-card {
    width: 100%;
    background: #000000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  }

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

  .mobile-yt-video-aspect video,
  #mobile-mp4-player-mount video {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
    background: #000000 !important;
  }

  .mobile-yt-cc-bar {
    padding: 8px 11px;
    background: #111217;
    border-top: 1px solid #232530;
    color: #e4e4e7;
    font-size: 12px;
    line-height: 1.42;
  }

  .mobile-yt-cc-badge {
    display: inline-block;
    padding: 1px 6px;
    margin-right: 6px;
    border-radius: 4px;
    background: #1f222d;
    border: 1px solid #323646;
    color: #93c5fd;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
  }

  .mobile-yt-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }

  /* 16px font prevents iOS Safari auto-zoom on tap */
  .mobile-yt-clip-select {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    padding: 0 10px;
    border-radius: 9px;
    border: 1px solid var(--border-strong, #d4d4d8);
    background: var(--bg-surface, #ffffff);
    color: var(--text-main, #09090b);
    font-size: 16px !important;
    font-weight: 700;
    box-sizing: border-box;
  }

  .mobile-yt-icon-pill {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--border-strong, #d4d4d8);
    background: var(--bg-surface, #ffffff);
    color: var(--text-main, #09090b);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .mobile-yt-action-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .mobile-yt-action-strip::-webkit-scrollbar {
    display: none;
  }

  .mobile-yt-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-strong, #d4d4d8);
    background: var(--bg-surface, #ffffff);
    color: var(--text-main, #09090b);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
    cursor: pointer;
  }

  .mobile-yt-pill.active {
    background: #09090b;
    color: #ffffff;
    border-color: #09090b;
  }

  [data-theme="dark"] .mobile-yt-pill.active {
    background: #ffffff;
    color: #09090b;
    border-color: #ffffff;
  }

  .mobile-yt-pill.emerald {
    background: rgba(16, 185, 129, 0.14);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.45);
  }

  [data-theme="dark"] .mobile-yt-pill.emerald {
    color: #34d399;
  }

  .mobile-yt-editor-drawer {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #272935;
    background: #0c0d12;
  }

  .mobile-yt-chat-card {
    background: #0d0e12;
    color: #ececf1;
    border: 1px solid #232530;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .mobile-yt-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #1d1f29;
    background: #111319;
  }

  .mobile-yt-time-badge {
    padding: 2px 8px;
    border-radius: 6px;
    background: #1a1d27;
    border: 1px solid #2b3040;
    color: #93c5fd;
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
  }

  .mobile-yt-chat-composer {
    padding: 10px 12px;
    background: #13151c;
    border-bottom: 1px solid #1e202b;
  }

  .mobile-yt-chat-composer textarea {
    width: 100%;
    border: 1px solid #292c3a;
    border-radius: 10px;
    padding: 9px 11px;
    background: #0b0c10;
    color: #f4f4f6;
    font-family: var(--font-sans);
    font-size: 16px !important; /* Prevents iOS Safari zoom on tap */
    line-height: 1.4;
    resize: none;
    outline: none;
    box-sizing: border-box;
    overflow: hidden;
  }

  .mobile-yt-chat-composer textarea:focus {
    border-color: #60a5fa;
  }

  .mobile-yt-composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
  }

  .mobile-yt-frame-btn {
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid #2e3242;
    background: #1a1c25;
    color: #d4d4d8;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-yt-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: #f4f4f6;
    color: #09090b;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-yt-chat-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .mobile-yt-chat-thread {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #1b1d26;
  }

  .mobile-yt-chat-thread:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .mobile-yt-user-bubble {
    padding: 9px 11px;
    border-radius: 10px;
    background: #171922;
    border: 1px solid #262938;
  }

  .mobile-yt-agent-reply {
    padding: 2px 2px 0;
  }
}

/* ============================================================================
   6. v16.3 P2_MEDIUM SWEEP: COARSE-POINTER TOUCH TARGETS (PORTRAIT + LANDSCAPE
   844x390 + IPAD MINI), COMPACT MOBILE HEADER TOGGLE, AND WCAG AA CONTRAST
   ============================================================================ */
@media (max-width: 480px) {
  #header-device-preview-toggle-btn {
    padding: 5px 7px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    justify-content: center !important;
  }

  #header-device-preview-toggle-btn span:last-child {
    display: none !important;
  }

  .page-current-title {
    max-width: 185px !important;
    min-width: 112px !important;
  }
}

@media (pointer: coarse), (max-width: 900px) {
  #header-nav-back-btn,
  #header-nav-fwd-btn,
  #mobile-header-new-btn,
  #mobile-theme-toggle-btn,
  #header-device-preview-toggle-btn,
  #tl-undo-btn,
  .tl-tool-btn,
  .chunk-del-btn,
  .role-select,
  .clip-owner-select,
  .status-filter-pill,
  #mod-M1-tab-clips,
  #mod-M1-tab-assets,
  #mod-M2-tab-clips,
  #mod-M2-tab-assets,
  .mobile-yt-user-bubble button,
  #page-view-container button,
  #page-view-container select,
  #page-view-container input:not([type="checkbox"]):not([type="radio"]),
  #page-view-container a.btn,
  #course-copilot-drawer-box button.btn {
    min-height: 32px !important;
    min-width: 32px !important;
  }
}

/* Prevent collapsed sidebar transition mid-opacity false contrast flags */
.app-sidebar.collapsed:not(:hover) .nav-label-text,
.app-sidebar.collapsed:not(:hover) .sidebar-hide-when-collapsed {
  visibility: hidden;
}

/* WCAG 2.1 AA (>= 4.5:1) Contrast Normalization for Theme & Inline Accent Colors */
:root:not([data-theme="dark"]),
[data-theme="light"] {
  --amber: #b45309;
  --brand-blue: #1d4ed8;
  --purple: #6d28d9;
}

[data-theme="dark"] {
  --brand-blue: #60a5fa;
  --purple: #a78bfa;
  --amber: #fbbf24;
}

:root:not([data-theme="dark"]) .pill-amber,
[data-theme="light"] .pill-amber {
  color: #92400e !important;
  background: #fef3c7 !important;
}

:root:not([data-theme="dark"]) [style*="color:#3b82f6" i],
:root:not([data-theme="dark"]) [style*="color: #3b82f6" i],
:root:not([data-theme="dark"]) [style*="color:#3366ff" i],
[data-theme="light"] [style*="color:#3b82f6" i],
[data-theme="light"] [style*="color: #3b82f6" i],
[data-theme="light"] [style*="color:#3366ff" i] {
  color: #1d4ed8 !important;
}

[data-theme="dark"] [style*="color:#3b82f6" i],
[data-theme="dark"] [style*="color: #3b82f6" i],
[data-theme="dark"] [style*="color:#3366ff" i] {
  color: #60a5fa !important;
}

:root:not([data-theme="dark"]) [style*="color:#10b981" i],
:root:not([data-theme="dark"]) [style*="color: #10b981" i],
:root:not([data-theme="dark"]) [style*="color:#059669" i],
[data-theme="light"] [style*="color:#10b981" i],
[data-theme="light"] [style*="color: #10b981" i],
[data-theme="light"] [style*="color:#059669" i],
:root:not([data-theme="dark"]) .mobile-yt-pill.emerald,
[data-theme="light"] .mobile-yt-pill.emerald {
  color: #047857 !important;
}

:root:not([data-theme="dark"]) [style*="color:#ff1675" i],
:root:not([data-theme="dark"]) [style*="color:#ec4899" i],
[data-theme="light"] [style*="color:#ff1675" i],
[data-theme="light"] [style*="color:#ec4899" i] {
  color: #be185d !important;
}

[data-theme="dark"] [style*="color:#ec4899" i],
[data-theme="dark"] [style*="color:#ff1675" i] {
  color: #f472b6 !important;
}

:root:not([data-theme="dark"]) [style*="color:#f59e0b" i],
:root:not([data-theme="dark"]) [style*="color:#d97706" i],
:root:not([data-theme="dark"]) [style*="color:#b45309" i],
[data-theme="light"] [style*="color:#f59e0b" i],
[data-theme="light"] [style*="color:#d97706" i],
[data-theme="light"] [style*="color:#b45309" i] {
  color: #92400e !important;
}

[data-theme="dark"] [style*="color:#b45309" i],
[data-theme="dark"] [style*="color:#d97706" i] {
  color: #fbbf24 !important;
}
