﻿/* ========================================================================
   DocFit — desktop / tablet styles
   ======================================================================== */

:root {
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --surface-dark: #0f172a;
  --text: #0f172a;
  --muted: #64748b;
  --muted-dark: #475569;
  --line: #e2e8f0;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;

  --purple: #7c3aed;
  --purple-dark: #6d28d9;
  --purple-soft: #f5f3ff;

  --green: #10b981;
  --green-dark: #059669;
  --green-soft: #ecfdf5;

  --danger: #dc3545;
  --danger-soft: #fef2f2;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.3);
  --radius: 16px;
  --radius-lg: 20px;
}

[data-theme="dark"] {
  --background: #0b1220;
  --surface: #131a2b;
  --surface-soft: #182138;
  --surface-dark: #0a1120;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted-dark: #cbd5e1;
  --line: #1e2a44;

  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-soft: #1e293b;

  --purple: #a78bfa;
  --purple-dark: #8b5cf6;
  --purple-soft: #241e3a;

  --green: #34d399;
  --green-dark: #10b981;
  --green-soft: #143026;

  --danger: #f87171;
  --danger-soft: #3a1d1d;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .ba-frame,
[data-theme="dark"] .result-preview,
[data-theme="dark"] .history-thumb,
[data-theme="dark"] .file-card-thumb,
[data-theme="dark"] .preview-image-wrap {
  background-color: #0f1829;
}
[data-theme="dark"] .ba-frame {
  background:
    linear-gradient(45deg, #141d30 25%, transparent 25%),
    linear-gradient(-45deg, #141d30 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #141d30 75%),
    linear-gradient(-45deg, transparent 75%, #141d30 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #0f1829;
}
[data-theme="dark"] .upload-zone { background: #0f1829; border-color: #2a3b5c; }
[data-theme="dark"] .upload-zone:hover,
[data-theme="dark"] .upload-zone.dragover { background: #16213a; border-color: var(--primary); }
[data-theme="dark"] .file-card,
[data-theme="dark"] .range-grid,
[data-theme="dark"] .info-panel,
[data-theme="dark"] .toggle-block { background: var(--surface-soft); }
[data-theme="dark"] .coming-soon-modal,
[data-theme="dark"] .prompt-modal,
[data-theme="dark"] .preview-modal { background: var(--surface); color: var(--text); }
[data-theme="dark"] .preview-close { background: var(--surface-soft); color: var(--text); }
[data-theme="dark"] .secondary-button { color: var(--text); background: var(--surface-soft); }
[data-theme="dark"] .secondary-button:hover { background: #1e2a44; }
[data-theme="dark"] .segmented { background: var(--surface-soft); }
[data-theme="dark"] .segment.active { background: var(--surface); color: var(--primary); }
[data-theme="dark"] .file-card-item { background: var(--surface); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

img, svg, canvas { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 24px 16px 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand { display: flex; align-items: center; padding: 4px 8px 0; margin-bottom: 28px; }
.brand-logo { height: 44px; width: auto; }

.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav-bottom { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted-dark);
  font-size: 14px; font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.nav-item:hover { color: var(--primary); background: var(--primary-soft); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.nav-icon { width: 22px; text-align: center; font-size: 17px; line-height: 1; }

.sidebar-footer {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: auto; padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.sidebar-footer strong { display: block; font-size: 12px; }
.sidebar-footer p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }

.privacy-icon {
  width: 22px; height: 22px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--green); background: var(--green-soft);
  font-size: 12px; font-weight: 800;
}

.main-content {
  width: calc(100% - 248px);
  margin-left: 248px;
  padding: 0 40px 60px;
  min-height: 100vh;
}

.view { display: block; }
.view.hidden { display: none; }

.topbar {
  height: 76px;
  display: flex; align-items: center; gap: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.mobile-brand { display: none; }
.brand-mark-img { width: 32px; height: 32px; }

.page-title h1 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }
.page-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.topbar-search {
  flex: 1; max-width: 440px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 42px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.topbar-search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 13px; color: var(--text); }
.topbar-search input::placeholder { color: #94a3b8; }
.search-icon { color: #94a3b8; font-size: 14px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.icon-ghost {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  border-radius: 10px;
  font-size: 17px; color: var(--muted-dark);
}
.icon-ghost:hover { background: var(--surface-soft); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 14px 5px 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.user-chip:hover { border-color: var(--primary); background: var(--primary-soft); }

.user-avatar {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary); color: white;
  font-weight: 800; font-size: 13px;
}
.user-meta { text-align: left; }
.user-meta strong { display: block; font-size: 12px; line-height: 1.1; }
.user-meta span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }

.welcome-section {
  display: flex; align-items: center; justify-content: space-between;
  gap: 40px; padding: 12px 0 36px;
}
.welcome-section h1 {
  margin: 0;
  font-size: clamp(28px, 3.6vw, 44px);
  line-height: 1.1; letter-spacing: -0.045em;
}
.welcome-text {
  max-width: 560px; margin: 14px 0 0;
  color: var(--muted); font-size: 15px; line-height: 1.65;
}

.welcome-illustration { position: relative; width: 300px; flex: 0 0 300px; text-align: center; }
.illus-stack { position: relative; height: 170px; }

.illus-card {
  position: absolute; width: 190px; height: 120px;
  padding: 12px; border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
}
.illus-card-a { left: 0; top: 10px; transform: rotate(-6deg); }
.illus-card-b { right: 0; bottom: 0; transform: rotate(6deg); background: #eef2ff; }
[data-theme="dark"] .illus-card-b { background: #1e293b; }

.illus-photo {
  width: 70px; height: 70px; margin: 8px auto 0; border-radius: 8px;
  background:
    radial-gradient(circle at 50% 32%, #f3c6a9 0 18%, transparent 19%),
    radial-gradient(ellipse at 50% 82%, #334155 0 28%, transparent 29%),
    linear-gradient(135deg, #dbeafe, #eff6ff);
}
.illus-signature {
  margin-top: 26px; color: var(--primary);
  font-family: "Brush Script MT", cursive;
  font-size: 30px; transform: rotate(-6deg);
}
.illus-badge {
  position: absolute; right: 8px; top: 0;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary); color: white;
  font-size: 18px; font-weight: 800;
  box-shadow: var(--shadow-md);
}
.illus-caption {
  margin: 8px 0 0; color: var(--primary);
  font-family: "Brush Script MT", cursive;
  font-size: 22px; transform: rotate(-4deg);
}

.tool-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 30px; }

.tool-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 24px; border-radius: var(--radius-lg);
  color: white;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-md);
}
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(15, 23, 42, 0.15); }

.tool-card-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.tool-card-purple { background: linear-gradient(135deg, #a78bfa, #6d28d9); }
.tool-card-green  { background: linear-gradient(135deg, #34d399, #059669); }

.tool-card-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 22px;
}
.tool-card h3 { margin: 4px 0 0; font-size: 19px; letter-spacing: -0.02em; }
.tool-card p { margin: 0; font-size: 13px; line-height: 1.5; opacity: 0.92; }

.tool-card-cta {
  margin-top: auto; padding: 9px 16px;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-radius: 8px;
  font-size: 13px; font-weight: 700;
}

.dashboard-row { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 18px; margin-bottom: 40px; }

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.panel-header h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.panel-link { color: var(--primary); font-size: 12px; font-weight: 700; cursor: pointer; }

.stats-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.stats-list li { display: flex; align-items: center; gap: 12px; }
.stats-list strong { display: block; font-size: 22px; letter-spacing: -0.02em; line-height: 1; }
.stats-list span:not(.stat-badge) { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.stat-badge { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; font-size: 18px; }
.stat-badge-blue { background: var(--primary-soft); color: var(--primary); }
.stat-badge-purple { background: var(--purple-soft); color: var(--purple); }
.stat-badge-green { background: var(--green-soft); color: var(--green); }

.why-panel { background: linear-gradient(140deg, #1e3a8a, #0f172a); color: white; border: 0; }
.why-panel h2 { margin: 0 0 14px; font-size: 16px; }
.why-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.why-list li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.why-list li span {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: white; font-size: 10px; font-weight: 800;
}
.why-cta {
  display: inline-block; padding: 9px 16px;
  background: white; color: #0f172a;
  border-radius: 8px; font-size: 12px; font-weight: 700;
}

.tool-section { margin-top: 40px; scroll-margin-top: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-kicker {
  margin: 0 0 6px; color: var(--primary);
  font-size: 10px; font-weight: 800; letter-spacing: 0.14em;
}
.section-heading h2 { margin: 0; font-size: 24px; letter-spacing: -0.025em; }
.section-heading p:not(.section-kicker) { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.workspace-card {
  display: grid;
  grid-template-columns: minmax(190px, 0.75fr) minmax(270px, 1.1fr) minmax(240px, 1fr);
  gap: 22px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

#photo-tools .workspace-card,
#signature-tools .workspace-card,
#image-tools .workspace-card {
  grid-template-columns: minmax(340px, 1.4fr) minmax(300px, 1fr);
}

.preview-column { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.preview-header h3 { margin: 0; font-size: 15px; }

.before-after-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ba-item { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.ba-label {
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase;
}
.ba-label-result { color: var(--green); }

.ba-frame {
  position: relative;
  min-height: 220px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #ffffff;
}

.ba-frame-result { border-color: #bbf7d0; }
.ba-frame img { max-width: 100%; max-height: 210px; object-fit: contain; border-radius: 6px; }
.signature-frame img { background-color: transparent; padding: 0; }

.ba-meta {
  font-size: 10.5px; color: var(--muted);
  line-height: 1.4; min-height: 28px;
  overflow-wrap: anywhere;
}

.crop-overlay {
  position: absolute;
  top: 12px; left: 12px; right: 12px; bottom: 12px;
  cursor: crosshair;
  background: transparent;
}
.crop-box {
  position: absolute;
  border: 2px solid var(--primary);
  background: rgba(37, 99, 235, 0.15);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45);
  cursor: move;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.crop-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  z-index: 3;
}
.crop-handle-tl { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-handle-tr { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-handle-bl { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-handle-br { bottom: -8px; right: -8px; cursor: nwse-resize; }

.crop-handle-edge {
  position: absolute;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 3;
}
.crop-handle-n { top: -6px; left: 50%; transform: translateX(-50%); width: 26px; height: 12px; cursor: ns-resize; }
.crop-handle-s { bottom: -6px; left: 50%; transform: translateX(-50%); width: 26px; height: 12px; cursor: ns-resize; }
.crop-handle-w { left: -6px; top: 50%; transform: translateY(-50%); width: 12px; height: 26px; cursor: ew-resize; }
.crop-handle-e { right: -6px; top: 50%; transform: translateY(-50%); width: 12px; height: 26px; cursor: ew-resize; }

.crop-controls {
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.crop-hint { font-size: 11px; color: var(--muted); }
.crop-actions { display: flex; gap: 8px; }

.crop-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px dashed #c7d2fe;
  border-radius: 10px;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 14px;
  transition: all 0.15s ease;
}
.crop-toggle:hover { background: var(--primary-soft); border-color: var(--primary); }
.crop-toggle.active { background: var(--primary-soft); border-style: solid; }

.compact-upload {
  min-height: auto; flex-direction: row; text-align: left;
  gap: 14px; padding: 14px; border-radius: 12px;
}
.compact-upload .upload-symbol { margin: 0; flex: 0 0 auto; width: 40px; height: 40px; font-size: 20px; }
.signature-compact { border-color: #ddd6fe; }
.signature-compact .upload-symbol { color: var(--purple); background: var(--purple-soft); }

.upload-copy { flex: 1; min-width: 0; }
.upload-copy strong { display: block; font-size: 13px; margin-bottom: 3px; }
.upload-copy span { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.4; }

.upload-zone {
  min-height: 250px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 22px 16px; text-align: center;
  border: 1.5px dashed #c7d2fe;
  border-radius: 14px;
  background: #fbfcff;
  transition: 0.2s ease;
  cursor: pointer;
}
.upload-zone.dragover, .upload-zone:hover { border-color: var(--primary); background: var(--primary-soft); }

.upload-symbol {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  margin-bottom: 12px; border-radius: 12px;
  color: var(--primary); background: var(--primary-soft);
  font-size: 24px; font-weight: 700;
}
.upload-zone h3 { margin: 0; font-size: 15px; }
.upload-zone p { max-width: 190px; margin: 8px 0 14px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.upload-zone small { margin-top: 10px; color: #94a3b8; font-size: 10px; }

.outline-button {
  padding: 9px 14px;
  color: var(--primary); background: var(--surface);
  border: 1px solid #c7d2fe;
  border-radius: 9px;
  font-size: 12px; font-weight: 700;
  flex: 0 0 auto;
}
.outline-button:hover { color: white; background: var(--primary); border-color: var(--primary); }

.file-card {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}
.file-thumbnail {
  width: 44px; height: 44px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  overflow: hidden; border-radius: 8px;
  background: #e8eefb;
}
.file-thumbnail.signature-thumbnail { background: white; }
.file-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.file-details { min-width: 0; flex: 1; }
.file-details strong, .file-details span {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-details strong { font-size: 11px; }
.file-details span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.icon-button {
  width: 26px; height: 26px; flex: 0 0 auto;
  display: grid; place-items: center;
  padding: 0; color: #94a3b8;
  background: transparent; border-radius: 50%;
  font-size: 20px; line-height: 1;
}
.icon-button:hover { color: var(--danger); background: #fff0f1; }

.settings-column, .result-column, .upload-column { min-width: 0; }

.settings-header, .result-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 16px;
}
.settings-header h3, .result-header h3 { margin: 0; font-size: 15px; }
.settings-header p, .result-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.settings-badge, .preview-status {
  padding: 5px 9px; border-radius: 6px;
  color: var(--primary); background: var(--primary-soft);
  font-size: 9px; font-weight: 800; letter-spacing: 0.06em;
}
.purple-badge { color: var(--purple); background: var(--purple-soft); }
.green-badge  { color: var(--green);  background: var(--green-soft); }
.preview-status { color: var(--muted); background: #f1f5f9; white-space: nowrap; }
.preview-status.ready { color: var(--green); background: var(--green-soft); }

.input-label {
  display: block; margin-bottom: 6px;
  color: var(--muted-dark); font-size: 10px; font-weight: 700;
}
.field-hint {
  margin: 6px 0 10px;
  font-size: 10.5px; color: var(--muted); line-height: 1.5;
}

.input-control, .color-control, .textarea {
  width: 100%;
  padding: 0 10px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none; font-size: 12px;
}
.input-control, .color-control { height: 38px; }
.textarea { padding: 10px; min-height: 90px; resize: vertical; font-family: inherit; line-height: 1.5; }
.input-control:focus, .color-control:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.color-control { padding: 4px; }

.field-grid, .range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px; margin-top: 12px;
}
.range-grid { margin-top: 16px; }

.range-heading { display: flex; align-items: center; justify-content: space-between; }
.range-heading output { color: var(--primary); font-size: 10px; font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
output#photoQualityValue,
output#signatureThresholdValue,
output#imageQualityValue,
output#setPhotoQualityValue,
output#setImageQualityValue { color: var(--primary); font-weight: 700; }

.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: #f1f5f9; border-radius: 10px; margin-bottom: 6px;
}
.segment {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 9px 6px;
  border: 0;
  background: transparent;
  color: var(--muted-dark);
  font-size: 12px; font-weight: 700;
  border-radius: 7px;
  transition: all 0.15s ease;
  line-height: 1.15;
}
.segment strong { font-size: 12px; font-weight: 800; }
.segment span { font-size: 10px; color: var(--muted); font-weight: 600; }
.segment:hover { color: var(--text); }
.segment.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.segment.active span { color: var(--primary); }

.toggle-block {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.toggle-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.toggle-row input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.toggle-switch {
  flex: 0 0 auto;
  width: 36px; height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.15s ease;
  margin-top: 2px;
}
.toggle-switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: transform 0.15s ease;
}
.toggle-row input[type="checkbox"]:checked + .toggle-switch { background: var(--primary); }
.toggle-row input[type="checkbox"]:checked + .toggle-switch::after { transform: translateX(16px); }

.toggle-label { min-width: 0; }
.toggle-label strong { display: block; font-size: 12px; }
.toggle-label small { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 3px; }

.toggle-extra {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 16px; }

.primary-button, .secondary-button, .text-button, .download-button {
  min-height: 40px; padding: 0 16px;
  border: 0; border-radius: 9px;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.primary-button.full-width { width: 100%; }
.primary-button.small { min-height: 32px; padding: 0 12px; font-size: 11px; }
.secondary-button.small { min-height: 32px; padding: 0 12px; font-size: 11px; }
.text-button.small { min-height: 32px; padding: 0 10px; font-size: 11px; }

.primary-button {
  color: white; background: var(--primary);
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.22);
}
.primary-button:hover { background: var(--primary-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.secondary-button { color: var(--text); background: #eef2f7; }
.secondary-button:hover { background: #e2e8f0; }
.secondary-button.danger { color: var(--danger); background: var(--danger-soft); }
.secondary-button.danger:hover { background: #fee2e2; }

.text-button { padding: 0 8px; color: var(--muted); background: transparent; }
.text-button:hover { color: var(--primary); }

/* Result actions row (Download / Copy / Share) */
.result-actions {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.result-actions .download-button {
  margin: 0;
  min-height: 40px;
  width: 100%;
}

.result-preview {
  min-height: 252px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.result-preview img {
  max-width: 100%; max-height: 220px;
  object-fit: contain; border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.empty-preview {
  display: flex; flex-direction: column; align-items: center;
  gap: 9px; color: #94a3b8; font-size: 11px; text-align: center;
}
.empty-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 14px;
  color: #b6c1d2;
  background: rgba(255, 255, 255, 0.8);
  font-size: 22px;
}
[data-theme="dark"] .empty-icon { background: var(--surface-soft); color: var(--muted); }

.result-meta {
  min-height: 40px;
  padding: 11px 0 2px;
  color: var(--muted);
  font-size: 11px; line-height: 1.5;
}

.download-button {
  color: white; background: var(--green);
}
.download-button:hover { background: var(--green-dark); }

.recent-files-list { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.recent-files-list::-webkit-scrollbar { display: none; }

.recent-file {
  min-width: 175px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.recent-file:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.recent-file img { width: 40px; height: 40px; flex: 0 0 auto; object-fit: cover; border-radius: 9px; }
.recent-file strong, .recent-file span {
  display: block; max-width: 100px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-file strong { font-size: 11px; }
.recent-file span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.recent-files-empty { color: var(--muted); font-size: 12px; }

.footer {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 18px;
  margin-top: 60px; padding-top: 26px;
  border-top: 1px solid var(--line);
}
.footer-logo { height: 34px; width: auto; }
.footer-features { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 22px; }
.footer-features li { display: flex; align-items: center; gap: 7px; color: var(--muted-dark); font-size: 12px; font-weight: 600; }
.footer-tag {
  margin: 0; color: var(--primary);
  font-family: "Brush Script MT", cursive;
  font-size: 20px; transform: rotate(-3deg);
}

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 100;
  max-width: 340px;
  padding: 12px 16px;
  color: white; background: #0f172a;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  opacity: 0; pointer-events: none;
  transform: translateY(12px);
  transition: 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.coming-soon-backdrop {
  position: fixed; inset: 0; z-index: 300;
  display: none; place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}
.coming-soon-backdrop:not([hidden]) { display: grid; }

.coming-soon-modal {
  width: min(420px, 100%);
  padding: 26px;
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.coming-soon-modal h2 { margin: 0 0 10px; font-size: 20px; }
.coming-soon-modal p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.prompt-backdrop {
  position: fixed; inset: 0; z-index: 310;
  display: none; place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}
.prompt-backdrop:not([hidden]) { display: grid; }

.prompt-modal {
  width: min(420px, 100%);
  padding: 24px;
  background: white;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.prompt-modal h2 { margin: 0 0 8px; font-size: 18px; }
.prompt-modal p { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.prompt-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.preview-backdrop {
  position: fixed; inset: 0; z-index: 320;
  display: none; place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
}
.preview-backdrop:not([hidden]) { display: grid; }

.preview-modal {
  position: relative;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px;
}
.preview-close {
  position: absolute; top: 12px; right: 12px;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--muted-dark);
  font-size: 14px;
  font-weight: 800;
}
.preview-close:hover { background: #e2e8f0; }

.preview-image-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 260px;
  padding: 12px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  border-radius: 12px;
  overflow: hidden;
}
.preview-image-wrap img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 8px;
}
.preview-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* HISTORY */
.history-tabs {
  display: flex; gap: 8px;
  margin-bottom: 20px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: fit-content;
  flex-wrap: wrap;
}
.history-tab {
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--muted-dark);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.15s ease;
}
.history-tab:hover { color: var(--primary); }
.history-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
}

.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  display: grid;
  grid-template-columns: 90px 24px 90px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}
.history-item:hover { border-color: #c7d2fe; }

.history-thumb {
  width: 90px; height: 70px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 4px;
  flex: 0 0 auto;
}
.history-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.history-arrow { text-align: center; color: var(--muted); font-size: 18px; font-weight: 800; }
.history-info { min-width: 0; }
.history-info-row1 { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; flex-wrap: wrap; }
.history-filename {
  font-size: 13.5px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 320px;
}
.history-type-badge {
  padding: 3px 9px; border-radius: 6px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase;
}
.history-type-photo { color: var(--primary); background: var(--primary-soft); }
.history-type-signature { color: var(--purple); background: var(--purple-soft); }
.history-type-image { color: var(--green); background: var(--green-soft); }
.history-info-row2 { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.history-info-row2 span { display: flex; align-items: center; gap: 4px; }
.history-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.history-action-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: var(--muted-dark);
  font-size: 15px;
  transition: all 0.15s ease;
}
.history-action-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.history-action-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.history-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 70px 20px; text-align: center;
}
.history-empty .empty-icon { width: 70px; height: 70px; font-size: 32px; }
.history-empty h2 { margin: 0; font-size: 20px; }
.history-empty p { margin: 0 0 12px; color: var(--muted); font-size: 13px; max-width: 340px; }

/* MY FILES */
.files-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}
.files-rail {
  position: sticky;
  top: 20px;
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.folder-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--muted-dark);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s ease;
}
.folder-item:hover { background: var(--primary-soft); color: var(--primary); }
.folder-item.active { background: var(--primary); color: white; }
.folder-item.active .folder-count { color: rgba(255,255,255,0.85); }
.folder-icon { font-size: 16px; flex: 0 0 auto; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
  background: rgba(15, 23, 42, 0.05);
  padding: 2px 7px;
  border-radius: 6px;
}
[data-theme="dark"] .folder-count { background: rgba(255,255,255,0.08); }
.folder-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }

.files-main { min-width: 0; }
.files-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.files-search {
  flex: 1; min-width: 200px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.files-search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 13px; color: var(--text); }
.files-bulk { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.files-select-all { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-dark); cursor: pointer; }
.files-heading { margin: 0 0 16px; font-size: 16px; letter-spacing: -0.01em; }
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.file-card-item {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.file-card-item:hover { border-color: #c7d2fe; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.file-card-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.file-card-thumb {
  aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: #ffffff;
  overflow: hidden;
}
.file-card-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.file-card-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; }
.file-card-name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-meta { font-size: 10.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.file-card-folder {
  font-size: 9.5px; color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 7px; border-radius: 5px;
  align-self: flex-start; font-weight: 700;
}
.file-card-checkbox {
  position: absolute;
  top: 8px; left: 8px;
  width: 20px; height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.file-card-item:hover .file-card-checkbox,
.file-card-item.selected .file-card-checkbox { opacity: 1; }

.files-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 70px 20px; text-align: center;
}
.files-empty .empty-icon { width: 70px; height: 70px; font-size: 32px; }
.files-empty h2 { margin: 0; font-size: 20px; }
.files-empty p { margin: 0 0 12px; color: var(--muted); font-size: 13px; max-width: 340px; }

/* SETTINGS */
.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 780px;
}
.settings-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.settings-card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.015em;
}
.settings-desc {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* HELP */
.help-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 780px;
}
.help-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.help-card h2 {
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: -0.015em;
}
.help-card ol, .help-card ul {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.8;
}
.help-card li { margin-bottom: 3px; }
.help-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.help-card details {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.help-card details:first-of-type { border-top: 0; padding-top: 0; }
.help-card details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 0;
}
.help-card details summary:hover { color: var(--primary); }
.help-card details p {
  margin: 6px 0 4px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}
.about-card { background: linear-gradient(140deg, #1e3a8a, #0f172a); color: white; border: 0; }
.about-card h2 { color: white; }
.about-card p { color: rgba(255,255,255,0.85); }
.feedback-card { border-color: #c7d2fe; }
.feedback-card .action-row { margin-top: 14px; }

/* Responsive */
@media (max-width: 1180px) {
  .main-content { padding: 0 24px 50px; }
  .workspace-card { grid-template-columns: 0.85fr 1fr; }
  .result-column { grid-column: 1 / -1; }
  #photo-tools .workspace-card,
  #signature-tools .workspace-card,
  #image-tools .workspace-card { grid-template-columns: 1fr; }
  .dashboard-row { grid-template-columns: 1fr 1fr; }
  .why-panel { grid-column: 1 / -1; }
  .files-layout { grid-template-columns: 190px 1fr; }
}

@media (max-width: 960px) {
  .tool-cards { grid-template-columns: 1fr; }
  .dashboard-row { grid-template-columns: 1fr; }
  .welcome-illustration { display: none; }
  .before-after-grid { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 70px 20px 70px 1fr; gap: 10px; }
  .history-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .history-thumb { width: 70px; height: 56px; }
  .history-filename { max-width: 180px; font-size: 12.5px; }
  .files-layout { grid-template-columns: 1fr; }
  .files-rail { position: static; }
  .folder-list { display: flex; flex-wrap: wrap; gap: 6px; }
  .folder-list .folder-item { width: auto; padding: 8px 12px; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar {
    position: static; width: 100%; height: auto;
    padding: 14px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { display: none; }
  .sidebar-nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .sidebar-nav-bottom { margin-top: 8px; }
  .nav-item { white-space: nowrap; padding: 9px 12px; font-size: 12px; }
  .nav-label { white-space: nowrap; }
  .sidebar-footer { display: none; }

  .main-content { width: 100%; margin-left: 0; padding: 0 18px 40px; }
  .topbar { height: 64px; gap: 12px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
  .topbar-search { display: none; }
  .user-meta { display: none; }
  .user-chip { padding: 4px; }
  .page-title h1 { font-size: 18px; }
  .page-title p { font-size: 10px; }

  .welcome-section { padding: 8px 0 24px; }
  .welcome-section h1 { font-size: 28px; }

  .tool-cards { gap: 12px; margin-bottom: 24px; }
  .tool-card { padding: 18px; }
  .tool-card h3 { font-size: 17px; }
  .tool-card p { font-size: 12px; }

  .workspace-card { grid-template-columns: 1fr; padding: 16px; gap: 18px; }
  .result-column { grid-column: auto; }
  .upload-zone { min-height: 210px; }

  .field-grid, .range-grid { grid-template-columns: 1fr; }

  .footer { flex-direction: column; align-items: flex-start; }
  .footer-features { gap: 14px; }

  .files-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

@media (max-width: 600px) {
  .history-item { grid-template-columns: 60px 16px 60px 1fr; gap: 8px; padding: 10px; }
  .history-thumb { width: 60px; height: 48px; }
  .history-arrow { font-size: 14px; }
  .history-filename { font-size: 11.5px; max-width: 110px; }
  .history-info-row2 { font-size: 10px; gap: 8px; }
  .history-type-badge { font-size: 8px; padding: 2px 6px; }
  .history-action-btn { width: 30px; height: 30px; font-size: 13px; }

  .files-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .file-card-info { padding: 8px 10px 10px; }
  .file-card-name { font-size: 11.5px; }
  .file-card-meta { font-size: 9.5px; }

  .result-actions { grid-template-columns: 1fr; }
}

/* =========================================================
   Quick Presets (Home)
   ========================================================= */
.quick-presets {
  margin: 0 0 32px;
}
.quick-presets-kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.quick-chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }

.quick-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 150px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.quick-chip:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.quick-chip-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 4px;
}
.quick-chip-label {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.quick-chip-sub {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

/* =========================================================
   Before/After Swipe Slider
   ========================================================= */
.swipe-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #ffffff;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

[data-theme="dark"] .swipe-wrap {
  background:
    linear-gradient(45deg, #141d30 25%, transparent 25%),
    linear-gradient(-45deg, #141d30 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #141d30 75%),
    linear-gradient(-45deg, transparent 75%, #141d30 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #0f1829;
}

.swipe-slider {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 380px;
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  cursor: ew-resize;
}

.swipe-img-after,
.swipe-before img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
  pointer-events: none;
  border-radius: 8px;
}
[data-theme="dark"] .swipe-img-after,
[data-theme="dark"] .swipe-before img { background: #0f1829; }

.swipe-before {
  position: absolute;
  inset: 0;
  overflow: hidden;
  width: 50%;
}

.swipe-before img {
  width: 100vw;
  max-width: none;
  height: 100%;
  object-fit: contain;
  object-position: left center;
}

.swipe-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: white;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15), 0 0 12px rgba(0, 0, 0, 0.4);
  cursor: ew-resize;
  z-index: 4;
}

.swipe-handle-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  color: #2563eb;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.swipe-label {
  position: absolute;
  top: 10px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.65);
  color: white;
  z-index: 3;
  backdrop-filter: blur(4px);
}
.swipe-label-before { left: 10px; }
.swipe-label-after  { right: 10px; }