/* ============ Theme tokens ============ */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e3e6ec;
  --border-strong: #cfd4dc;
  --text: #1a1d23;
  --text-2: #4b5260;
  --muted: #7a8190;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --viewer-bg: #e7e9ee;
  --page-shadow: 0 1px 3px rgba(16, 24, 40, .12), 0 6px 20px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .18), 0 4px 12px rgba(16, 24, 40, .08);
  --radius: 8px;
  --radius-sm: 6px;
  --sel: #4f46e5;
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15171c;
  --surface: #1c1f26;
  --surface-2: #21252d;
  --surface-3: #2a2f39;
  --border: #2d323c;
  --border-strong: #3c4350;
  --text: #e8eaef;
  --text-2: #b4bac6;
  --muted: #8a91a0;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, .14);
  --accent-text: #11131a;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --viewer-bg: #0f1115;
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
  --sel: #818cf8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13px/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

svg.icon { width: 18px; height: 18px; flex: none; display: block; }
.icon-btn.sm svg.icon { width: 16px; height: 16px; }

/* ============ Layout ============ */
.app { display: flex; flex-direction: column; height: 100vh; }
.app > .topbar, .app > .toolbar, .app > .statusbar { flex: none; }
.app > .workspace { flex: 1; }
.app[data-state="empty"] .needs-doc { display: none !important; }
.app[data-state="empty"] .workspace { grid-template-columns: 1fr; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; color: inherit; text-decoration: none; }
.pro-badge { display: none; font-size: 10px; font-weight: 750; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.app.pro .pro-badge { display: inline-block; }
.upgrade-btn { border: 0; color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed); box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .6); }
.upgrade-btn:hover { background: linear-gradient(135deg, #4338ca, #6d28d9); }
.app.pro .upgrade-btn { display: none; }
.upsell { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); }
.upsell svg.icon { width: 22px; height: 22px; color: var(--accent); }
.drop-card a { color: var(--accent); }
.brand-mark { color: var(--accent); width: 26px; height: 26px; display: grid; }
.brand-mark svg { width: 26px; height: 26px; }
.topbar-group { display: flex; align-items: center; gap: 4px; }
.divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.file-name-wrap { display: flex; align-items: center; gap: 6px; margin-left: 8px; min-width: 0; }
.file-name {
  border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm);
  padding: 5px 8px; width: 220px; font-weight: 500; color: var(--text-2); text-overflow: ellipsis;
  field-sizing: content; min-width: 90px; max-width: 280px;
}
.file-name:hover { border-color: var(--border); }
.file-name:focus { outline: none; border-color: var(--accent); background: var(--surface); color: var(--text); }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; display: none; }
.app.dirty .dirty-dot { display: block; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, .icon-btn:focus-visible, .tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.block { width: 100%; justify-content: flex-start; }
.btn:disabled, .icon-btn:disabled { opacity: .4; cursor: default; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }

.select, .input {
  height: 32px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); padding: 0 8px; min-width: 0;
}
.select:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select.compact { width: 104px; }
textarea.input { height: auto; padding: 8px; resize: vertical; }
.page-input { width: 42px; height: 28px; text-align: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.page-input:focus { outline: none; border-color: var(--accent); }
.page-nav .muted { min-width: 34px; }

:root .theme-light-icon { display: none; }
:root[data-theme="dark"] .theme-light-icon { display: block; }
:root[data-theme="dark"] .theme-dark-icon { display: none; }

/* ============ Toolbar ============ */
.toolbar {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.tool-group { display: flex; gap: 2px; }
.tool-sep { width: 1px; height: 28px; background: var(--border); margin: 0 6px; flex: none; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 58px; padding: 5px 6px 4px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 11px; font-weight: 500;
}
.tool:hover { background: var(--surface-3); color: var(--text); }
.tool.active { background: var(--accent-soft); color: var(--accent); }
.tool svg.icon { width: 19px; height: 19px; }

/* ============ Workspace ============ */
.workspace { display: grid; grid-template-columns: 208px 1fr 268px; min-height: 0; }
.sidebar { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.sidebar.left { border-right: 1px solid var(--border); }
.sidebar.right { border-left: 1px solid var(--border); overflow-y: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.panel-title { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.panel-foot { display: flex; gap: 8px; padding: 14px; margin-top: auto; border-top: 1px solid var(--border); }
.panel-foot svg.icon { width: 16px; height: 16px; }
.page-actions { display: flex; gap: 2px; padding: 0 10px 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* Thumbnails */
.thumbs { flex: 1; overflow-y: auto; padding: 12px 10px 24px; outline: none; }
.thumb {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px; border-radius: var(--radius); cursor: pointer; user-select: none; margin-bottom: 4px;
  border: 2px solid transparent;
}
.thumb:hover { background: var(--surface-3); }
.thumb.current .thumb-num { color: var(--accent); font-weight: 650; }
.thumb.selected { background: var(--accent-soft); border-color: var(--accent); }
.thumb-canvas-wrap { position: relative; background: #fff; box-shadow: 0 0 0 1px var(--border), 0 1px 3px rgba(0,0,0,.08); line-height: 0; }
.thumb canvas { display: block; }
.thumb-num { font-size: 11px; color: var(--muted); }
.thumb-badge {
  position: absolute; right: 4px; top: 4px; background: var(--accent); color: var(--accent-text);
  font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 8px; text-align: center;
}
.thumb.dragging { opacity: .4; }
.thumb.drop-before::before, .thumb.drop-after::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 2px; background: var(--accent);
}
.thumb.drop-before::before { top: -4px; }
.thumb.drop-after::after { bottom: -4px; }

/* Viewer */
.viewer { position: relative; overflow: auto; background: var(--viewer-bg); outline: none; min-width: 0; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; min-width: min-content; }
.app[data-state="empty"] .pages { display: none; }
.page {
  position: relative; background: #fff; box-shadow: var(--page-shadow); flex: none;
}
.page canvas.pdf { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .page-label {
  position: absolute; left: 0; top: -17px; font-size: 11px; color: var(--muted); user-select: none;
}
.overlay { position: absolute; inset: 0; overflow: hidden; }
.ui-layer { position: absolute; inset: 0; pointer-events: none; }
.text-layer { position: absolute; inset: 0; }

.viewer[data-tool="hand"] .overlay { cursor: grab; }
.viewer.panning .overlay { cursor: grabbing; }
.viewer[data-tool="text"] .overlay { cursor: text; }
.viewer[data-tool="ink"] .overlay,
.viewer[data-tool="highlight"] .overlay,
.viewer[data-tool="rect"] .overlay,
.viewer[data-tool="ellipse"] .overlay,
.viewer[data-tool="line"] .overlay,
.viewer[data-tool="arrow"] .overlay,
.viewer[data-tool="whiteout"] .overlay,
.viewer[data-tool="redact"] .overlay { cursor: crosshair; }

/* Annotation elements */
.annot { position: absolute; }
.annot-svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.annot-svg .hit { pointer-events: all; cursor: move; }
.annot-svg .hit-stroke { pointer-events: stroke; cursor: move; }
.annot-svg.blend-multiply { mix-blend-mode: multiply; }
.annot-text {
  white-space: pre; line-height: 1.2; cursor: move; user-select: none; transform-origin: center center;
  min-width: 4px;
}
.annot-text.editing { cursor: text; user-select: text; outline: none; }
.annot-text:empty::before { content: "\200b"; }
.annot-img { cursor: move; user-select: none; -webkit-user-drag: none; }
.viewer:not([data-tool="select"]) .annot-svg .hit,
.viewer:not([data-tool="select"]) .annot-svg .hit-stroke,
.viewer:not([data-tool="select"]) .annot-img { cursor: inherit; }
.viewer[data-tool="text"] .annot-text { cursor: text; }

.sel-box {
  position: absolute; border: 1.5px solid var(--sel); pointer-events: none; transform-origin: center center;
}
.sel-box.multi { border-style: dashed; }
.sel-box.editing { border-style: dashed; opacity: .7; }
.handle {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #fff;
  border: 1.5px solid var(--sel); border-radius: 2px; pointer-events: all; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.handle.round { border-radius: 50%; }
.marquee { position: absolute; border: 1px dashed var(--sel); background: rgba(79, 70, 229, .08); pointer-events: none; }

/* Objects tool */
.obj-layer { position: absolute; inset: 0; pointer-events: none; }
.obj-box { position: absolute; border: 1px solid var(--sel); border-radius: 1px; }
.obj-box.hover { background: rgba(79, 70, 229, .08); }
.obj-box.selected { border: 1.5px solid #ef4444; background: rgba(239, 68, 68, .12); }
.obj-note { position: absolute; left: 12px; right: 12px; top: 12px; padding: 8px 10px; border-radius: 6px; background: var(--surface); color: var(--text-2); box-shadow: var(--page-shadow); font-size: 12px; }
.viewer[data-tool="objects"] .overlay { pointer-events: none; }
.viewer[data-tool="objects"] .page { cursor: default; }

/* Edit-text hover boxes */
.text-item {
  position: absolute; cursor: text; border-radius: 2px;
  outline: 1px dashed transparent; transition: background .08s;
}
.text-item:hover { background: rgba(79, 70, 229, .12); outline-color: var(--sel); }

/* Empty / drop state */
.empty-state { position: absolute; inset: 0; display: none; place-items: center; padding: 24px; overflow: auto; background: var(--bg); }
.app[data-state="empty"] .empty-state { display: grid; }
.drop-card {
  width: min(620px, 100%); text-align: center; padding: 48px 40px 36px;
  background: var(--surface); border: 1.5px dashed var(--border-strong); border-radius: 16px;
}
.drop-card h1 { font-size: 24px; letter-spacing: -.02em; margin: 18px 0 6px; }
.drop-card p { margin: 0 0 22px; color: var(--text-2); }
.drop-icon { width: 60px; height: 60px; margin: 0 auto; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.drop-icon svg.icon { width: 28px; height: 28px; }
.drop-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.feature-list { list-style: none; padding: 22px 0 0; margin: 22px 0 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; color: var(--text-2); }
.feature-list li { display: flex; align-items: center; gap: 8px; justify-content: center; }
.feature-list svg.icon { width: 16px; height: 16px; color: var(--accent); }
.drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: none; place-items: center; pointer-events: none;
  background: rgba(79, 70, 229, .12); border: 3px dashed var(--accent);
}
.drop-overlay > div { display: flex; gap: 10px; align-items: center; padding: 14px 22px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg); font-weight: 600; font-size: 15px; color: var(--accent); }
body.dragover .drop-overlay { display: grid; }

/* ============ Properties ============ */
.props { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); }
.prop-row { display: flex; flex-direction: column; gap: 6px; }
.prop-row > label, .prop-label { font-size: 12px; font-weight: 550; color: var(--text-2); display: flex; justify-content: space-between; }
.prop-inline { display: flex; gap: 6px; align-items: center; }
.prop-inline > .select, .prop-inline > .input { flex: 1; }
.props .hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.props .hint kbd { font-size: 11px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0;
  position: relative;
}
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.none { background: linear-gradient(135deg, #fff 45%, #ef4444 45%, #ef4444 55%, #fff 55%); }
.swatch-custom { width: 22px; height: 22px; border: 0; padding: 0; border-radius: 50%; overflow: hidden; cursor: pointer; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch-custom::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-custom::-webkit-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.swatch-custom::-moz-color-swatch { border: 0; opacity: 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.toggle-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-group button { border: 0; background: var(--surface); width: 32px; height: 30px; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.toggle-group button + button { border-left: 1px solid var(--border-strong); }
.toggle-group button.active { background: var(--accent-soft); color: var(--accent); }
.toggle-group svg.icon { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; padding: 0 8px; }
.doc-actions { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.notice { display: flex; gap: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 12px; line-height: 1.45; }
.notice svg.icon { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ============ Status bar ============ */
.statusbar {
  display: flex; align-items: center; gap: 16px; height: 26px; padding: 0 14px;
  background: var(--surface); border-top: 1px solid var(--border); font-size: 12px; color: var(--muted);
}

/* ============ Modal ============ */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(10, 12, 18, .45); padding: 16px; animation: fade .12s ease-out; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .14s ease-out; }
.modal.wide { width: min(680px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; }
.modal-head h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.modal-body { padding: 4px 20px 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.modal-foot:empty { display: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 550; color: var(--text-2); }
.field.full { grid-column: 1 / -1; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--surface-3); border-radius: var(--radius); }
.tabs button { flex: 1; border: 0; background: transparent; height: 30px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; color: var(--text-2); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.sig-pad { position: relative; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; height: 200px; touch-action: none; }
.sig-pad canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.sig-pad .sig-line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1px solid #cbd5e1; pointer-events: none; }
.sig-pad .sig-hint { position: absolute; left: 24px; bottom: 22px; color: #94a3b8; font-size: 12px; pointer-events: none; }
.sig-type-preview { height: 120px; display: grid; place-items: center; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 46px; color: #111; overflow: hidden; white-space: nowrap; }
.sig-saved { display: flex; gap: 8px; flex-wrap: wrap; }
.sig-saved .sig-item { position: relative; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; padding: 4px; cursor: pointer; height: 54px; }
.sig-saved .sig-item:hover { border-color: var(--accent); }
.sig-saved img { height: 44px; display: block; }
.sig-saved .sig-del { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0; }
.sig-saved .sig-del svg.icon { width: 12px; height: 12px; }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; }
.kbd-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--border); gap: 12px; }
kbd { font: 11px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; padding: 3px 6px; border-radius: 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.preview-strip { background: var(--surface-3); border-radius: var(--radius); padding: 18px; display: grid; place-items: center; }
.mini-page { position: relative; width: 120px; height: 155px; background: #fff; box-shadow: var(--page-shadow); overflow: hidden; }
.mini-page .mini-text { position: absolute; white-space: nowrap; font-family: Helvetica, Arial, sans-serif; }
.stamp-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.stamp-chip { border: 2px solid; border-radius: 6px; background: var(--surface); padding: 4px 8px; font: 700 11px/1.2 Helvetica, Arial, sans-serif; letter-spacing: .04em; cursor: pointer; }
.stamp-chip:hover { background: var(--surface-3); }
.preview-strip img { background: #fff; padding: 6px; border-radius: 4px; }
.hf-grid { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 8px; align-items: center; }
.hf-opts { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .hf-grid { grid-template-columns: 1fr; } .hf-opts { grid-template-columns: 1fr 1fr; } }

/* ============ Toast / busy ============ */
.toasts { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: #1f2330; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .16s ease-out; max-width: 520px; }
.toast.error { background: #b91c1c; }
.toast.success svg.icon { color: #4ade80; }
.toast svg.icon { width: 16px; height: 16px; }
.busy { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(10, 12, 18, .35); color: #fff; font-weight: 600; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } }

/* Scrollbars */
.thumbs, .viewer, .sidebar.right, .modal-body { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .tool span { display: none; }
  .tool { min-width: 38px; padding: 7px; }
  .btn.ghost span { display: none; }
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 150px 1fr 240px; }
  .file-name { width: 140px; }
  .brand-name { display: none; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: none !important; }
  .page-nav, .zoom-group + .divider { display: none !important; }
  .feature-list { grid-template-columns: repeat(2, 1fr); }
  .btn.primary span, .upgrade-btn span { display: none; }
}
