:root {
  --bg: #0e141b;
  --bar: #16202b;
  --line: #263444;
  --text: #e6edf3;
  --muted: #8ea0b3;
  --accent: #1f7ac0;
  --accent-2: #4fb3e8;
  --ok: #2fbf71;
  --warn: #e0a526;
  --bad: #e5534b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; overflow: hidden; }

.bar { height: 48px; display: flex; align-items: center; gap: 16px; padding: 0 12px;
  background: var(--bar); border-bottom: 1px solid var(--line); user-select: none; }
.brand { font-weight: 600; letter-spacing: .02em; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--accent-2); font-weight: 600; }
.brand .dash { width: 14px; height: 3px; background: var(--accent-2); display: inline-block; }
.target { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
#target { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 280px; }
.sub { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.tools { display: flex; align-items: center; gap: 6px; }
.stats { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 0; text-align: right; font-size: 12px; }

button, select, summary { font: inherit; color: var(--text); background: #1d2a38; border: 1px solid var(--line);
  border-radius: 6px; height: 32px; padding: 0 10px; cursor: pointer; }
button:hover:not(:disabled), select:hover, summary:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.danger { background: #3a1d22; border-color: #5a2a31; }
button.danger:hover { border-color: var(--bad); }
#btnCad { background: var(--accent); border-color: var(--accent); font-weight: 600; }

.menu { position: relative; }
.menu summary { list-style: none; display: flex; align-items: center; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: "▾"; margin-left: 6px; color: var(--muted); }
.menu-list { position: absolute; top: 38px; left: 0; z-index: 10; display: flex; flex-direction: column;
  background: var(--bar); border: 1px solid var(--line); border-radius: 8px; padding: 4px; min-width: 210px; }
.menu-list button { border: 0; background: transparent; text-align: left; height: 30px; }
.menu-list button:hover { background: #1d2a38; }

main { position: absolute; top: 48px; left: 0; right: 0; bottom: 0; }
main.fit { display: flex; align-items: center; justify-content: center; overflow: hidden; }
main.real { overflow: auto; }
canvas { display: block; outline: none; cursor: default; image-rendering: auto; background: #000; }
main.real canvas { margin: 0 auto; }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: rgba(14, 20, 27, .86); text-align: center; padding: 24px; }
.overlay.hidden { display: none; }
.overlay p { margin: 0; max-width: 460px; font-size: 15px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent-2);
  border-radius: 50%; animation: spin 0.9s linear infinite; }
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .stats, .sub, #quality { display: none; }
}
