/* PDF2Scan product UI: one design system for the scan tool and the signed-in workspace. */
:root {
  --bg: #fafaf9;
  --canvas: #ecebe6;
  --surface: #ffffff;
  --fill: rgba(120, 116, 104, 0.10);
  --fill-strong: rgba(120, 116, 104, 0.16);
  --border: #e8e6e1;
  --separator: #efede9;
  --text: #1a1917;
  --muted: #6b6860;
  --placeholder: #8f8b82;
  --accent: oklch(52% 0.18 248);
  --accent-hover: oklch(46% 0.18 248);
  --accent-lt: oklch(96% 0.04 248);
  --accent-dk: oklch(38% 0.18 248);
  --accent-ring: oklch(52% 0.18 248 / 0.32);
  --success: oklch(50% 0.15 155);
  --success-lt: oklch(96% 0.04 155);
  --warning: oklch(48% 0.12 65);
  --warning-lt: oklch(96.5% 0.045 85);
  --danger: oklch(52% 0.19 27);
  --danger-lt: oklch(96.5% 0.03 27);
  --green: var(--success);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: var(--sans);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 56px;
  --nav-h: 56px;
  --panel-w: 300px;
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-size-adjust: 100%; }
body { font: 400 14px/1.45 var(--sans); background: var(--bg); color: var(--text); caret-color: var(--accent); }
::selection { background: oklch(52% 0.18 248 / 0.18); }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg.icon-sm { width: 16px; height: 16px; }

/* ── Top bar ─────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50; flex-shrink: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
  height: var(--topbar-h); padding: 0 16px;
  background: rgba(255, 255, 255, 0.86); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; object-fit: contain; }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }

.product-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--fill); }
.product-tabs a, .product-tabs button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 14px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--text); text-decoration: none; white-space: nowrap;
  transition: background-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.product-tabs a:hover:not([aria-current="page"]), .product-tabs button:hover:not([aria-current="page"]) { background: rgba(255, 255, 255, 0.55); }
.product-tabs [aria-current="page"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgba(26, 25, 23, 0.12), 0 0 0 0.5px rgba(26, 25, 23, 0.06); }
.product-tabs .tab-badge { padding: 1px 6px; border-radius: 99px; background: var(--accent-lt); color: var(--accent-dk); font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; }

.locale-select { position: relative; display: flex; align-items: center; }
.locale-select select {
  -webkit-appearance: none; appearance: none; height: 32px; min-width: 0; padding: 0 28px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: 500 13px var(--sans); cursor: pointer; outline: none; box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%236b6860' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.locale-select select:hover { border-color: #d5d2ca; }
.locale-select select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.locale-select::after { content: none; }

.balance-pill, .credit-chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 12px; border-radius: 99px;
  background: var(--fill); color: var(--text); border: 0;
  font: 500 13px var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; text-decoration: none;
}
.balance-pill .dot, .credit-chip-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--success); }
a.balance-pill:hover { background: var(--fill-strong); }

.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; text-decoration: none; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 16px;
  border: 0; border-radius: var(--radius-sm); font: 600 14px var(--sans); white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease), opacity 150ms var(--ease), transform 120ms var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: #f6f5f2; border-color: #d5d2ca; color: var(--text); }
.btn-tinted { background: var(--accent-lt); color: var(--accent-dk); }
.btn-tinted:hover:not(:disabled) { background: oklch(93% 0.06 248); }
.btn-gray { background: var(--fill); color: var(--text); }
.btn-gray:hover:not(:disabled) { background: var(--fill-strong); }
.btn-plain { min-height: 32px; padding: 0 8px; background: transparent; color: var(--accent); font-weight: 500; }
.btn-plain:hover:not(:disabled) { background: var(--accent-lt); }
.btn-plain.danger { color: var(--danger); }
.btn-plain.danger:hover:not(:disabled) { background: var(--danger-lt); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 44px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.icon-btn:hover:not(:disabled) { background: var(--fill); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.accent { color: var(--accent); }
.icon-btn.accent:hover { background: var(--accent-lt); }
.link { color: var(--accent); font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Workspace: effects · preview · output ──── */
.workspace-shell { display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--panel-w); flex: 1; min-height: 0; overflow: hidden; }
.panel { display: flex; flex-direction: column; min-height: 0; overflow-x: hidden; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); }
.panel:last-child { border-right: 0; border-left: 1px solid var(--border); }
.panel-header {
  flex-shrink: 0; padding: 18px 20px 4px; border: 0;
  font: 600 15px var(--sans); letter-spacing: -0.01em; text-transform: none; color: var(--text);
}
.panel-body { flex: 1; display: flex; flex-direction: column; gap: 22px; padding: 14px 20px 24px; }
.panel-footer { flex-shrink: 0; padding: 14px 20px 18px; border-top: 1px solid var(--border); background: var(--surface); }
.group-label, .control-group > .control-label.group-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.divider { height: 1px; background: var(--separator); }

/* Segmented control (also styles the tool's preset chips) */
.segmented, .preset-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented > button, .preset-row > .preset-chip {
  min-height: 30px; padding: 0 6px; border: 0; border-radius: 7px; background: transparent; color: var(--text);
  font: 500 13px var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.segmented > button:hover:not([aria-pressed="true"]), .preset-row > .preset-chip:hover:not(.active) { background: rgba(255, 255, 255, 0.55); color: var(--text); border: 0; }
.segmented > button[aria-pressed="true"], .preset-row > .preset-chip.active {
  background: var(--surface); color: var(--text); font-weight: 600; border: 0;
  box-shadow: 0 1px 3px rgba(26, 25, 23, 0.12), 0 0 0 0.5px rgba(26, 25, 23, 0.06);
}

/* Sliders: Apple-style track with filled progress (--pct set by script) */
.control-group { display: flex; flex-direction: column; gap: 8px; }
.controls-group { display: flex; flex-direction: column; }
.controls-group > .control-group, .controls-group > .control { padding: 11px 0 7px; }
.controls-group > * + * { border-top: 1px solid var(--separator); }
.control-label, .control-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; font-weight: 500; color: var(--text); }
.control-value, .control-head output { padding: 0; border-radius: 0; background: none; font: 400 13px var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); }
input[type=range].slider, .ui-range {
  --pct: 50%;
  width: 100%; height: 20px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer; outline: none;
}
input[type=range].slider::-webkit-slider-runnable-track, .ui-range::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: linear-gradient(to right, var(--accent) var(--pct), #dedbd4 var(--pct)); }
input[type=range].slider::-moz-range-track, .ui-range::-moz-range-track { height: 4px; border-radius: 99px; background: #dedbd4; }
input[type=range].slider::-moz-range-progress, .ui-range::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--accent); }
input[type=range].slider::-webkit-slider-thumb, .ui-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  transition: transform 120ms var(--ease);
}
input[type=range].slider::-moz-range-thumb, .ui-range::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.14); }
input[type=range].slider:active::-webkit-slider-thumb, .ui-range:active::-webkit-slider-thumb { transform: scale(1.1); }
input[type=range].slider:focus-visible::-webkit-slider-thumb, .ui-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-ring), 0 3px 8px rgba(0, 0, 0, 0.14); }

/* Fields */
.field, .format-select {
  width: 100%; min-height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 400 14px var(--sans);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.field:focus, .format-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field::placeholder { color: var(--placeholder); }
select.field, .format-select {
  -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%236b6860' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
[dir="rtl"] select.field, [dir="rtl"] .format-select { padding-right: 12px; padding-left: 34px; background-position: left 12px center; }

/* Drop zone */
.dropzone, .upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; cursor: pointer;
  padding: 26px 18px; border: 1.5px dashed #d5d2ca; border-radius: var(--radius-lg); background: var(--bg);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.dropzone:hover, .upload-zone:hover, .dropzone.dragging, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-lt); }
.drop-art, .upload-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 12px; background: var(--accent-lt); color: var(--accent); }
.drop-art svg, .upload-icon svg { width: 22px; height: 22px; }
.drop-title, .upload-title { font-size: 14px; font-weight: 600; color: var(--text); }
.drop-sub, .upload-sub { font-size: 12.5px; line-height: 1.5; color: var(--muted); }

/* Preview canvas area */
.canvas-area { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; overflow: auto; padding: 72px 40px 40px; background: var(--canvas); }
.preview-toolbar, .canvas-toolbar {
  position: absolute; top: 16px; left: 50%; z-index: 5; transform: translateX(-50%);
  display: flex; gap: 0; padding: 2px; border: 0; border-radius: 9px;
  background: rgba(255, 255, 255, 0.72); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 0 0 0.5px rgba(26, 25, 23, 0.08), 0 2px 10px rgba(26, 25, 23, 0.06);
}
.tab-btn {
  min-height: 28px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--text);
  font: 500 13px var(--sans); cursor: pointer; transition: background-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.tab-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.7); }
.tab-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(26, 25, 23, 0.12), 0 0 0 0.5px rgba(26, 25, 23, 0.06); }
.paper { background: #fff; border-radius: 2px; box-shadow: 0 1px 2px rgba(26, 25, 23, 0.10), 0 12px 40px rgba(26, 25, 23, 0.14); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 300px; padding: 24px; text-align: center; color: var(--muted); }
.empty-state .drop-art { width: 56px; height: 56px; border-radius: 16px; background: rgba(255, 255, 255, 0.7); color: var(--muted); }
.empty-state strong { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.5; }

/* Rows and grouped lists */
.info-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.info-row-label { color: var(--muted); }
.info-row-val { font: 500 13px var(--sans); font-variant-numeric: tabular-nums; color: var(--text); }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.note { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg); color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.note svg { margin-top: 1px; color: var(--muted); }
.note strong { display: block; color: var(--text); font-weight: 600; font-size: 13px; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--fill-strong); border-top-color: var(--accent); animation: ui-spin 800ms linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 300; max-width: calc(100vw - 32px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 99px;
  background: rgba(28, 27, 25, 0.92); color: #fff; font: 500 13.5px var(--sans);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(26, 25, 23, 0.16); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
  :root { --panel-w: 272px; }
  .topbar .auth-email { display: none; }
}
@media (max-width: 860px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 0 12px; }
  .topbar .product-tabs-wrap { grid-column: 1 / -1; grid-row: 2; }
  .topbar:has(.product-tabs-wrap:not([hidden])) { height: auto; padding-top: 10px; padding-bottom: 10px; }
  .product-tabs-wrap { display: flex; overflow-x: auto; scrollbar-width: none; }
  .product-tabs-wrap::-webkit-scrollbar { display: none; }
  .product-tabs { flex: 1; }
  .product-tabs a, .product-tabs button { flex: 1; justify-content: center; padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
