/* ============================================================
   SparkyForm — components
   Faithful CSS translation of the design-system UI kit
   (design_system/ui_kits/sparkyform-app/*.jsx). Mobile-first.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--fg-primary);
  font: var(--text-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: var(--blue-600); text-decoration: none; }

/* The phone-width app column, centred on larger screens (desktop == mobile). */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---- Type helpers ---------------------------------------------------------- */
.sf-h1 { font: var(--text-h1); letter-spacing: -0.01em; margin: 0; }
.sf-h2 { font: var(--text-h2); letter-spacing: -0.005em; margin: 0; }
.sf-h3 { font: var(--text-h3); margin: 0; }
.sf-lead { font: var(--text-lead); color: var(--fg-secondary); }
.sf-label { font: var(--text-label); color: var(--fg-secondary); }
.sf-caption { font: var(--text-caption); color: var(--fg-tertiary); }
.sf-overline {
  font: var(--text-overline); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-tertiary);
}
.sf-data { font: var(--text-data); color: var(--fg-primary); font-feature-settings: "tnum" 1; }
.sf-muted { color: var(--fg-tertiary); }

/* ---- Icons (Lucide) -------------------------------------------------------- */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon svg { width: 1em; height: 1em; stroke-width: 2; }
[data-lucide] { width: 1em; height: 1em; }

/* ---- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border: none; border-radius: var(--r-md);
  cursor: pointer; font: var(--text-ui); font-weight: 600; font-size: 15px;
  white-space: nowrap; text-decoration: none;
  transition: background var(--dur) var(--ease-out), transform var(--dur-fast), box-shadow var(--dur);
}
.btn:active { transform: scale(0.975); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn .icon { font-size: 18px; }
.btn--full { width: 100%; }
.btn--sm { height: 38px; padding: 0 14px; font-size: 14px; }
.btn--sm .icon { font-size: 15px; }
.btn--lg { height: 56px; font-size: 17px; }

.btn--primary { background: var(--ink-900); color: var(--fg-on-ink); }
.btn--primary:hover { background: var(--ink-800); }
.btn--volt { background: var(--volt-500); color: var(--ink-900); box-shadow: var(--shadow-volt); }
.btn--volt:hover { background: var(--volt-400); }
.btn--ai { background-image: var(--ai-gradient); color: var(--ink-900); }
.btn--secondary { background: var(--white); color: var(--ink-900); border: 1.5px solid var(--border-strong); }
.btn--secondary:hover { background: var(--slate-50); }
.btn--ghost { background: transparent; color: var(--fg-secondary); }
.btn--ghost:hover { background: var(--slate-100); }
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; }
.btn--block { display: flex; width: 100%; }

/* ---- Field label + AI tag -------------------------------------------------- */
.field { margin-bottom: 16px; }
.field-label {
  font: var(--text-label); color: var(--fg-secondary);
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.ai-tag {
  display: inline-flex; align-items: center; gap: 3px;
  font: var(--text-overline); letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-full);
  background-image: var(--ai-gradient); color: var(--ink-900);
}
.ai-tag .icon { font-size: 10px; }

/* ---- Inputs ---------------------------------------------------------------- */
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--white); font: var(--text-ui); color: var(--fg-primary);
  outline: none; transition: border-color var(--dur), box-shadow var(--dur);
  -webkit-appearance: none; appearance: none;
}
.textarea { padding: 12px 14px; min-height: 84px; line-height: 1.5; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--focus-ring); box-shadow: var(--shadow-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--slate-400); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error-input { border-color: var(--fail-600); }
.field-hint { font: var(--text-caption); color: var(--fg-tertiary); margin-top: 6px; }

/* ---- AI field (gradient edge + tint + review actions) ---------------------- */
.ai-field { margin-bottom: 16px; }
.ai-field__box {
  position: relative; border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--white); background-image: var(--ai-tint);
  padding: 0; overflow: hidden;
}
.ai-field__box::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--ai-edge); background-image: var(--ai-gradient); z-index: 1;
}
.ai-field--accepted .ai-field__box { background-image: none; }
.ai-field--accepted .ai-field__box::before { display: none; }
.ai-field__box .input, .ai-field__box .textarea {
  border: none; background: transparent; box-shadow: none; padding-left: 18px;
}
.ai-field__box .input:focus, .ai-field__box .textarea:focus { box-shadow: none; }
.ai-field__actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---- Cards ----------------------------------------------------------------- */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 16px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--link { cursor: pointer; transition: box-shadow var(--dur), transform var(--dur-fast); }
.card--link:hover { box-shadow: var(--shadow-md); }
.card--link:active { transform: scale(0.995); }

/* ---- Chips ----------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
  border-radius: var(--r-full); font: 600 12px/1 var(--font-body); white-space: nowrap;
  background: var(--slate-100); color: var(--fg-secondary);
}
.chip .icon { font-size: 13px; }
.chip--pass { background: var(--pass-100); color: var(--pass-700); }
.chip--fail { background: var(--fail-100); color: var(--fail-700); }
.chip--warn { background: var(--warn-100); color: var(--warn-700); }
.chip--info { background: var(--blue-100); color: var(--blue-600); }
.chip--neutral { background: var(--slate-100); color: var(--fg-secondary); }

/* ---- Reading (overline + mono value + unit) -------------------------------- */
.reading { display: flex; flex-direction: column; gap: 2px; position: relative; }
.reading--ai { padding-left: 10px; }
.reading--ai::before {
  content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: var(--ai-edge);
  border-radius: 2px; background-image: var(--ai-gradient);
}
.reading__k {
  font: var(--text-overline); letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--fg-tertiary);
}
.reading__v { font: var(--text-data); color: var(--ink-900); font-feature-settings: "tnum" 1; }
.reading__v--pass { color: var(--pass-700); }
.reading__v--fail { color: var(--fail-700); }
.reading__unit { color: var(--fg-tertiary); font-weight: 400; }

/* ---- App header ------------------------------------------------------------ */
.app-header { padding: 24px 20px 12px; background: var(--bg-app); }
.app-header__row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.app-header__back {
  width: 38px; height: 38px; margin-left: -8px; border-radius: var(--r-sm);
  border: none; background: transparent; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; color: var(--ink-900);
}
.app-header__back .icon { font-size: 24px; }
.app-header__logo { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.app-header__titles { flex: 1; min-width: 0; }
.app-header__title { font: var(--text-h2); color: var(--fg-primary); }
.app-header__sub { font: var(--text-caption); color: var(--fg-tertiary); margin-top: 1px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--ink-900);
  color: var(--volt-500); display: inline-flex; align-items: center; justify-content: center;
  font: 700 14px/1 var(--font-display); text-decoration: none; flex-shrink: 0;
}

/* ---- Step bar -------------------------------------------------------------- */
.stepbar { display: flex; gap: 6px; padding: 0 20px 14px; }
.stepbar__seg { flex: 1; display: flex; flex-direction: column; gap: 6px; text-decoration: none; }
.stepbar__bar { height: 4px; border-radius: 2px; background: var(--slate-200); transition: background var(--dur); }
.stepbar__seg.is-done .stepbar__bar { background: var(--ink-900); }
.stepbar__label { font: 600 11px/1 var(--font-body); color: var(--fg-tertiary); }
.stepbar__seg.is-active .stepbar__label { color: var(--ink-900); }

/* ---- Screen + action bar --------------------------------------------------- */
.screen { display: flex; flex-direction: column; flex: 1; min-height: 100vh; background: var(--bg-app); }
.screen__body { flex: 1; padding: 4px 20px 24px; }
.action-bar {
  position: sticky; bottom: 0; padding: 12px 20px calc(env(safe-area-inset-bottom) + 20px);
  background: rgba(246,248,251,0.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); z-index: 20;
}

/* ---- Section --------------------------------------------------------------- */
.section { margin-bottom: 14px; }
.section__head { display: flex; align-items: center; gap: 8px; padding: 0 4px 10px; }
.section__head .icon { font-size: 16px; color: var(--fg-tertiary); }
.section__title {
  font: var(--text-overline); letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--fg-tertiary); flex: 1;
}

/* ---- Chip-select (radio pills) --------------------------------------------- */
.chip-select { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-select input { position: absolute; opacity: 0; pointer-events: none; }
.chip-select label {
  display: inline-flex; align-items: center; height: 38px; padding: 0 14px;
  border-radius: var(--r-full); cursor: pointer; border: 1.5px solid var(--border-strong);
  background: var(--white); color: var(--fg-secondary); font: 600 14px/1 var(--font-body);
  transition: all var(--dur);
}
.chip-select input:checked + label { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }
.chip-select input:focus-visible + label { box-shadow: var(--shadow-focus); }

/* ---- Segmented control (Type / Paste / Photo) ------------------------------ */
.segmented {
  display: flex; gap: 4px; padding: 4px; background: var(--slate-100);
  border-radius: var(--r-md); margin-bottom: 14px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  flex: 1; height: 40px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--fg-tertiary); font: 600 13px/1 var(--font-body); transition: all var(--dur);
}
.segmented label .icon { font-size: 15px; }
.segmented input:checked + label { background: var(--white); color: var(--ink-900); box-shadow: var(--shadow-sm); }

/* ---- Pass/Fail toggle ------------------------------------------------------ */
.passfail { display: inline-flex; background: var(--slate-100); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.passfail input { position: absolute; opacity: 0; pointer-events: none; }
.passfail label {
  height: 40px; padding: 0 18px; border-radius: var(--r-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; color: var(--fg-tertiary);
  font: 600 14px/1 var(--font-body); transition: all var(--dur) var(--ease-spring);
}
.passfail label .icon { font-size: 16px; }
.passfail input[value="pass"]:checked + label { background: var(--pass-600); color: #fff; box-shadow: var(--shadow-sm); }
.passfail input[value="fail"]:checked + label { background: var(--fail-600); color: #fff; box-shadow: var(--shadow-sm); }

/* ---- Capture mode panels (Type / Paste / Photo) ---------------------------- */
.capture { margin-bottom: 14px; }
.cap-panel { display: none; margin-bottom: 12px; }
.capture:has(input[value="paste"]:checked) .cap-panel--paste { display: block; }
.capture:has(input[value="photo"]:checked) .cap-panel--photo { display: block; }
.cap-panel__row { display: flex; gap: 8px; margin-top: 10px; }

/* ---- AI hint banner -------------------------------------------------------- */
.ai-hint {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-radius: var(--r-sm); background-image: var(--ai-tint); margin-bottom: 14px;
  font: var(--text-caption); color: var(--fg-secondary);
}
.ai-hint .icon { color: var(--warn-600); font-size: 14px; }

/* ---- Home dashboard -------------------------------------------------------- */
.new-cert {
  border: none; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; margin-bottom: 22px; display: block; width: 100%;
  cursor: pointer; padding: 0; background: var(--ink-900);
}
.new-cert__inner { padding: 22px 20px; display: flex; align-items: center; gap: 16px; }
.new-cert__icon {
  width: 52px; height: 52px; border-radius: var(--r-md); background: var(--volt-500);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-900);
}
.new-cert__icon .icon { font-size: 28px; }
.new-cert__text { flex: 1; text-align: left; }
.new-cert__title { font: var(--text-h3); color: #fff; }
.new-cert__sub { font: var(--text-caption); color: rgba(255,255,255,0.6); }
.new-cert__arrow { color: rgba(255,255,255,0.5); }
.new-cert__arrow .icon { font-size: 22px; }

.list-label {
  font: var(--text-overline); letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--fg-tertiary); padding: 0 4px 10px; display: block;
}
.list-label--spaced { padding-top: 14px; }

.cert-row { display: block; margin-bottom: 10px; text-decoration: none; color: inherit; }
.cert-row__inner { display: flex; align-items: center; gap: 12px; }
.cert-row__icon {
  width: 42px; height: 42px; border-radius: var(--r-md); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.cert-row__icon .icon { font-size: 20px; }
.cert-row__icon--draft { background: var(--warn-50); color: var(--warn-600); }
.cert-row__icon--issued { background: var(--pass-50); color: var(--pass-600); }
.cert-row__text { flex: 1; min-width: 0; }
.cert-row__title { font: var(--text-ui); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cert-row__meta { font: var(--text-caption); color: var(--fg-tertiary); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--fg-tertiary); }
.empty-state .icon { font-size: 32px; margin-bottom: 8px; color: var(--slate-300); }

/* ---- Circuit card (tests) -------------------------------------------------- */
.circuit { margin-bottom: 14px; scroll-margin-top: 80px; }
.circuit__head { display: flex; align-items: center; gap: 10px; padding: 0 4px 10px; }
.circuit__num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--ink-900); color: var(--volt-500);
  font: 700 12px/1 var(--font-mono); display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.circuit__name { font: var(--text-ui); font-weight: 600; flex: 1; }
.circuit__action {
  border: none; background: transparent; color: var(--fg-tertiary); cursor: pointer;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
}
.circuit__action .icon { font-size: 16px; }
.circuit__readings { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.circuit__chips { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; }

/* CTA cards on the tests step */
.scan-cta {
  display: block; width: 100%; border: 1.5px solid var(--volt-400); border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 10px; cursor: pointer; padding: 0; background: var(--volt-50);
}
.scan-cta__inner { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.scan-cta__icon {
  width: 46px; height: 46px; border-radius: var(--r-md); background: var(--volt-500);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-900);
  box-shadow: var(--shadow-volt);
}
.scan-cta__icon .icon { font-size: 22px; }
.scan-cta__text { flex: 1; text-align: left; }
.scan-cta__title { font: var(--text-ui); font-weight: 700; color: var(--ink-900); }
.scan-cta__sub { font: var(--text-caption); color: var(--warn-700); }
.scan-cta__arrow { color: var(--volt-700); }

.row-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px; border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--white); color: var(--fg-secondary); font: var(--text-ui); font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.row-btn--dashed { border-style: dashed; background: transparent; padding: 14px; }
.row-btn--spaced { margin-bottom: 18px; }

/* ---- Attachments ----------------------------------------------------------- */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--white);
  padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; margin-bottom: 18px;
}
.dropzone__icon {
  width: 48px; height: 48px; border-radius: var(--r-md); background: var(--volt-50); color: var(--volt-700);
  display: inline-flex; align-items: center; justify-content: center;
}
.dropzone__icon .icon { font-size: 24px; }
.dropzone__title { font: var(--text-ui); font-weight: 600; }
.dropzone__hint { font: var(--text-caption); color: var(--fg-tertiary); max-width: 240px; }
.dropzone__actions { display: flex; gap: 8px; margin-top: 6px; }

.attachment { padding: 12px; margin-bottom: 8px; }
.attachment__inner { display: flex; align-items: center; gap: 10px; }
.attachment__icon {
  width: 32px; height: 32px; border-radius: 8px; background: var(--slate-100); color: var(--slate-500);
  display: inline-flex; align-items: center; justify-content: center;
}
.attachment__name { flex: 1; font: 600 14px/1.2 var(--font-body); overflow: hidden; text-overflow: ellipsis; }
.attachment__size { font: var(--text-caption); color: var(--fg-tertiary); }
.attachment__remove { border: none; background: transparent; cursor: pointer; color: var(--fg-tertiary); display: inline-flex; }

/* ---- Declarations ---------------------------------------------------------- */
.decl-list { }
.decl {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.decl:last-child { border-bottom: none; }
.decl__text { flex: 1; font: var(--text-body); font-size: 15px; }
.decl__toggle { display: inline-flex; background: var(--slate-100); border-radius: var(--r-full); padding: 3px; gap: 2px; }
.decl__toggle input { position: absolute; opacity: 0; pointer-events: none; }
.decl__toggle label {
  font: 700 12px/1 var(--font-body); padding: 5px 10px; border-radius: var(--r-full); cursor: pointer;
  color: var(--fg-tertiary); transition: all var(--dur);
}
.decl__toggle input[value="true"]:checked + label { background: var(--pass-100); color: var(--pass-700); }
.decl__toggle input[value="false"]:checked + label { background: var(--slate-200); color: var(--fg-secondary); }

/* ---- Certifier identity ---------------------------------------------------- */
.identity { display: flex; align-items: center; gap: 12px; }
.identity__text { flex: 1; }
.identity__name { font: var(--text-ui); font-weight: 600; }
.identity__reg { font: var(--text-caption); color: var(--fg-tertiary); }

/* ---- Signature pad --------------------------------------------------------- */
.signature {
  width: 100%; min-height: 110px; border-radius: var(--r-md); cursor: pointer;
  border: 1.5px dashed var(--border-strong); background: var(--white);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  position: relative; overflow: hidden;
}
.signature.is-signed { border-style: solid; border-color: var(--ink-900); background: var(--slate-50); }
.signature.is-signed .signature__hint { display: none; }
.signature:not(.is-signed) .signature__mark { display: none; }
.signature__hint { font: var(--text-caption); color: var(--fg-tertiary); }
.signature__hint .icon { font-size: 22px; color: var(--fg-tertiary); }
.signature__mark {
  font: 400 38px/1 "Segoe Script", "Snell Roundhand", "Brush Script MT", cursive;
  color: var(--ink-900); transform: rotate(-4deg);
}
.signature__canvas { width: 100%; height: 110px; display: block; touch-action: none; }
.signature__legal { font: var(--text-caption); color: var(--fg-tertiary); margin: 12px 2px 0; line-height: 1.5; }

/* ---- Done / issued screen -------------------------------------------------- */
.done {
  min-height: 100vh; background: var(--ink-900); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 0 32px; text-align: center;
}
.done__badge {
  width: 84px; height: 84px; border-radius: 50%; background: var(--pass-600);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 24px;
  box-shadow: 0 10px 40px rgba(18,160,99,0.5); color: #fff;
}
.done__badge .icon { font-size: 44px; }
.done__title { font: var(--text-h1); color: #fff; margin-bottom: 8px; }
.done__sub { font: var(--text-body); color: rgba(255,255,255,0.6); margin-bottom: 4px; }
.done__ref { font: var(--text-data); color: var(--volt-500); margin-bottom: 36px; }
.done__actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 280px; }
.btn--on-dark { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.25); }
.btn--ghost-dark { background: transparent; color: rgba(255,255,255,0.6); }

/* ---- Sheet (camera / manual entry) ----------------------------------------- */
.sheet { min-height: 100vh; background: var(--bg-app); display: flex; flex-direction: column; }
.sheet__head { padding: 20px 20px 8px; display: flex; align-items: center; gap: 12px; }
.sheet__close {
  width: 38px; height: 38px; margin-left: -8px; border-radius: var(--r-sm); border: none;
  background: transparent; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-900); text-decoration: none;
}
.sheet__close .icon { font-size: 22px; }
.sheet__titles { flex: 1; }
.sheet__step { font: var(--text-overline); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-tertiary); }
.sheet__title { font: var(--text-h2); color: var(--fg-primary); }
.sheet__body { flex: 1; padding: 8px 20px 20px; }

.substep { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.substep__n {
  width: 20px; height: 20px; border-radius: 50%; background: var(--ink-900); color: var(--volt-500);
  font: 700 11px/1 var(--font-mono); display: inline-flex; align-items: center; justify-content: center;
}
.substep__label { font: var(--text-label); color: var(--fg-secondary); }

/* ---- Pickers (circuit / reading type) -------------------------------------- */
.picker { display: flex; flex-direction: column; gap: 8px; }
.picker input { position: absolute; opacity: 0; pointer-events: none; }
.picker__item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: var(--r-md); background: var(--white);
  transition: border-color var(--dur);
}
.picker input:checked + .picker__item { border-color: var(--ink-900); }
.picker input:focus-visible + .picker__item { box-shadow: var(--shadow-focus); }
.picker__item .icon { font-size: 18px; color: var(--fg-tertiary); }
.picker input:checked + .picker__item .icon { color: var(--ink-900); }
.picker__name { flex: 1; font: var(--text-ui); font-weight: 600; }
.picker__check { color: var(--ink-900); display: none; }
.picker input:checked + .picker__item .picker__check { display: inline-flex; }
.picker__sym {
  width: 34px; height: 34px; border-radius: 8px; background: var(--slate-100); color: var(--fg-tertiary);
  display: inline-flex; align-items: center; justify-content: center; font: 600 13px/1 var(--font-mono);
}
.picker input:checked + .picker__item .picker__sym { background: var(--ink-900); color: var(--volt-500); }
.picker__new {
  display: flex; align-items: center; gap: 8px; padding: 13px 14px; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: transparent;
  color: var(--fg-secondary); font: var(--text-ui); font-weight: 600; width: 100%;
}

.picker__item { position: relative; overflow: hidden; }
.picker__ai-edge { position: absolute; left: 0; top: 0; bottom: 0; width: var(--ai-edge); background-image: var(--ai-gradient); }
.new-circuit-field { display: none; margin-top: 8px; }
.circuit-pick:has(input[value="new"]:checked) .new-circuit-field { display: block; }

/* captured photo / confirm header */
.captured {
  display: flex; align-items: baseline; gap: 8px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--ink-900); margin-bottom: 16px;
}
.captured__value { font: var(--text-data-lg); color: #fff; }
.captured__unit { font: 500 18px/1 var(--font-mono); color: var(--volt-500); }
.captured__circuit { font: var(--text-caption); color: rgba(255,255,255,0.6); margin-left: 6px; }

/* big value input (manual entry) */
.value-input {
  display: flex; align-items: center; height: 64px; border-radius: var(--r-md); background: var(--white);
  border: 1.5px solid var(--border-strong); padding: 0 16px; margin-bottom: 22px;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.value-input:focus-within { border-color: var(--focus-ring); box-shadow: var(--shadow-focus); }
.value-input input {
  flex: 1; border: none; outline: none; background: transparent; width: 100%;
  font: var(--text-data-lg); color: var(--ink-900);
}
.value-input__unit { font: 500 22px/1 var(--font-mono); color: var(--fg-tertiary); margin-left: 10px; }

/* photo capture input */
.capture-photo {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 20px;
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--white);
  text-align: center; cursor: pointer; margin-bottom: 18px;
}
.capture-photo__icon {
  width: 56px; height: 56px; border-radius: 50%; background: var(--volt-500); color: var(--ink-900);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-volt);
}
.capture-photo__icon .icon { font-size: 26px; }
.capture-photo input[type="file"] { display: none; }
.capture-preview { width: 100%; border-radius: var(--r-md); margin-bottom: 14px; display: block; }

/* ---- Flash / toast --------------------------------------------------------- */
.flash-wrap { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 440px; width: calc(100% - 32px);
  background: var(--ink-900); color: #fff; border-radius: var(--r-md); padding: 13px 16px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-xl); font: var(--text-ui);
  animation: toast-in var(--dur) var(--ease-out);
}
.toast--alert { background: var(--fail-600); }
.toast__icon {
  width: 22px; height: 22px; border-radius: 50%; background: var(--pass-600); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.toast--alert .toast__icon { background: rgba(255,255,255,0.2); }
.toast__icon .icon { font-size: 14px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- Auth screens ---------------------------------------------------------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; text-align: center; }
.auth__logo { width: 64px; height: 64px; border-radius: 18px; }
.auth__title { font: var(--text-h1); }
.auth__sub { font: var(--text-body); color: var(--fg-secondary); }
.auth__card { display: flex; flex-direction: column; gap: 14px; }
.auth__foot { text-align: center; margin-top: 20px; font: var(--text-caption); color: var(--fg-tertiary); }

.errors {
  background: var(--fail-50); border: 1px solid var(--fail-100); color: var(--fail-700);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 14px; font: var(--text-caption);
}
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* button_to wraps its button in <form class="button_to"> — let the button lay
   itself out (full-width or inline) without the form disrupting flex/grid. */
form.button_to { display: contents; }

/* ---- Add-circuit disclosure ------------------------------------------------ */
.add-circuit { margin-top: 4px; }
.add-circuit > summary { list-style: none; cursor: pointer; }
.add-circuit > summary::-webkit-details-marker { display: none; }
.add-circuit__form { margin-top: 10px; padding: 14px; background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); }
.add-circuit__row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font: var(--text-ui); color: var(--fg-secondary); cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--ink-900); }

/* ---- Issued certificate summary -------------------------------------------- */
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.summary-row:last-child { border-bottom: none; }
.summary-row__k { color: var(--fg-tertiary); font: var(--text-caption); }
.summary-row__v { font: var(--text-ui); font-weight: 600; text-align: right; }

/* ---- Utilities ------------------------------------------------------------- */
.stack > * + * { margin-top: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
