/* EletroB — styles. One column, system fonts only (nothing leaves the device), light and dark themes. */
:root {
  --paper: #ffffff;
  --soft: #f3f4f6;
  --rule: #e3e5e9;
  --ink: #1b1e24;
  --muted: #6b7079;
  --signal: #d4163c;
  --signal-hover: #b8102f;
  --signal-ink: #ffffff;
  --signal-soft: #fbe3e8;
  --ok: #1d7a4c; --ok-soft: #e2f2e9;
  --warn: #8f5d00; --warn-soft: #faefd8;
  --bad: #b42318; --bad-soft: #fde5e2;
  --focus: #2f6fdb;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15171b; --soft: #1e2127; --rule: #2c3038; --ink: #eceef2; --muted: #969ca8;
    --signal: #ff4d6a; --signal-hover: #ff6b84; --signal-ink: #1a0509; --signal-soft: #3a1820;
    --ok: #5fd197; --ok-soft: #15301f; --warn: #f0c063; --warn-soft: #362a12; --bad: #ff8b80; --bad-soft: #3a1a18; --focus: #7aa7ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15171b; --soft: #1e2127; --rule: #2c3038; --ink: #eceef2; --muted: #969ca8;
  --signal: #ff4d6a; --signal-hover: #ff6b84; --signal-ink: #1a0509; --signal-soft: #3a1820;
  --ok: #5fd197; --ok-soft: #15301f; --warn: #f0c063; --warn-soft: #362a12; --bad: #ff8b80; --bad-soft: #3a1a18; --focus: #7aa7ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.fine { font-size: 13.5px; color: var(--muted); }

.wrap { max-width: 680px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; gap: 24px; padding: calc(16px + env(safe-area-inset-top, 0px)) 0 calc(24px + env(safe-area-inset-bottom, 0px)); }
.main { display: grid; align-content: start; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.top .textbtn { padding: 8px 0 8px 10px; }
footer { text-align: center; }

/* wordmark */
.mark { display: inline-flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 750; letter-spacing: -0.03em; }
.mark svg { width: 30px; height: 15px; fill: none; stroke: var(--signal); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* home: one action */
.home { min-height: 58vh; display: grid; justify-items: center; align-content: center; gap: 10px; text-align: center; border-radius: 24px; transition: background .15s; }
.home.over { background: var(--signal-soft); }
.shutter {
  width: 132px; height: 132px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--signal); color: var(--signal-ink);
  display: grid; place-items: center;
  box-shadow: 0 0 0 8px var(--paper), 0 0 0 10px var(--rule);
  transition: transform .08s, background .15s;
}
.shutter:hover { background: var(--signal-hover); }
.shutter:active { transform: scale(.96); }
.shutter svg { width: 46px; height: 46px; }
.home-label { margin-top: 14px; font-size: 18px; font-weight: 600; }
.textbtn { border: 0; background: none; padding: 8px 10px; cursor: pointer; color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.textbtn:hover { text-decoration-color: var(--ink); }
.textbtn.inline { padding: 0; font-size: inherit; }
.desk { display: none; }
@media (hover: hover) and (pointer: fine) { .desk { display: block; } }
input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--rule); background: var(--paper); cursor: pointer; font-weight: 550;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); }
.btn.big { min-height: 54px; font-size: 17px; padding: 12px 22px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

/* progress, photo check, error */
.state { min-height: 46vh; display: grid; align-content: center; justify-items: start; gap: 14px; }
#progress { justify-items: center; text-align: center; }
.pulse { width: 72px; height: 32px; }
.pulse path { fill: none; stroke: var(--signal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw 1.4s linear infinite; }
@keyframes draw { to { stroke-dashoffset: -160; } }
@media (prefers-reduced-motion: reduce) { .pulse path { animation: none; stroke-dashoffset: 0; } }
.msg { font-weight: 550; }
.bar { width: min(260px, 70vw); height: 4px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--signal); transition: width .35s ease; }
.issues { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--muted); }
.issues strong { color: var(--ink); font-weight: 600; }
#error h2 { color: var(--bad); }

/* result */
.result { display: grid; gap: 18px; }
.verdict { display: grid; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.level { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; border-radius: 99px; font-size: 14px; font-weight: 650; }
.level::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.level.ok { background: var(--ok-soft); color: var(--ok); }
.level.warn { background: var(--warn-soft); color: var(--warn); }
.level.bad { background: var(--bad-soft); color: var(--bad); }
.chips .meta { font-size: 14px; color: var(--muted); }
.chips .pace { font-size: 14px; color: var(--warn); font-weight: 600; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.metric { padding: 12px 4px; min-width: 0; }
.metric dt { font-size: 13px; color: var(--muted); }
.metric dd { margin: 2px 0 0; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.metric dd small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.why > summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.notes { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.actions { display: flex; gap: 10px; }
.actions #btn-copy { flex: 1; }
.copied { font-size: 14px; color: var(--ok); font-weight: 550; margin-top: -8px; }
.copied:empty { display: none; }

.sheetfig { margin: 0; display: grid; gap: 8px; }
.zoomwrap { position: relative; overflow: auto; border-radius: 12px; background: #fff; max-height: 80vh; -webkit-overflow-scrolling: touch; box-shadow: inset 0 0 0 1px var(--rule); }
.zoomwrap canvas { width: 100%; height: auto; display: block; cursor: zoom-in; }
.zoomwrap.zoomed canvas { width: auto; max-width: none; cursor: zoom-out; }
.zoomwrap.tool canvas { cursor: crosshair; }
.zoomwrap.tool-bounds canvas { cursor: ew-resize; touch-action: pan-y; }
.zoomwrap.dragging canvas { touch-action: none; }
.busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.55); }
.busy span { padding: 6px 14px; border-radius: 99px; background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 550; box-shadow: 0 0 0 1px var(--rule); }

/* collapsed extras */
.more { border-top: 1px solid var(--rule); }
.more details { border-bottom: 1px solid var(--rule); }
.more summary { list-style: none; cursor: pointer; padding: 14px 2px; display: flex; align-items: center; gap: 10px; font-weight: 550; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.more details[open] > summary::after { transform: rotate(-135deg); }
.more summary .fine { font-weight: 400; }
.panel { display: grid; gap: 12px; padding: 0 2px 16px; min-width: 0; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 14px; }
.field { display: grid; gap: 4px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.field select { min-height: 42px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); width: 100%; }
.toggle { display: inline-flex; gap: 10px; align-items: center; font-size: 14.5px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--signal); }
.text-out { margin: 0; max-height: 420px; overflow: auto; padding: 14px; border-radius: 10px; background: var(--soft);
  font: 400 12.5px/1.5 var(--mono); white-space: pre; tab-size: 4; -webkit-user-select: text; user-select: text; }

/* correction tools */
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.segbtn { min-height: 40px; padding: 6px 12px; border: 0; border-right: 1px solid var(--rule); background: transparent; cursor: pointer; font-size: 14px; color: var(--ink); }
.segbtn:last-child { border-right: 0; }
.segbtn.on { background: var(--signal-soft); color: var(--signal); font-weight: 600; }
.segbtn:disabled { color: var(--muted); opacity: .5; cursor: default; }
.tool-help { min-height: 1.3em; }
.tool-help.err { color: var(--bad); }

/* copy button pinned on phones */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: none;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--rule); }
.dock .btn { width: 100%; }
@media (max-width: 640px) {
  .wrap { gap: 16px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--rule); }
  .metric dd { font-size: 20px; }
  .dock.on { display: block; }
  .actions { display: none; }
  .result { padding-bottom: 72px; }
  .seg { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .segbtn { border-bottom: 1px solid var(--rule); }
  .seg[role=radiogroup] .segbtn:nth-child(2n) { border-right: 0; }
  .seg[role=radiogroup] .segbtn:nth-last-child(-n+2), .seg:not([role]) .segbtn { border-bottom: 0; }
}

/* live camera */
.cam-open, .cam-open body { overflow: hidden; }
.cam { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: grid; grid-template-rows: 1fr auto; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.cam-guide { position: absolute; border: 2px solid rgba(255,255,255,.55); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0,0,0,.28); pointer-events: none; transition: border-color .2s; }
.cam-guide i { position: absolute; width: 26px; height: 26px; border: 4px solid #ffcf4a; }
.cam-guide i:nth-child(1) { left: -4px; top: -4px; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.cam-guide i:nth-child(2) { right: -4px; top: -4px; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.cam-guide i:nth-child(3) { left: -4px; bottom: -4px; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.cam-guide i:nth-child(4) { right: -4px; bottom: -4px; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.cam[data-state="ok"] .cam-guide { border-color: #4ee08f; }
.cam[data-state="ok"] .cam-guide i { border-color: #4ee08f; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; display: grid; justify-items: center; gap: 4px; pointer-events: none; }
.cam-hint { margin: 0; max-width: 46ch; text-align: center; padding: 8px 14px; border-radius: 12px; background: rgba(0,0,0,.62); font-weight: 600; font-size: 15px; }
.cam[data-state="ok"] .cam-hint { background: rgba(20,110,60,.85); }
.cam-info { margin: 0; font-size: 12px; color: rgba(255,255,255,.8); text-align: center; text-shadow: 0 1px 2px #000; }
.cam-bar { grid-row: 2; position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); background: rgba(0,0,0,.55); }
.cam-side { color: #fff; border-color: rgba(255,255,255,.4); min-height: 44px; padding: 8px 12px; font-size: 14px; }
.cam-side:first-child { justify-self: start; } .cam-side:last-child { justify-self: end; }
.cam-shoot { width: 74px; height: 74px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; cursor: pointer; }
.cam-shoot span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .08s; }
.cam-shoot:active span { transform: scale(.9); }
.cam-shoot:disabled { opacity: .5; }
