/* PhotoForensics — neutral dark UI so image colours are judged against a neutral ground */
:root {
  --bg: #111317;
  --stage: #0b0c0f;
  --panel: #181b20;
  --panel-2: #1f232a;
  --panel-3: #272c34;
  --border: #2b3038;
  --text: #e5e8ec;
  --muted: #98a1ad;
  --faint: #6b7380;
  --accent: #3ec7a8;
  --accent-ink: #07211b;
  --warn: #f0a030;
  --bad: #ef5a52;
  --good: #4cc26a;
  --info: #5aaaff;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: .2px; color: var(--text); }
.brand svg { color: var(--accent); }
.offline-pill { font-size: 11px; font-weight: 600; color: var(--good); background: #4cc26a1a; border: 1px solid #4cc26a40; padding: 1px 8px; border-radius: 99px; margin-left: 4px; white-space: nowrap; }
.file-info { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.file-info b { color: var(--text); font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px;
  background: var(--panel-3); border: 1px solid var(--border); color: var(--text); cursor: pointer; font-weight: 550;
  white-space: nowrap; user-select: none;
}
.btn:hover:not(:disabled) { background: #303641; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #5ad6ba; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }

.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 38px; z-index: 30; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; min-width: 230px; box-shadow: 0 10px 30px #0008; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 5px; cursor: pointer; }
.menu button:hover { background: var(--panel-3); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 208px minmax(0, 1fr) 360px; height: calc(100% - 52px - 30px); }

/* ---------- footer ---------- */
.sitefoot {
  height: 30px; display: flex; align-items: center; justify-content: center;
  background: var(--panel); border-top: 1px solid var(--border);
}
.sitefoot a {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px; border-radius: 6px;
  color: var(--muted); font-size: 11.5px; text-decoration: none;
}
.sitefoot a:hover { background: var(--panel-2); color: var(--text); }
.sitefoot a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sitefoot img { height: 16px; width: auto; display: block; opacity: .9; }
.sitefoot a:hover img { opacity: 1; }

.tools { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 8px; }
.tools .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); padding: 12px 8px 6px; font-weight: 700; }
.tool {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin: 1px 0; border-radius: 6px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; text-align: left;
}
.tool svg { width: 18px; height: 18px; flex: none; }
.tool:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.tool.on { background: var(--panel-3); border-color: var(--border); color: var(--text); }
.tool.on svg { color: var(--accent); }
.tool:disabled { opacity: .4; cursor: default; }
.tool .key { margin-left: auto; font: 10px var(--mono); color: var(--faint); }
.tool .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.tool .dot + .key { margin-left: 6px; }

.stage { display: flex; flex-direction: column; min-width: 0; background: var(--stage); }
.viewer-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#viewer { position: absolute; inset: 0; display: block; touch-action: none; cursor: grab; }

.dropzone { position: absolute; inset: 18px; border: 2px dashed var(--border); border-radius: 14px; display: grid; place-items: center; background: var(--stage); }
.dropzone.over { border-color: var(--accent); background: #3ec7a80d; }
.drop-inner { text-align: center; max-width: 460px; color: var(--muted); }
.drop-inner svg { color: var(--faint); }
.drop-inner h1 { color: var(--text); font-size: 20px; margin: 10px 0 6px; }
.drop-inner p { margin: 0 0 18px; }
.drop-inner .hint { margin-top: 14px; font-size: 12px; color: var(--faint); }

.busy { position: absolute; inset: 0; display: flex; gap: 12px; align-items: center; justify-content: center; background: #0b0c0fb0; z-index: 10; font-weight: 600; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #ffffff2a; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-toolbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  padding: 4px; background: #181b20e8; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px #0007; z-index: 5;
}
.icon-btn { width: 32px; height: 30px; display: grid; place-items: center; border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .txt { font: 600 11px var(--mono); }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.on { background: #3ec7a826; color: var(--accent); }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.opacity { display: flex; align-items: center; gap: 8px; padding: 0 8px; color: var(--muted); font-size: 12px; }
.opacity input { width: 110px; accent-color: var(--accent); }
.opacity span:last-child { width: 34px; font-variant-numeric: tabular-nums; }
.opacity.disabled { opacity: .4; pointer-events: none; }

.statusbar { height: 28px; display: flex; gap: 18px; align-items: center; padding: 0 12px; font: 11.5px var(--mono); color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.statusbar .grow { flex: 1; }
.swatch-inline { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; border: 1px solid #fff3; }

/* ---------- right panel ---------- */
.panel { background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 6px; flex: none; }
.tab { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 4px 10px; color: var(--muted); cursor: pointer; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel-3); font-size: 11px; color: var(--muted); }
.tab-body { flex: 1; overflow-y: auto; padding: 16px; }

.tab-body h2 { font-size: 15px; margin: 0 0 6px; }
.tab-body h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--faint); margin: 20px 0 8px; font-weight: 700; }
.help { color: var(--muted); margin: 0 0 14px; }
.empty { color: var(--faint); text-align: center; padding: 40px 10px; }

.param { margin-bottom: 12px; }
.param .lbl { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--muted); }
.param .lbl b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.param input[type=range] { width: 100%; accent-color: var(--accent); }
.param select { width: 100%; height: 30px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; }
.param.check label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.param.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }

.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.stats .k { color: var(--muted); }
.stats .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.note { margin-top: 10px; padding: 9px 11px; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--info); color: var(--muted); font-size: 12px; }
.note.warn { border-left-color: var(--warn); }
.note.bad { border-left-color: var(--bad); }
.note.good { border-left-color: var(--good); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.gradbar { height: 10px; border-radius: 3px; background: linear-gradient(90deg, #000004, #55106d, #ba3655, #f98c0a, #fcffa4); margin: 8px 0 3px; }
.gradlbl { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }

canvas.chart { width: 100%; height: 150px; display: block; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); }

/* verdict */
.gauge { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.gauge .pct { font-size: 34px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.gauge .pct small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.gauge .verdict { font-size: 15px; font-weight: 700; margin: 8px 0 12px; }
.bar { position: relative; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--good), #9aa1ad 45%, var(--warn) 70%, var(--bad)); }
.bar .needle { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 2px #0009; transform: translateX(-2px); }
.bar-lbl { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 6px; }
.tone-bad { color: var(--bad); } .tone-warn { color: var(--warn); } .tone-good { color: var(--good); } .tone-neutral { color: var(--text); }

.ind { display: grid; grid-template-columns: 46px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.ind:last-child { border-bottom: 0; }
.chip { font: 700 11px var(--mono); text-align: center; padding: 2px 0; border-radius: 4px; height: fit-content; }
.chip.up { background: #ef5a5222; color: #ff8a83; }
.chip.down { background: #4cc26a22; color: #7fdc93; }
.chip.zero { background: var(--panel-3); color: var(--muted); }
.ind .t { font-weight: 600; }
.ind .d { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-word; }
.ind .g { color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; }

/* metadata */
table.kv { width: 100%; border-collapse: collapse; font-size: 12px; }
table.kv td { padding: 5px 4px; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }
table.kv td:first-child { color: var(--muted); width: 42%; }
pre.raw { white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font: 11px/1.45 var(--mono); color: #c9d1d9; margin: 0; }
details { margin-bottom: 8px; }
details summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.qt { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; font: 10.5px var(--mono); text-align: center; }
.qt span { background: var(--panel-2); padding: 3px 0; }
.sig { padding: 8px 10px; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--bad); margin-bottom: 8px; }
.sig.edit { border-left-color: var(--warn); }
.sig.info { border-left-color: var(--info); }
.sig .snip { font: 11px var(--mono); color: var(--muted); margin-top: 4px; word-break: break-all; }
.thumb { max-width: 100%; border-radius: 6px; border: 1px solid var(--border); display: block; }

/* marks */
.mark-item { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: start; padding: 9px 8px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.mark-item:hover { background: var(--panel-2); }
.mark-item.sel { background: var(--panel-2); border-color: var(--border); }
.mark-item .sw { width: 12px; height: 12px; border-radius: 3px; margin-top: 3px; }
.mark-item .t { font-weight: 600; }
.mark-item .d { color: var(--muted); font-size: 11.5px; }
.mark-item input { width: 100%; background: var(--panel-3); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; }
.mark-item .x { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 16px; padding: 0 4px; }
.mark-item .x:hover { color: var(--bad); }

/* popover / toast */
.popover { position: fixed; z-index: 40; width: 280px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; box-shadow: 0 12px 34px #000a; }
.popover label { display: block; font-weight: 600; margin-bottom: 6px; }
.popover input { width: 100%; height: 32px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel); outline: none; }
.popover input:focus { border-color: var(--accent); }
.popover .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); background: var(--panel-3); border: 1px solid var(--border); padding: 9px 16px; border-radius: 8px; z-index: 50; box-shadow: 0 8px 24px #0009; max-width: 70vw; }
.toast.err { border-color: var(--bad); }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2f3540; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 56px minmax(0, 1fr) 320px; }
  .tool span.name, .tool .key, .tools .group { display: none; }
  .tool { justify-content: center; padding: 9px 0; }
}
