:root {
  --bg: #0e0e10;
  --panel: #18181c;
  --line: #2c2c33;
  --text: #f2f2f4;
  --muted: #9a9aa5;
  --accent: #ff5a3c;
  --accent-text: #ffffff;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); }
h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.pill { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ready { color: #7ee2a8; border-color: #2b5a40; }

#stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; }
#empty { text-align: center; max-width: 320px; color: var(--muted); line-height: 1.5; }
#empty b { color: var(--text); }

#wrap { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
#wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#mask { opacity: .5; cursor: crosshair; touch-action: none; }
#before { visibility: hidden; }
#wrap.comparing #before { visibility: visible; }
#wrap.comparing #mask { visibility: hidden; }

#busy { position: absolute; inset: 0; background: rgba(8,8,10,.78); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px; z-index: 5; }
#busy p { margin: 0; font-size: 15px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: min(280px, 80vw); height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#barFill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

#toast { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); background: var(--panel);
  border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; font-size: 14px; z-index: 6;
  max-width: calc(100% - 32px); text-align: center; }

footer { border-top: 1px solid var(--line); background: var(--panel);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.brush { padding: 0 4px; }
.brush input { flex: 1; accent-color: var(--accent); }
.dot { width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center; }
.dot::after { content: ""; width: var(--d, 14px); height: var(--d, 14px); border-radius: 50%; background: #ff2850; opacity: .7; }
.buttons { flex-wrap: wrap; justify-content: center; }

.btn { appearance: none; border: 1px solid var(--line); background: #222228; color: var(--text);
  font: inherit; font-size: 14px; padding: 10px 13px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.big { padding: 14px 22px; font-size: 16px; display: inline-block; margin-top: 8px; }

@media (min-width: 760px) {
  footer { flex-direction: row; align-items: center; justify-content: space-between; }
  .brush { width: 260px; }
}
