/* iOutlet Device Test — functional diagnostics UI.
   Warm monochrome, flat, SF Pro. Pastel accents reserved for verdicts only. */

#io-devtest-app {
  --canvas: #fbfbfa;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --border: #e5e5e7;
  --pass-bg: #edf3ec; --pass-fg: #346538;
  --fail-bg: #fdebec; --fail-fg: #9f2f2d;
  --skip-bg: #f2f2f0; --skip-fg: #6e6e73;
  --radius: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  position: fixed;
  inset: 0;
  z-index: 100000;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
}
/* :where() keeps this reset at zero specificity so class rules (.dt-sub margin, etc.) actually win */
:where(#io-devtest-app *) { box-sizing: border-box; margin: 0; padding: 0; }

.io-devtest-loading {
  margin: auto;
  color: var(--muted);
  font-size: 15px;
}

/* ---- Layout scaffold ---- */
.dt-header {
  flex: 0 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(251, 251, 250, 0.86);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.dt-header .dt-back {
  appearance: none; background: none; border: none;
  color: var(--ink); padding: 6px; margin: -6px;
  display: inline-flex; cursor: pointer; border-radius: 8px;
}
.dt-header .dt-back:active { background: rgba(0,0,0,0.05); }
.dt-progress {
  flex: 1 1 auto;
  height: 4px; border-radius: 9999px;
  background: var(--border); overflow: hidden;
}
.dt-progress > i {
  display: block; height: 100%; width: 0;
  background: var(--ink); border-radius: 9999px;
  transition: width 400ms var(--ease);
}
.dt-step {
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--muted); letter-spacing: 0.02em;
}

.dt-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
/* Inner grows to fill the body (so short scenes can centre) but is not a scroll
   container itself — so the scene's auto-margins resolve. Scroll lives on .dt-body. */
.dt-inner {
  flex: 1 0 auto;
  padding: 28px 20px 16px;
  display: flex; flex-direction: column;
}
/* margin-block:auto centres short scenes; collapses to 0 (top-aligned, scrollable) when taller than the viewport */
.dt-scene { width: 100%; max-width: 560px; margin-inline: auto; margin-block: auto; }

.dt-footer {
  flex: 0 0 auto;
  padding: 14px 20px max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--canvas);
  display: flex; flex-direction: column; gap: 10px;
}

/* ---- Typography ---- */
.dt-title { font-size: 26px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 600; }
.dt-sub   { margin-top: 12px; font-size: 16px; line-height: 1.55; color: var(--muted); }
.dt-hint  { margin-top: 16px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.dt-q     { font-size: 19px; line-height: 1.3; letter-spacing: -0.01em; font-weight: 600; }

/* ---- Buttons ---- */
.dt-btn {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  width: 100%; min-height: 54px; padding: 0 20px;
  border-radius: 13px; border: 1px solid transparent;
  font-size: 16px; font-weight: 540; font-family: inherit; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  /* ease-out-quart: quick response, smooth settle — no bounce */
  transition: transform 180ms cubic-bezier(0.25, 1, 0.5, 1),
              background 180ms cubic-bezier(0.25, 1, 0.5, 1),
              border-color 180ms ease, box-shadow 180ms ease, opacity 160ms ease;
}
.dt-btn > svg { flex: 0 0 auto; opacity: 0.9; }
.dt-btn:active { transform: scale(0.965); }
.dt-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--canvas), 0 0 0 5px var(--ink); }
.dt-btn[disabled] { opacity: 0.38; pointer-events: none; }

.dt-btn--primary {
  background: var(--ink); color: #fff;
  box-shadow: 0 1px 2px rgba(29,29,31,0.16), 0 4px 14px rgba(29,29,31,0.10);
}
.dt-btn--primary:active { background: #000; box-shadow: 0 1px 2px rgba(29,29,31,0.20); }

.dt-btn--ghost {
  background: var(--surface); color: var(--ink); border-color: var(--border);
}
.dt-btn--ghost:active { background: #f2f2f0; border-color: #dcdcdd; }

.dt-btn--text { background: none; color: var(--muted); min-height: 46px; font-size: 15px; font-weight: 500; }
.dt-btn--text:active { color: var(--ink); transform: none; }

.dt-btn--pass { background: var(--pass-bg); color: var(--pass-fg); font-weight: 580; }
.dt-btn--pass:active { background: #e0ecde; }
.dt-btn--fail { background: var(--fail-bg); color: var(--fail-fg); font-weight: 580; }
.dt-btn--fail:active { background: #fbdfe0; }

.dt-choices { display: flex; gap: 11px; }
.dt-choices .dt-btn { flex: 1; }

/* ---- Intro: editorial hero + numbered test list ---- */
.dt-kicker {
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.dt-title--hero { font-size: clamp(28px, 8vw, 38px); line-height: 1.08; letter-spacing: -0.025em; }
.dt-meta {
  margin-top: 16px; font-size: 13px; letter-spacing: 0.02em; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dt-testlist { list-style: none; margin-top: 28px; border-top: 1px solid var(--border); }
.dt-testrow {
  display: flex; align-items: baseline; gap: 16px;
  padding: 16px 2px; border-bottom: 1px solid var(--border);
  opacity: 0; transform: translateY(10px);
  animation: dt-in 520ms var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 45ms + 60ms);
}
.dt-testnum {
  flex: 0 0 auto; width: 24px; padding-top: 1px;
  font-family: 'SF Mono', 'Geist Mono', ui-monospace, monospace;
  font-size: 13px; font-weight: 500; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.dt-testmeta h3 { font-size: 16px; font-weight: 580; letter-spacing: -0.01em; }
.dt-testmeta p  { margin-top: 3px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }

@keyframes dt-in { to { opacity: 1; transform: none; } }

/* ---- Screen test: fullscreen color cycle ---- */
.dt-colorpane {
  position: fixed; inset: 0; z-index: 100010;
  display: grid; place-items: end center;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  touch-action: none; user-select: none;
}
.dt-colorpane span {
  font-size: 13px; padding: 8px 14px; border-radius: 9999px;
  background: rgba(0,0,0,0.42); color: #fff; backdrop-filter: blur(6px);
}
.dt-colorpane[data-light="1"] span { background: rgba(255,255,255,0.5); color: #1d1d1f; }

/* ---- Screen test: fullscreen touch grid (covers the whole display) ---- */
.dt-touchpane {
  position: fixed; inset: 0; z-index: 100010;
  width: 100vw; height: 100dvh;
  background: var(--border);
  touch-action: none; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
.dt-touchfull {
  position: absolute; inset: 0;
  display: grid; gap: 1px; background: var(--border);
}
.dt-touchfull > i { background: var(--surface); transition: background 60ms linear; }
.dt-touchfull > i.on { background: var(--ink); }
.dt-touchhint {
  position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top));
  transform: translateX(-50%); z-index: 100012;
  max-width: 88vw; text-align: center;
  font-size: 13px; line-height: 1.4; padding: 9px 16px; border-radius: 9999px;
  background: rgba(0,0,0,0.55); color: #fff; backdrop-filter: blur(8px);
  pointer-events: none;
}
.dt-touchnext {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 100012;
  width: auto; min-width: 180px; padding-inline: 28px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}

/* ---- Camera test ---- */
.dt-camstage {
  position: relative; margin-top: 20px;
  border-radius: var(--radius); overflow: hidden;
  background: #000; aspect-ratio: 3 / 4; max-height: 52vh; margin-inline: auto;
}
.dt-camstage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.dt-camstage .dt-camswitch {
  position: absolute; top: 12px; right: 12px;
  appearance: none; border: none; cursor: pointer;
  width: 44px; height: 44px; border-radius: 9999px;
  background: rgba(0,0,0,0.5); color: #fff; display: grid; place-items: center;
  backdrop-filter: blur(6px);
}
.dt-camlabel {
  position: absolute; bottom: 12px; left: 12px;
  font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 9999px;
  background: rgba(0,0,0,0.5); color: #fff; backdrop-filter: blur(6px);
}
.dt-meter {
  margin-top: 16px; height: 8px; border-radius: 9999px;
  background: var(--border); overflow: hidden;
}
.dt-meter > i {
  display: block; height: 100%; width: 0%;
  background: var(--pass-fg); border-radius: 9999px;
  transition: width 60ms linear;
}

/* ---- Motion test ---- */
.dt-readout {
  margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.dt-readout div {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); padding: 16px;
}
.dt-readout span { display: block; font-size: 12px; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.dt-readout b {
  display: block; margin-top: 6px; font-size: 22px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Geist Mono', ui-monospace, monospace;
}

/* ---- Notice (denied / unsupported) ---- */
.dt-notice {
  margin-top: 20px; padding: 16px; border-radius: 10px;
  background: var(--fail-bg); color: var(--fail-fg);
  font-size: 14px; line-height: 1.5;
}

/* ---- Summary verdict ---- */
.dt-verdict {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-top: 18px;
}
.dt-vc { font-size: 18px; font-weight: 620; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dt-vc--pass { color: var(--pass-fg); }
.dt-vc--fail { color: var(--fail-fg); }
.dt-vc--skip { color: var(--skip-fg); }
.dt-vsep { color: #c8c8c8; font-weight: 400; }

/* ---- Summary ---- */
.dt-summary { margin-top: 24px; border-top: 1px solid var(--border); }
.dt-summary--final .row {
  opacity: 0; transform: translateY(8px);
  animation: dt-in 480ms var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 38ms + 50ms);
}
.dt-summary .row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 2px; border-bottom: 1px solid var(--border);
}
.dt-summary .row > span { font-size: 16px; font-weight: 500; }
.dt-badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 9999px;
}

/* ---- Repair-vs-replace bridge CTA (PT only) ---- */
.dt-repair-cta {
  margin-top: 28px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.dt-repair-cta-title { font-size: 18px; font-weight: 620; letter-spacing: -0.01em; }
.dt-repair-cta-body { margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.dt-repair-cta .dt-btn { margin-top: 16px; text-decoration: none; }
.dt-badge--pass { background: var(--pass-bg); color: var(--pass-fg); }
.dt-badge--fail { background: var(--fail-bg); color: var(--fail-fg); }
.dt-badge--skip { background: var(--skip-bg); color: var(--skip-fg); }

/* ---- Multitouch ---- */
.dt-touchpad {
  margin-top: 20px; height: 40vh; min-height: 220px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface);
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.dt-bignum {
  display: block; margin-top: 6px; font-size: 34px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Geist Mono', ui-monospace, monospace;
}

/* ---- Key/value readout rows ---- */
.dt-kv-val {
  font-weight: 500; color: var(--ink); text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', 'Geist Mono', ui-monospace, monospace;
  font-size: 15px; word-break: break-word;
}

/* ---- Manual input (battery health) ---- */
.dt-field { margin-top: 24px; }
.dt-label { display: block; font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.dt-input {
  width: 100%; min-height: 52px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-size: 18px; font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.dt-input:focus { outline: none; border-color: var(--ink); }

/* ---- Test cover (visual identity per test) ---- */
.dt-head { margin-bottom: 10px; }
.dt-head-row { display: flex; align-items: center; justify-content: space-between; }
.dt-head-num {
  font-family: 'SF Mono', 'Geist Mono', ui-monospace, monospace;
  font-size: 46px; font-weight: 600; line-height: 1; letter-spacing: -0.03em;
  color: #d3d3d6; font-variant-numeric: tabular-nums;
}
.dt-head-ico { color: var(--muted); display: inline-flex; }
.dt-head-ico svg { width: 26px; height: 26px; }
.dt-head-title {
  margin-top: 20px; font-size: 27px; line-height: 1.12;
  letter-spacing: -0.025em; font-weight: 600;
}
.dt-head .dt-sub { margin-top: 12px; }

/* ---- Orchestrated entrance: stagger scene blocks ---- */
.dt-rise { animation: dt-rise 560ms var(--ease) backwards; animation-delay: calc(var(--si, 0) * 60ms + 30ms); }
@keyframes dt-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- Delight: confirmation flash on pass/fail ---- */
.dt-flash {
  position: fixed; inset: 0; z-index: 100020;
  display: grid; place-items: center;
  background: rgba(251, 251, 250, 0.7);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: dt-flash-bg 680ms var(--ease) forwards;
}
.dt-flash svg { width: 84px; height: 84px; animation: dt-flash-pop 680ms cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.dt-flash--pass { color: var(--pass-fg); }
.dt-flash--fail { color: var(--fail-fg); }
@keyframes dt-flash-bg { 0% { opacity: 0; } 22% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes dt-flash-pop {
  0% { transform: scale(0.5); opacity: 0; }
  30% { opacity: 1; }
  55% { transform: scale(1); }
  78% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.04); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #io-devtest-app *, #io-devtest-app *::before { animation: none !important; transition: none !important; }
}
