:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef1f7;
  --text: #172033;
  --muted: #647087;
  --soft: #8b95a8;
  --border: #dfe4ec;
  --border-strong: #c9d0dc;
  --primary: #5557e8;
  --primary-hover: #4648d2;
  --primary-soft: #ececff;
  --cyan: #14b8d4;
  --green: #14a96f;
  --green-soft: #e5f7ef;
  --amber: #d88912;
  --danger: #e1495b;
  --magenta: #e23f8f;
  --shadow-sm: 0 1px 2px rgba(19, 27, 46, .05), 0 4px 14px rgba(19, 27, 46, .05);
  --shadow-lg: 0 22px 70px rgba(19, 27, 46, .16);
  --radius: 18px;
  --radius-sm: 11px;
  --header-h: 72px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1420;
  --surface: #171d2a;
  --surface-2: #1d2433;
  --surface-3: #252e40;
  --text: #f2f5fb;
  --muted: #a9b3c5;
  --soft: #838fa5;
  --border: #2c364a;
  --border-strong: #3d4960;
  --primary: #7779ff;
  --primary-hover: #8d8fff;
  --primary-soft: #282951;
  --green-soft: #12392d;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.22), 0 6px 18px rgba(0,0,0,.16);
  --shadow-lg: 0 22px 70px rgba(0,0,0,.46);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--text); font: 15px/1.5 inherit; overflow-x: hidden; }
button, input, select { font: inherit; }
button, select, input[type="range"] { accent-color: var(--primary); }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 38%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: none; }

.app-header { position: sticky; top: 0; z-index: 50; min-height: var(--header-h); border-bottom: 1px solid color-mix(in srgb, var(--border) 82%, transparent); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(18px); }
.header-inner { width: min(100% - 32px, 1540px); min-height: var(--header-h); margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: grid; line-height: 1.18; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.brand-mark { position: relative; width: 41px; height: 41px; flex: none; overflow: hidden; border-radius: 12px; background: var(--text); box-shadow: inset 0 0 0 1px rgba(255,255,255,.13); }
.brand-mark i { position: absolute; left: 9px; bottom: 9px; width: 23px; height: 2px; border-radius: 2px; transform-origin: left center; background: #fff; }
.brand-mark i:first-child { transform: rotate(-46deg); }
.brand-mark b { position: absolute; top: 8px; right: 4px; color: #9ea0ff; font-size: 8px; font-weight: 800; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.engine-status { min-height: 34px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.engine-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 14%, transparent); animation: pulse 1.5s ease-in-out infinite; }
.engine-status.ready i { background: var(--green); animation: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 14%, transparent); }
.engine-status.error i { background: var(--danger); animation: none; }
.icon-btn, .tool-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: none; }
.icon-btn:hover, .tool-btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.theme-toggle span { font-size: 21px; }

.app-shell { width: min(100% - 32px, 1540px); margin: 24px auto 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 390px); gap: 18px; align-items: start; }
.workspace-card, .control-panel { min-width: 0; }
.workspace-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.workspace-heading { min-height: 116px; padding: 22px 24px 20px; display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 1px solid var(--border); }
.workspace-heading h1 { margin: 2px 0 5px; font-size: clamp(23px, 2.1vw, 33px); line-height: 1.12; letter-spacing: -.035em; }
.workspace-heading p:last-child { max-width: 680px; margin: 0; color: var(--muted); }
.eyebrow { margin: 0 0 2px; color: var(--primary); font-size: 11px; line-height: 1.2; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--border-strong); border-radius: 11px; padding: 0 16px; background: var(--surface); font-weight: 720; transition: .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 22%, transparent); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.button.secondary { background: var(--surface-2); }
.button.subtle { min-height: 40px; color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.button.full { width: 100%; }
.text-button { border: 0; padding: 3px; background: transparent; color: var(--primary); font-weight: 720; }

.canvas-toolbar { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow-x: auto; padding: 7px 10px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.canvas-toolbar::-webkit-scrollbar { display: none; }
.tool-group { display: flex; align-items: center; gap: 5px; flex: none; }
.tool-btn { width: 38px; height: 38px; border-color: transparent; background: transparent; font-size: 18px; }
.tool-btn.text-tool { width: auto; padding: 0 10px; font-size: 13px; font-weight: 750; }
.tool-btn.is-on { color: var(--primary); background: var(--primary-soft); }
#zoomOutput { min-width: 49px; color: var(--muted); font-size: 12px; font-weight: 750; text-align: center; }
.canvas-stage { position: relative; min-height: clamp(430px, calc(100dvh - 276px), 760px); overflow: hidden; background-color: #dfe3eb; background-image: linear-gradient(45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.35) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.35) 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; touch-action: none; }
[data-theme="dark"] .canvas-stage { background-color: #252c38; background-image: linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.025) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.025) 75%); }
.upload-state { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; padding: 34px 24px; text-align: center; background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 35%), var(--surface-2); }
.upload-state.dragging { background: color-mix(in srgb, var(--primary) 9%, var(--surface-2)); box-shadow: inset 0 0 0 3px var(--primary); }
.upload-orbit { position: relative; width: 82px; height: 82px; margin-bottom: 18px; border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border)); border-radius: 50%; background: var(--surface); box-shadow: 0 13px 28px color-mix(in srgb, var(--primary) 12%, transparent); }
.upload-orbit:after { content: ""; position: absolute; inset: -9px; border: 1px dashed color-mix(in srgb, var(--primary) 28%, transparent); border-radius: 50%; }
.upload-orbit b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--primary); font-size: 34px; font-weight: 500; }
.upload-orbit span, .upload-orbit i { position: absolute; left: 19px; top: 42px; width: 43px; height: 2px; background: var(--text); transform-origin: left center; }
.upload-orbit i { transform: rotate(-46deg); }
.drop-kicker { margin: 0 0 4px; color: var(--primary); font-size: 12px; font-weight: 800; }
.upload-state h2 { margin: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.03em; }
.upload-state > p:not(.drop-kicker):not(.inline-error) { max-width: 520px; margin: 10px 0 22px; color: var(--muted); }
.upload-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.camera-button { display: none; }
.upload-hint { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; font-size: 12px; }
.upload-hint span:before { content: "✓"; margin-right: 6px; color: var(--green); font-weight: 900; }
.inline-error { max-width: 520px; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); border-radius: 9px; color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.canvas-stack { position: absolute; inset: 0; }
.canvas-stack canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlayCanvas { z-index: 2; touch-action: none; cursor: crosshair; }
.canvas-badge { position: absolute; z-index: 3; top: 12px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 28px); padding: 7px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 99px; background: rgba(18, 24, 37, .78); color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.2); backdrop-filter: blur(8px); font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.drop-cover, .processing { position: absolute; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; text-align: center; color: #fff; background: rgba(34, 35, 78, .88); backdrop-filter: blur(8px); }
.drop-cover { border: 3px solid #aaaaff; }
.drop-cover strong { font-size: 25px; }
.drop-cover span { color: #d8d9ff; }
.processing strong { margin-top: 18px; font-size: 20px; }
.processing > span { margin-top: 3px; color: #d7dbec; }
.processing-ring { position: relative; width: 62px; height: 62px; border: 2px solid rgba(255,255,255,.2); border-radius: 50%; }
.processing-ring span { position: absolute; inset: -2px; border: 3px solid transparent; border-top-color: #fff; border-radius: 50%; animation: spin .9s linear infinite; }
.progress-track { width: min(380px, calc(100vw - 74px)); height: 5px; margin: 22px 0 12px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.15); }
.progress-track i { display: block; width: 10%; height: 100%; border-radius: inherit; background: #8ee9cf; transition: width .25s ease; }
.processing ol { margin: 0; padding: 0; display: flex; gap: 14px; list-style: none; color: rgba(255,255,255,.48); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.processing li.active, .processing li.done { color: #fff; }
.placement-guide { position: absolute; z-index: 5; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(470px, calc(100% - 28px)); display: grid; grid-template-columns: 1fr auto; padding: 11px 12px 11px 15px; border: 1px solid rgba(255,255,255,.18); border-radius: 13px; color: #fff; background: rgba(19, 25, 39, .88); box-shadow: 0 8px 24px rgba(0,0,0,.25); backdrop-filter: blur(10px); }
.placement-guide strong, .placement-guide span { grid-column: 1; }
.placement-guide span { color: #c8d0de; font-size: 12px; }
.placement-guide button { grid-column: 2; grid-row: 1 / 3; align-self: center; min-height: 38px; border: 0; border-radius: 8px; padding: 0 12px; background: rgba(255,255,255,.12); color: #fff; }
.image-meta { min-height: 42px; display: flex; align-items: center; gap: 14px; padding: 8px 15px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }
.image-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-meta span:first-child { color: var(--green); font-weight: 700; }
.privacy-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); }

.control-panel { display: grid; gap: 12px; }
.primary-card, .summary-grid, .panel-tabs, .tab-panel, .export-card { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-sm); }
.primary-card { padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.primary-copy { display: grid; min-width: 0; }
.primary-copy strong { margin-top: 4px; }
.primary-copy p { margin: 2px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.step-chip { width: max-content; padding: 3px 7px; border-radius: 99px; color: var(--primary); background: var(--primary-soft); font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.detect-button { min-width: 140px; }
.button-icon { font-size: 20px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; }
.summary-grid article { min-width: 0; padding: 12px 7px 10px; display: grid; justify-items: center; border-right: 1px solid var(--border); }
.summary-grid article:last-child { border: 0; }
.summary-grid strong { font-size: 18px; letter-spacing: -.03em; }
.summary-grid span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.panel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 5px; }
.panel-tabs button { min-height: 40px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 750; }
.panel-tabs button[aria-selected="true"] { color: var(--text); background: var(--surface-3); }
.panel-tabs span { display: inline-grid; min-width: 18px; height: 18px; margin-left: 3px; place-items: center; padding: 0 5px; border-radius: 99px; color: #fff; background: var(--primary); font-size: 9px; }
.tab-panel { min-height: 250px; max-height: min(540px, calc(100dvh - 390px)); overflow: auto; padding: 14px; scrollbar-width: thin; }
.result-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 11px; }
label { color: var(--muted); font-size: 11px; font-weight: 650; }
select, input[type="text"] { width: 100%; min-height: 39px; margin-top: 4px; padding: 0 32px 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 11px; }
.results-list { display: grid; gap: 8px; }
.panel-empty { min-height: 188px; display: grid; place-content: center; justify-items: center; padding: 20px; text-align: center; color: var(--muted); }
.panel-empty > span { width: 45px; height: 45px; display: grid; place-items: center; margin-bottom: 8px; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 22px; }
.panel-empty strong { color: var(--text); }
.panel-empty p { max-width: 260px; margin: 4px 0 0; font-size: 11px; }
.result-item { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: center; padding: 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); transition: .14s ease; }
.result-item:hover, .result-item.selected { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); background: var(--primary-soft); }
.result-id { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: var(--surface); font-size: 11px; font-weight: 850; }
.result-main { min-width: 0; display: grid; }
.result-main > span { display: flex; align-items: baseline; gap: 7px; }
.result-main strong { font-size: 18px; letter-spacing: -.03em; }
.result-main small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.confidence { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.confidence i { width: 45px; height: 3px; overflow: hidden; border-radius: 4px; background: var(--border); }
.confidence i:after { content: ""; display: block; width: var(--confidence); height: 100%; background: var(--green); }
.result-actions { display: flex; gap: 2px; }
.result-actions button { width: 32px; height: 32px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.result-actions button:hover { background: var(--surface); color: var(--text); }
.result-actions button[aria-pressed="false"] { opacity: .48; }
#restoreButton { margin-top: 12px; }

.section-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 14px; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.mode-button { min-height: 76px; display: grid; place-items: center; align-content: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.mode-button > span { color: var(--muted); font-size: 19px; line-height: 1; }
.mode-button strong { margin-top: 5px; font-size: 10px; }
.mode-button small { color: var(--muted); font-size: 8px; }
.mode-button:hover, .mode-button.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.mode-button.selected > span { color: var(--primary); }
.selection-card { margin-top: 10px; padding: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.selection-card > div:first-child { display: grid; min-width: 0; }
.selection-card span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.selection-card strong { overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.selection-actions { display: flex; gap: 3px; }
.selection-actions button { border: 0; border-radius: 6px; padding: 6px; background: var(--surface); font-size: 9px; }
.selection-actions .danger-link { color: var(--danger); }
.switch-row { margin-top: 12px; position: relative; min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.switch-row > span { display: grid; }
.switch-row strong { color: var(--text); font-size: 10px; }
.switch-row small { font-size: 9px; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { width: 36px; height: 20px; padding: 3px; border-radius: 99px; background: var(--border-strong); }
.switch-row i:after { content: ""; display: block; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.switch-row input:checked + i { background: var(--primary); }
.switch-row input:checked + i:after { transform: translateX(16px); }
.tool-history { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 15px; }
.preset-grid button { min-height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 10px; font-weight: 700; }
.preset-grid button.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.settings-list { display: grid; gap: 13px; }
.settings-list label > span { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-list strong { color: var(--text); font-size: 10px; }
.settings-list output { min-width: 27px; padding: 2px 4px; border-radius: 5px; color: var(--primary); background: var(--primary-soft); text-align: center; font-size: 9px; }
.settings-list small { display: block; margin: 1px 0 5px; color: var(--muted); font-size: 8px; }
input[type="range"] { width: 100%; height: 4px; margin: 0; }
.setting-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 11px; padding-top: 13px; border-top: 1px solid var(--border); }
.export-card { position: relative; min-height: 68px; padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.export-card > div:first-child { display: flex; align-items: center; gap: 9px; }
.export-card > div span:last-child { display: grid; }
.export-card strong { font-size: 11px; }
.export-card small { color: var(--muted); font-size: 9px; }
.export-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--green); background: var(--green-soft); font-size: 18px; }
.export-menu { position: absolute; z-index: 20; right: 10px; top: calc(100% - 5px); width: 230px; padding: 6px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-lg); }
.export-menu button { width: 100%; min-height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; font-size: 11px; }
.export-menu button:hover { background: var(--surface-2); }
.export-menu button span { width: 22px; color: var(--primary); }
.privacy-note { margin: 0; display: flex; gap: 7px; justify-content: center; color: var(--muted); font-size: 9px; text-align: center; }
.privacy-note span { color: var(--green); }

footer { width: min(100% - 32px, 1540px); min-height: 62px; margin: 0 auto; display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 10px; }
footer span:first-child { color: var(--text); font-weight: 800; }
footer span:nth-child(2) { margin-right: auto; }
.mobile-action-bar { display: none; }
.legal-page { width: min(100% - 32px, 780px); margin: clamp(40px, 8vw, 90px) auto; padding: clamp(24px, 5vw, 52px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.legal-page h1 { margin: 5px 0 20px; font-size: clamp(30px, 6vw, 48px); line-height: 1.05; letter-spacing: -.045em; }
.legal-page h2 { margin: 26px 0 7px; font-size: 17px; }
.legal-page p { color: var(--muted); }
.legal-page .button { width: max-content; margin-top: 18px; color: #fff; text-decoration: none; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px)); display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-lg); color: var(--text); font-size: 12px; animation: toast-in .25s ease both; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--danger); }

.modal { width: min(760px, calc(100% - 28px)); max-height: min(88dvh, 820px); overflow: auto; border: 1px solid var(--border); border-radius: 20px; padding: 27px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(10, 14, 25, .62); backdrop-filter: blur(6px); }
.modal-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 9px; background: var(--surface-2); font-size: 23px; }
.modal-icon { width: 45px; height: 45px; display: grid; place-items: center; margin-bottom: 13px; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-size: 23px; }
.modal h2 { margin: 4px 46px 18px 0; font-size: 25px; letter-spacing: -.03em; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.help-grid section { padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.help-grid h3 { margin: 0 0 5px; font-size: 13px; }
.help-grid p, .help-grid ul { margin: 0; color: var(--muted); font-size: 11px; }
.help-grid ul { padding-left: 17px; }
.disclaimer { margin: 12px 0 18px; padding: 13px; border: 1px solid color-mix(in srgb, var(--amber) 38%, var(--border)); border-radius: 11px; background: color-mix(in srgb, var(--amber) 8%, var(--surface)); }
.disclaimer strong { font-size: 11px; }
.disclaimer p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.onboarding-modal { width: min(540px, calc(100% - 28px)); }
.onboarding-art { position: relative; width: 128px; height: 91px; margin: 4px auto 19px; }
.onboarding-art i { position: absolute; left: 12px; bottom: 14px; width: 112px; height: 3px; border-radius: 4px; background: var(--primary); transform-origin: left center; }
.onboarding-art i:first-child { transform: rotate(-43deg); }
.onboarding-art:after { content: ""; position: absolute; left: 31px; bottom: 17px; width: 45px; height: 45px; border: 2px solid var(--green); border-left-color: transparent; border-bottom-color: transparent; border-radius: 50%; transform: rotate(-22deg); }
.onboarding-art span { position: absolute; top: 4px; right: 0; padding: 4px 8px; border-radius: 99px; color: var(--green); background: var(--green-soft); font-size: 11px; font-weight: 800; }
.onboarding-modal .eyebrow, .onboarding-modal h2 { text-align: center; margin-right: 0; }
.onboarding-modal ol { display: grid; gap: 9px; margin: 0 0 19px; padding: 0; list-style: none; }
.onboarding-modal li { display: flex; gap: 11px; align-items: center; }
.onboarding-modal li > b { width: 31px; height: 31px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 11px; }
.onboarding-modal li span { display: grid; }
.onboarding-modal li strong { font-size: 11px; }
.onboarding-modal li small { color: var(--muted); font-size: 9px; }
.small-modal { width: min(440px, calc(100% - 28px)); }
.small-modal > p { color: var(--muted); font-size: 12px; }
.small-modal label { display: block; margin: 12px 0 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Readable application type scale */
body { font-size: 16px; line-height: 1.55; }
.brand small { font-size: 12px; }
.brand-mark b { font-size: 9px; }
.engine-status, #zoomOutput, .drop-kicker, .upload-hint { font-size: 13px; }
.eyebrow { font-size: 12px; line-height: 1.25; }
.canvas-badge { padding: 8px 14px; font-size: 12px; }
.processing ol { font-size: 11px; }
.placement-guide span { font-size: 13px; }
.image-meta { min-height: 44px; font-size: 12px; }
.primary-copy p { font-size: 13px; line-height: 1.4; }
.step-chip { padding: 4px 8px; font-size: 11px; }
.summary-grid strong { font-size: 21px; }
.summary-grid span { font-size: 11px; }
.panel-tabs button { min-height: 42px; font-size: 13px; }
.panel-tabs span { min-width: 20px; height: 20px; font-size: 10px; }
label { font-size: 12px; }
select, input[type="text"] { min-height: 42px; font-size: 13px; }
.panel-empty p { max-width: 280px; font-size: 13px; }
.result-id { width: 38px; height: 38px; font-size: 12px; }
.result-main small { font-size: 12px; }
.confidence { font-size: 11px; }
.section-heading h2 { font-size: 16px; }
.section-heading p { font-size: 12px; }
.mode-button { min-height: 82px; }
.mode-button strong { font-size: 12px; }
.mode-button small { font-size: 10px; }
.selection-card span { font-size: 10px; }
.selection-card strong { font-size: 12px; }
.selection-actions button { padding: 7px; font-size: 11px; }
.switch-row strong, .settings-list strong { font-size: 12px; }
.switch-row small, .settings-list small { font-size: 11px; line-height: 1.35; }
.settings-list small { margin: 2px 0 6px; }
.preset-grid button { min-height: 40px; font-size: 12px; }
.settings-list output { min-width: 30px; padding: 3px 5px; font-size: 11px; }
.export-card strong { font-size: 13px; }
.export-card small, .privacy-note { font-size: 11px; }
.export-menu button { min-height: 42px; font-size: 13px; }
footer { min-height: 64px; font-size: 12px; }
.toast { font-size: 13px; }
.help-grid h3, .disclaimer strong { font-size: 14px; }
.help-grid p, .help-grid ul { font-size: 13px; }
.disclaimer p, .onboarding-art span { font-size: 12px; }
.onboarding-modal li > b { width: 34px; height: 34px; font-size: 12px; }
.onboarding-modal li strong, .small-modal > p { font-size: 13px; }
.onboarding-modal li small { font-size: 11px; }

.about-section { padding: clamp(54px, 7vw, 96px) 0 clamp(64px, 8vw, 110px); border-top: 1px solid var(--border); background: var(--surface-2); }
.info-shell { width: min(100% - 32px, 1180px); margin-inline: auto; }
.info-heading { max-width: 760px; margin: 0 auto clamp(30px, 4vw, 48px); text-align: center; }
.info-heading h2, .faq-heading h2 { margin: 7px 0 12px; font-size: clamp(28px, 4vw, 44px); line-height: 1.08; letter-spacing: -.045em; }
.info-heading > p:last-child { margin: 0; color: var(--muted); font-size: clamp(16px, 1.7vw, 19px); }
.about-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(330px, .92fr); gap: 18px; }
.about-story, .process-card { min-width: 0; padding: clamp(24px, 3.4vw, 40px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.info-icon { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 15px; color: var(--primary); background: var(--primary-soft); font-size: 27px; }
.about-story h3 { margin: 0 0 10px; font-size: clamp(22px, 2.5vw, 30px); line-height: 1.15; letter-spacing: -.035em; }
.about-story > p { margin: 0; color: var(--muted); font-size: 16px; }
.about-points { margin: 28px 0 0; padding: 22px 0 0; display: grid; gap: 18px; border-top: 1px solid var(--border); list-style: none; }
.about-points li { display: flex; gap: 14px; align-items: flex-start; }
.about-points li > span { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 850; }
.about-points li div { display: grid; }
.about-points strong { font-size: 15px; }
.about-points small { margin-top: 2px; color: var(--muted); font-size: 13px; }
.process-card { background: var(--text); color: var(--surface); }
[data-theme="dark"] .process-card { background: #242d3e; color: #fff; }
.process-card .eyebrow { color: #aeb0ff; }
.process-list { margin: 21px 0 24px; padding: 0; display: grid; gap: 5px; list-style: none; }
.process-list li { position: relative; min-height: 66px; display: grid; grid-template-columns: 40px 1fr; gap: 13px; align-items: flex-start; }
.process-list li:not(:last-child):after { content: ""; position: absolute; left: 19px; top: 39px; bottom: -6px; width: 1px; background: rgba(255,255,255,.17); }
.process-list b { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; color: #b9f5e2; background: rgba(255,255,255,.08); font-size: 13px; }
.process-list div { display: grid; padding-top: 1px; }
.process-list strong { font-size: 15px; }
.process-list span { color: #b8c0cf; font-size: 13px; }
.accuracy-callout { display: flex; gap: 11px; padding: 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; background: rgba(255,255,255,.07); }
.accuracy-callout > span { color: #82e6c7; font-size: 22px; }
.accuracy-callout p { margin: 0; color: #cbd2df; font-size: 12px; }
.accuracy-callout strong { display: block; color: #fff; font-size: 13px; }
.use-cases { margin: 18px 0 clamp(58px, 8vw, 92px); display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.use-cases span { padding: 8px 13px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 700; }
.faq-section { scroll-margin-top: calc(var(--header-h) + 20px); }
.faq-heading { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 390px); gap: 34px; align-items: end; margin-bottom: 28px; }
.faq-heading h2 { margin-bottom: 0; }
.faq-heading > p { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.faq-list { border-top: 1px solid var(--border-strong); }
.faq-list details { border-bottom: 1px solid var(--border-strong); }
.faq-list summary { min-height: 72px; display: grid; grid-template-columns: 1fr 30px; gap: 20px; align-items: center; padding: 16px 4px; color: var(--text); font-size: clamp(16px, 1.7vw, 19px); font-weight: 760; list-style: none; cursor: pointer; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary i { position: relative; width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); transition: transform .18s ease, background .18s ease; }
.faq-list summary i:before, .faq-list summary i:after { content: ""; position: absolute; left: 8px; right: 8px; top: 13px; height: 2px; border-radius: 2px; background: var(--primary); }
.faq-list summary i:after { transform: rotate(90deg); }
.faq-list details[open] summary i { transform: rotate(45deg); background: var(--primary-soft); }
.faq-list details[open] summary { color: var(--primary); }
.faq-answer { padding: 0 min(70px, 6vw) 22px 4px; }
.faq-answer p { max-width: 850px; margin: 0; color: var(--muted); font-size: 15px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .4; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: minmax(0, 1fr) 330px; }
  .workspace-heading { min-height: 104px; }
  .workspace-heading p:last-child { max-width: 560px; }
  .tab-panel { max-height: 480px; }
  .primary-card { grid-template-columns: 1fr; }
  .detect-button { width: 100%; }
}

@media (max-width: 820px) {
  :root { --header-h: 64px; }
  .header-inner, .app-shell, footer { width: min(100% - 20px, 720px); }
  .brand small { display: none; }
  .engine-status span { display: none; }
  .engine-status { width: 34px; justify-content: center; padding: 0; border: 0; background: transparent; }
  .app-shell { margin-top: 10px; display: block; padding-bottom: 84px; }
  .camera-button { display: inline-flex; }
  .workspace-heading { min-height: auto; padding: 17px; }
  .workspace-heading .eyebrow, .workspace-heading p:last-child, .desktop-upload { display: none; }
  .workspace-heading h1 { margin: 0; font-size: 21px; }
  .canvas-stage { min-height: min(68dvh, 590px); }
  .control-panel { margin-top: 10px; }
  .summary-grid, .panel-tabs, .tab-panel, .export-card, .privacy-note { display: none; }
  .control-panel.mobile-open .panel-tabs, .control-panel.mobile-open .tab-panel { display: grid; }
  .control-panel.mobile-open .panel-tabs { position: sticky; top: var(--header-h); z-index: 9; }
  .control-panel.mobile-open .tab-panel { max-height: none; min-height: 250px; }
  .control-panel.mobile-open .summary-grid { display: grid; }
  .control-panel.mobile-export .export-card { position: fixed; z-index: 55; left: 12px; right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); display: flex; box-shadow: var(--shadow-lg); }
  .control-panel.mobile-export .export-menu { top: auto; bottom: calc(100% + 6px); right: 0; }
  .primary-card { grid-template-columns: 1fr auto; }
  .detect-button { width: auto; min-width: 145px; }
  .mobile-action-bar { position: fixed; z-index: 40; left: 10px; right: 10px; bottom: max(9px, env(safe-area-inset-bottom)); height: 62px; display: grid; grid-template-columns: repeat(5, 1fr); padding: 5px; border: 1px solid var(--border); border-radius: 16px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow-lg); backdrop-filter: blur(16px); }
  .mobile-action-bar button { min-width: 0; display: grid; place-items: center; align-content: center; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
  .mobile-action-bar span { font-size: 18px; line-height: 1.1; }
  .mobile-action-bar .mobile-detect { margin: -14px 2px 0; border-radius: 14px; background: var(--primary); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 28%, transparent); }
  .about-section { padding-block: 48px 78px; }
  .about-grid, .faq-heading { grid-template-columns: 1fr; }
  .faq-heading { gap: 8px; }
  footer { padding-bottom: 82px; flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .header-inner { width: calc(100% - 20px); }
  .brand-mark { width: 38px; height: 38px; }
  .brand strong { font-size: 15px; }
  .app-shell { width: calc(100% - 12px); }
  .workspace-card { border-radius: 14px; }
  .workspace-heading { padding: 13px 14px; }
  .workspace-heading h1 { font-size: 18px; }
  .canvas-stage { min-height: 54dvh; }
  .upload-state { padding: 26px 17px; }
  .upload-orbit { width: 68px; height: 68px; margin-bottom: 14px; }
  .upload-orbit span, .upload-orbit i { left: 15px; top: 35px; width: 38px; }
  .upload-orbit b { font-size: 28px; }
  .upload-state h2 { font-size: 21px; }
  .upload-state > p:not(.drop-kicker):not(.inline-error) { margin: 8px 0 17px; font-size: 13px; }
  .upload-actions { width: 100%; }
  .upload-actions .button { width: 100%; }
  .upload-hint { margin-bottom: 0 !important; gap: 4px 12px; }
  .canvas-toolbar { padding-inline: 5px; }
  .tool-btn { width: 36px; height: 36px; }
  .primary-card { grid-template-columns: 1fr; }
  .detect-button { width: 100%; }
  .image-meta { gap: 8px; }
  #imageDimensions { display: none; }
  .help-grid { grid-template-columns: 1fr; }
  .modal { padding: 22px 18px; }
  .modal h2 { font-size: 21px; }
  .mode-grid { grid-template-columns: repeat(2, 1fr); }
  .result-controls, .setting-footer { grid-template-columns: 1fr; }
  .info-shell { width: calc(100% - 20px); }
  .info-heading { text-align: left; }
  .info-heading h2, .faq-heading h2 { font-size: 28px; }
  .about-story, .process-card { padding: 22px 18px; }
  .use-cases { justify-content: flex-start; }
  .faq-list summary { min-height: 68px; padding-block: 15px; font-size: 16px; }
  .faq-answer { padding-right: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .app-header, .control-panel, .canvas-toolbar, .workspace-heading, footer, .mobile-action-bar, .image-meta { display: none !important; }
  body { background: #fff; }
  .app-shell { width: 100%; margin: 0; display: block; }
  .workspace-card { border: 0; box-shadow: none; }
  .canvas-stage { min-height: 90vh; background: #fff; }
}
