/*
  Wangpan Light Console
  Inspired by 115CAS-style media dashboard: light rail, bright blue active nav,
  soft pastel workspace, airy white cards, high-readability Chinese typography.
*/

:root {
  --wp-sidebar: #f7f8fa;
  --wp-sidebar-text: #6b7280;
  --wp-sidebar-text-strong: #111827;
  --wp-sidebar-line: #e8ebf0;
  --wp-accent: #3b82f6;
  --wp-accent-strong: #2563eb;
  --wp-accent-soft: rgba(59, 130, 246, .12);
  --wp-success: #22c55e;
  --wp-success-strong: #16a34a;
  --wp-success-soft: #ecfdf5;
  --wp-warning: #f59e0b;
  --wp-warning-soft: #fffbeb;
  --wp-danger: #ef4444;
  --wp-danger-soft: #fef2f2;
  --wp-ink: #0f172a;
  --wp-body: #334155;
  --wp-muted: #64748b;
  --wp-canvas: #ffffff;
  --wp-surface: #f4f7fc;
  --wp-surface-2: #eef2f8;
  --wp-line: #e5eaf2;
  --wp-line-strong: #d5dce8;
  --wp-shadow: 0 8px 28px rgba(15, 23, 42, .06);
  --wp-shadow-soft: 0 4px 16px rgba(15, 23, 42, .04);
  --wp-radius: 16px;
  --wp-radius-sm: 12px;
  --wp-radius-xs: 10px;
  --wp-focus: 0 0 0 3px rgba(59, 130, 246, .18);

  --bg: var(--wp-surface);
  --panel: var(--wp-canvas);
  --line: var(--wp-line);
  --text: var(--wp-ink);
  --sub: var(--wp-muted);
  --primary: var(--wp-accent-strong);
  --accent: var(--wp-success-strong);
  --soft: var(--wp-accent-soft);
  --panel-strong: #ffffff;
  --surface: var(--wp-surface);
  --shadow: var(--wp-shadow);
  --shadow-soft: var(--wp-shadow-soft);
  --primary-dark: #1d4ed8;
  --accent-dark: #15803d;
}

* { letter-spacing: 0; box-sizing: border-box; }

html, body {
  background:
    radial-gradient(900px 420px at 18% -8%, rgba(147, 197, 253, .28), transparent 55%),
    radial-gradient(760px 380px at 92% 0%, rgba(196, 181, 253, .18), transparent 48%),
    linear-gradient(180deg, #f8fafc 0%, var(--wp-surface) 42%, #eef3f9 100%) !important;
  color: var(--wp-body) !important;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
    Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif !important;
  font-size: 14.5px !important;
  line-height: 1.55 !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.login-mode {
  min-height: 100vh;
  background:
    radial-gradient(980px 520px at 12% -12%, rgba(59, 130, 246, .22), transparent 55%),
    radial-gradient(820px 460px at 100% 0%, rgba(167, 139, 250, .16), transparent 48%),
    linear-gradient(160deg, #f8fbff 0%, #eef4ff 46%, #f7f8fa 100%) !important;
}

a { color: var(--wp-accent-strong); text-decoration: none; }
a:hover { color: #1d4ed8; }

.app-shell {
  min-height: 100vh;
  background: transparent !important;
}

.sidebar {
  width: 248px !important;
  padding: 18px 14px 18px !important;
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%) !important;
  border-right: 1px solid var(--wp-sidebar-line) !important;
  box-shadow: none !important;
  color: var(--wp-sidebar-text) !important;
}

.brand {
  display: flex !important;
  align-items: center;
  gap: 12px;
  min-height: 56px !important;
  padding: 8px 10px !important;
  border: 0 !important;
  border-left: 0 !important;
  border-radius: var(--wp-radius-sm) !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--wp-sidebar-text-strong) !important;
}

.brand-symbol {
  width: 36px !important;
  height: 36px !important;
  flex: 0 0 36px !important;
  border-radius: 12px !important;
  border: 0 !important;
  overflow: hidden;
  background: #ffffff !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem !important;
  box-shadow: 0 8px 18px rgba(59, 130, 246, .28) !important;
}

.brand h4 {
  margin: 0 0 2px !important;
  color: var(--wp-sidebar-text-strong) !important;
  font-size: 1.05rem !important;
  font-weight: 750 !important;
  line-height: 1.2 !important;
}

.brand p {
  margin: 0 !important;
  color: #94a3b8 !important;
  font-size: .75rem !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.nav-section-label {
  margin: 16px 12px 8px !important;
  color: #94a3b8 !important;
  font-size: .72rem !important;
  font-weight: 650 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.menu {
  display: grid !important;
  gap: 4px !important;
  margin-top: 8px !important;
}

.menu .btn {
  min-height: 44px !important;
  margin: 0 !important;
  margin-bottom: 0 !important;
  padding: 10px 14px !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  color: #64748b !important;
  font-size: .94rem !important;
  font-weight: 600 !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  box-shadow: none !important;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.menu .btn i {
  width: 1.15rem;
  color: #94a3b8 !important;
  font-size: 1.05rem;
}

.menu .btn:hover {
  background: rgba(59, 130, 246, .08) !important;
  border-color: transparent !important;
  color: #1e293b !important;
  box-shadow: none !important;
}

.menu .btn:hover i { color: #3b82f6 !important; }

.menu .btn.active {
  background: linear-gradient(90deg, #3b82f6 0%, #4f8dff 100%) !important;
  border-color: transparent !important;
  color: #ffffff !important;
  box-shadow: 0 10px 22px rgba(59, 130, 246, .28) !important;
}

.menu .btn.active i { color: #ffffff !important; }

.sidebar-footer {
  position: absolute !important;
  left: 14px !important;
  right: 14px !important;
  bottom: 16px !important;
  padding-top: 12px !important;
  border-top: 1px solid var(--wp-sidebar-line) !important;
}

.sidebar-footer .btn,
.sidebar-footer .btn.btn-outline-danger,
.sidebar-footer .btn-outline-danger {
  min-height: 40px !important;
  border-radius: 12px !important;
  border: 1px solid #e5e7eb !important;
  background: #fff !important;
  color: #64748b !important;
  font-weight: 600 !important;
}

.sidebar-footer .btn:hover,
.sidebar-footer .btn.btn-outline-danger:hover {
  background: #f8fafc !important;
  color: #b91c1c !important;
  border-color: #fecaca !important;
}

.main {
  margin-left: 248px !important;
  padding: 22px 24px 28px !important;
  min-height: 100vh;
  background: transparent !important;
}

.topbar {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px !important;
  border: 1px solid rgba(226, 232, 240, .9) !important;
  border-radius: 14px !important;
  background: rgba(255,255,255,.86) !important;
  backdrop-filter: blur(10px);
  box-shadow: var(--wp-shadow-soft) !important;
}

.connectivity-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 16px;
  padding: 11px 14px;
  border: 1px solid #f5c26b;
  border-radius: 14px;
  background: #fffbeb;
  color: #92400e;
  box-shadow: var(--wp-shadow-soft);
}

.connectivity-banner-icon {
  flex: 0 0 auto;
  font-size: 1.05rem;
}

.connectivity-banner-copy {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 1px;
}

.connectivity-banner-copy strong {
  font-size: .88rem;
}

.connectivity-banner-copy span {
  overflow-wrap: anywhere;
  font-size: .8rem;
}

.file-list-large .file-item {
  content-visibility: auto;
  contain-intrinsic-size: 64px;
}

.file-list-more {
  display: flex;
  justify-content: center;
  padding: 12px;
}

.file-loading {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.file-loading-row {
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--wp-surface-2) 25%, #f8fbff 40%, var(--wp-surface-2) 60%);
  background-size: 240% 100%;
  animation: file-loading-shimmer 1.4s ease-in-out infinite;
}

@keyframes file-loading-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .file-loading-row { animation: none; }
}

.mobile-heading strong {
  color: var(--wp-ink);
  font-size: 1.05rem;
  font-weight: 720;
}

.workspace-head {
  display: flex !important;
  align-items: flex-end !important;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 0 18px !important;
  padding: 4px 2px 16px !important;
  border-bottom: 0 !important;
}

.workspace-kicker {
  margin-bottom: 6px;
  color: #94a3b8 !important;
  font-size: .74rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.workspace-head h1 {
  margin: 0 !important;
  color: var(--wp-ink) !important;
  font-size: clamp(1.55rem, 2.1vw, 2rem) !important;
  font-weight: 760 !important;
  line-height: 1.18 !important;
  letter-spacing: 0 !important;
}

.workspace-note {
  max-width: 420px;
  color: #64748b !important;
  font-size: .9rem !important;
  text-align: right;
  line-height: 1.5;
}

.panel,
.tool-pane,
.settings-card,
.modal-content,
.frame,
.sync-stat,
.copy-stat,
.task-card,
.copy-task-card,
.native-job,
.task,
.sync-task,
.tool-row,
.login-card {
  border: 1px solid rgba(226, 232, 240, .95) !important;
  border-radius: var(--wp-radius) !important;
  background: rgba(255, 255, 255, .92) !important;
  box-shadow: var(--wp-shadow) !important;
  backdrop-filter: blur(8px);
}

.panel {
  padding: 16px !important;
  min-height: auto;
}

.dashboard-panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(248,250,255,.96) 100%) !important;
}

.panel-header,
.tool-pane-head,
.copy-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid rgba(226, 232, 240, .9) !important;
}

.title,
.tool-pane-title,
.native-job-title,
.copy-task-name,
.sync-task-title {
  color: var(--wp-ink) !important;
  font-weight: 720 !important;
}

.title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  line-height: 1.25;
}

.title i { color: var(--wp-accent) !important; }

.meta,
.sync-help,
.copy-task-meta,
.form-text,
.login-subtitle {
  color: var(--wp-muted) !important;
}

.grid-2,
.grid-3,
.integrated-grid,
.settings-grid {
  gap: 16px !important;
}

/* Settings uses a stable navigation/content split on desktop. */
.settings-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.settings-nav {
  display: grid;
  gap: 6px;
  position: sticky;
  top: 18px;
  padding: 8px;
  border-right: 1px solid var(--wp-line);
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--wp-muted);
  text-align: left;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.settings-nav-item i {
  width: 1.1rem;
  color: #94a3b8;
  text-align: center;
}

.settings-nav-item:hover {
  background: #f1f6ff;
  color: #1d4ed8;
}

.settings-nav-item.active {
  background: #eaf2ff;
  color: #2563eb;
}

.settings-nav-item.active i { color: #3b82f6; }

.settings-content { min-width: 0; }

.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

.settings-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 14px;
}

.settings-section-heading h3 {
  margin: 0;
  color: var(--wp-ink);
  font-size: 1.14rem;
  font-weight: 750;
}

.settings-section-heading p {
  margin: 4px 0 0;
  color: var(--wp-muted);
  font-size: .84rem;
}

.settings-content .settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.settings-content .settings-grid .settings-card:only-child {
  grid-column: 1 / -1;
  max-width: 760px;
}

/* Keep the two integrated tools readable on narrow screens. */
@media (max-width: 920px) {
  .integrated-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .integrated-grid .tool-pane {
    min-height: 0 !important;
    max-height: none !important;
  }

  .integrated-grid .tool-pane-body {
    overflow: visible;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .settings-nav {
    display: flex;
    position: static;
    gap: 6px;
    padding: 0 0 8px;
    border-right: 0;
    border-bottom: 1px solid var(--wp-line);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .settings-nav::-webkit-scrollbar { display: none; }

  .settings-nav-item {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    white-space: nowrap;
    padding: 8px 11px;
    font-size: .86rem;
  }

  .settings-content .settings-grid {
    grid-template-columns: 1fr !important;
  }

  .settings-content .settings-grid .settings-card:only-child {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .dashboard-sort-button {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 34px;
    border: 1px solid #dbe3ef;
    border-radius: 9px;
    background: #fff;
    color: #64748b;
    overflow: hidden;
  }

  .dashboard-sort-button:hover,
  .dashboard-sort-button:focus-within {
    border-color: #93c5fd;
    color: #2563eb;
    background: #f8fbff;
  }

  .dashboard-sort-icon {
    pointer-events: none;
    font-size: .98rem;
    line-height: 1;
  }

  .dashboard-sort {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    flex: none !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0;
    cursor: pointer;
  }

  #view-dashboard .dashboard-panel .panel-header {
    grid-template-columns: minmax(0, 1fr) auto !important;
  }

  .dashboard-panel .toolbar .form-select {
    flex: 0 0 78px !important;
    min-width: 78px !important;
    max-width: 78px !important;
    padding-left: 8px !important;
    padding-right: 18px !important;
    font-size: .74rem !important;
  }

  .settings-section-heading {
    margin-bottom: 10px;
  }

  .settings-section-heading h3 { font-size: 1rem; }
  .settings-section-heading p { font-size: .76rem; }

  #view-subtitle-tools .integrated-grid,
  #view-mkv-tools .integrated-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  #view-subtitle-tools .tool-pane,
  #view-mkv-tools .tool-pane {
    display: none !important;
  }

  #view-subtitle-tools .tool-pane.tool-pane-active,
  #view-mkv-tools .tool-pane.tool-pane-active {
    display: flex !important;
  }

  #view-subtitle-tools .tool-pane.tool-pane-active,
  #view-mkv-tools .tool-pane.tool-pane-active {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 14px !important;
  }

  #view-subtitle-tools .tool-pane-body,
  #view-mkv-tools .tool-pane-body {
    max-height: none !important;
    overflow: visible !important;
  }

  #view-subtitle-tools .compact-form,
  #view-mkv-tools .compact-form {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #view-subtitle-tools .compact-form .span-2,
  #view-mkv-tools .compact-form .span-2 {
    grid-column: auto !important;
  }

  #view-subtitle-tools .tool-pane-head,
  #view-mkv-tools .tool-pane-head {
    min-height: 48px;
    padding: 10px 12px;
  }

  #view-subtitle-tools .tool-pane-body,
  #view-mkv-tools .tool-pane-body {
    padding: 12px;
  }

  #view-subtitle-tools .tool-mini-actions,
  #view-mkv-tools .tool-mini-actions {
    gap: 6px;
  }

  #view-subtitle-tools .tool-mini-actions .btn,
  #view-mkv-tools .tool-mini-actions .btn {
    min-height: 36px;
  }

  #view-subtitle-tools input[type="file"] {
    max-width: 100%;
    overflow: hidden;
    font-size: .8rem;
  }
}

.theme-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.theme-toggle-mobile {
  display: none;
  flex: 0 0 40px;
  width: 40px;
  min-height: 36px;
  padding: 0 !important;
  margin-left: auto;
}

.sync-search-row {
  display: flex;
  min-width: 0;
  margin: 0 0 12px;
}

.sync-page-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.sync-page-toolbar .toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 560px) {
  .sync-page-toolbar .toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .sync-page-toolbar .toolbar .btn {
    min-width: 0;
  }

  .sync-page-toolbar .toolbar .btn:last-child {
    grid-column: 1 / -1;
  }
}

.sync-search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 0 10px 0 13px;
  border: 1px solid var(--wp-line-strong);
  border-radius: 12px;
  background: var(--wp-canvas);
  color: var(--wp-muted);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.sync-search-box:focus-within {
  border-color: var(--wp-accent);
  box-shadow: var(--wp-focus);
}

.sync-search-box > i {
  flex: 0 0 auto;
  color: var(--wp-accent);
}

.sync-search-box input {
  min-width: 0;
  flex: 1;
  height: 40px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--wp-ink);
  font: inherit;
}

.sync-search-box input::placeholder {
  color: var(--wp-muted);
  opacity: .86;
}

.sync-search-box input::-webkit-search-cancel-button,
.sync-search-box input::-webkit-search-decoration,
.sync-search-box input::-ms-clear {
  display: none;
  appearance: none;
}

.sync-search-clear {
  display: inline-grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--wp-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, background .16s ease, color .16s ease;
}

.sync-search-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.sync-search-clear:hover,
.sync-search-clear:focus-visible {
  background: var(--wp-surface-2);
  color: var(--wp-ink);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --wp-sidebar: #0f172a;
  --wp-sidebar-text: #94a3b8;
  --wp-sidebar-text-strong: #f8fafc;
  --wp-sidebar-line: #243244;
  --wp-ink: #f8fafc;
  --wp-body: #cbd5e1;
  --wp-muted: #94a3b8;
  --wp-canvas: #111827;
  --wp-surface: #0b1220;
  --wp-surface-2: #172033;
  --wp-line: #243244;
  --wp-line-strong: #334155;
  --bg: #0b1220;
  --panel: #111827;
  --line: #243244;
  --text: #f8fafc;
  --sub: #94a3b8;
  --panel-strong: #1f2937;
  --surface: #0b1220;
}

html[data-theme="dark"] body,
html[data-theme="dark"] body.login-mode {
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%) !important;
  color: var(--wp-body) !important;
}

html[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%) !important;
  border-color: var(--wp-sidebar-line) !important;
}

html[data-theme="dark"] .brand,
html[data-theme="dark"] .mobile-heading,
html[data-theme="dark"] .topbar {
  color: var(--wp-sidebar-text-strong) !important;
}

html[data-theme="dark"] .brand p,
html[data-theme="dark"] .nav-section-label,
html[data-theme="dark"] .workspace-kicker,
html[data-theme="dark"] .workspace-note {
  color: var(--wp-muted) !important;
}

html[data-theme="dark"] .menu .btn,
html[data-theme="dark"] .settings-nav-item {
  color: var(--wp-muted) !important;
}

html[data-theme="dark"] .menu .btn:hover,
html[data-theme="dark"] .menu .btn.active,
html[data-theme="dark"] .settings-nav-item:hover {
  background: #1e293b !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .menu .btn.active {
  background: linear-gradient(90deg, #2563eb, #1d4ed8) !important;
  color: #fff !important;
}

html[data-theme="dark"] .sidebar-footer .btn,
html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-dark {
  border-color: #334155 !important;
  background: #172033 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .sidebar-footer .btn:hover,
html[data-theme="dark"] .btn-outline-primary:hover,
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-dark:hover {
  border-color: #60a5fa !important;
  background: #1e293b !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .tool-pane,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .frame,
html[data-theme="dark"] .sync-stat,
html[data-theme="dark"] .copy-stat,
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .copy-task-card,
html[data-theme="dark"] .native-job,
html[data-theme="dark"] .task,
html[data-theme="dark"] .sync-task,
html[data-theme="dark"] .tool-row,
html[data-theme="dark"] .login-card {
  border-color: #243244 !important;
  background: #111827 !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22) !important;
}

html[data-theme="dark"] .dashboard-panel,
html[data-theme="dark"] .sync-task,
html[data-theme="dark"] .settings-card {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%) !important;
}

html[data-theme="dark"] .panel-header,
html[data-theme="dark"] .tool-pane-head,
html[data-theme="dark"] .copy-section-head,
html[data-theme="dark"] .topbar {
  border-color: #243244 !important;
}

html[data-theme="dark"] .workspace-head h1,
html[data-theme="dark"] .mobile-heading strong,
html[data-theme="dark"] .title,
html[data-theme="dark"] .tool-pane-title,
html[data-theme="dark"] .native-job-title,
html[data-theme="dark"] .copy-task-name,
html[data-theme="dark"] .sync-task-title,
html[data-theme="dark"] .settings-section-heading h3,
html[data-theme="dark"] .form-label {
  color: var(--wp-ink) !important;
}

html[data-theme="dark"] .meta,
html[data-theme="dark"] .sync-help,
html[data-theme="dark"] .copy-task-meta,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .login-subtitle,
html[data-theme="dark"] .settings-section-heading p,
html[data-theme="dark"] .sync-task-path,
html[data-theme="dark"] .sync-active-file {
  color: var(--wp-muted) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] .login-card .form-control {
  border-color: #334155 !important;
  background: #0f172a !important;
  color: var(--wp-ink) !important;
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .login-card .form-control::placeholder {
  color: #64748b !important;
}

html[data-theme="dark"] .file-item:hover,
html[data-theme="dark"] .dir-item:hover,
html[data-theme="dark"] .tool-row:hover {
  background: #172033 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .file-list,
html[data-theme="dark"] .task-list,
html[data-theme="dark"] .dir-browser,
html[data-theme="dark"] .tool-list,
html[data-theme="dark"] .dashboard-panel .file-list {
  border-color: #243244 !important;
  background: #0f172a !important;
}

html[data-theme="dark"] .file-item,
html[data-theme="dark"] .dir-item,
html[data-theme="dark"] .tool-row {
  border-bottom-color: #243244 !important;
  background: #0f172a !important;
  color: var(--wp-body) !important;
}

html[data-theme="dark"] .file-item .filename,
html[data-theme="dark"] .dir-item .filename,
html[data-theme="dark"] .file-item .clickable,
html[data-theme="dark"] .dir-item .clickable,
html[data-theme="dark"] .selection-label {
  color: var(--wp-ink) !important;
}

html[data-theme="dark"] .selection-header {
  border-bottom-color: #243244 !important;
  background: #172033 !important;
  color: var(--wp-body) !important;
}

html[data-theme="dark"] .file-item.selected,
html[data-theme="dark"] .dir-item.selected {
  background: linear-gradient(90deg, rgba(59, 130, 246, .22), rgba(59, 130, 246, .08)) !important;
  border-color: #3b82f6 !important;
}

html[data-theme="dark"] .sync-status-tab,
html[data-theme="dark"] .tool-module-launcher > button {
  border-color: #334155 !important;
  background: #111827 !important;
  color: var(--wp-body) !important;
}

html[data-theme="dark"] .sync-status-tab:hover,
html[data-theme="dark"] .tool-module-launcher > button:hover {
  border-color: #60a5fa !important;
  background: #172033 !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .sync-status-tab.active,
html[data-theme="dark"] .tool-module-launcher > button.active {
  border-color: #60a5fa !important;
  background: linear-gradient(180deg, #172554, #111827) !important;
  color: #dbeafe !important;
}

html[data-theme="dark"] .sync-status-tab-icon,
html[data-theme="dark"] .sync-status-tab-count,
html[data-theme="dark"] .tool-module-icon {
  background: #1e293b !important;
  color: #93c5fd !important;
}

html[data-theme="dark"] .sync-search-box {
  border-color: #334155;
  background: #0f172a;
}

html[data-theme="dark"] .sync-search-box input {
  color: var(--wp-ink);
}

html[data-theme="dark"] .sync-empty,
html[data-theme="dark"] .native-empty,
html[data-theme="dark"] .copy-task-card.done,
html[data-theme="dark"] .tool-pane-head,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .sync-wizard-footer,
html[data-theme="dark"] .bg-light {
  border-color: #243244 !important;
  background: #172033 !important;
  color: var(--wp-body) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-muted {
  color: var(--wp-muted) !important;
}

html[data-theme="dark"] .table {
  --bs-table-color: var(--wp-body);
  --bs-table-bg: transparent;
  --bs-table-border-color: #243244;
  color: var(--wp-body) !important;
}

html[data-theme="dark"] .dropdown-menu {
  border-color: #334155 !important;
  background: #111827 !important;
  color: var(--wp-body) !important;
}

@media (max-width: 920px) {
  .theme-toggle-mobile { display: inline-grid !important; }
}

@media (max-width: 560px) {
  .sync-search-box input {
    font-size: .82rem;
  }
}

.btn {
  border-radius: var(--wp-radius-xs) !important;
  font-weight: 650 !important;
  box-shadow: none !important;
}

.btn-sm {
  min-height: 32px;
  padding: .3rem .7rem;
  font-size: .82rem;
  border-radius: 10px !important;
}

.btn-primary,
.btn-success {
  background: linear-gradient(90deg, #3b82f6, #4f8dff) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(59, 130, 246, .22) !important;
}

.btn-primary:hover,
.btn-success:hover,
.btn-primary:focus,
.btn-success:focus {
  background: linear-gradient(90deg, #2563eb, #3b82f6) !important;
  border-color: transparent !important;
  color: #fff !important;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-dark {
  background: #fff !important;
  border-color: #dbe3ef !important;
  color: #334155 !important;
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-dark:hover {
  background: #f8fbff !important;
  border-color: #93c5fd !important;
  color: #1e40af !important;
}

.btn-outline-warning,
.btn-warning {
  background: var(--wp-warning-soft) !important;
  border-color: #fcd34d !important;
  color: #b45309 !important;
}

.btn-outline-warning:hover,
.btn-warning:hover {
  background: #f59e0b !important;
  border-color: #f59e0b !important;
  color: #111827 !important;
}

.btn-outline-danger,
.btn-danger {
  background: var(--wp-danger-soft) !important;
  border-color: #fecaca !important;
  color: #dc2626 !important;
}

.btn-outline-danger:hover,
.btn-danger:hover {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #fff !important;
}

.btn-outline-success {
  background: var(--wp-success-soft) !important;
  border-color: #86efac !important;
  color: #15803d !important;
}

.form-control,
.form-select,
.input-group-text {
  min-height: 40px !important;
  border-color: #dbe3ef !important;
  border-radius: 12px !important;
  color: var(--wp-ink) !important;
  background: #fff !important;
  box-shadow: none !important;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #93c5fd !important;
  box-shadow: var(--wp-focus) !important;
}

.form-label {
  color: #475569 !important;
  font-weight: 650 !important;
  margin-bottom: .4rem;
}

.form-check-input:checked {
  background-color: var(--wp-accent);
  border-color: var(--wp-accent);
}

.toolbar,
.bottom-actions,
.tool-mini-actions,
.copy-done-actions {
  gap: 8px !important;
}

.toolbar .badge,
.badge {
  border-radius: 999px !important;
  font-weight: 650 !important;
}

.badge.bg-secondary {
  background: #eef2ff !important;
  color: #4f46e5 !important;
}

.badge.bg-primary {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}

.badge.bg-success {
  background: #dcfce7 !important;
  color: #15803d !important;
}

.badge.bg-danger {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

.file-item,
.dir-item,
.tool-row,
.task-card,
.copy-task-card,
.native-job {
  border-radius: 14px !important;
  border: 1px solid transparent !important;
  transition: background .14s ease, border-color .14s ease;
}

.file-item:hover,
.dir-item:hover,
.tool-row:hover {
  background: #f8fbff !important;
  border-color: #dbeafe !important;
}

.file-item.selected,
.dir-item.selected {
  background: linear-gradient(90deg, rgba(59,130,246,.08), rgba(59,130,246,.03)) !important;
  border-color: #bfdbfe !important;
}

.file-item.selected::before {
  background: var(--wp-accent) !important;
}

.progress,
.progress-mini {
  height: 8px !important;
  border-radius: 999px !important;
  background: #e8eef7 !important;
  overflow: hidden;
}

.progress-bar,
.progress-mini span {
  background: linear-gradient(90deg, #22c55e 0%, #3b82f6 100%) !important;
}

.subtitle-job-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.subtitle-job-actions > .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: .36rem .78rem;
  border-radius: 7px !important;
  font-size: .82rem;
  line-height: 1.25;
}

.subtitle-media-type-select {
  width: 116px;
  min-height: 36px;
  padding: .34rem 2rem .34rem .72rem;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #334155;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}

.subtitle-media-type-select:hover,
.subtitle-media-type-select:focus {
  border-color: #60a5fa;
  outline: 0;
  box-shadow: 0 0 0 .18rem rgba(59, 130, 246, .14);
}

.sync-overview,
.copy-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.copy-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sync-stat,
.copy-stat {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 0 !important;
  padding: 10px 12px !important;
  border-radius: 12px !important;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%) !important;
  border: 1px solid #e0e7ff !important;
  box-shadow: none !important;
}

.sync-stat span,
.copy-stat span,
.copy-stat .text-muted,
.copy-stat .small {
  display: block;
  margin-bottom: 0 !important;
  color: #64748b !important;
  font-size: .72rem !important;
  font-weight: 650 !important;
  line-height: 1.2 !important;
}

.sync-stat strong,
.copy-stat strong {
  color: var(--wp-ink) !important;
  font-size: 1.12rem !important;
  font-weight: 760 !important;
  line-height: 1.15 !important;
}

.sync-stat:nth-child(1) strong,
.copy-stat:nth-child(1) strong { color: #16a34a !important; }
.sync-stat:nth-child(2) strong,
.copy-stat:nth-child(2) strong { color: #2563eb !important; }
.sync-stat:nth-child(3) strong,
.copy-stat:nth-child(3) strong { color: #7c3aed !important; }
.sync-stat:nth-child(4) strong,
.copy-stat:nth-child(4) strong { color: #0f172a !important; }

.sync-task {
  padding: 16px !important;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%) !important;
  border-radius: 16px !important;
}

.sync-task-path,
.sync-active-file,
.sync-help {
  color: var(--wp-muted) !important;
}

.sync-active-file {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fbff;
  color: #1e3a8a !important;
  font-size: .84rem;
}

.sync-stepbar { gap: 8px; }

.sync-step {
  border-radius: 999px !important;
  border: 1px solid var(--wp-line);
  background: var(--wp-surface-2);
  color: var(--wp-muted);
}

.sync-step.active {
  background: var(--wp-accent) !important;
  border-color: var(--wp-accent) !important;
  color: #fff !important;
}

.sync-step.done {
  background: #dbeafe !important;
  border-color: #93c5fd !important;
  color: #1d4ed8 !important;
}

.sync-empty,
.task-empty,
.native-empty,
.copy-task-card.done {
  color: var(--wp-muted) !important;
  background: #f8fafc !important;
  border-radius: var(--wp-radius);
}

.status-pill,
.sync-status,
.job-status,
.login-card {
  max-width: 420px;
  margin: 0 auto;
  border: 1px solid rgba(226, 232, 240, .95) !important;
  border-left: 0 !important;
  background: rgba(255, 255, 255, .92) !important;
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .10) !important;
  color: var(--wp-body) !important;
}

.login-card .modal-body { padding: 32px !important; }

.login-mark {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 0;
  overflow: hidden;
  background: #ffffff;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(10, 132, 255, .28);
}

.login-title {
  color: var(--wp-ink) !important;
  font-size: 1.45rem !important;
  font-weight: 760 !important;
}

.login-subtitle {
  color: #64748b !important;
  margin: 8px 0 20px !important;
  line-height: 1.55;
}

.login-card .form-control {
  background: #fff !important;
  border-color: #dbe3ef !important;
  color: var(--wp-ink) !important;
}

.login-card .form-control::placeholder { color: #94a3b8; }

.login-submit {
  min-height: 46px !important;
  background: linear-gradient(90deg, #3b82f6, #4f8dff) !important;
  border-color: transparent !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 22px rgba(59, 130, 246, .25) !important;
}

.modal-header,
.modal-footer,
.sync-wizard-footer {
  background: #f8fafc !important;
  border-color: var(--wp-line) !important;
}

.table { color: var(--wp-body); }
.table > :not(caption) > * > * { border-color: var(--wp-line); }

.job-log,
pre {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
}

.toast {
  border-radius: 14px !important;
  box-shadow: var(--wp-shadow) !important;
}

.settings-card {
  padding: 18px !important;
  background: linear-gradient(180deg, #fff, #f8fbff) !important;
}

.settings-secret-textarea:not(:focus) {
  -webkit-text-security: disc;
}

.tool-pane-head {
  min-height: 52px;
  padding: 12px 14px;
  background: #f8fafc;
}

.tool-pane-body { padding: 14px; }

@media (max-width: 1100px) {
  .grid-2,
  .grid-3,
  .integrated-grid,
  .settings-grid,
  .sync-overview,
  .copy-summary {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 920px) {
  .sidebar {
    width: min(86vw, 300px) !important;
    transform: translateX(-105%);
    box-shadow: 18px 0 40px rgba(15, 23, 42, .12) !important;
  }
  .sidebar.show { transform: translateX(0); }
  .main {
    margin-left: 0 !important;
    padding: 14px !important;
  }
  .topbar { display: flex !important; }
  .workspace-head { display: none !important; }
  .sync-overview,
  .copy-summary,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 560px) {
  .connectivity-banner {
    align-items: flex-start;
  }

  .connectivity-banner .btn {
    flex: 0 0 auto;
  }

  .panel { padding: 12px !important; }
  .bottom-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }
  .brand { min-height: 52px; }
  .workspace-head h1 { font-size: 1.35rem !important; }
}

/* Compact metric cards on phones */
@media (max-width: 920px) {
  .sync-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .copy-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .sync-stat,
  .copy-stat {
    padding: 8px 10px !important;
    border-radius: 12px !important;
    min-height: 58px !important;
  }
  .sync-stat strong,
  .copy-stat strong {
    font-size: 1.02rem !important;
  }
  .sync-stat span,
  .copy-stat span,
  .copy-stat .text-muted,
  .copy-stat .small {
    font-size: .68rem !important;
  }
}

@media (max-width: 560px) {
  .sync-overview,
  .copy-summary {
    margin-bottom: 10px !important;
  }
  .sync-stat,
  .copy-stat {
    padding: 8px 9px !important;
    min-height: 54px !important;
  }
  .panel-header .toolbar .badge {
    display: none !important;
  }
}

.app-mark-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Show each media submodule as a focused workspace instead of a crowded column. */
.tool-module-launcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.subtitle-module-launcher {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tool-module-launcher > button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #fff;
  color: var(--wp-ink);
  text-align: left;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.tool-module-launcher > button:hover {
  border-color: #93c5fd;
  background: #f8fbff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .08);
  transform: translateY(-1px);
}

.tool-module-launcher > button.active {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #eff6ff, #fff);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, .16), 0 7px 18px rgba(37, 99, 235, .08);
}

.tool-module-icon {
  display: grid;
  place-items: center;
  align-self: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #eaf2ff;
  color: #2563eb;
  font-size: 1rem;
}

.tool-module-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: stretch;
  gap: 3px;
  min-width: 0;
}

.tool-module-copy strong {
  overflow-wrap: anywhere;
  font-size: .9rem;
  line-height: 1.25;
}

.tool-module-copy small {
  overflow-wrap: anywhere;
  color: var(--wp-muted);
  font-size: .72rem;
  line-height: 1.3;
}

.tool-module-arrow {
  align-self: center;
  color: #94a3b8;
  font-size: .82rem;
}

.tool-module-stage {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
}

.tool-module-stage > .tool-pane {
  display: none !important;
  width: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
}

.tool-module-stage > .tool-pane.tool-pane-active {
  display: flex !important;
  flex-direction: column;
}

.tool-module-stage > .tool-pane.tool-pane-active .tool-pane-body {
  overflow: visible;
}

@media (max-width: 1100px) {
  .tool-module-launcher,
  .subtitle-module-launcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .tool-module-launcher,
  .subtitle-module-launcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .tool-module-launcher > button {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 7px;
    min-height: 78px;
    padding: 9px 8px;
    border-radius: 14px;
  }

  .tool-module-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: .9rem;
  }

  .tool-module-copy {
    justify-content: center;
    gap: 2px;
    min-height: 3.7em;
  }

  .tool-module-copy strong {
    align-self: flex-start;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .82rem;
    line-height: 1.2;
  }

  .tool-module-copy small {
    display: -webkit-box;
    align-self: flex-start;
    min-height: 2.5em;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: .64rem;
    line-height: 1.25;
  }

  .tool-module-arrow {
    font-size: .7rem;
  }
}

/* Keep the final dark-theme layer after component defaults and mobile rules. */
html[data-theme="dark"] body,
html[data-theme="dark"] body.login-mode {
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%) !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .tool-pane,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .frame,
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .copy-task-card,
html[data-theme="dark"] .native-job,
html[data-theme="dark"] .task,
html[data-theme="dark"] .sync-task,
html[data-theme="dark"] .tool-row,
html[data-theme="dark"] .login-card {
  background: #111827 !important;
  border-color: #243244 !important;
  color: #cbd5e1 !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22) !important;
}

html[data-theme="dark"] .topbar {
  background: #172033 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .connectivity-banner {
  border-color: #854d0e;
  background: #2b2110;
  color: #fde68a;
}

html[data-theme="dark"] .file-loading-row {
  background: linear-gradient(90deg, #172033 25%, #243244 40%, #172033 60%);
  background-size: 240% 100%;
}

html[data-theme="dark"] .dashboard-panel,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .sync-task {
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%) !important;
}

html[data-theme="dark"] .panel-header,
html[data-theme="dark"] .tool-pane-head,
html[data-theme="dark"] .copy-section-head,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .sync-wizard-footer {
  background: #172033 !important;
  border-color: #243244 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] .file-list,
html[data-theme="dark"] .task-list,
html[data-theme="dark"] .dir-browser,
html[data-theme="dark"] .tool-list,
html[data-theme="dark"] .dashboard-panel .file-list,
html[data-theme="dark"] .sync-task-list {
  background: #0f172a !important;
  border-color: #243244 !important;
}

html[data-theme="dark"] .file-item,
html[data-theme="dark"] .dir-item,
html[data-theme="dark"] .tool-row {
  background: #0f172a !important;
  border-bottom-color: #243244 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .selection-header,
html[data-theme="dark"] .sync-empty,
html[data-theme="dark"] .task-empty,
html[data-theme="dark"] .native-empty,
html[data-theme="dark"] .copy-task-card.done {
  background: #172033 !important;
  border-color: #243244 !important;
  color: #94a3b8 !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] .login-card .form-control {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] .btn-outline-primary,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-dark,
html[data-theme="dark"] .sidebar-footer .btn {
  background: #172033 !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .btn-outline-warning,
html[data-theme="dark"] .btn-warning {
  background: #3b2a0d !important;
  border-color: #a16207 !important;
  color: #fcd34d !important;
}

html[data-theme="dark"] .btn-outline-danger,
html[data-theme="dark"] .btn-danger {
  background: #3b151b !important;
  border-color: #9f1239 !important;
  color: #fda4af !important;
}

html[data-theme="dark"] .btn-outline-success {
  background: #0f2d20 !important;
  border-color: #166534 !important;
  color: #86efac !important;
}

html[data-theme="dark"] .subtitle-media-type-select {
  border-color: #475569;
  background: #0f172a;
  color: #f8fafc;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .copy-task-meta,
html[data-theme="dark"] .sync-help,
html[data-theme="dark"] .sync-task-path,
html[data-theme="dark"] .sync-active-file {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .title,
html[data-theme="dark"] .tool-pane-title,
html[data-theme="dark"] .copy-task-name,
html[data-theme="dark"] .sync-task-title,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .file-item .filename,
html[data-theme="dark"] .dir-item .filename,
html[data-theme="dark"] .selection-label,
html[data-theme="dark"] .mobile-heading strong,
html[data-theme="dark"] .workspace-head h1 {
  color: #f8fafc !important;
}

html[data-theme="dark"] .dashboard-panel .panel-header,
html[data-theme="dark"] .dashboard-panel .toolbar,
html[data-theme="dark"] .mkv-subtitle-order-panel,
html[data-theme="dark"] .mkv-subtitle-preferences,
html[data-theme="dark"] .track-row,
html[data-theme="dark"] .external-subtitle-list,
html[data-theme="dark"] .native-job,
html[data-theme="dark"] .storage-browser {
  background: #172033 !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .mkv-subtitle-order-row,
html[data-theme="dark"] .external-subtitle-row,
html[data-theme="dark"] .dashboard-panel .file-list {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .mkv-subtitle-order-number {
  background: #1e3a8a !important;
  color: #dbeafe !important;
}

html[data-theme="dark"] .mkv-subtitle-order-row .meta,
html[data-theme="dark"] .mkv-subtitle-preferences .meta,
html[data-theme="dark"] .track-row .meta,
html[data-theme="dark"] .external-subtitle-row .meta {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .dashboard-sort-button {
  background: #172033 !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .dashboard-sort-button:hover,
html[data-theme="dark"] .dashboard-sort-button:focus-within {
  background: #1e293b !important;
  border-color: #60a5fa !important;
  color: #bfdbfe !important;
}

html[data-theme="dark"] .dashboard-sort-icon {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .form-check-input {
  appearance: none;
  -webkit-appearance: none;
  width: 1em;
  height: 1em;
  background-color: #0f172a !important;
  border-color: #64748b !important;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .35) !important;
  accent-color: #60a5fa;
}

html[data-theme="dark"] .form-check-input:checked {
  background-color: #3b82f6 !important;
  border-color: #60a5fa !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .form-check-input:focus {
  border-color: #93c5fd !important;
  box-shadow: 0 0 0 .2rem rgba(96, 165, 250, .22) !important;
}

html[data-theme="dark"] .form-check,
html[data-theme="dark"] .form-check-label,
html[data-theme="dark"] .mkv-subtitle-checks,
html[data-theme="dark"] .mkv-track-flags {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .aria2-profile-box {
  background: #172033 !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .aria2-profile-box-head strong {
  color: #f8fafc !important;
}

html[data-theme="dark"] .aria2-profile-box-head small {
  color: #94a3b8 !important;
}

.mkv-job-log-hint {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 72px;
  padding: 14px;
  border: 1px dashed var(--wp-line);
  border-radius: 8px;
  color: var(--wp-muted);
  background: var(--wp-surface-2);
}

.mkv-job-log-hint i {
  color: var(--primary);
  font-size: 1.1rem;
}

.modal-subtitle {
  margin-top: 3px;
  color: var(--wp-muted);
  font-size: .78rem;
}

.job-log-modal {
  min-height: min(56vh, 460px);
  max-height: 62vh;
  margin: 0;
  border-radius: 8px;
}

.terminology-page-body {
  padding: 16px;
}

.terminology-intro {
  color: var(--wp-muted);
  font-size: .88rem;
}

.terminology-controls {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.terminology-merge-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
  background: var(--wp-surface-2);
}

.terminology-merge-help {
  display: grid;
  gap: 2px;
  color: var(--wp-muted);
  font-size: .8rem;
  line-height: 1.45;
}

.terminology-merge-help strong {
  color: var(--wp-ink);
  font-size: .83rem;
}

.terminology-select-column,
.terminology-primary-column {
  width: 52px;
  text-align: center;
}

.terminology-select-input,
.terminology-primary-input {
  margin: 0;
  cursor: pointer;
}

.terminology-primary-input:disabled {
  cursor: not-allowed;
}

.terminology-search {
  flex: 0 1 480px;
  min-width: 0;
  width: 100%;
}

.terminology-summary {
  display: flex;
  gap: 18px;
  margin: 14px 0;
  color: var(--wp-muted);
  font-size: .86rem;
}

.terminology-summary strong,
.terminology-count {
  color: var(--wp-ink);
  font-variant-numeric: tabular-nums;
}

.terminology-detail-trigger {
  padding: 0;
  border: 0;
  color: var(--wp-ink);
  background: transparent;
  font: inherit;
  text-align: inherit;
}

.terminology-detail-trigger:hover,
.terminology-detail-trigger:focus-visible {
  color: var(--wp-accent);
  text-decoration: underline;
}

.terminology-series-trigger {
  font-weight: 700;
}

.terminology-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
}

.terminology-table {
  min-width: 720px;
}

.terminology-table th {
  color: var(--wp-muted);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.terminology-stored-keys {
  display: grid;
  gap: 4px;
}

.terminology-stored-key {
  width: fit-content;
  max-width: 360px;
  overflow: hidden;
  color: var(--wp-body);
  font-size: .76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminology-rename-current {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
  background: var(--wp-surface-2);
}

.terminology-rename-current span,
.terminology-rename-current small {
  color: var(--wp-muted);
  font-size: .78rem;
}

.terminology-rename-current strong {
  color: var(--wp-ink);
  overflow-wrap: anywhere;
}

.terminology-detail-body {
  display: grid;
  gap: 14px;
}

.terminology-detail-toolbar,
.terminology-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminology-detail-toolbar {
  justify-content: space-between;
}

.terminology-detail-search {
  max-width: 420px;
}

.terminology-detail-category-filter {
  width: min(150px, 100%);
  flex: 0 0 150px;
}

.terminology-detail-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.terminology-detail-count,
.terminology-detail-selected {
  color: var(--wp-muted);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.terminology-detail-selected {
  color: var(--wp-ink);
}

.terminology-term-editor {
  padding: 12px;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
  background: var(--wp-surface-2);
}

.terminology-term-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.terminology-term-fields {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) minmax(180px, 1.3fr) minmax(100px, .65fr) auto auto;
  align-items: end;
  gap: 10px;
}

.terminology-term-batch-fields {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(120px, .7fr) auto auto;
  align-items: end;
  gap: 10px;
}

.terminology-term-fields label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--wp-muted);
  font-size: .76rem;
}

.terminology-term-batch-fields label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--wp-muted);
  font-size: .76rem;
}

.terminology-term-batch-fields textarea {
  min-height: 104px;
  resize: vertical;
}

.terminology-term-batch-fields small {
  min-height: 18px;
  color: var(--wp-muted);
}

.terminology-term-fields .terminology-term-lock,
.terminology-term-batch-fields .terminology-term-lock {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding-bottom: 2px;
  color: var(--wp-body);
  white-space: nowrap;
}

.terminology-term-lock .form-check-input {
  margin: 0;
}

.terminology-term-submit {
  white-space: nowrap;
}

.terminology-detail-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
}

.terminology-detail-table {
  min-width: 860px;
}

.subtitle-terminology-review-wrap {
  overflow-x: auto;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
}

.subtitle-terminology-review-table {
  min-width: 760px;
}

.subtitle-terminology-review-table th {
  color: var(--wp-muted);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.subtitle-terminology-review-table td:first-child,
.subtitle-terminology-review-table td:last-child {
  width: 64px;
  text-align: center;
}

.subtitle-terminology-review-table td:nth-child(2) {
  min-width: 165px;
}

.subtitle-terminology-review-table td:nth-child(2) small {
  display: block;
  margin-top: 3px;
  color: var(--wp-muted);
  overflow-wrap: anywhere;
}

.subtitle-terminology-review-table tr.is-disabled {
  opacity: .48;
}

.terminology-detail-table th {
  color: var(--wp-muted);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.terminology-detail-select {
  width: 52px;
  text-align: center;
}

.terminology-detail-aliases {
  color: var(--wp-muted);
  font-size: .84rem;
}

.terminology-category,
.terminology-locked {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--wp-line);
  border-radius: 999px;
  color: var(--wp-muted);
  font-size: .74rem;
  line-height: 1.35;
  white-space: nowrap;
}

.terminology-locked.is-locked {
  border-color: color-mix(in srgb, var(--wp-accent) 40%, var(--wp-line));
  color: var(--wp-accent);
}

html[data-theme="dark"] .mkv-job-log-hint,
html[data-theme="dark"] .terminology-table-wrap,
html[data-theme="dark"] .terminology-detail-table-wrap,
html[data-theme="dark"] .subtitle-terminology-review-wrap {
  border-color: #334155;
  background: #172033;
}

.video-fps-job-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.video-fps-job-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.video-fps-job-actions .meta {
  white-space: nowrap;
}

.video-fps-job {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--wp-line);
  border-radius: 8px;
  background: var(--wp-surface-2);
}

.video-fps-job-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.video-fps-job-title > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.video-fps-job strong,
.video-fps-job small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-fps-job small {
  color: var(--wp-muted);
}

.video-fps-job-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  font-size: .82rem;
  white-space: nowrap;
}

html[data-theme="dark"] .video-fps-job {
  border-color: #334155;
  background: #172033;
}

html[data-theme="dark"] .terminology-table > :not(caption) > * > *,
html[data-theme="dark"] .terminology-detail-table > :not(caption) > * > * {
  border-color: #334155;
}

@media (max-width: 640px) {
  .terminology-page-body { padding: 12px; }
  .terminology-controls { display: block; }
  .terminology-search {
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
    min-height: 32px;
    height: 32px;
  }
  .terminology-search > .input-group-text,
  .terminology-search > .form-control,
  .terminology-search > .btn {
    min-height: 32px;
    height: 32px;
  }
  .terminology-search > .form-control {
    min-width: 0;
  }
  .terminology-merge-bar { align-items: stretch; flex-direction: column; }
  .terminology-summary { gap: 12px; }
  .terminology-detail-toolbar { align-items: stretch; flex-direction: column; }
  .terminology-detail-search { max-width: none; }
  .terminology-detail-category-filter { width: 100%; flex-basis: auto; }
  .terminology-detail-actions { justify-content: flex-start; }
  .terminology-term-fields { grid-template-columns: 1fr 1fr; }
  .terminology-term-batch-fields { grid-template-columns: 1fr 1fr; }
  .terminology-term-submit { grid-column: 1 / -1; }
  .job-log-modal { min-height: 54vh; max-height: 64vh; }
  .video-fps-job { align-items: flex-start; flex-direction: column; }
  .video-fps-job-meta { justify-content: flex-start; flex-wrap: wrap; }
  .video-fps-job-actions { justify-content: flex-start; width: 100%; }
  .video-fps-job-actions .meta { margin-right: auto; }
}
