/* 1Scanner in the browser: the tool itself. Uses the line's tokens from 1buck.css with 1Scanner's red. */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url(vendor/inter/inter-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --accent: #E60C09;
    --accent-deep: #B80306;
    --accent-soft: rgba(230, 12, 9, 0.12);
    --shadow-accent: 0 18px 40px rgba(230, 12, 9, 0.24);
    --warn-bg: #FFF5E5;
    --warn-text: #8A4B00;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.sc-app {
    position: relative;
    min-width: 0;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow), 0 0 0 1px var(--hairline);
    padding: 20px;
    min-height: 340px;
    font-size: 15px;
    line-height: 1.45;
}
.sc-app.is-drop { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.sc-app.is-loading::after {
    content: "Opening…";
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(255, 255, 255, 0.78); border-radius: 24px; font-weight: 700; z-index: 5;
}

.sc-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Buttons */
.sc-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 40px; padding: 8px 14px; border: 0; border-radius: 12px;
    background: var(--bg); color: var(--text); font: inherit; font-weight: 650; font-size: 14px;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    box-shadow: inset 0 0 0 1px var(--hairline);
}
.sc-btn:hover { background: #EFEBE6; }
.sc-btn:focus-visible, .sc-tab:focus-visible, .sc-chip:focus-visible, .sc-card:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.sc-btn[disabled] { opacity: .45; cursor: default; }
.sc-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; box-shadow: 0 8px 20px rgba(230, 12, 9, 0.22); }
.sc-btn.primary:hover { filter: brightness(1.05); }
.sc-btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.sc-btn.sc-icon-only { padding: 8px; width: 40px; }
.sc-btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }

.sc-chip {
    border: 0; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 600;
    background: var(--bg); color: var(--text); cursor: pointer; box-shadow: inset 0 0 0 1px var(--hairline);
}
.sc-chip.on { background: var(--text); color: #fff; box-shadow: none; }

.sc-input {
    width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 12px; border: 1px solid #DDD6CF;
    font: inherit; background: #fff; color: var(--text);
}
.sc-input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.sc-input.short { width: 84px; }

.sc-row { display: flex; align-items: center; gap: 8px; }
.sc-row.wrap { flex-wrap: wrap; }
.sc-grow { flex: 1; }
.sc-sep { width: 1px; height: 24px; background: var(--hairline); margin: 0 4px; }
.sc-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.sc-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; }
.sc-label { font-weight: 700; margin: 14px 0 8px; font-size: 14px; }

/* Empty state */
.sc-drop {
    display: grid; justify-items: center; gap: 8px; text-align: center;
    border: 2px dashed #D9D1C9; border-radius: 20px; padding: 56px 20px; cursor: pointer; background: var(--bg);
}
.sc-drop:hover { border-color: var(--accent); }
.sc-drop .sc-icon { width: 40px; height: 40px; color: var(--accent); }
.sc-drop-title { font-size: 20px; font-weight: 800; }
.sc-drop-sub { color: var(--muted); margin-bottom: 8px; }
.sc-drop.small { padding: 32px 16px; margin-top: 12px; }
.sc-foot { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; margin-top: 14px; }
.sc-foot .sc-icon { width: 14px; height: 14px; }

/* Workspace */
.sc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sc-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.sc-title strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.sc-head-actions { display: flex; gap: 8px; }
.sc-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); font-size: 12px; font-weight: 700; }
.sc-badge .sc-icon { width: 12px; height: 12px; }

.sc-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px; background: var(--bg); border-radius: 14px; margin-bottom: 16px; scrollbar-width: none; }
.sc-tabs::-webkit-scrollbar { display: none; }
.sc-tab { border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 650; padding: 8px 14px; border-radius: 10px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.sc-tab.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(20, 18, 16, 0.12); }

.sc-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.sc-hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* Pages grid */
.sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
.sc-card { border-radius: 14px; padding: 8px; cursor: pointer; user-select: none; -webkit-user-select: none; position: relative; }
.sc-card:hover { background: var(--bg); }
.sc-card.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.sc-card.dragging { opacity: .4; }
.sc-card.drop-before { box-shadow: inset 4px 0 0 var(--accent); }
.sc-card.drop-after { box-shadow: inset -4px 0 0 var(--accent); }
.sc-thumb { background: #fff; box-shadow: 0 2px 10px rgba(20, 18, 16, 0.14); border-radius: 4px; overflow: hidden; width: 100%; max-height: 220px; display: grid; place-items: center; margin: 0 auto; }
.sc-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sc-card-label { display: flex; justify-content: center; gap: 6px; align-items: center; margin-top: 8px; font-size: 13px; font-weight: 650; min-width: 0; }
.sc-card-label .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.sc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.sc-files { background: var(--bg); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; }
.sc-files-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sc-files ol { list-style: none; display: grid; gap: 4px; }
.sc-file { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 10px; padding: 4px 6px 4px 12px; }
.sc-file-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sc-file .sc-btn.sc-icon-only { width: 34px; min-height: 34px; padding: 6px; }
.sc-files .sc-btn[aria-label="Move up"] .sc-icon { transform: rotate(90deg); }
.sc-files .sc-btn[aria-label="Move down"] .sc-icon { transform: rotate(90deg); }

/* Sign & Stamp */
.sc-sign { display: grid; grid-template-columns: 96px minmax(0, 1fr) 250px; gap: 16px; align-items: start; }
.sc-sign-pages { display: grid; gap: 10px; max-height: 80vh; overflow-y: auto; padding: 2px; }
.sc-mini { border: 0; background: transparent; padding: 4px; border-radius: 10px; cursor: pointer; display: grid; gap: 4px; justify-items: center; font: inherit; font-size: 12px; color: var(--muted); position: relative; }
.sc-mini img { box-shadow: 0 1px 6px rgba(20, 18, 16, 0.18); border-radius: 2px; background: #fff; max-height: 110px; width: auto; }
.sc-mini.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; }
.sc-mini.stamped::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.sc-stage { min-width: 0; }
.sc-page-no { font-weight: 650; font-size: 14px; min-width: 96px; text-align: center; }
.sc-sheet-wrap { display: flex; justify-content: center; background: var(--bg); border-radius: 16px; padding: 16px; }
.sc-sheet { position: relative; background: #fff; box-shadow: 0 6px 26px rgba(20, 18, 16, 0.18); touch-action: none; }
.sc-page-canvas { width: 100%; height: 100%; display: block; }
.sc-layer { position: absolute; inset: 0; }
.sc-placed { position: absolute; cursor: move; touch-action: none; }
.sc-placed img { width: 100%; height: auto; pointer-events: none; user-select: none; -webkit-user-select: none; }
.sc-placed.on { outline: 1.5px dashed var(--accent); outline-offset: 2px; }
.sc-handle { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.sc-handle::before { content: ""; position: absolute; inset: -12px; }
.sc-handle.resize { right: -10px; bottom: -10px; cursor: nwse-resize; }
.sc-handle.turn { left: 50%; top: -34px; margin-left: -8px; cursor: grab; }
.sc-handle.turn::after { content: ""; position: absolute; left: 5px; top: 14px; width: 2px; height: 18px; background: var(--accent); }

.sc-library { background: var(--bg); border-radius: 16px; padding: 14px; display: grid; gap: 10px; }
.sc-library h3 { font-size: 15px; }
.sc-lib-actions { display: grid; gap: 6px; }
.sc-lib-actions .sc-btn { justify-content: flex-start; background: #fff; }
.sc-lib-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; }
.sc-lib-item { position: relative; }
.sc-lib-pick { width: 100%; aspect-ratio: 4 / 3; border: 0; border-radius: 10px; background: #fff; padding: 8px; cursor: pointer; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--hairline); }
.sc-lib-pick:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.sc-lib-pick img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sc-lib-remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); display: grid; place-items: center; cursor: pointer; opacity: 0; }
.sc-lib-remove .sc-icon { width: 12px; height: 12px; }
.sc-lib-item:hover .sc-lib-remove, .sc-lib-remove:focus-visible { opacity: 1; }
@media (hover: none) { .sc-lib-remove { opacity: 1; } }

/* Panels: compress, split, password, images, codes */
.sc-panel { max-width: 720px; margin: 0 auto; }
.sc-panel.narrow { max-width: 520px; }
.sc-panel h3 { font-size: 17px; margin-bottom: 6px; }
.sc-options { display: grid; gap: 8px; margin: 12px 0; }
.sc-option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--bg); cursor: pointer; box-shadow: inset 0 0 0 1px var(--hairline); }
.sc-option.on { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
.sc-option input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.sc-option-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.sc-option-text .muted { font-size: 13px; }
.sc-option input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--accent); }
.sc-option .sc-input { margin-top: 6px; }
.sc-size { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 14px; margin-top: 8px; }
.sc-note.warn { background: var(--warn-bg); color: var(--warn-text); }
.sc-split-preview { font-weight: 600; margin-top: 4px; }
.sc-callout { background: var(--accent-soft); border-radius: 16px; padding: 14px 16px; margin-bottom: 18px; display: grid; gap: 8px; justify-items: start; }
.sc-callout p:first-child { display: flex; gap: 8px; align-items: center; }
.sc-form { display: grid; gap: 10px; }

.sc-codes { list-style: none; display: grid; gap: 12px; margin-top: 16px; }
.sc-code { background: var(--bg); border-radius: 16px; padding: 14px 16px; display: grid; gap: 8px; }
.sc-code-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sc-code-text { white-space: pre-wrap; word-break: break-word; }
.sc-code > .sc-btn { justify-self: start; }
.sc-address { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; word-break: break-all; background: #fff; padding: 8px 10px; border-radius: 10px; }
.sc-address mark { background: var(--accent-soft); color: var(--accent-deep); font-weight: 800; border-radius: 4px; padding: 0 2px; }
.sc-link { display: grid; gap: 8px; }
.sc-warnings { list-style: none; display: grid; gap: 4px; }
.sc-warnings li { display: flex; gap: 6px; color: var(--warn-text); font-size: 14px; }
.sc-field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sc-field .muted { min-width: 80px; font-size: 13px; }
.sc-field-value { font-weight: 650; word-break: break-word; }

/* Dialogs, progress, toasts (outside the tool) */
.sc-dialog { margin: auto; border: 0; border-radius: 22px; padding: 0; max-width: min(440px, calc(100vw - 32px)); width: 100%; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); }
.sc-dialog.wide { max-width: min(640px, calc(100vw - 32px)); }
.sc-dialog::backdrop { background: rgba(20, 18, 16, .45); }
.sc-dialog-body { padding: 22px; display: grid; gap: 12px; }
.sc-dialog h3 { font-size: 18px; }
.sc-dialog p { color: var(--muted); }
.sc-dialog form { display: grid; gap: 12px; }
.sc-draw { width: 100%; height: auto; aspect-ratio: 900 / 360; background: #fff; border-radius: 14px; box-shadow: inset 0 0 0 1px #DDD6CF; touch-action: none; cursor: crosshair; }
.sc-ready-preview { min-height: 120px; display: grid; place-items: center; background: var(--bg); border-radius: 14px; padding: 12px; }
.sc-ready-preview canvas { max-width: 100%; max-height: 140px; width: auto; height: auto; }

.sc-busy { position: fixed; inset: 0; background: rgba(20, 18, 16, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.sc-busy-card { background: #fff; border-radius: 20px; padding: 24px; width: min(360px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.sc-busy-label { font-weight: 650; }
.sc-progress { width: 100%; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.sc-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.sc-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: sc-spin 0.9s linear infinite; }
@keyframes sc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sc-spinner { animation-duration: 3s; } }

.sc-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: #fff; border-radius: 14px; padding: 12px 16px; z-index: 110; display: grid; gap: 4px; max-width: min(520px, calc(100vw - 32px)); font-size: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.sc-toast a { color: #FFB4B2; font-weight: 600; }

@media (max-width: 960px) {
    .sc-sign { grid-template-columns: minmax(0, 1fr); }
    .sc-sign-pages { display: none; }
    .sc-library { order: 3; }
    .sc-lib-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sc-lib-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); max-height: none; }
}
@media (max-width: 600px) {
    .sc-app { padding: 12px; border-radius: 18px; }
    .sc-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
    .sc-sheet-wrap { padding: 8px; }
    .sc-lib-actions { grid-template-columns: 1fr; }
    .sc-toolbar .sc-btn.primary { width: 100%; }
    .sc-toolbar .sc-grow { display: none; }
    .sc-title strong { max-width: 70vw; }
}
