/* ==========================================================================
   Image Compressor - Professional Utility Design System
   Philosophy: Clean, structured, high-contrast, zero-gradient distraction.
   ========================================================================== */

:root {
  /* Neutral Color Palette (Zinc / Slate) */
  --bg-app: #090a0f;
  --bg-surface: #12151e;
  --bg-surface-raised: #181d2a;
  --bg-input: #0e111a;
  --bg-hover: #1f2536;

  /* Borders & Dividers */
  --border-dim: #212838;
  --border-base: #2d374b;
  --border-focus: #3b82f6;

  /* Text & Contrast */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  /* Semantic Accents */
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-text: #ffffff;
  
  --success-text: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --success-border: rgba(34, 197, 94, 0.25);

  --warning-text: #f59e0b;
  --danger-text: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);

  /* Typography & Layout */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  /* Clean, Crisp Slate Light Theme */
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f8fafc;
  --bg-input: #ffffff;
  --bg-hover: #e2e8f0;

  --border-dim: #e2e8f0;
  --border-base: #cbd5e1;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;

  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-text: #ffffff;
  
  --success-text: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.12);
  --success-border: rgba(22, 163, 74, 0.25);

  --warning-text: #d97706;
  --danger-text: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.12);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* App Header */
.app-header {
  height: 64px;
  border-bottom: 1px solid var(--border-dim);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  width: 34px;
  height: 34px;
  background-color: var(--accent-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.brand-info p {
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* Top App Navigation Tabs */
.header-nav {
  display: flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-tab-btn.active {
  background-color: var(--bg-surface-raised);
  color: var(--text-main);
  border: 1px solid var(--border-dim);
}

.nav-tab-btn:hover:not(.active) {
  color: var(--text-main);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success-text);
}

/* Main Layout Grid */
.main-layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 2.25rem 2rem;
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 2.25rem;
  align-items: start;
}

@media (max-width: 1120px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 1.75rem;
    padding: 1.25rem;
  }
  .work-area {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* Analytics View Container (Full width inside main layout or standalone) */
.analytics-view-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

/* Sidebar / Settings Panel */
.config-sidebar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

/* Preset Profiles */
.profile-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

.profile-btn {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.95rem;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-btn:hover {
  border-color: var(--border-base);
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.03);
}

.profile-btn.active {
  background-color: rgba(37, 99, 235, 0.12);
  border-color: var(--accent-primary);
  color: var(--text-main);
  font-weight: 600;
}

.profile-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-text);
  background-color: var(--accent-primary);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-xs);
}

/* Segmented Control (Tabs) */
.segmented-control {
  display: flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 4px;
  margin-top: 0.25rem;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.segment-btn.active {
  background-color: var(--bg-surface-raised);
  color: var(--text-main);
  border: 1px solid var(--border-dim);
}

.segment-btn:hover:not(.active) {
  color: var(--text-main);
}

/* Target Size Control */
.input-with-unit {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  height: 48px;
  margin-top: 0.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-with-unit:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.num-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.6rem 0;
  width: 100%;
  outline: none;
}

.unit-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.range-slider-wrapper {
  margin: 1.15rem 0 1rem;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: var(--border-base);
  border-radius: 3px;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-surface);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Preset Buttons Grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.preset-btn {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 0.65rem 0.45rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--border-base);
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.04);
}

.preset-btn.active {
  background-color: rgba(37, 99, 235, 0.2);
  border-color: var(--accent-primary);
  color: #93c5fd;
  font-weight: 600;
}

/* Dimension Constraints Inputs */
.dim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.35rem;
}

.dim-box {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0; /* Prevents grid column blowout from intrinsic input width */
}

.dim-label {
  font-size: 0.74rem;
  color: var(--text-faint);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dim-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dim-input::placeholder {
  color: var(--text-faint);
  opacity: 0.7;
}

.dim-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Remove number input spinner steppers for clean minimalist appearance */
.dim-input::-webkit-outer-spin-button,
.dim-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dim-input[type="number"],
.num-input[type="number"] {
  -moz-appearance: textfield;
}

/* Radio Group */
.radio-tile-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.radio-tile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-tile:hover {
  border-color: var(--border-base);
  background-color: rgba(255, 255, 255, 0.03);
}

.radio-tile input[type="radio"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
}

.radio-tile-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.radio-tile-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
}

.radio-tile-desc {
  font-size: 0.74rem;
  color: var(--text-faint);
  line-height: 1.35;
}

/* Work Area (Right Column - Sticky) */
.work-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-right: 4px;
}

.work-area::-webkit-scrollbar {
  width: 5px;
}

.work-area::-webkit-scrollbar-track {
  background: transparent;
}

.work-area::-webkit-scrollbar-thumb {
  background-color: var(--border-base);
  border-radius: 4px;
}

.work-area::-webkit-scrollbar-thumb:hover {
  background-color: var(--border-focus);
}

/* Dropzone */
.dropzone {
  background-color: var(--bg-surface);
  border: 1.5px dashed var(--border-base);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-primary);
  background-color: var(--bg-surface-raised);
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.dropzone-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.dropzone-subtitle {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: 1.25rem;
}

/* Privacy & Zero Data Storage Disclaimer Badge */
.privacy-disclaimer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.35rem;
  padding: 0.55rem 1.15rem;
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 9999px;
  max-width: 95%;
  transition: all 0.2s ease;
  user-select: none;
}

.privacy-disclaimer-pill:hover {
  border-color: var(--success-text);
  background-color: rgba(34, 197, 94, 0.16);
}

.privacy-shield-icon {
  color: var(--success-text);
  flex-shrink: 0;
}

.privacy-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: left;
}

.privacy-text strong {
  color: var(--success-text);
  font-weight: 600;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.12s ease;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  color: #ffffff;
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-dim);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.12s ease;
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-base);
}

.btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.12s ease;
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.2);
}

/* Local Directory Card */
.local-folder-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.panel-header p {
  font-size: 0.82rem;
  color: var(--text-faint);
  margin-top: 0.2rem;
}

.path-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.path-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.path-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.path-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-main);
  margin-top: 0.25rem;
  word-break: break-all;
}

.btn-execute {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.15s ease;
}

.btn-execute:hover {
  background-color: var(--accent-primary-hover);
}

.btn-execute:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Results / Queue Section */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Metrics Overview Bar */
.metrics-bar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.15rem;
}

.metric-value.success {
  color: var(--success-text);
}

/* Table / List View */
.table-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header-bar h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.files-table th {
  background-color: var(--bg-surface-raised);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-dim);
}

.files-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-dim);
  font-size: 0.85rem;
  vertical-align: middle;
}

.files-table tr:last-child td {
  border-bottom: none;
}

.files-table tr:hover td {
  background-color: var(--bg-hover);
}

.cell-file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 320px;
}

.table-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  cursor: pointer;
  flex-shrink: 0;
}

.file-name-wrapper {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name {
  font-weight: 500;
  color: var(--text-main);
}

.badge-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
}

.badge-saved {
  background-color: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge-neutral {
  background-color: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-dim);
}

.badge-error {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.mono-num {
  font-family: var(--font-mono);
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-table-icon {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-table-icon:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-base);
}

/* ==========================================================================
   Analytics Dashboard Styles
   ========================================================================== */

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.analytics-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.analytics-title p {
  font-size: 0.82rem;
  color: var(--text-faint);
}

/* Analytics KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.kpi-num {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Format Distribution Bar */
.format-bar-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.format-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.format-bar-visual {
  height: 10px;
  background-color: var(--bg-input);
  border-radius: var(--radius-xs);
  display: flex;
  overflow: hidden;
}

.format-bar-segment {
  height: 100%;
  transition: width 0.3s ease;
}

.format-bar-legend {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

/* Filter Toolbar */
.toolbar-bar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  max-width: 650px;
}

.search-input-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  flex: 1;
}

.search-input-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  width: 100%;
}

.select-filter {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Empty State */
.empty-history-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 4rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

.empty-history-box svg {
  color: var(--text-faint);
  width: 40px;
  height: 40px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  max-width: 960px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

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

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
}

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

.modal-body {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.preview-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.preview-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Toast */
.toast-shelf {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-base);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}


/* ==========================================================================
   Admin Authentication Portal Styles
   ========================================================================== */

.admin-login-wrapper {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.admin-login-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

.admin-login-icon {
  width: 54px;
  height: 54px;
  background-color: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.2rem;
}

.admin-pass-input {
  width: 100%;
  box-sizing: border-box;
  background-color: var(--bg-input);
  border: 1px solid var(--border-base);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease;
}

.admin-pass-input:focus {
  border-color: var(--accent-primary);
}

.auth-error-banner {
  background-color: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger-text);
  font-size: 0.8rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: left;
}

/* ==========================================================================
   Curtain Diff Slider & Interactive Comparison Styles
   ========================================================================== */

.modal-card-curtain {
  max-width: 980px;
  width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.modal-view-mode {
  display: inline-flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.mode-tab.active {
  background-color: var(--bg-hover);
  color: var(--text-main);
  font-weight: 600;
}

.zoom-controls {
  display: inline-flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.zoom-btn.active, .zoom-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

.curtain-viewport-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background-color: #0b0d13;
  border-radius: var(--radius-sm);
  margin: 1rem 1.25rem 1.25rem 1.25rem;
  border: 1px solid var(--border-dim);
  overflow: hidden;
}

.curtain-viewport {
  position: relative;
  flex: 1;
  min-height: 380px;
  max-height: 65vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  cursor: ew-resize;
  background-image: 
    linear-gradient(45deg, #11141d 25%, transparent 25%), 
    linear-gradient(-45deg, #11141d 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #11141d 75%), 
    linear-gradient(-45deg, transparent 75%, #11141d 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.curtain-img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
}

.curtain-clipped-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

.curtain-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
  z-index: 10;
  pointer-events: none;
}

.curtain-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  background-color: #1e293b;
  border: 2px solid var(--accent-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  cursor: ew-resize;
  pointer-events: auto;
}

.curtain-badge {
  position: absolute;
  top: 1rem;
  padding: 0.4rem 0.75rem;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  color: var(--text-faint);
  z-index: 5;
  pointer-events: none;
}

.curtain-badge strong {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
}

.curtain-badge-left {
  left: 1rem;
}

.curtain-badge-right {
  right: 1rem;
  text-align: right;
}

.curtain-toolbar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-dim);
}

.curtain-meta-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Watermark & Settings Helpers */
.watermark-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.toggle-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 0.25rem;
}

.toggle-pill:hover {
  border-color: var(--border-base);
  background-color: rgba(255, 255, 255, 0.03);
}

.toggle-pill.active {
  border-color: rgba(34, 197, 94, 0.4);
  background-color: rgba(34, 197, 94, 0.08);
}

.toggle-pill input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* --- SIDEBAR ACCORDION SYSTEM --- */
.sidebar-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.25rem 0.75rem;
  border-bottom: 1px solid var(--border-dim);
  margin-bottom: 0.2rem;
}

.sidebar-main-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.btn-sidebar-toggle {
  background: none;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 0.25rem 0.65rem;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-sidebar-toggle:hover {
  border-color: var(--border-base);
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-accordion {
  border: 1px solid var(--border-dim);
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.sidebar-accordion:hover {
  border-color: var(--border-base);
}

.sidebar-accordion.is-open {
  border-color: var(--border-base);
  box-shadow: none;
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
}

.accordion-header:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.accordion-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.accordion-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.sidebar-accordion.is-open .accordion-num {
  color: var(--accent-primary);
}

.accordion-title {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.12s ease;
  white-space: nowrap;
}

.sidebar-accordion.is-open .accordion-title {
  color: var(--text-main);
}

.accordion-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.accordion-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-faint);
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-xs);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accordion-pill.accent {
  color: var(--accent-primary);
  border-color: rgba(37, 99, 235, 0.35);
  background-color: rgba(37, 99, 235, 0.08);
  font-weight: 600;
}

.accordion-chevron {
  color: var(--text-faint);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
  flex-shrink: 0;
}

.sidebar-accordion.is-open .accordion-chevron {
  transform: rotate(180deg);
  color: var(--text-main);
}

.accordion-body {
  padding: 0.4rem 1.1rem 1.25rem 1.1rem;
  display: none;
}

.sidebar-accordion.is-open .accordion-body {
  display: block;
}

/* --- PATTERN & PRESET CHIPS STYLING --- */
.pattern-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.65rem 0.85rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pattern-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.preset-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.preset-chip {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-xs);
  padding: 0.32rem 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}

.preset-chip:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-base);
  color: var(--text-main);
}

.preset-chip.active {
  background-color: rgba(37, 99, 235, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

/* --- UPLOAD & SKELETON LOADER BANNER --- */
.upload-loader-banner {
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-base);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  transition: opacity 0.3s ease;
}

.upload-loader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.upload-loader-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.upload-loader-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border-base);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: upload-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes upload-spin {
  to { transform: rotate(360deg); }
}

.upload-loader-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.upload-loader-text strong {
  font-size: 0.88rem;
  color: var(--text-main);
}

.upload-loader-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.upload-loader-count {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-primary);
  background-color: rgba(37, 99, 235, 0.12);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-xs);
}

.upload-progress-track {
  width: 100%;
  height: 4px;
  background-color: var(--border-dim);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), #38bdf8);
  border-radius: 2px;
  transition: width 0.2s ease-out;
}

/* --- SKELETON SHIMMER LOADING STRUCTURE --- */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-input) 20%,
    var(--bg-hover) 50%,
    var(--bg-input) 80%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
  border-radius: var(--radius-xs);
  display: inline-block;
}

[data-theme="light"] .skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #e2e8f0 20%,
    #f8fafc 50%,
    #e2e8f0 80%
  );
  background-size: 200% 100%;
}

.skeleton-row {
  pointer-events: none;
  user-select: none;
}

.skeleton-row td {
  border-bottom: 1px solid var(--border-dim);
}

.skeleton-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.skeleton-line {
  height: 12px;
  border-radius: 3px;
}

.skeleton-line.w-long {
  width: 140px;
  max-width: 85%;
}

.skeleton-line.w-med {
  width: 85px;
  max-width: 60%;
}

.skeleton-line.w-sm {
  width: 45px;
}

.skeleton-badge {
  width: 85px;
  height: 20px;
  border-radius: var(--radius-xs);
}

.skeleton-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
}

@keyframes row-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-loaded {
  animation: row-fade-in 0.28s ease-out forwards;
}

/* --- CONVERT ACTION BANNER --- */
.convert-banner {
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: none;
  flex-wrap: wrap;
}

.convert-banner-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #3b82f6;
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  animation: pulse-ring 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
  flex-shrink: 0;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(59, 130, 246, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.convert-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.convert-banner-text strong {
  font-size: 0.88rem;
  color: var(--text-main);
}

.convert-banner-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.badge-size-target {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-primary);
  background-color: rgba(37, 99, 235, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
}

.btn-convert-execute {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 0.15s ease;
}

.btn-convert-execute:hover {
  background-color: var(--accent-primary-hover);
  color: #ffffff;
  box-shadow: none;
  transform: translateY(-1px);
}

.btn-convert-execute:active {
  transform: translateY(0);
}

.btn-convert-execute:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Disabled action button state */
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==========================================================================
   Theme Switcher & PWA Install Controls
   ========================================================================== */
.theme-toggle-btn {
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--border-base);
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.pwa-install-btn {
  background-color: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: var(--accent-primary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pwa-install-btn:hover {
  background-color: var(--accent-primary);
  color: #ffffff;
}

/* ==========================================================================
   Custom Profile Presets UI
   ========================================================================== */
.btn-add-profile {
  background-color: transparent;
  border: 1px dashed var(--border-base);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  width: 100%;
  margin-top: 0.4rem;
}

.btn-add-profile:hover {
  border-color: var(--accent-primary);
  color: var(--text-main);
  background-color: rgba(37, 99, 235, 0.08);
}

.profile-btn-custom-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.profile-btn-custom-wrap .profile-btn {
  flex: 1;
}

.btn-delete-preset {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-delete-preset:hover {
  color: var(--danger-text);
  border-color: var(--danger-text);
  background-color: var(--danger-bg);
}

.modal-card-preset {
  max-width: 440px;
  width: 90%;
}

/* ==========================================================================
   Table Row Drag-and-Drop (Reorder for PDF)
   ========================================================================== */
.drag-col {
  width: 32px !important;
  text-align: center !important;
  padding: 0.5rem 0.2rem !important;
}

.drag-handle {
  color: var(--text-faint);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-xs);
  user-select: none;
  transition: all 0.15s ease;
}

.drag-handle:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.drag-handle:active {
  cursor: grabbing;
}

tr.is-dragging {
  opacity: 0.35;
  background-color: rgba(37, 99, 235, 0.1) !important;
}

tr.drag-over-above td {
  border-top: 2px solid var(--accent-primary) !important;
}

tr.drag-over-below td {
  border-bottom: 2px solid var(--accent-primary) !important;
}

/* ==========================================================================
   Visual Quality Badges (SSIM & PSNR)
   ========================================================================== */
.badge-quality {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-base);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-quality.high-quality {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--success-text);
  background-color: rgba(34, 197, 94, 0.08);
}

/* ==========================================================================
   Interactive Canvas Crop & Rotate Modal
   ========================================================================== */
.modal-card-crop {
  max-width: 860px;
  width: 95vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.crop-modal-body {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.85rem;
  overflow: hidden;
}

.crop-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-base);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
}

.crop-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.crop-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
}

.crop-ratio-btn-group {
  display: inline-flex;
  background-color: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.crop-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.crop-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-hover);
}

.crop-btn.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
}

.crop-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 480px;
  max-height: 55vh;
  background-color: #0b0f19;
  background-image: 
    linear-gradient(45deg, #131b2e 25%, transparent 25%), 
    linear-gradient(-45deg, #131b2e 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #131b2e 75%), 
    linear-gradient(-45deg, transparent 75%, #131b2e 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

#cropCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.crop-box {
  position: absolute;
  border: 2px dashed #3b82f6;
  outline: 9999px solid rgba(0, 0, 0, 0.55);
  cursor: move;
  box-sizing: border-box;
  touch-action: none;
}

.crop-grid-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

.crop-grid-lines::before,
.crop-grid-lines::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.crop-grid-lines::before {
  top: 33.333%;
  bottom: 33.333%;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.35);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.35);
}

.crop-grid-lines::after {
  left: 33.333%;
  right: 33.333%;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.35);
  border-right: 1px dashed rgba(255, 255, 255, 0.35);
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background-color: #ffffff;
  border: 2px solid #2563eb;
  border-radius: 2px;
  box-sizing: border-box;
  z-index: 10;
}

.crop-handle.nw {
  top: -6px;
  left: -6px;
  cursor: nwse-resize;
}

.crop-handle.ne {
  top: -6px;
  right: -6px;
  cursor: nesw-resize;
}

.crop-handle.sw {
  bottom: -6px;
  left: -6px;
  cursor: nesw-resize;
}

.crop-handle.se {
  bottom: -6px;
  right: -6px;
  cursor: nwse-resize;
}

.crop-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-base);
}

.crop-dims {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   SEO Content & FAQ Section Styles
   ========================================================================== */
.seo-section {
  max-width: 1480px;
  margin: 3.5rem auto 2rem;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.seo-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.seo-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.seo-card p, .seo-card li {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-top: 0.25rem;
}

.seo-feature-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 1.35rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.seo-feature-box h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.seo-feature-box p {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* FAQ Accordions */
.seo-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-item:hover {
  border-color: var(--border-base);
}

.faq-question {
  padding: 1rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--accent-primary);
  font-weight: 400;
}

.faq-item[open] .faq-question::after {
  content: '−';
}

.faq-answer {
  padding: 0 1.25rem 1.15rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.seo-footer {
  text-align: center;
  padding: 1.5rem 0 1rem;
  font-size: 0.8rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border-dim);
}

/* ==========================================================================
   Comprehensive Mobile & Tablet Responsive Design System
   ========================================================================== */

/* Tablet & Intermediate Viewports (<= 1120px) */
@media (max-width: 1120px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 1.75rem;
    padding: 1.5rem 1.25rem;
  }
  .work-area {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }
}

/* Mobile & Narrow Viewports (<= 860px) */
/* Reorders work area above sidebar, expands dropzone touch targets, stacks convert banner */
@media (max-width: 860px) {
  .main-layout {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1rem 0.75rem;
    width: 100%;
    box-sizing: border-box;
  }

  /* Invert Visual Flow: Work Area (Dropzone & Queue) First, Controls Second */
  .work-area {
    order: 1;
    position: static;
    max-height: none;
    overflow-y: visible;
    width: 100%;
    padding-right: 0;
  }

  .config-sidebar {
    order: 2;
    width: 100%;
    position: static;
    padding: 1.1rem 0.9rem;
    box-sizing: border-box;
  }

  /* Mobile Dropzone: Large touch target, hide desktop-only directory picker */
  .dropzone {
    padding: 2rem 1rem;
    min-height: 180px;
  }

  .dropzone-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
  }

  .dropzone-title {
    font-size: 1rem;
  }

  .dropzone-subtitle {
    font-size: 0.8rem;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
  }

  .dropzone .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 0.92rem;
  }

  .hide-on-mobile {
    display: none !important;
  }

  /* Metrics Summary Bar: 2x2 grid */
  .metrics-bar {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
  }

  .metric-item {
    padding: 0.2rem 0.35rem;
  }

  .metric-title {
    font-size: 0.68rem;
  }

  .metric-value {
    font-size: 1.05rem;
  }

  /* Two-Stage Convert Banner: Full-width stacked */
  .convert-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
  }

  .convert-banner-left {
    flex-direction: column;
    text-align: center;
    gap: 0.4rem;
  }

  .btn-convert-execute {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 0.9rem;
  }

  /* Queue Table Header & Batch Action Buttons */
  .table-header-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .table-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .table-actions .btn-primary,
  .table-actions .btn-execute {
    grid-column: span 2;
    justify-content: center;
    min-height: 46px;
    font-size: 0.88rem;
  }

  .table-actions .btn-secondary {
    justify-content: center;
    min-height: 44px;
    font-size: 0.82rem;
  }

  .accordion-pill {
    max-width: 100px;
  }
}

/* Smartphone Portrait & Card View (<= 768px) */
/* Transforms rigid 6-column table into responsive touch-friendly cards */
@media (max-width: 768px) {
  .files-table,
  .files-table tbody,
  .files-table tr,
  .files-table td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .files-table thead {
    display: none;
  }

  .files-table {
    background: transparent;
    border: none;
    border-radius: 0;
  }

  .files-table tr {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    margin-bottom: 0.85rem;
    box-sizing: border-box;
    box-shadow: none;
  }

  .files-table tr:hover td {
    background-color: transparent;
  }

  /* Hide drag reorder handle on mobile since tap & scroll interferes */
  .files-table td.drag-col {
    display: none !important;
  }

  /* File thumbnail & name header of card */
  .files-table td.file-col {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0 0 0.55rem 0;
    border-bottom: 1px solid var(--border-dim);
  }

  .files-table td.file-col .cell-file {
    max-width: 100%;
    width: 100%;
    gap: 0.75rem;
  }

  .files-table .table-thumb,
  .files-table .skeleton-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
  }

  .files-table .file-name {
    font-size: 0.88rem;
    line-height: 1.3;
  }

  /* Key-value rows inside the card */
  .files-table td[data-label] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    border: none;
    font-size: 0.84rem;
  }

  .files-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-faint);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Card footer with 44px touch action buttons */
  .files-table td.actions-col {
    border-top: 1px solid var(--border-dim);
    margin-top: 0.5rem;
    padding: 0.65rem 0 0 0;
    display: block;
  }

  .files-table td.actions-col::before {
    display: none;
  }

  .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }

  .row-actions .btn-table-icon {
    width: 100%;
    height: 44px;
    border-radius: var(--radius-sm);
    justify-content: center;
  }

  .row-actions .btn-table-icon svg {
    width: 16px;
    height: 16px;
  }

  /* Admin Analytics View on Mobile */
  .analytics-view-container {
    padding: 1rem 0.75rem;
    gap: 1.25rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .toolbar-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .toolbar-left {
    flex-direction: column;
    max-width: 100%;
  }

  .search-input-box {
    width: 100%;
  }

  .toolbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .toolbar-right .select-filter {
    flex: 1;
    min-height: 38px;
  }

  .path-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  /* SEO Section Mobile */
  .seo-section {
    padding: 0 0.75rem;
    margin: 2rem auto 1.5rem;
  }

  .seo-card {
    padding: 1.5rem 1.15rem;
  }

  .seo-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .faq-question {
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
  }

  .faq-answer {
    padding: 0 1rem 1rem;
    font-size: 0.84rem;
  }
}

/* Modals & Dialogs on Mobile (<= 600px) */
/* Bottom-sheet modals with touch-friendly hit areas */
@media (max-width: 600px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card,
  .modal-card-curtain,
  .modal-card-crop,
  .modal-card-preset {
    width: 100%;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    margin: 0;
    box-sizing: border-box;
  }

  .modal-header {
    padding: 0.85rem 1rem;
  }

  .modal-body {
    padding: 1rem;
    gap: 1rem;
    grid-template-columns: 1fr;
  }

  /* Interactive Crop Modal Mobile Layout */
  .crop-modal-body {
    padding: 0.75rem;
    gap: 0.65rem;
    overflow-y: auto;
  }

  .crop-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
  }

  .crop-group {
    justify-content: space-between;
    width: 100%;
  }

  .crop-ratio-btn-group {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding: 2px;
    scrollbar-width: none;
  }

  .crop-ratio-btn-group::-webkit-scrollbar {
    display: none;
  }

  .crop-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.72rem;
    white-space: nowrap;
    min-height: 34px;
  }

  .crop-canvas-wrapper {
    height: 280px;
    max-height: 40vh;
  }

  /* Crop Handle Enlarged Touch Area */
  .crop-handle {
    width: 20px;
    height: 20px;
  }

  .crop-handle::after {
    content: '';
    position: absolute;
    inset: -12px;
  }

  .crop-handle.nw { top: -10px; left: -10px; }
  .crop-handle.ne { top: -10px; right: -10px; }
  .crop-handle.sw { bottom: -10px; left: -10px; }
  .crop-handle.se { bottom: -10px; right: -10px; }

  /* Curtain / Interactive Comparison Modal */
  .curtain-viewport-container {
    margin: 0.5rem;
  }

  .curtain-viewport {
    min-height: 260px;
    max-height: 45vh;
  }

  .curtain-handle {
    width: 40px;
    height: 40px;
  }

  .curtain-badge {
    font-size: 0.68rem;
    padding: 0.3rem 0.5rem;
  }

  .curtain-toolbar-footer {
    flex-direction: column;
    gap: 0.65rem;
    align-items: stretch;
    padding: 0.65rem 0.75rem;
  }

  .curtain-meta-info {
    justify-content: space-between;
  }

  .curtain-toolbar-footer .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  /* Phone Sync QR Modal */
  #mobileConnectModal .modal-card {
    padding-bottom: 1rem;
  }

  #mobileConnectModal #qrCodeContainer {
    min-width: auto;
    min-height: auto;
    padding: 10px;
    width: 200px;
    height: 200px;
  }

  #mobileConnectModal #qrCodeContainer canvas,
  #mobileConnectModal #qrCodeContainer img {
    width: 180px !important;
    height: 180px !important;
  }

  .toast-shelf {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
  }
}

/* Extra-Compact Smartphone (<= 480px) */
/* Icon-only header buttons, iOS 16px input zoom fix */
@media (max-width: 480px) {
  .app-header {
    padding: 0 0.65rem;
    height: 56px;
    gap: 0.25rem;
  }

  .brand-wrapper {
    gap: 0.45rem;
  }

  .brand-badge {
    width: 30px;
    height: 30px;
  }

  .brand-badge svg {
    width: 16px;
    height: 16px;
  }

  .brand-info h1 {
    font-size: 0.9rem;
  }

  .brand-info p {
    display: none;
  }

  .header-actions {
    gap: 0.25rem !important;
  }

  .btn-text {
    display: none;
  }

  #statusText {
    display: none;
  }

  .header-status {
    padding: 0.35rem 0.45rem;
    min-width: auto;
  }

  #mobileConnectBtn,
  .pwa-install-btn,
  .theme-toggle-btn,
  a.btn-secondary[href="admin.html"],
  a.btn-secondary[href="index.html"] {
    padding: 0.35rem 0.5rem !important;
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .metrics-bar {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  /* Prevent automatic iOS Safari zoom when focusing text inputs */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }
}



