/* Image Provenance — minimalist monochrome UI
 * Light/Dark via [data-theme]. Zero frameworks, zero runtime deps. */

/* ---------- Design tokens ---------- */
:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #fafafa;
    --surface-hover: #f4f4f5;
    --border: #e7e7e9;
    --border-strong: #d4d4d8;
    --text: #0a0a0b;
    --text-muted: #71717a;
    --text-subtle: #a1a1aa;
    --accent: #0a0a0b;
    --accent-fg: #ffffff;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --info: #1e40af;
    --info-bg: #eff6ff;
    --warn: #a16207;
    --warn-bg: #fefce8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 12px -2px rgba(0,0,0,.06), 0 24px 48px -16px rgba(0,0,0,.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --ease: cubic-bezier(.2,.8,.2,1);
    --dur-fast: 160ms;
    --dur: 240ms;
    --dur-slow: 380ms;
}

[data-theme="dark"] {
    --bg: #0a0a0b;
    --surface: #111113;
    --surface-alt: #18181b;
    --surface-hover: #27272a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-subtle: #71717a;
    --accent: #fafafa;
    --accent-fg: #0a0a0b;
    --danger: #f87171;
    --danger-bg: rgba(239,68,68,.09);
    --success: #4ade80;
    --success-bg: rgba(34,197,94,.09);
    --info: #60a5fa;
    --info-bg: rgba(59,130,246,.09);
    --warn: #facc15;
    --warn-bg: rgba(234,179,8,.09);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 1px 3px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
    --shadow-lg: 0 4px 12px -2px rgba(0,0,0,.4), 0 24px 48px -16px rgba(0,0,0,.6);
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: light dark; -webkit-text-size-adjust: 100%; }
body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
                 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg); color: var(--text);
    min-height: 100vh; font-size: 15px; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.mono { font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'JetBrains Mono', monospace; }
img { max-width: 100%; display: block; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--text); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--text-muted); }

/* ---------- Shell layout ---------- */
.shell {
    max-width: 960px; margin: 0 auto;
    padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 32px) 64px;
    display: flex; flex-direction: column; gap: clamp(20px, 3vw, 32px);
}

/* ---------- Top bar ---------- */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: clamp(8px, 2vw, 16px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; color: var(--text); }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-actions { display: flex; gap: 4px; align-items: center; }
.icon-link, .theme-toggle {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent;
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.icon-link:hover, .theme-toggle:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.theme-toggle { position: relative; overflow: hidden; }
.theme-icon { position: absolute; transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease); }
[data-theme="light"] .icon-sun { transform: translateY(0) rotate(0); opacity: 1; }
[data-theme="light"] .icon-moon { transform: translateY(200%) rotate(90deg); opacity: 0; }
[data-theme="dark"] .icon-sun { transform: translateY(-200%) rotate(-90deg); opacity: 0; }
[data-theme="dark"] .icon-moon { transform: translateY(0) rotate(0); opacity: 1; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: clamp(4px, 1vw, 12px) 0; }
.hero-title {
    font-size: clamp(28px, 5vw, 40px);
    letter-spacing: -0.025em; font-weight: 600; line-height: 1.1;
    margin-bottom: 12px;
}
.hero-sub {
    color: var(--text-muted); font-size: clamp(13px, 1.6vw, 15px);
    max-width: 560px; margin: 0 auto; line-height: 1.65;
}
.dot-sep { display: inline-block; width: 3px; height: 3px; border-radius: 50%;
    background: var(--text-subtle); margin: 0 8px; vertical-align: middle; opacity: .7; }

/* ---------- Upload ---------- */
.upload-area {
    border: 1.5px dashed var(--border-strong); border-radius: var(--radius-xl);
    background: var(--surface);
    padding: clamp(32px, 6vw, 56px) 24px;
    text-align: center; cursor: pointer;
    transition: all var(--dur) var(--ease);
    position: relative; overflow: hidden;
}
.upload-area:hover { border-color: var(--text); background: var(--surface-alt); transform: translateY(-1px); }
.upload-area.dragover { border-color: var(--text); background: var(--surface-alt);
    transform: scale(1.01); box-shadow: var(--shadow-lg); }
.upload-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.upload-mark { width: 40px; height: 40px; color: var(--text-subtle); }
.upload-text { font-size: clamp(14px, 1.8vw, 16px); color: var(--text-muted); }
.upload-text strong { color: var(--text); font-weight: 600; border-bottom: 1.5px solid var(--text); padding-bottom: 1px; }
.upload-hint { font-size: 12px; color: var(--text-subtle); }
#fileInput { display: none; }

/* ---------- Generic card / summary ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.eyebrow {
    display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-subtle); margin-bottom: 6px;
}

.summary {
    padding: clamp(20px, 3vw, 28px);
    display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
}
.summary-main { flex: 1; min-width: 0; }
.summary-title {
    font-size: clamp(18px, 2.4vw, 22px); font-weight: 600; line-height: 1.3;
    letter-spacing: -0.015em; margin-bottom: 4px;
}
.summary-sub { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.pill {
    display: inline-flex; align-items: center; padding: 6px 14px;
    border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
    border: 1px solid var(--border);
}
.pill.badge-hit { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.pill.badge-clean { background: var(--success-bg); color: var(--success); border-color: transparent; }
.pill.badge-uncertain { background: var(--info-bg); color: var(--info); border-color: transparent; }

/* ---------- Meta row ---------- */
.meta-row {
    display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 1px;
    background: var(--border); border: 1px solid var(--border);
    border-radius: var(--radius-md); overflow: hidden;
}
.meta-cell {
    background: var(--surface); padding: 14px 16px;
    display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.meta-label { font-size: 11px; font-weight: 500; color: var(--text-subtle);
    letter-spacing: 0.05em; text-transform: uppercase; }
.meta-value { font-size: 14px; font-weight: 500; color: var(--text);
    word-break: break-all; overflow-wrap: anywhere; }

/* ---------- Detail section (preview + detection tabs) ---------- */
.detail-section { display: grid; grid-template-columns: 5fr 7fr; gap: 16px; }
.preview-card { padding: clamp(14px, 2vw, 20px); display: flex; flex-direction: column; gap: 12px; }
.preview-card img {
    width: 100%; border-radius: var(--radius-md); max-height: 420px;
    object-fit: contain; background: var(--surface-alt);
    border: 1px solid var(--border);
}
.file-meta { font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.detection-card { padding: clamp(14px, 2vw, 20px); }

/* ---------- Tabs ---------- */
.tab-bar { display: flex; gap: 2px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.tab-btn {
    border: none; background: transparent; padding: 10px 14px;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    cursor: pointer; position: relative;
    transition: color var(--dur-fast) var(--ease);
}
.tab-btn::after {
    content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px;
    background: var(--text); transform: scaleX(0); transform-origin: center;
    transition: transform var(--dur) var(--ease);
}
.tab-btn.active { color: var(--text); }
.tab-btn.active::after { transform: scaleX(1); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel.hidden { display: none; }
.tab-panel { animation: fadeIn var(--dur) var(--ease); }
/* Convert tab children stack with breathing room between each block.
 * Without this, convert-head / camera selector / watermark block /
 * advanced-panel / Convert button / result all glue together because
 * they each declare their own top-level margins or none at all. */
.tab-panel[data-panel="convert"] { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 560px) { .tab-panel[data-panel="convert"] { gap: 16px; } }

/* ---------- Detection items ---------- */
.detection-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.detection-item:first-child { padding-top: 10px; }
.detection-item:last-child { border-bottom: none; padding-bottom: 4px; }
.detection-item-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.detection-item-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detection-item-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; }
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.badge-hit { background: var(--danger-bg); color: var(--danger); }
.badge-clean { background: var(--success-bg); color: var(--success); }
.badge-uncertain { background: var(--info-bg); color: var(--info); }
.conf {
    display: inline-block; padding: 1px 8px; border-radius: 6px;
    font-size: 10.5px; font-weight: 600; border: 1px solid var(--border);
}
.conf-strong { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.conf-medium { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.conf-weak { background: var(--surface-alt); color: var(--text-muted); }
.conf-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.detection-item-details { margin-top: 10px; font-size: 12px; }
.detection-item-details summary {
    cursor: pointer; color: var(--text-muted); user-select: none; padding: 2px 0;
    list-style: none; font-size: 11.5px; font-weight: 500;
    transition: color var(--dur-fast) var(--ease);
}
.detection-item-details summary::-webkit-details-marker { display: none; }
.detection-item-details summary::before {
    content: '→'; margin-right: 6px; display: inline-block;
    transition: transform var(--dur-fast) var(--ease);
}
.detection-item-details[open] summary::before { transform: rotate(90deg); }
.detection-item-details summary:hover { color: var(--text); }
.detection-item-detail {
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 11px; color: var(--text-muted); margin-top: 10px;
    max-height: 200px; overflow-y: auto; white-space: pre-wrap;
    word-break: break-all; line-height: 1.65;
}

/* ---------- Buttons ---------- */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--accent); color: var(--accent-fg);
    border: 1px solid var(--accent); border-radius: var(--radius-md);
    padding: 11px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: transform var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                opacity var(--dur-fast) var(--ease);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-full { width: 100%; }
.btn-secondary {
    display: inline-flex; align-items: center; gap: 8px; background: transparent;
    color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    padding: 9px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--text); }

/* ---------- Convert section ---------- */
.convert-section { padding: clamp(20px, 3vw, 28px); display: flex; flex-direction: column; gap: 18px; }
.convert-head { display: flex; flex-direction: column; gap: 2px; }
.camera-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.camera-option {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 14px 10px; text-align: center; cursor: pointer;
    background: var(--surface);
    transition: all var(--dur-fast) var(--ease);
}
.camera-option:hover { border-color: var(--border-strong); background: var(--surface-alt); }
.camera-option.selected {
    border-color: var(--text); background: var(--surface-alt);
    box-shadow: inset 0 0 0 1px var(--text);
}
.camera-option .icon { font-size: 20px; margin-bottom: 4px; }
.camera-option .name { font-size: 12.5px; font-weight: 600; }
.camera-option .model { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Toggle (checkbox pill) ---------- */
.disrupt-row {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
    background: var(--surface-alt);
}
.toggle-row { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-slider {
    width: 36px; height: 20px; border-radius: 999px;
    background: var(--border-strong); position: relative; flex-shrink: 0;
    transition: background-color var(--dur-fast) var(--ease);
}
.toggle-slider::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%; background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-fast) var(--ease);
}
.toggle-row input:checked + .toggle-slider { background: var(--text); }
.toggle-row input:checked + .toggle-slider::after { transform: translateX(16px); }
.toggle-text { font-size: 13.5px; font-weight: 500; }
.panel-hint, .panel-hint-inline {
    font-size: 12px; color: var(--text-muted); line-height: 1.6;
}
.panel-hint-inline { margin-left: 46px; margin-top: -4px; }
.slider-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); margin-left: 46px; }
.slider-row input[type="range"] {
    flex: 1; max-width: 200px; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--border-strong); border-radius: 999px; outline: none; cursor: pointer;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--text); border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm); cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%; background: var(--text);
    border: 2px solid var(--surface); cursor: pointer;
}
.slider-val { font-weight: 600; color: var(--text); min-width: 12px; }
.slider-label { min-width: 28px; }

.convert-result {
    margin-top: 4px; padding: 16px; background: var(--success-bg);
    border: 1px solid transparent; border-radius: var(--radius-md); display: none;
}
.convert-result.error { background: var(--danger-bg); }
.convert-result img { max-width: 100%; border-radius: var(--radius-sm); margin: 10px 0;
    border: 1px solid var(--border); }
.convert-result .download-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--text); color: var(--accent-fg); padding: 9px 16px;
    border-radius: var(--radius-md); text-decoration: none;
    font-size: 13px; font-weight: 500; border: none; cursor: pointer;
    transition: opacity var(--dur-fast) var(--ease);
}
.convert-result .download-btn:hover { opacity: .85; }

/* ---------- Loading ---------- */
.loading { text-align: center; padding: 32px; color: var(--text-muted); font-size: 13px; }
.spinner {
    display: inline-block; width: 24px; height: 24px; border: 2px solid var(--border-strong);
    border-top-color: var(--text); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Frequency panel ---------- */
.freq-head { padding: 10px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.freq-verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.freq-verdict-label { font-size: 11px; color: var(--text-subtle);
    text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.freq-verdict-value { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.freq-verdict.conf-strong .freq-verdict-value { color: var(--danger); }
.freq-verdict.conf-medium .freq-verdict-value { color: var(--warn); }
.freq-verdict.conf-info .freq-verdict-value { color: var(--success); }
.freq-score { font-size: 11.5px; color: var(--text-muted); margin-left: auto; }
.freq-timing { margin-top: 6px; font-size: 11px; color: var(--text-subtle); }

.freq-viz { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.freq-viz-box { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.freq-viz-title { font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; }
.freq-viz-box canvas {
    width: 100%; height: auto; border-radius: var(--radius-sm);
    background: #000; border: 1px solid var(--border);
}
.freq-viz-box canvas#radialCanvas { background: var(--surface-alt); }
.freq-viz-hint { font-size: 11px; color: var(--text-subtle); line-height: 1.55; }

.freq-subtitle { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: 0.05em; }
.freq-vote {
    display: flex; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
    margin-bottom: 6px; font-size: 13px; line-height: 1.45;
    border: 1px solid var(--border); background: var(--surface-alt);
}
.vote-pos { border-left: 2px solid var(--danger); }
.vote-neg { border-left: 2px solid var(--success); }
.vote-weight { font-weight: 700; min-width: 24px; text-align: center; }
.vote-pos .vote-weight { color: var(--danger); }
.vote-neg .vote-weight { color: var(--success); }
.vote-reason { color: var(--text); flex: 1; }
.freq-empty { font-size: 12px; color: var(--text-subtle); padding: 10px 0; }

.freq-features { margin-top: 14px; font-size: 12px; }
.freq-features summary {
    cursor: pointer; color: var(--text-muted); font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
    padding: 8px 0; list-style: none;
    border-top: 1px solid var(--border);
}
.freq-features summary::-webkit-details-marker { display: none; }
.freq-features summary::before { content: '+ '; }
.freq-features[open] summary::before { content: '− '; }
.freq-features summary:hover { color: var(--text); }
.freq-table {
    width: 100%; border-collapse: collapse; margin-top: 8px;
    font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px;
}
.freq-table td { border-bottom: 1px solid var(--border); padding: 4px 10px; }
.freq-table td:first-child { color: var(--text-muted); }
.freq-table td:last-child { text-align: right; color: var(--text); }

/* ---------- Footer ---------- */
.foot {
    padding-top: 24px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-subtle);
    display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px;
}
.foot a { color: var(--text-muted); border-bottom: 1px solid var(--border-strong); padding-bottom: 1px; }
.foot a:hover { color: var(--text); border-bottom-color: var(--text); }

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Animations ---------- */
.anim-in { opacity: 0; transform: translateY(8px); animation: revealUp var(--dur-slow) var(--ease) forwards; }
.anim-in:nth-child(1) { animation-delay: 0ms; }
.anim-in:nth-child(2) { animation-delay: 60ms; }
.anim-in:nth-child(3) { animation-delay: 120ms; }
.anim-in:nth-child(4) { animation-delay: 180ms; }
.anim-in:nth-child(5) { animation-delay: 240ms; }
#results > .anim-in { animation-delay: 0ms; }
#results > .anim-in + .anim-in { animation-delay: 60ms; }
#results > .anim-in + .anim-in + .anim-in { animation-delay: 120ms; }
#results > .anim-in + .anim-in + .anim-in + .anim-in { animation-delay: 180ms; }
@keyframes revealUp { to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important; transition-duration: 0.01ms !important;
    }
    .anim-in { opacity: 1; transform: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    .detail-section { grid-template-columns: 1fr; }
    .meta-row { grid-template-columns: 1fr 1fr; }
    .meta-cell-wide { grid-column: 1 / -1; }
    .summary { flex-direction: column; gap: 12px; }
    .pill { align-self: flex-start; }
    .freq-viz { grid-template-columns: 1fr; }
    .freq-score { margin-left: 0; }
    .panel-hint-inline, .slider-row { margin-left: 0; }
    .camera-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* ========== Two-pane workspace layout ========== */
.shell {
    max-width: 1200px;
    min-height: 100vh;
    display: flex; flex-direction: column;
    gap: 20px;
}
.workspace {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    gap: 20px;
    align-items: start;
}
.pane { min-width: 0; }
.pane-left {
    display: flex; flex-direction: column; gap: 16px;
    position: sticky; top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;          /* failsafe: if content exceeds max-height, scroll inside the pane rather than crop */
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.pane-left::-webkit-scrollbar { width: 6px; }
.pane-left::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.pane-left::-webkit-scrollbar-track { background: transparent; }

/* Upload area in left pane */
.pane-left .upload-area { padding: clamp(28px, 4vw, 40px) 20px; }
.pane-left .upload-mark { width: 32px; height: 32px; }
.pane-left .upload-text { font-size: 13px; line-height: 1.6; }

/* Preview block (visible after upload) */
.preview-block {
    display: flex; flex-direction: column; gap: 14px;
    animation: revealUp var(--dur-slow) var(--ease);
}
.preview-frame {
    position: relative; border-radius: var(--radius-lg);
    overflow: hidden; background: var(--surface-alt);
    border: 1px solid var(--border);
}
.preview-frame img {
    width: 100%; display: block; object-fit: contain;
    /* Dynamic height: don't let a tall portrait push the file-meta card
     * out of the viewport. Cap at 60vh and also at (viewport − reserved
     * space for the meta card). Minimum 180px so a tiny landscape image
     * still shows usefully. */
    max-height: min(60vh, calc(100vh - 300px));
    min-height: 180px;
    background: var(--surface-alt);
}
.preview-change {
    position: absolute; top: 10px; right: 10px;
    background: rgba(0,0,0,.7); color: #fff; backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none; border-radius: 999px; padding: 6px 12px;
    font-size: 12px; font-weight: 500; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    /* Always visible: touch devices have no hover */
    opacity: 1; transform: translateY(0);
    transition: opacity var(--dur-fast) var(--ease),
                background-color var(--dur-fast) var(--ease);
    z-index: 2;
}
.preview-change:hover { background: rgba(0,0,0,.85); }
@media (hover: hover) {
    /* Desktop: fade in on hover so the button doesn't distract while
     * viewing the image */
    .preview-change { opacity: 0; }
    .preview-frame:hover .preview-change,
    .preview-change:focus-visible { opacity: 1; }
}

.file-meta-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 14px 16px;
    display: flex; flex-direction: column; gap: 10px;
    box-shadow: var(--shadow-sm);
}
.fm-name {
    font-size: 13px; font-weight: 600; word-break: break-all;
    padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.fm-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.fm-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fm-label {
    font-size: 10px; font-weight: 600; color: var(--text-subtle);
    text-transform: uppercase; letter-spacing: 0.08em;
}
.fm-value { font-size: 12.5px; font-weight: 500; word-break: break-word; }
.fm-hash {
    display: flex; flex-direction: column; gap: 3px;
    padding-top: 10px; border-top: 1px solid var(--border);
}
.fm-hash .fm-value {
    font-size: 10.5px; color: var(--text-muted); line-height: 1.5;
    word-break: break-all; letter-spacing: -0.02em;
}

/* ========== Right pane ========== */
.pane-right {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    padding: clamp(20px, 3vw, 32px);
    min-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
}

/* Empty state (before upload) */
.empty-state {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; align-items: flex-start; gap: 18px;
    padding: 20px 0;
}
.empty-state .hero-title {
    font-size: clamp(28px, 4vw, 40px); text-align: left;
    letter-spacing: -0.025em; line-height: 1.1; margin: 0;
}
.empty-state .hero-sub {
    font-size: clamp(13px, 1.5vw, 15px); text-align: left;
    color: var(--text-muted); line-height: 1.65; margin: 0; max-width: 520px;
}
.empty-checks {
    margin-top: 12px; display: flex; flex-direction: column; gap: 10px;
}
.empty-check {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; color: var(--text-muted);
}
.ec-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-subtle); flex-shrink: 0;
}

/* Result view (after upload) */
.result-view {
    flex: 1; display: flex; flex-direction: column; gap: 18px;
    animation: fadeIn var(--dur) var(--ease);
}
.result-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; padding-bottom: 22px; border-bottom: 1px solid var(--border);
}
.result-head-text { flex: 1; min-width: 0; }
.result-head .summary-title { margin-top: 2px; }

/* ========== Analysis log (progressive / fake streaming) ========== */
.analysis-log {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12.5px; line-height: 1.7; color: var(--text-muted);
    margin-bottom: 16px;
    display: flex; flex-direction: column; gap: 4px;
}
.log-line {
    display: flex; align-items: center; gap: 10px; padding: 2px 0;
    animation: logLineIn 240ms var(--ease);
}
@keyframes logLineIn {
    from { opacity: 0; transform: translateX(-4px); }
    to { opacity: 1; transform: translateX(0); }
}
.log-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; flex-shrink: 0;
}
.log-line.pending .log-mark::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-subtle); animation: pulseDot 1s infinite;
}
@keyframes pulseDot {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}
.log-line.done .log-mark { color: var(--success); }
.log-line.done.warn .log-mark { color: var(--warn); }
.log-line.done.hit .log-mark { color: var(--danger); }
.log-text { flex: 1; min-width: 0; }
.log-text .dots {
    display: inline-block; animation: dotDance 1.2s infinite steps(4, end);
    width: 1.5em; text-align: left;
}
@keyframes dotDance {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}
.log-line.pending .log-text::after { content: ''; display: inline-block; width: 1.5em; }
.log-line.pending .log-text .trail::after {
    content: '...'; color: var(--text-subtle);
    animation: dots 1.2s infinite;
}
@keyframes dots {
    0%, 100% { opacity: 0; }
    20% { opacity: 0; }
    40% { opacity: 1; }
    60% { opacity: 1; }
    80% { opacity: 1; }
}
.log-line.done .log-text .trail { display: none; }
.log-line .log-detail {
    font-size: 11px; color: var(--text-subtle); margin-left: 8px;
}

/* ========== Mobile: stack panes ========== */
@media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; gap: 14px; }
    .pane-left { position: static; max-height: none; }
    .pane-right { min-height: auto; }
    .pane-left .preview-frame img { max-height: 280px; }
    .empty-state { padding: 20px 0; }
}
@media (max-width: 720px) {
    .fm-grid { grid-template-columns: repeat(2, 1fr); }
}

/* hide the old hero/results CSS that's no longer used */
.hero, .meta-row, .detail-section, .card.summary, .card.convert-section,
.card.preview-card, .card.detection-card { /* unused — markup replaced */ }

/* ========== Metadata panel ========== */
.md-verdict {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px; border-radius: var(--radius-md);
    background: var(--surface-alt); border: 1px solid var(--border);
    margin-bottom: 18px;
}
.md-verdict-strong { background: var(--success-bg); border-color: transparent; }
.md-verdict-ai { background: var(--danger-bg); border-color: transparent; }
.md-verdict-medium { background: var(--warn-bg); border-color: transparent; }
.md-verdict-icon {
    font-size: 24px; width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
}
.md-verdict-text { flex: 1; min-width: 0; }
.md-verdict-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.md-verdict-strong .md-verdict-title { color: var(--success); }
.md-verdict-ai .md-verdict-title { color: var(--danger); }
.md-verdict-medium .md-verdict-title { color: var(--warn); }
.md-verdict-sub { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.md-section { margin-bottom: 18px; }
.md-section.accent { padding: 14px 16px; background: var(--surface-alt);
    border: 1px solid var(--border); border-radius: var(--radius-md); }
.md-section-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-subtle);
    margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.md-section.accent .md-section-title { border-bottom: none; padding-bottom: 0; margin-bottom: 6px; }
.md-count {
    display: inline-block; background: var(--text); color: var(--accent-fg);
    font-size: 10px; padding: 1px 6px; border-radius: 999px; font-weight: 700;
}
.md-note {
    font-size: 12px; color: var(--text-muted);
    padding: 8px 10px; background: var(--surface); border-radius: var(--radius-sm);
    margin-bottom: 10px; line-height: 1.5;
}
.md-note.warn { color: var(--warn); background: var(--warn-bg); }
.md-rows { display: flex; flex-direction: column; }
.md-row {
    display: flex; gap: 14px; padding: 7px 0; font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.md-row:last-child { border-bottom: none; }
.md-label { flex: 0 0 110px; color: var(--text-muted); font-size: 12px; }
.md-value { flex: 1; min-width: 0; word-break: break-word; color: var(--text); }
.md-value.mono { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }

.md-actions { margin-top: 10px; }
.btn-xs { font-size: 11.5px; padding: 6px 12px; }

.md-hist { list-style: none; counter-reset: h; padding: 0; margin: 0; }
.md-hist li {
    counter-increment: h; padding: 8px 0 8px 28px; position: relative;
    border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.md-hist li:last-child { border-bottom: none; }
.md-hist li::before {
    content: counter(h); position: absolute; left: 0; top: 8px;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--surface-alt); border: 1px solid var(--border);
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
}
.md-hist-action { font-weight: 600; }
.md-hist-meta { color: var(--text-muted); font-size: 11px; margin-left: 6px; }

.md-raw { margin-top: 16px; font-size: 11.5px; }
.md-raw summary {
    cursor: pointer; padding: 8px 0; color: var(--text-muted);
    font-weight: 600; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.06em; list-style: none;
    border-top: 1px solid var(--border);
}
.md-raw summary::-webkit-details-marker { display: none; }
.md-raw summary::before { content: '+ '; }
.md-raw[open] summary::before { content: '− '; }
.md-raw pre {
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px;
    font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px;
    color: var(--text-muted); line-height: 1.7; max-height: 360px;
    overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.md-empty {
    padding: 20px; text-align: center; color: var(--text-muted);
    background: var(--surface-alt); border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md); font-size: 13px;
}

/* Frequency disclaimer banner */
.freq-disclaimer {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px; margin-bottom: 16px;
    background: var(--warn-bg); border-radius: var(--radius-sm);
    font-size: 12px; color: var(--text); line-height: 1.5;
}
.freq-disclaimer-tag {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 4px;
    background: var(--warn); color: var(--bg);
    font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; flex-shrink: 0;
}
[data-theme="dark"] .freq-disclaimer-tag { color: var(--accent-fg); }

/* ========== Camera selector (grouped) ========== */
.camera-group { margin-bottom: 18px; }
.camera-group:last-child { margin-bottom: 0; }
.camera-group-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--text-subtle);
    margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.camera-group-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: 999px; font-size: 10px; color: var(--text-muted);
}

/* ========== Advanced options panel ========== */
.advanced-panel {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-alt);
    margin-top: 6px;
}
.advanced-panel summary {
    padding: 12px 16px; cursor: pointer; user-select: none;
    font-size: 13px; font-weight: 500; color: var(--text);
    display: flex; align-items: center; gap: 8px;
    list-style: none;
}
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-chev {
    font-size: 10px; color: var(--text-muted);
    transition: transform var(--dur-fast) var(--ease);
}
.advanced-panel[open] .advanced-chev { transform: rotate(90deg); }
.advanced-note {
    margin-left: auto; font-size: 11px; font-weight: 400; color: var(--text-subtle);
}
.advanced-body {
    padding: 4px 16px 16px; border-top: 1px solid var(--border);
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px;
}
.adv-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.adv-field.adv-full { grid-column: 1 / -1; }
.adv-label {
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    letter-spacing: 0.04em;
}
.adv-control { display: flex; align-items: center; gap: 8px; }
.adv-control input[type="range"] { flex: 1; max-width: 140px; }
.advanced-body select,
.advanced-body input[type="number"],
.advanced-body input[type="datetime-local"] {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 7px 10px;
    font-size: 13px; color: var(--text); width: 100%;
    transition: border-color var(--dur-fast) var(--ease);
    outline: none;
}
.advanced-body select:focus,
.advanced-body input[type="number"]:focus,
.advanced-body input[type="datetime-local"]:focus {
    border-color: var(--text);
}
[data-theme="dark"] .advanced-body input[type="datetime-local"] { color-scheme: dark; }
@media (max-width: 600px) {
    .advanced-body { grid-template-columns: 1fr; }
}

/* ========== Watermark controls ========== */
.wm-controls {
    display: flex; flex-direction: column; gap: 12px;
    margin-top: 4px;
}
.wm-control-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-left: 46px;
    font-size: 12px; color: var(--text-muted);
}
.wm-ctrl-label { min-width: 28px; }
.wm-control-row input[type="range"] {
    flex: 1; max-width: 200px; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--border-strong); border-radius: 999px; outline: none; cursor: pointer;
}
.wm-control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--text); border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm); cursor: pointer;
}

.preset-bar {
    display: inline-flex; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 2px; flex-wrap: wrap;
}
.preset-btn {
    background: transparent; border: none; padding: 6px 12px;
    font-size: 12px; font-weight: 500; color: var(--text-muted);
    cursor: pointer; border-radius: calc(var(--radius-md) - 2px);
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
    font-family: inherit;
    display: inline-flex; align-items: center; gap: 4px;
}
.preset-btn:hover { color: var(--text); }
.preset-btn.active {
    background: var(--text); color: var(--accent-fg);
}
.preset-warn {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--warn);
}

.tech-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
    margin-left: 46px; margin-top: 4px;
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height var(--dur) var(--ease), opacity var(--dur) var(--ease),
                margin-top var(--dur) var(--ease);
}
.tech-grid.is-locked { pointer-events: none; }
.tech-grid.is-locked .tech-cell { opacity: 0.55; }
.tech-grid.is-locked input[type="checkbox"] { cursor: default; }
.tech-grid.is-open, .tech-grid.is-locked {
    max-height: 600px; opacity: 1; margin-top: 8px;
}
.tech-cell {
    display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto;
    column-gap: 8px; padding: 8px 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 12px;
    cursor: pointer; user-select: none;
    transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.tech-cell:hover { border-color: var(--border-strong); }
.tech-cell input { grid-row: 1 / 3; margin-top: 3px; accent-color: var(--text); }
.tech-cell input:checked ~ .tech-name { color: var(--text); font-weight: 600; }
.tech-name {
    grid-column: 2; grid-row: 1;
    font-size: 12.5px; font-weight: 500; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
}
.tech-desc {
    grid-column: 2; grid-row: 2;
    font-size: 11px; color: var(--text-subtle); line-height: 1.5;
}
.tech-badge {
    display: inline-block; padding: 1px 6px; background: var(--warn-bg);
    color: var(--warn); border-radius: 4px; font-size: 10px; font-weight: 600;
}
@media (max-width: 560px) {
    .tech-grid { grid-template-columns: 1fr; margin-left: 0; }
    .wm-control-row { margin-left: 0; }
}

/* ========== Open-source credit ========== */
.credit-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: clamp(14px, 2.5vw, 24px);
    align-items: center;
    padding: clamp(16px, 3vw, 22px);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-top: 8px;
}
.credit-mark {
    width: 54px; height: 54px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    background: var(--text); color: var(--accent-fg);
    font-size: 13px; font-weight: 800; letter-spacing: 0.05em;
}
.credit-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.credit-eyebrow {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-subtle);
}
.credit-title {
    font-size: clamp(16px, 2vw, 18px); font-weight: 600;
    letter-spacing: -0.01em; margin: 0;
}
.credit-sub {
    font-size: 13px; color: var(--text-muted); line-height: 1.55; margin: 0;
}
.credit-link {
    width: fit-content; font-size: 12px; font-weight: 600;
    color: var(--text); border-bottom: 1px solid var(--border-strong);
    padding-bottom: 1px; margin-top: 2px;
}
.credit-link:hover { border-bottom-color: var(--text); }
@media (max-width: 560px) {
    .credit-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .credit-text { align-items: center; }
}

/* ========== Stats bar ========== */
.stats-bar {
    display: grid; grid-template-columns: repeat(6, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-top: 8px;
}
.stat-cell {
    background: var(--surface);
    padding: 15px 10px;
    text-align: center;
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0;
}
.stat-num {
    font-size: clamp(18px, 2.4vw, 24px);
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 11px; font-weight: 600;
    color: var(--text-subtle);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
@media (max-width: 820px) {
    .stats-bar { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
}

/* ========== Language toggle ========== */
.lang-toggle {
    display: inline-flex; align-items: center; gap: 4px;
    height: 36px; padding: 0 10px; border: 1px solid transparent;
    background: transparent; color: var(--text-muted); cursor: pointer;
    border-radius: 10px; font-size: 12px; font-weight: 500;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.lang-toggle:hover { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.lang-opt {
    padding: 2px 6px; border-radius: 5px; cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.lang-opt.active { background: var(--text); color: var(--accent-fg); font-weight: 600; }
.lang-sep { color: var(--text-subtle); font-weight: 400; }

/* ========== Pane-left: room to hover-translate without getting clipped ========== */
.pane-left {
    /* hover lifts the upload area by 1px; give that 1px (plus a safety
     * margin for box-shadow spread) room above the sticky crop line so
     * shadows/motion don't hit the overflow edge */
    padding-top: 6px;
    padding-bottom: 6px;
    /* match the pane-right's real height via grid stretch */
    align-self: stretch;
}
/* Two-pane workspace: stretch cells so pane-left tracks pane-right height */
.workspace { align-items: stretch; }
