/* ==========================================================================
   Manga Video Studio — modern professional dark UI (vanilla CSS, no build).
   Layout: left sidebar + top bar + <main id="view">. Sidebar collapses
   into an off-canvas drawer under 900px (toggled by #nav-toggle).
   ========================================================================== */

:root {
  --bg: #0e1320;
  --bg-soft: #131a2b;
  --panel: #17203630;
  --card: #182134;
  --card-border: #28334d;
  --text: #e9eef7;
  --muted: #94a2ba;
  --accent: #4f8cff;
  --accent-hover: #3b76e6;
  --success: #22c55e;
  --danger: #ef4444;
  --danger-hover: #d63a3a;
  --warn: #f59e0b;
  --info: #38bdf8;
  --radius: 10px;
  --sidebar-w: 280px;
  --topbar-h: 52px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  scroll-behavior: smooth;
}

/* Modern sleek dark scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: #090e1a;
}
::-webkit-scrollbar-thumb {
  background: #23304d;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #364975;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
}

/* ------------------------------------------------------------------ layout */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.main-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#view {
  flex: 1;
  padding: 22px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
}

#view.view-wide,
body.route-editor #view {
  max-width: 100%;
  padding: 10px 16px;
}

body.route-panels #view > h1 {
  display: none !important;
}

body.route-panels .footer {
  display: none !important;
}

body.route-panels #view {
  max-width: 100%;
  padding: 0 !important;
  margin: 0 !important;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.route-panels .view-body {
  flex: 1;
  height: 100%;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.footer {
  padding: 6px 18px;
  color: var(--muted);
  flex-shrink: 0;
  background: #0a0a0a;
  border-top: 1px solid #1f2937;
  font-size: 11.5px;
}

/* ----------------------------------------------------------------- sidebar (slide bar & tabs) */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #0a0a0a;
  border-right: 1px solid rgba(38, 38, 38, 0.85);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(23, 23, 23, 0.5);
  border-bottom: 1px solid rgba(38, 38, 38, 0.8);
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981 0%, #6366f1 100%);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-text {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  color: #34d399;
  font-weight: 500;
  margin-top: 3px;
  line-height: 1;
}

.sidebar-close-btn {
  display: none;
  background: #171717;
  border: 1px solid rgba(64, 64, 64, 0.8);
  color: #a3a3a3;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 13px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.16s ease;
}
.sidebar-close-btn:hover, .sidebar-close-btn:active {
  color: #fff;
  border-color: #525252;
  background: #262626;
}

.sidebar-section-bar {
  padding: 8px 14px;
  background: rgba(23, 23, 23, 0.8);
  border-bottom: 1px solid rgba(38, 38, 38, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-section-title {
  font-size: 11px;
  color: #a3a3a3;
  font-weight: 500;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 10px 14px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.nav::-webkit-scrollbar {
  width: 4px;
}
.nav::-webkit-scrollbar-track {
  background: transparent;
}
.nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
.nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: #a3a3a3;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 10px 4px;
  user-select: none;
}

.nav-section-label-mgmt {
  padding-top: 14px;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  color: #d4d4d4;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-link:hover {
  color: #ffffff;
  background: #171717;
  border-color: transparent;
}

.nav-link-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #94a3b8;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link:hover .nav-icon,
.nav-link.is-active .nav-icon {
  color: #38bdf8;
}

.nav-arrow svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-text-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.nav-title {
  display: block;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-desc {
  display: block;
  font-size: 10px;
  color: #737373;
  line-height: 1.2;
  margin-top: 1.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.nav-link:hover .nav-desc {
  color: #a3a3a3;
}

.nav-arrow {
  color: #525252;
  font-size: 11px;
  flex-shrink: 0;
  margin-left: 6px;
  transition: color 0.15s ease, transform 0.15s ease;
}

.nav-link:hover .nav-arrow {
  color: #a3a3a3;
  transform: translateX(2px);
}

.nav-badge-active {
  display: none;
  font-size: 9.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  font-weight: 600;
  flex-shrink: 0;
  margin-left: 6px;
  line-height: 1.2;
}

.nav-link.active {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.nav-link.active .nav-title {
  color: #a7f3d0;
}

.nav-link.active .nav-desc {
  color: #6ee7b7;
  opacity: 0.85;
}

.nav-link.active .nav-arrow {
  display: none;
}

.nav-link.active .nav-badge-active {
  display: inline-block;
}

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(38, 38, 38, 0.8);
  background: rgba(23, 23, 23, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.sidebar-foot-note {
  color: #a3a3a3;
  font-size: 11px;
}

.sidebar-foot-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 6px;
  background: #059669;
  color: #ffffff;
  font-weight: 600;
  font-size: 11.5px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease;
}

.sidebar-foot-btn:hover {
  background: #10b981;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  min-height: 52px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: #0a0a0a;
  border-bottom: 1px solid #262626;
  position: sticky;
  top: 0;
  z-index: 50;
  box-sizing: border-box;
  flex-shrink: 0;
  flex-wrap: wrap;
  min-width: 0;
  white-space: nowrap;
}

#nav-toggle {
  display: none;
  background: #171717;
  border: 1px solid #262626;
  color: #d4d4d4;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#nav-toggle:hover {
  background: #262626;
  border-color: #404040;
  color: #ffffff;
}

/* Status Badges */
.health {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #171717;
  border: 1px solid #262626;
  color: #d4d4d4;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1.3;
  user-select: none;
  height: 26px;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.health:hover {
  background: #202020;
  border-color: #404040;
  color: #ffffff;
}

.health:active {
  background: #141414;
}

/* Active Render Badge */
#render-pill {
  background: #171717;
  border: 1px solid #3b82f6;
  color: #93c5fd;
  flex-shrink: 0;
}

#render-pill:hover {
  background: #1e293b;
  border-color: #60a5fa;
  color: #ffffff;
}

/* Status Indicators */
.health-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #737373;
}

.health-dot.is-ok {
  background: #10b981;
}

.health-dot.is-bad {
  background: #ef4444;
}

.health-dot.is-checking {
  background: #f59e0b;
}

/* Manga & Chapter Picker Toolbar - Fixed & Never Scrollable */
.picker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  background: #171717;
  border: 1px solid #262626;
  border-radius: 6px;
  padding: 3px 6px;
  flex: 1 1 390px;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
}

.picker-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #737373;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 1px;
  user-select: none;
  flex-shrink: 0;
}

.picker .select {
  background: #0a0a0a;
  color: #f5f5f5;
  border: 1px solid #262626;
  border-radius: 4px;
  padding: 2px 20px 2px 6px;
  font-size: 11.5px;
  font-weight: 500;
  height: 26px;
  line-height: 1.3;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23a3a3a3' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 8px 8px;
  width: 115px;
  max-width: 125px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  flex: 1 1 115px;
  min-width: 0;
  transition: border-color 0.15s ease;
}

.picker .select:hover {
  border-color: #404040;
}

.picker .select:focus {
  outline: none;
  border-color: #10b981;
}

.picker .select option {
  background-color: #171717;
  color: #f5f5f5;
}

#reload-library {
  background: #262626;
  border: 1px solid #404040;
  color: #d4d4d4;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  height: 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

#reload-library:hover {
  background: #333333;
  border-color: #525252;
  color: #ffffff;
}

#reload-library:active {
  background: #202020;
}

/* Keep the Renderer target visible while its long settings form scrolls. */
.renderer-context-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  padding: 8px 10px;
  margin: -4px -4px 10px;
  background: color-mix(in srgb, var(--bg-soft) 94%, transparent);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(8px);
}

/* -------------------------------------------------------------------- cards */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2, .card h3 { margin: 0 0 10px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.spacer { flex: 1; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }

.empty-state {
  text-align: center;
  padding: 36px 20px;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: #222d47;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); background: #273453; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible, .select:focus-visible, .input:focus-visible,
.nav-link:focus-visible, .health:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: #3a1f28; border-color: #7a2e3a; color: #ffb4b4; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 8px 11px; font-size: 16px; }

/* ------------------------------------------------------------------- inputs */
.input, .select, textarea.input {
  background: #101828;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  max-width: 100%;
}

.select { cursor: pointer; }
.input::placeholder { color: #5d6b86; }

textarea.input {
  width: 100%;
  min-height: 90px;
  resize: vertical;
}

.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row > label { font-size: 13px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border-radius: 8px; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th, .table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--card-border);
}

.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover td { background: #1c2740; }

/* ------------------------------------------------------------- progress bar */
.progress {
  height: 10px;
  background: #0d1322;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  overflow: hidden;
  min-width: 120px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--info));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* -------------------------------------------------------------- status pill */
.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-waiting    { background: #2a2f3d; color: #c3cad7; border-color: #454c60; }
.pill-preparing  { background: #12324a; color: #7dd3fc; border-color: #1e5a86; }
.pill-rendering,
.pill-muxing,
.pill-running    { background: #10294f; color: #7db4ff; border-color: #2b5cb8; animation: pulse 1.6s infinite; }
.pill-completed,
.pill-connected,
.pill-done       { background: #0e3a24; color: #4ade80; border-color: #1c7a45; }
.pill-failed,
.pill-error      { background: #451a1e; color: #fca5a5; border-color: #8c2f36; }
.pill-cancelled,
.pill-skipped    { background: #3d2f10; color: #fcd34d; border-color: #8a6a1f; }
.pill-disconnected,
.pill-unknown    { background: #2a2f3d; color: var(--muted); border-color: #454c60; }

/* --------------------------------------------------------------- log viewer */
.log-viewer {
  background: #0a0f1c;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.log-line-error { color: #fca5a5; }
.log-line-warn { color: #fcd34d; }

/* ------------------------------------------------------------ thumbnails */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.thumb {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  background: #0d1322;
}

.thumb img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.thumb-caption {
  padding: 6px 9px;
  font-size: 12px;
  color: var(--muted);
}

/* ------------------------------------------------------------------- modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

.modal {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal h2 { margin-top: 0; }

/* ------------------------------------------------------------------ toasts */
#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  background: #1f2a44;
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--info); }

.sidebar-backdrop {
  display: none;
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  }

  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.85);
    z-index: 100;
  }

  body.nav-open .sidebar { transform: translateX(0); }

  .sidebar-close-btn { display: inline-flex; }

  #nav-toggle { display: inline-flex; position: relative; z-index: 101; }

  #view { padding: 12px 10px 76px; }

  .topbar {
    height: auto;
    min-height: 52px;
    padding: 6px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .picker {
    margin-left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #171717;
    border: 1px solid #262626;
    padding: 4px 6px;
    border-radius: 6px;
  }
  .picker-label { font-size: 10.5px; }
  .picker .select { flex: 1; min-width: 0; font-size: 12px; padding: 4px 20px 4px 8px; max-width: none; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .thumb img { height: 120px; }
}

@media (max-width: 600px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  #view { padding: 10px 8px 80px; }
  .topbar { gap: 6px; padding: 6px 10px; }
  .health { padding: 4px 8px; font-size: 11px; gap: 5px; border-radius: 6px; }
  .picker {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
    flex-basis: 100%;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 6px;
  }
  .picker-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .picker .select { width: 100%; font-size: 12px; padding: 4px 18px 4px 6px; height: 44px; max-width: none; }
  #reload-library { padding: 4px 8px; font-size: 12px; height: 44px; }
  .topbar .health, #nav-toggle { min-height: 44px; }
  #nav-toggle { min-width: 44px; align-items: center; justify-content: center; }
  .btn { min-height: 44px; padding: 9px 12px; font-size: 13px; touch-action: manipulation; }
  .btn-sm { min-height: 40px; padding: 8px 11px; }
  input, select, textarea, .select, .input { min-height: 44px; font-size: 16px; }
  .vp-row { gap: 8px; }
  .vp-table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
  .vp-table th, .vp-table td { padding: 10px 11px; white-space: nowrap; }
  .vp-card { max-width: 100%; overflow: hidden; }
  .vp-modal-overlay, .modal-overlay { align-items: flex-end; padding: 0; }
  .vp-modal, .modal { width: 100% !important; max-width: none !important; max-height: 90dvh; max-height: 90vh; border-radius: 16px 16px 0 0; padding-bottom: max(18px, env(safe-area-inset-bottom, 18px)); }
}


@media (prefers-reduced-motion: reduce) {
  .health-dot.is-checking, .pill-rendering, .pill-muxing, .pill-running {
    animation: none;
  }
  .progress-fill { transition: none; }
  .sidebar { transition: none; }
}

/* ------------------------------------------------- view (vp-*) aliases ---
   Pipeline/processing views use vp-* class names. They map 1:1 onto the
   shell tokens above so every view renders styled with no unstyled DOM. */
.view-body { display: flex; flex-direction: column; gap: 16px; }
.vp-sub, .vp-small { color: var(--muted); font-size: 12.5px; }
.vp-sub { margin: 0 0 10px; }
.vp-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vp-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.vp-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.vp-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.vp-pair { display: flex; gap: 8px; align-items: center; }
.vp-pair input[type="range"] { flex: 1; }
.vp-context { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.vp-context-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.vp-context input { background: #101828; border: 1px solid var(--card-border); color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.vp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 12px; }
.vp-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 18px; }
.vp-card h3 { margin: 0 0 10px; }
.vp-links { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.vp-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.vp-toolbar input { background: #101828; border: 1px solid var(--card-border); color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.vp-table-wrap { overflow-x: auto; border-radius: 8px; margin-bottom: 12px; }
table.vp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vp-table th, .vp-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--card-border); }
.vp-table th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.vp-detail { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.vp-detail-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.vp-detail-imgs img { border-radius: 8px; border: 1px solid var(--card-border); }
.vp-upload { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.vp-task { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 14px; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.vp-task-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vp-task-label { font-size: 13px; color: var(--text); }
.vp-log, .vp-loglist { background: #0a0f1c; border: 1px solid var(--card-border); border-radius: 8px; padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; max-height: 220px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.vp-log-title { font-size: 12px; color: var(--muted); }
.vp-logline { padding: 2px 0; border-bottom: 1px solid #111827; }
.vp-log-src { color: var(--info); }
.vp-bar { height: 10px; background: #0d1322; border: 1px solid var(--card-border); border-radius: 999px; overflow: hidden; min-width: 120px; }
.vp-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--info)); border-radius: 999px; transition: width 0.25s ease; }
.vp-checklist { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.vp-check { display: flex; gap: 6px; align-items: center; font-size: 13px; background: #0d1322; border: 1px solid var(--card-border); border-radius: 8px; padding: 6px 9px; }
.vp-check img { border-radius: 6px; }
.vp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 10px; }
.vp-thumb { border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; background: #0d1322; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.vp-thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.vp-thumb img { display: block; width: 100%; height: 150px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.vp-badge { display: inline-block; font-size: 11px; color: var(--muted); }
.vp-preview-frame { border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; background: #0d1322; padding: 8px; }
.vp-preview-frame img { display: block; max-width: 100%; border-radius: 6px; }
.vp-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 10px 0; }
.vp-bbox-overlay { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.vp-preview-info { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.vp-modal-overlay { position: fixed; inset: 0; background: rgba(4, 8, 16, 0.7); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 100; }
.vp-modal { background: var(--card); border: 1px solid var(--card-border); border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 20px; }
.vp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.vp-ops, .vp-files { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.vp-op { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 12px; }
.vp-op-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.vp-op-params { display: flex; flex-direction: column; gap: 10px; }
.vp-file { display: flex; gap: 10px; align-items: center; background: #0d1322; border: 1px solid var(--card-border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.vp-img-missing { font-size: 12px; color: var(--warn); background: #0d1322; border: 1px dashed var(--card-border); border-radius: 8px; padding: 10px; }

/* Lightbox modal & Preview enhancements */
.vp-modal-lightbox {
  max-width: 92vw;
  width: 920px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}
.vp-modal-lightbox .vp-lightbox-viewport {
  overflow: auto;
  max-height: 72vh;
  background: #070b14;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
}
.vp-modal-lightbox img.vp-lightbox-img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  cursor: zoom-in;
  transition: max-width 0.2s ease;
  image-rendering: -webkit-optimize-contrast;
}
.vp-modal-lightbox img.vp-lightbox-img.zoomed {
  max-width: none;
  cursor: zoom-out;
}
.vp-modal-lightbox .vp-lightbox-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.vp-preview-card {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  background: #0d1322;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.vp-preview-card:hover {
  border-color: var(--accent);
}
.vp-preview-card img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
}
.vp-preview-card-strip img {
  height: 220px;
  object-fit: contain;
  background: #050811;
  image-rendering: -webkit-optimize-contrast;
}
.vp-preview-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vp-preview-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.vp-preview-card-actions button,
.vp-preview-card-actions a {
  font-size: 11px;
  padding: 3px 8px;
}
.vp-detail-imgs img {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.vp-detail-imgs img:hover {
  transform: scale(1.04);
  border-color: var(--accent);
}



/* Full-resolution coordinates over independently decoded long-strip tiles. */
.vp-crop-modal { width: min(1000px, 96vw); max-width: 1000px; }
.vp-crop-scroll { max-height: 58vh; overflow: auto; background: #181818; margin-top: 12px; }
.vp-crop-surface { position: relative; width: 100%; max-width: 800px; margin: auto; cursor: crosshair; touch-action: pan-y; }
.vp-crop-surface > img { display: block; width: 100%; height: auto; max-height: none; object-fit: contain; user-select: none; image-rendering: -webkit-optimize-contrast; }
.vp-crop-selection { position: absolute; box-sizing: border-box; border: 2px solid #f6c94c; background: #f6c94c22; pointer-events: none; }
.vp-crop-fields input { width: 90px; }

.vp-prompt { margin: 16px 0; }
.vp-prompt summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }
.vp-prompt textarea { width: 100%; box-sizing: border-box; line-height: 1.5; resize: vertical; }
.vp-panel-extractor .vp-thumb img { object-fit: contain; height: 240px; background: #080b12; }
.vp-panel-extractor .vp-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.vp-all-crops { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.vp-all-crops figure { margin: 0; min-width: 0; }
.vp-all-crops img { display: block; width: 100%; height: auto; max-height: none; }
.vp-all-crops figcaption { margin: 8px 0; }

.vp-source-scroll { max-height: 480px; overflow-y: auto; background: #080b12; }
.vp-panel-extractor .vp-source-scroll img { display: block; width: 100%; height: auto; max-height: none; border-radius: 0; cursor: default; font-size: 0; line-height: 0; color: transparent; background: #0b0f19; }

/* Source Section & 1-Page Continuous Preview */
.vp-source-section {
  background: var(--card-bg, #111827);
  border: 1px solid var(--card-border, #1f2937);
  border-radius: 10px;
  padding: 16px;
  margin: 18px 0 24px 0;
}
.vp-source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.vp-source-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.vp-source-title-row h3 {
  margin: 0;
  font-size: 1.15rem;
}
.vp-source-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.vp-mode-btn-group {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color, #374151);
}
.vp-mode-btn-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-color, #374151);
  font-size: 0.82rem;
  padding: 6px 12px;
  background: #1f2937;
  color: #9ca3af;
  cursor: pointer;
}
.vp-mode-btn-group .btn:last-child {
  border-right: none;
}
.vp-mode-btn-group .btn.active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

/* Continuous 1-Page Viewer */
.vp-continuous-container {
  display: flex;
  flex-direction: column;
  background: #060911;
  border: 1px solid #1f2937;
  border-radius: 8px;
  overflow: hidden;
}
.vp-continuous-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(8px);
  padding: 8px 14px;
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.vp-continuous-scroll {
  max-height: 680px;
  overflow-y: auto;
  position: relative;
  background: #03060a;
  scroll-behavior: smooth;
}
.vp-continuous-inner {
  max-width: 820px;
  margin: 0 auto;
  background: #080c16;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  position: relative;
}
.vp-continuous-strip-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #0f172a;
  border-top: 2px solid #3b82f6;
  border-bottom: 1px solid #1e293b;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.vp-strip-divider-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.vp-strip-divider-title {
  font-weight: 700;
  color: #60a5fa;
  font-size: 0.88rem;
}
.vp-strip-divider-meta {
  color: #94a3b8;
  font-size: 0.8rem;
}
.vp-strip-divider-actions {
  display: flex;
  gap: 6px;
}
.vp-continuous-strip-chunk {
  width: 100%;
  font-size: 0;
  line-height: 0;
}
.vp-continuous-strip-chunk img,
.vp-continuous-slice {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  margin: 0 auto;
  font-size: 0;
  line-height: 0;
  color: transparent;
  background: #0b0f19;
  border-radius: 0;
}

/* Single Strip Viewer */
.vp-single-container {
  display: flex;
  flex-direction: column;
  background: #060911;
  border: 1px solid #1f2937;
  border-radius: 8px;
  overflow: hidden;
}
.vp-single-nav {
  padding: 10px 14px;
  background: #0f172a;
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.vp-single-scroll {
  max-height: 680px;
  overflow-y: auto;
  background: #03060a;
}
.vp-single-inner {
  max-width: 820px;
  margin: 0 auto;
  background: #080c16;
}

/* Fullscreen Reader Modal */
.vp-reader-modal {
  width: min(1200px, 98vw);
  max-width: 1200px;
  height: 94vh;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
}
.vp-reader-modal .vp-continuous-scroll {
  max-height: calc(94vh - 120px);
  flex: 1;
}

/* Strip vs Panels Manual Comparison Tool */
.vp-compare-modal {
  width: min(1400px, 98vw);
  max-width: 1400px;
  height: 94vh;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
}
.vp-compare-split {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 0;
  margin-top: 12px;
}
.vp-compare-strip-col {
  flex: 1.25;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  background: #060911;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
}
.vp-compare-strip-scroll {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: #03060a;
}
.vp-compare-strip-surface {
  position: relative;
  margin: 0 auto;
  user-select: none;
}
.vp-compare-strip-surface > img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  user-select: none;
  image-rendering: -webkit-optimize-contrast;
}
.vp-compare-panels-col {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: #080d1a;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
}
.vp-compare-panels-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.vp-compare-panel-item {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #0d1322;
  padding: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: all 0.15s ease;
  cursor: pointer;
}
.vp-compare-panel-item:hover, .vp-compare-panel-item.active {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}
.vp-compare-panel-item.active {
  border-color: #60a5fa;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.4);
}
.vp-compare-overlay-box {
  position: absolute;
  box-sizing: border-box;
  transition: all 0.15s ease;
  cursor: pointer;
  z-index: 2;
}
.vp-compare-overlay-box.box-art {
  border: 2px solid #10b981;
  background: rgba(16, 185, 129, 0.18);
}
.vp-compare-overlay-box.box-dia {
  border: 2px solid #8b5cf6;
  background: rgba(139, 92, 246, 0.22);
}
.vp-compare-overlay-box.active {
  border: 3px solid #fbbf24 !important;
  background: rgba(251, 191, 36, 0.3) !important;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.7);
  z-index: 10;
}
.vp-compare-overlay-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  pointer-events: none;
  white-space: nowrap;
}
.vp-compare-gap-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px dashed #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  z-index: 1;
}
.vp-compare-gap-box:hover {
  background: rgba(245, 158, 11, 0.28);
  border-color: #fbbf24;
}

/* ==========================================================================
   Manga Video Studio — Studio & Photo Editor (Desktop & Mobile Ergonomics)
   ========================================================================== */

.studio-topbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.studio-workspace {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
  min-height: 520px;
  position: relative;
  width: 100%;
}

.studio-sidebar {
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  transition: all 0.25s ease;
}

.studio-sidebar-left {
  width: 340px;
  min-width: 320px;
  max-width: 390px;
}

.studio-sidebar-right {
  width: 370px;
  min-width: 340px;
  max-width: 430px;
  overflow-y: auto;
  max-height: 680px;
}

.studio-center-pane {
  flex: 1 1 500px;
  min-width: 360px;
  background: #070a13;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

.studio-monitor-viewport {
  position: relative;
  background: #030712;
  border: 1px solid #1f2937;
  border-radius: 8px;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;
  max-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.85);
}

.studio-monitor-viewport img.monitor-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  user-select: none;
  pointer-events: none;
  object-fit: contain;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.85));
  transition: filter 0.2s ease;
}

.studio-monitor-viewport img.monitor-img.no-shadow {
  filter: none !important;
}

.studio-caption-bar {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 5px 10px;
  color: #f3f4f6;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  line-height: 1.3;
}

.studio-transport-bar {
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Touch-friendly high-precision scrubber */
input[type="range"].studio-scrubber,
.studio-scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  touch-action: pan-x;
  margin: 6px 0;
  border: 1px solid #334155;
}
input[type="range"].studio-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.85);
  cursor: grab;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
input[type="range"].studio-scrubber::-webkit-slider-thumb:active {
  transform: scale(1.22);
  cursor: grabbing;
  box-shadow: 0 0 16px rgba(59, 130, 246, 1);
}
input[type="range"].studio-scrubber::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.85);
  cursor: grab;
}

.studio-play-btn {
  min-height: 38px;
  min-width: 82px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  transition: transform 0.1s ease;
}
.studio-play-btn:active {
  transform: scale(0.96);
}

.studio-step-btn {
  background: #1f2937;
  border: 1px solid #374151;
  color: #e5e7eb;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11px;
  cursor: pointer;
  touch-action: manipulation;
  font-weight: 600;
  min-height: 28px;
}
.studio-step-btn:active {
  transform: scale(0.95);
  background: #374151;
}

.studio-timeline-panel {
  background: #0f172a;
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.25s ease;
  margin-bottom: 12px;
}

.studio-drawer-backdrop {
  display: none;
}

.studio-mobile-bar {
  display: none;
}

/* Mobile & Tablet Adaptations (Android / Touchscreens <= 900px) */
@media (max-width: 900px) {
  .studio-workspace {
    flex-direction: column;
    min-height: auto;
    gap: 8px;
  }

  .studio-edge-btn {
    display: none !important;
  }

  .studio-center-pane {
    width: 100%;
    min-width: 0;
    padding: 8px;
    flex: none;
  }

  .studio-monitor-viewport {
    max-height: 38vh;
    min-height: 180px;
    border-radius: 6px;
  }

  .studio-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 400 !important;
    width: min(390px, 92vw) !important;
    max-width: 92vw !important;
    background: #0f172a !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.85) !important;
    display: flex !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .studio-sidebar-left {
    left: 0 !important;
    border-right: 1px solid #374151 !important;
    border-left: none !important;
    transform: translateX(-100%) !important;
  }

  .studio-sidebar-left.is-open {
    transform: translateX(0) !important;
  }

  .studio-sidebar-right {
    right: 0 !important;
    left: auto !important;
    border-left: 1px solid #374151 !important;
    border-right: none !important;
    transform: translateX(100%) !important;
  }

  .studio-sidebar-right.is-open {
    transform: translateX(0) !important;
  }

  .studio-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 16, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 380;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .studio-drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Floating Bottom Thumb Navigation Bar on Mobile */
  .studio-mobile-bar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid #374151;
    padding: 5px 6px max(6px, env(safe-area-inset-bottom, 6px));
    z-index: 250;
    gap: 4px;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6);
  }

  .studio-mob-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    white-space: nowrap;
    transition: all 0.12s ease;
  }

  .studio-mob-btn:active {
    background: #1e293b;
    transform: scale(0.95);
  }

  .studio-mob-btn.active {
    color: #fff;
    background: #1e293b;
    border-color: #3b82f6;
  }

  .studio-mob-btn-icon {
    font-size: 15px;
    line-height: 1;
  }

  .studio-mob-btn-split {
    color: #c7d2fe;
    background: #312e81;
    border-color: #4f46e5;
  }

  .studio-mob-btn-play {
    color: #bbf7d0;
    background: #064e3b;
    border-color: #059669;
  }
}

/* ------------------------------------------------ Android Native Agent View UX */

body.route-agent .footer {
  display: none !important;
}

@media (max-width: 768px) {
  body.route-agent .topbar {
    display: none !important;
  }
  body.route-agent #view {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100vw !important;
    overflow: hidden !important;
  }
  body.route-agent #view > h1 {
    display: none !important;
  }
  body.route-agent .view-body {
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    height: 100dvh !important;
    height: 100vh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  body.route-agent .agent-view-root {
    height: 100% !important;
    max-height: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  body.route-agent .agent-input-bar {
    position: sticky !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
    background: #090d16 !important;
    border-top: 1.5px solid rgba(56, 189, 248, 0.4) !important;
    padding: 10px 12px max(12px, env(safe-area-inset-bottom, 12px)) !important;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.85) !important;
  }
}

/* Typing Dots Animation */
@keyframes typing-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.typing-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 2px;
  background: #38bdf8;
  border-radius: 50%;
  animation: typing-pulse 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* ------------------------------------------------ Source Protection & Armor --- */
body, .app, .sidebar, .topbar, .card, .btn, .nav-link, pre, code, span, div, p, h1, h2, h3, table {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  -khtml-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

input, textarea, [contenteditable="true"] {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

img {
  -webkit-user-drag: none !important;
  user-drag: none !important;
  pointer-events: auto;
}

/* --------------------------------------------------------- Admin Dashboard --- */
.admin-dashboard-container {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* ----------------------------------- Android UI/UX: Subscription & Checkout --- */
@keyframes mvsAndroidSheetUp {
  0% {
    transform: translateY(100%);
    opacity: 0.7;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes mvsAndroidPop {
  0% {
    transform: scale(0.92) translateY(20px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* ============================================================================
   ENTERPRISE CHECKOUT & ACTIVATION UI/UX (Clean, Authoritative, Stripe/Vercel standard)
   ============================================================================ */

.mvs-android-sheet-overlay,
.mvs-checkout-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: mvsFadeIn 0.2s ease-out forwards;
}

@keyframes mvsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (min-width: 769px) {
  .mvs-android-sheet-overlay,
  .mvs-checkout-overlay {
    align-items: center;
    padding: 24px;
  }
}

.mvs-android-sheet,
.mvs-checkout-modal {
  width: 100%;
  max-height: 94vh;
  border-radius: 24px 24px 0 0;
  background: #0b0f19;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: none;
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  animation: mvsSheetSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
}

@keyframes mvsSheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (min-width: 769px) {
  .mvs-android-sheet,
  .mvs-checkout-modal {
    max-width: 580px;
    max-height: 90vh;
    border-radius: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 24px 72px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: mvsModalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    padding-bottom: 0;
  }
}

@keyframes mvsModalPop {
  from { transform: scale(0.96) translateY(12px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.mvs-android-drag-handle,
.mvs-checkout-drag-bar {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 10px auto 4px auto;
  flex-shrink: 0;
}

@media (min-width: 769px) {
  .mvs-android-drag-handle,
  .mvs-checkout-drag-bar {
    display: none;
  }
}

.mvs-android-sheet-header,
.mvs-checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
  flex-shrink: 0;
}

.mvs-checkout-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mvs-checkout-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #38bdf8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mvs-checkout-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.2px;
}

.mvs-checkout-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.mvs-checkout-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

.mvs-android-sheet-body,
.mvs-checkout-body {
  padding: 20px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

/* Stepper Card */
.mvs-config-card {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mvs-config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mvs-config-label {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mvs-config-rate {
  font-size: 12px;
  font-weight: 600;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.mvs-stepper-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #080c14;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px 10px;
}

.mvs-stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.mvs-stepper-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

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

.mvs-stepper-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.mvs-stepper-input {
  width: 52px;
  text-align: center;
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 22px;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  outline: none;
}

.mvs-stepper-unit {
  font-size: 14px;
  color: #94a3b8;
  font-weight: 600;
}

.mvs-chips-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mvs-preset-pill,
.mvs-dur-chip {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #94a3b8;
  transition: all 0.15s ease;
  user-select: none;
}

.mvs-preset-pill:hover,
.mvs-dur-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

.mvs-preset-pill.active,
.mvs-dur-chip.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  color: #60a5fa;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

/* Order Summary Box */
.mvs-receipt-box {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mvs-receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #94a3b8;
}

.mvs-receipt-row.highlight {
  color: #34d399;
}

.mvs-receipt-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

.mvs-receipt-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 2px;
}

.mvs-receipt-total-val {
  font-size: 24px;
  font-weight: 800;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Payment Method Cards */
.mvs-payment-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mvs-method-tile,
.mvs-android-payment-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.5);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.mvs-method-tile:hover,
.mvs-android-payment-tile:hover {
  background: rgba(17, 24, 39, 0.85);
  border-color: rgba(255, 255, 255, 0.18);
}

.mvs-method-tile.active,
.mvs-android-payment-tile.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.15);
}

.mvs-method-tile-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mvs-method-icon-wrap {
  width: 34px;
  height: 24px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mvs-method-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #f8fafc;
}

.mvs-method-desc {
  font-size: 11px;
  color: #94a3b8;
}

.mvs-radio-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.mvs-method-tile.active .mvs-radio-circle,
.mvs-android-payment-tile.active .mvs-radio-circle {
  border-color: #3b82f6;
  background: #3b82f6;
}

.mvs-radio-inner {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
}

/* Sticky Action Bar */
.mvs-checkout-footer {
  padding: 16px 24px 18px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 15, 25, 0.95);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.mvs-primary-cta,
.mvs-android-cta-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(59, 130, 246, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  user-select: none;
}

.mvs-primary-cta:hover:not(:disabled),
.mvs-android-cta-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.45);
}

.mvs-primary-cta:active:not(:disabled),
.mvs-android-cta-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.mvs-primary-cta:disabled,
.mvs-android-cta-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mvs-trust-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 11px;
  color: #64748b;
  flex-wrap: wrap;
}

.mvs-trust-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mvs-android-welcome-banner {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(59, 130, 246, 0.15));
  border: 1.5px solid rgba(168, 85, 247, 0.45);
  border-radius: 22px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
  animation: mvsAndroidPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mobile responsive enhancements for Subscription & Plans */
@media (max-width: 768px) {
  .subscription-page-container {
    padding: 0 12px 40px 12px !important;
  }
  .mvs-desktop-only {
    display: none !important;
  }
  .mvs-mobile-only {
    display: block !important;
  }
}

@media (min-width: 769px) {
  .mvs-mobile-only {
    display: none !important;
  }
}


