:root {
  color-scheme: light;
  --bg: #e8eeea;
  --bg-deep: #dce5df;
  --surface: #f8faf8;
  --surface-strong: #ffffff;
  --surface-muted: #edf2ee;
  --text: #17201d;
  --text-soft: #52615a;
  --text-faint: #728079;
  --line: #cbd6cf;
  --line-strong: #aabbb1;
  --accent: #267451;
  --accent-strong: #195d3f;
  --accent-soft: #d8ece1;
  --accent-text: #f5faf7;
  --danger: #a13636;
  --danger-soft: #f6dfdc;
  --warning: #825719;
  --warning-soft: #f6ead2;
  --info: #315b70;
  --info-soft: #dcebf1;
  --shadow: 0 20px 54px rgba(37, 58, 48, 0.13);
  --shadow-soft: 0 8px 24px rgba(37, 58, 48, 0.08);
  --card-radius: 18px;
  --control-radius: 12px;
  --header-height: 72px;
  --content-width: 880px;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101714;
  --bg-deep: #0b110e;
  --surface: #17201d;
  --surface-strong: #1d2824;
  --surface-muted: #202c27;
  --text: #edf3ef;
  --text-soft: #b6c2bb;
  --text-faint: #8f9d95;
  --line: #33413a;
  --line-strong: #4c5e55;
  --accent: #63c291;
  --accent-strong: #7bd5a6;
  --accent-soft: #173d2b;
  --accent-text: #0b1b13;
  --danger: #ffaaaa;
  --danger-soft: #4a2424;
  --warning: #f2c36f;
  --warning-soft: #49371b;
  --info: #9ccfe4;
  --info-soft: #1d3742;
  --shadow: 0 20px 54px rgba(0, 0, 0, 0.3);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101714;
    --bg-deep: #0b110e;
    --surface: #17201d;
    --surface-strong: #1d2824;
    --surface-muted: #202c27;
    --text: #edf3ef;
    --text-soft: #b6c2bb;
    --text-faint: #8f9d95;
    --line: #33413a;
    --line-strong: #4c5e55;
    --accent: #63c291;
    --accent-strong: #7bd5a6;
    --accent-soft: #173d2b;
    --accent-text: #0b1b13;
    --danger: #ffaaaa;
    --danger-soft: #4a2424;
    --warning: #f2c36f;
    --warning-soft: #49371b;
    --info: #9ccfe4;
    --info-soft: #1d3742;
    --shadow: 0 20px 54px rgba(0, 0, 0, 0.3);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.22);
  }
}

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

html {
  min-width: 280px;
  min-height: 100%;
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  min-width: 280px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 88% -6%, color-mix(in srgb, var(--accent) 12%, transparent) 0, transparent 34rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="radio"],
input[type="range"] {
  accent-color: var(--accent);
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 58%, transparent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: calc(var(--header-height) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(120%);
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(46px, 1fr) auto minmax(46px, 1fr);
  align-items: center;
  width: min(100%, 1080px);
  min-height: var(--header-height);
  margin: 0 auto;
  padding: 8px clamp(12px, 3vw, 28px);
}

.brand-lockup {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  white-space: nowrap;
}

.brand-name {
  font-size: clamp(1.12rem, 5vw, 1.42rem);
  font-weight: 760;
  letter-spacing: -0.045em;
}

.brand-by {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.055em;
}

.header-actions {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.icon-button:disabled {
  border-color: var(--line);
  background: var(--surface-muted);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.38;
}

.icon-button:disabled:hover {
  border-color: var(--line);
  background: var(--surface-muted);
}

.device-control-icon {
  width: 31px;
  height: 31px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(58%) sepia(83%) saturate(1555%) hue-rotate(184deg) brightness(96%) contrast(90%);
}

.icon-button.active .device-control-icon {
  filter: brightness(0) invert(1);
}

.icon-back { transform: rotate(-90deg); }

.icon-button:active,
.button:active,
.choice-card:active,
.direction-button:active {
  transform: translateY(1px);
}

.home-button {
  grid-column: 1;
  justify-self: start;
  font-size: 1.65rem;
  line-height: 1;
}

.theme-toggle {
  font-size: 1.3rem;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}

.connection-status::before {
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  content: "";
}

.connection-status[data-state="connected"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.connection-status[data-state="connected"]::before {
  background: var(--accent);
}

.connection-status[data-state="offline"]::before {
  background: var(--warning);
}

.app-root {
  width: min(100%, var(--content-width));
  min-height: calc(100dvh - var(--header-height));
  margin: 0 auto;
  padding: clamp(22px, 5vw, 48px) clamp(16px, 4vw, 32px) calc(112px + env(safe-area-inset-bottom));
}

.screen {
  animation: screen-in 240ms ease-out both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-header {
  max-width: 650px;
  margin-bottom: clamp(22px, 5vw, 36px);
}

.screen-title,
.step-title {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(1.86rem, 7.4vw, 3.35rem);
  font-weight: 720;
  letter-spacing: -0.052em;
  line-height: 1.02;
}

.step-title {
  font-size: clamp(1.7rem, 6vw, 2.7rem);
}

.screen-body,
.step-body {
  max-width: 62ch;
  margin: 13px 0 0;
  color: var(--text-soft);
  font-size: clamp(0.98rem, 2.6vw, 1.08rem);
  line-height: 1.62;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.95fr);
  align-items: center;
  min-height: min(560px, calc(100dvh - 180px));
  gap: clamp(28px, 7vw, 72px);
}

.home-copy {
  min-width: 0;
}

.home-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 26px;
}

.hero-visual {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 76%, var(--surface)), var(--surface-strong));
  box-shadow: var(--shadow);
}

.hero-visual::before {
  position: absolute;
  inset: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: calc(var(--card-radius) - 5px);
  content: "";
}

.hero-visual img {
  position: absolute;
  z-index: 2;
  left: 5%;
  bottom: 47px;
  width: 90%;
  height: auto;
  object-fit: contain;
}

.hero-ground,
.vehicle-ground {
  position: absolute;
  z-index: 1;
  right: 7%;
  bottom: 47px;
  left: 7%;
  height: 2px;
  background: color-mix(in srgb, var(--accent) 48%, var(--line));
}

.section-block {
  margin-top: clamp(28px, 6vw, 48px);
  padding-top: clamp(24px, 5vw, 38px);
  border-top: 1px solid var(--line);
}

.section-title {
  margin: 0 0 8px;
  font-size: 1.18rem;
  letter-spacing: -0.025em;
}

.section-copy {
  max-width: 62ch;
  margin: 0 0 20px;
  color: var(--text-soft);
}

.live-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.live-heading .section-copy {
  margin-bottom: 0;
}

.live-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 760;
}

.live-badge[data-connected="true"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.live-card {
  display: grid;
  min-height: 138px;
  padding: clamp(17px, 4vw, 24px);
  align-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-soft);
}

.live-label {
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 720;
}

.live-reading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.live-reading strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2rem, 9vw, 3.5rem);
  font-weight: 720;
  letter-spacing: -0.07em;
  line-height: 0.95;
}

.live-reading small {
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 780;
}

.connection-grid,
.summary-grid,
.choice-grid,
.pairing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.info-panel,
.connection-panel,
.summary-card,
.form-panel,
.ota-panel,
.alert-panel {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-soft);
}

.info-panel,
.connection-panel,
.summary-card,
.form-panel,
.ota-panel {
  padding: clamp(18px, 4vw, 26px);
}

.connection-panel h3,
.summary-card h3,
.info-panel h3,
.ota-panel h3,
.alert-panel h3 {
  margin: 0 0 7px;
  font-size: 1rem;
  letter-spacing: -0.015em;
}

.connection-panel p,
.summary-card p,
.info-panel p,
.ota-panel p,
.alert-panel p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.connection-panel .button {
  width: 100%;
  margin-top: 18px;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--control-radius);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 720;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 21%, transparent);
  cursor: pointer;
}

.button:hover {
  background: var(--accent-strong);
}

:root[data-theme="dark"] .button:hover {
  color: #0b1b13;
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: none;
}

.button-secondary:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
  box-shadow: none;
}

.button-ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.button-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: none;
}

.button:disabled {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--text-faint);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.8;
}

.address-stack {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.address-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.6fr) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.address-row:last-child {
  border-bottom: 0;
}

.address-row span {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.address-row a,
.address-row code {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 650;
}

.device-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 18px;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.device-strip strong {
  color: var(--text);
}

.alert-panel {
  margin: 0 0 24px;
  padding: 18px 20px;
  border-left: 4px solid var(--warning);
  background: var(--warning-soft);
}

.alert-panel-danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.alert-panel-info {
  border-left-color: var(--info);
  background: var(--info-soft);
}

.alert-panel-success {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.alert-panel .button-row {
  margin-top: 15px;
}

.wizard-shell {
  max-width: 780px;
  margin: 0 auto;
}

.wizard-progress {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: clamp(26px, 6vw, 42px);
}

.progress-label {
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 720;
  white-space: nowrap;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-value {
  display: block;
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 240ms ease-out;
}

.step-heading {
  margin-bottom: clamp(22px, 5vw, 34px);
}

.step-name {
  display: block;
  margin-bottom: 9px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0.02em;
}

.wizard-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label,
legend {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 720;
}

.field-help {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  line-height: 1.5;
}

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: var(--surface-strong);
  color: var(--text);
  font-size: 1rem;
}

select:hover,
input[type="number"]:hover,
input[type="text"]:hover {
  border-color: var(--accent);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-card {
  position: relative;
  display: grid;
  min-height: 124px;
  padding: 18px 18px 18px 50px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  cursor: pointer;
}

.choice-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.choice-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.choice-card input {
  position: absolute;
  top: 20px;
  left: 18px;
  width: 20px;
  height: 20px;
  margin: 0;
}

.choice-card strong {
  display: block;
  margin-bottom: 6px;
  line-height: 1.25;
}

.choice-card span {
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.48;
}

.vehicle-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.65fr) minmax(0, 1.35fr);
  gap: 18px;
  align-items: stretch;
}

.vehicle-preview {
  position: relative;
  display: grid;
  min-height: 280px;
  margin: 0;
  overflow: hidden;
  align-items: end;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 45%, var(--surface)) 0%, var(--surface-strong) 78%);
}

.vehicle-preview img {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  max-height: 220px;
  margin-bottom: 20px;
  object-fit: contain;
  object-position: center bottom;
}

.vehicle-preview .vehicle-ground {
  right: 22px;
  bottom: 42px;
  left: 22px;
}

.front-indicator {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
}

.front-indicator::after {
  font-size: 1.15rem;
  content: "→";
}

.image-fallback {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--text-soft);
  background: var(--surface);
  text-align: center;
}

.vehicle-image-loading {
  visibility: hidden;
}

.top-preview .image-fallback {
  top: 28px;
  background: transparent;
}

.direction-board {
  display: grid;
  grid-template-columns: minmax(74px, 0.55fr) minmax(128px, 1.3fr) minmax(74px, 0.55fr);
  grid-template-rows: auto minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: min(100%, 570px);
  margin: 0 auto;
  padding: clamp(12px, 3vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.usb-position-board {
  position: relative;
  width: min(100%, 570px);
  min-height: 390px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.device-orientation-preview {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 126px;
  height: 206px;
  border: 3px solid var(--line-strong);
  border-radius: 24px;
  background: var(--surface-strong);
  box-shadow: 0 18px 36px rgba(0, 0, 0, .22);
  transform: translate(-50%, -50%);
}

.device-screen-preview {
  position: absolute;
  inset: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 54%),
    var(--page);
}

.device-usb-port {
  position: absolute;
  width: 38px;
  height: 10px;
  border-radius: 5px;
  background: var(--accent-strong);
  box-shadow: 0 0 0 4px var(--surface);
}

.device-orientation-preview[data-usb-position="down"] .device-usb-port {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}

.device-orientation-preview[data-usb-position="up"] .device-usb-port {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
}

.device-orientation-preview[data-usb-position="left"] .device-usb-port {
  top: 50%;
  left: -20px;
  transform: rotate(90deg) translateX(-50%);
  transform-origin: center;
}

.device-orientation-preview[data-usb-position="right"] .device-usb-port {
  top: 50%;
  right: -20px;
  transform: rotate(90deg) translateX(-50%);
  transform-origin: center;
}

.usb-position-button {
  position: absolute;
  z-index: 2;
  display: grid;
  min-width: 132px;
  min-height: 52px;
  padding: 8px 12px;
  place-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  font-weight: 780;
}

.usb-position-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.usb-position-dot {
  width: 11px;
  height: 11px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}

.usb-position-button[aria-pressed="true"] .usb-position-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.usb-up,
.usb-down {
  left: 50%;
  transform: translateX(-50%);
}

.usb-up { top: 14px; }
.usb-down { bottom: 14px; }
.usb-left { top: 50%; left: 14px; transform: translateY(-50%); }
.usb-right { top: 50%; right: 14px; transform: translateY(-50%); }

.usb-position-board.portrait-only .device-orientation-preview {
  top: 50%;
}

@media (max-width: 520px) {
  .usb-position-board { min-height: 360px; padding: 10px; }
  .usb-position-button {
    width: 104px;
    min-width: 104px;
    min-height: 50px;
    padding: 6px;
    overflow-wrap: anywhere;
    font-size: .68rem;
    line-height: 1.08;
    text-align: center;
  }
  .device-orientation-preview { width: 104px; height: 176px; }
  .usb-left { left: 7px; }
  .usb-right { right: 7px; }
}

.top-preview {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  display: grid;
  min-width: 0;
  min-height: 220px;
  padding-top: 28px;
  place-items: center;
}

.top-preview img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 330px;
  object-fit: contain;
}

.top-front-label {
  position: absolute;
  top: 2px;
  left: 50%;
  width: max-content;
  max-width: 145px;
  transform: translateX(-50%);
  color: var(--text-soft);
  font-size: 0.7rem;
  font-weight: 740;
  text-align: center;
}

.direction-button {
  display: grid;
  min-width: 0;
  min-height: 74px;
  padding: 8px;
  place-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface-strong);
  color: var(--text-soft);
  cursor: pointer;
}

.direction-button:hover {
  border-color: var(--line-strong);
}

.direction-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent);
}

.direction-arrow {
  color: currentColor;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
}

.direction-label {
  max-width: 10ch;
  overflow-wrap: anywhere;
  font-size: 0.69rem;
  font-weight: 760;
  line-height: 1.15;
  text-align: center;
}

.direction-front { grid-column: 2; grid-row: 1; }
.direction-left { grid-column: 1; grid-row: 2; }
.direction-right { grid-column: 3; grid-row: 2; }
.direction-rear { grid-column: 2; grid-row: 3; }

.selection-summary {
  margin: 16px auto 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  text-align: center;
}

.selection-summary strong {
  color: var(--text);
}

.range-stack {
  display: grid;
  gap: 14px;
}

.range-field {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
}

.range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}

.range-value {
  min-width: 74px;
  color: var(--accent-strong);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 760;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  min-height: 44px;
  height: 44px;
  margin: 5px 0 0;
  cursor: pointer;
}

.geometry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 54px;
}

.input-unit {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--text-soft);
  font-size: 0.85rem;
  font-weight: 700;
  pointer-events: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: calc(var(--control-radius) + 4px);
  background: var(--surface-muted);
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segment {
  position: relative;
  display: grid;
  min-height: 44px;
  place-items: center;
  padding: 8px 10px;
  border-radius: var(--control-radius);
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 720;
  text-align: center;
  cursor: pointer;
}

.segment:has(input:checked) {
  background: var(--surface-strong);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.segment input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.calibration-stage {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
  padding: clamp(20px, 5vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.calibration-stage h3 {
  margin: 0 0 7px;
}

.calibration-stage p {
  margin: 0;
  color: var(--text-soft);
}

.calibration-status {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text-soft);
  font-size: 2.1rem;
}

.calibration-stage[data-state="done"] .calibration-status {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pairing-grid .connection-panel {
  min-height: 150px;
}

.network-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.network-detail {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface-muted);
}

.network-detail span {
  display: block;
  margin-bottom: 3px;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 680;
}

.network-detail strong {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
}

.wizard-nav {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
  margin-top: 30px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: calc(var(--card-radius) + 2px);
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.wizard-nav .button {
  width: 100%;
}

.inline-error {
  margin: 13px 0 0;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 650;
}

.settings-list {
  display: grid;
  gap: 14px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row h3 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.settings-row p {
  max-width: 56ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.settings-row select {
  min-width: 160px;
}

.ota-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.ota-phase {
  min-height: 156px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
}

.ota-phase[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ota-phase h3 {
  margin: 0 0 7px;
}

.ota-phase p {
  min-height: 46px;
  margin: 0 0 15px;
}

.ota-variant-field,
.ota-local-file {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.ota-variant-field > span,
.ota-local-file h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 850;
}

.ota-local-file p {
  margin: 0;
  color: var(--text-soft);
}

.file-picker {
  position: relative;
  display: grid;
  min-height: 52px;
  padding: 12px 16px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--accent);
  border-radius: 15px;
  color: var(--text);
  font-weight: 800;
  text-align: center;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ota-phase .button + .button {
  margin-top: 9px;
}

.ota-guide {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.ota-guide h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.ota-guide ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
  color: var(--text-soft);
  line-height: 1.45;
}

.ota-guide li::marker {
  color: var(--accent);
  font-weight: 900;
}

.ota-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.ota-meter span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms linear;
}

.ota-progress-overlay {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: grid;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  place-items: center;
  overflow: auto;
  background: rgb(6 9 16 / 84%);
  backdrop-filter: blur(10px);
}

.ota-progress-card {
  display: grid;
  width: min(460px, 100%);
  gap: 15px;
  padding: clamp(22px, 6vw, 34px);
  border: 1px solid var(--accent);
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: 0 24px 80px rgb(0 0 0 / 45%);
  color: var(--text);
  text-align: center;
}

.ota-progress-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 20px;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  animation: ota-progress-pulse 1.2s ease-in-out infinite;
}

.ota-progress-icon svg {
  width: 35px;
  height: 35px;
  stroke-width: 2.2;
}

.ota-progress-card[data-completed="true"] .ota-progress-icon {
  animation: none;
}

.ota-progress-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.ota-progress-card h2 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.08;
}

.ota-progress-percent {
  color: var(--accent);
  font-size: clamp(3rem, 14vw, 5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.ota-progress-stage {
  min-height: 1.5em;
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
  font-weight: 750;
}

.ota-progress-meter {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.ota-progress-meter span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 72%, transparent);
  transition: width 160ms linear;
}

.ota-progress-warning {
  margin: 0;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 15px;
  background: var(--accent-soft);
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.4;
}

@keyframes ota-progress-pulse {
  0%, 100% { transform: scale(1); opacity: 0.82; }
  50% { transform: scale(1.07); opacity: 1; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .ota-progress-card {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    width: min(720px, 100%);
    gap: 10px 18px;
    padding: 18px 22px;
    text-align: left;
  }

  .ota-progress-icon,
  .ota-progress-card > div,
  .ota-progress-percent {
    align-self: center;
  }

  .ota-progress-stage,
  .ota-progress-meter,
  .ota-progress-warning,
  .ota-progress-card > .button {
    grid-column: 1 / -1;
  }

  .ota-progress-percent {
    font-size: clamp(2.5rem, 12vh, 4rem);
    text-align: right;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ota-progress-icon {
    animation: none;
  }
}

.app-update {
  position: relative;
  z-index: 40;
  width: min(420px, calc(100% - 32px));
  margin: 12px auto 0;
  padding: 17px;
  border: 1px solid var(--line-strong);
  border-radius: var(--card-radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.app-update h2 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.app-update p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.app-update .button-row {
  margin-top: 12px;
}

.app-update .button {
  min-height: 44px;
  padding: 8px 13px;
  font-size: 0.84rem;
}

.install-promotion {
  position: relative;
  z-index: 39;
  width: min(720px, calc(100% - 24px));
  margin: 10px auto 0;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--line));
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--surface-strong));
  box-shadow: var(--shadow-soft);
}

.install-promotion-copy {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
}

.install-promotion-copy img {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgb(0 0 0 / 24%);
}

.install-promotion h2 {
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.15;
}

.install-promotion p {
  margin: 0;
  color: var(--text-soft);
  font-size: .82rem;
  line-height: 1.35;
}

.install-promotion .button-row {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(88px, .55fr);
  margin-top: 10px;
}

.install-promotion .button {
  min-height: 44px;
  padding: 7px 11px;
  font-size: .82rem;
}

.toast-region {
  position: fixed;
  z-index: 50;
  top: calc(var(--header-height) + env(safe-area-inset-top) + 12px);
  right: 14px;
  display: grid;
  width: min(390px, calc(100% - 28px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 650;
  animation: toast-in 180ms ease-out both;
}

.toast-error {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: var(--danger-soft);
  color: var(--danger);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.initial-loader {
  display: grid;
  gap: 12px;
  max-width: 640px;
  margin-top: 54px;
}

.loader-line,
.loader-panel {
  display: block;
  border-radius: var(--control-radius);
  background: linear-gradient(90deg, var(--surface-muted), var(--surface-strong), var(--surface-muted));
  background-size: 220% 100%;
  animation: skeleton 1.25s ease-in-out infinite;
}

.loader-line {
  width: 76%;
  height: 40px;
}

.loader-line-short {
  width: 55%;
  height: 18px;
}

.loader-panel {
  height: 240px;
  margin-top: 18px;
}

@keyframes skeleton {
  to { background-position: -220% 0; }
}

.noscript {
  margin: 30px;
  color: var(--danger);
  text-align: center;
}

@media (max-width: 760px) {
  .connection-status {
    width: 10px;
    min-width: 10px;
    height: 10px;
    min-height: 10px;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--text-faint);
    color: transparent;
  }

  .connection-status::before {
    display: none;
  }

  .connection-status[data-state="connected"] {
    background: var(--accent);
  }

  .connection-status[data-state="offline"] {
    background: var(--warning);
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 28px;
  }

  .hero-visual {
    min-height: 270px;
  }

  .connection-grid,
  .summary-grid,
  .choice-grid,
  .pairing-grid,
  .vehicle-layout,
  .ota-steps {
    grid-template-columns: 1fr;
  }

  .vehicle-layout {
    gap: 14px;
  }

  .vehicle-preview {
    min-height: 230px;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .settings-row select,
  .settings-row .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  :root {
    --header-height: 66px;
  }

  .topbar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .brand-by {
    font-size: 0.61rem;
  }

  .theme-toggle,
  .home-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .app-root {
    padding-right: 14px;
    padding-left: 14px;
  }

  .screen-title,
  .step-title {
    max-width: 100%;
  }

  .home-actions,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .home-actions .button,
  .button-row .button {
    width: 100%;
  }

  .address-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .geometry-grid,
  .network-details {
    grid-template-columns: 1fr;
  }

  .direction-board {
    grid-template-columns: minmax(62px, 0.55fr) minmax(112px, 1.35fr) minmax(62px, 0.55fr);
    grid-template-rows: auto minmax(195px, 1fr) auto;
    gap: 7px;
    padding: 10px;
  }

  .direction-button {
    min-height: 66px;
    padding: 5px;
  }

  .direction-label {
    font-size: 0.63rem;
  }

  .direction-arrow {
    font-size: 1.24rem;
  }

  .top-preview {
    min-height: 195px;
  }

  .top-preview img {
    max-height: 240px;
  }

  .calibration-stage {
    grid-template-columns: 1fr;
  }

  .calibration-status {
    width: 82px;
    height: 82px;
    justify-self: center;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .segmented.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 340px) {
  .brand-name {
    font-size: 1rem;
  }

  .brand-by {
    font-size: 0.56rem;
  }

  .direction-board {
    grid-template-columns: 60px minmax(100px, 1fr) 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .app-header,
  .wizard-nav {
    background: var(--surface);
    backdrop-filter: none;
  }
}

/*
 * Visual shell retained from the deployed VanPoziom PWA 1.2-beta3.
 * The 2.0 features live inside the established product rather than replacing it.
 */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f8;
  --bg-deep: #f3f4f8;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-muted: #f8f9fc;
  --text: #1f222b;
  --text-soft: #6d7381;
  --text-faint: #8d94a2;
  --line: rgba(29, 34, 44, .08);
  --line-strong: rgba(29, 34, 44, .18);
  --accent: #2677b9;
  --accent-strong: #1c659f;
  --accent-soft: #e0eef8;
  --accent-text: #ffffff;
  --shadow: 0 18px 34px rgba(20, 24, 34, .15);
  --shadow-soft: 0 12px 30px rgba(20, 24, 34, .15);
  --card-radius: 27px;
  --control-radius: 16px;
  --header-height: 66px;
  --content-width: 520px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #22212a;
  --bg-deep: #22212a;
  --surface: #302f39;
  --surface-strong: #302f39;
  --surface-muted: #373642;
  --text: #f2f2ef;
  --text-soft: #c2c4cb;
  --text-faint: #9296a1;
  --line: rgba(235, 240, 255, .09);
  --line-strong: rgba(235, 240, 255, .20);
  --accent: #4c85c8;
  --accent-strong: #6198d6;
  --accent-soft: #303e54;
  --accent-text: #ffffff;
  --shadow: 0 18px 36px rgba(0, 0, 0, .48);
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, .34);
}

html {
  background: var(--bg);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% -10%, color-mix(in srgb, var(--surface) 55%, transparent) 0, transparent 38vh),
    var(--bg);
  line-height: 1.35;
  overscroll-behavior-y: contain;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: min(520px, 100%);
  min-height: calc(66px + env(safe-area-inset-top));
  margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) 14px 10px;
  border: 0;
  background: linear-gradient(to bottom, var(--bg) 72%, transparent);
  backdrop-filter: none;
}

.topbar {
  display: grid;
  grid-template-columns: 48px 48px minmax(0, 1fr) 48px 48px;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0;
}

.header-slot {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
}

.header-slot:first-child { grid-column: 1; }
#calibrate-quick { grid-column: 2; }
.brand-lockup { grid-column: 3; }
#theme-toggle { grid-column: 4; }
.header-status-slot { grid-column: 5; }

.brand-name {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
  letter-spacing: -.035em;
}

.brand-by {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: .66rem;
  font-weight: 750;
  letter-spacing: 0;
}

.icon-button {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft), inset 0 1px 0 color-mix(in srgb, white 45%, transparent);
}

.icon-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.connection-status {
  position: absolute;
  top: 4px;
  right: 3px;
  z-index: 2;
  width: 9px;
  min-width: 9px;
  height: 9px;
  min-height: 9px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: #d1822a;
  box-shadow: 0 0 0 4px color-mix(in srgb, #d1822a 18%, transparent);
  color: transparent;
}

.connection-status::before { display: none; }
.connection-status[data-state="connected"] {
  background: #05a85a;
  box-shadow: 0 0 0 4px color-mix(in srgb, #05a85a 18%, transparent);
}

.app-root {
  width: min(520px, 100%);
  min-height: auto;
  margin: 0 auto;
  padding: 0 14px calc(22px + env(safe-area-inset-bottom));
}

/* Widok jest fokusowany programowo po zmianie ekranu dla czytników ekranu.
   Domyślny obrys przeglądarki tworzył jednak niebieską ramkę wokół całej
   aplikacji; kontrolki nadal zachowują własny focus-visible. */
.app-root:focus { outline: none; }

.screen {
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}

.home-status {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 30px;
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 650;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d1822a;
  box-shadow: 0 0 0 5px color-mix(in srgb, #d1822a 16%, transparent);
}

.status-dot.ok {
  background: #05a85a;
  box-shadow: 0 0 0 5px color-mix(in srgb, #05a85a 18%, transparent);
}

.level-card {
  position: relative;
  overflow: hidden;
  min-height: 248px;
  margin: 12px 0;
  padding: 18px 18px 14px;
  border-radius: 27px;
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 1px 0 color-mix(in srgb, white 45%, transparent);
}

.level-card::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: inherit;
  content: "";
}

.card-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  overflow: hidden;
}

.axis-label {
  min-width: 0;
  color: var(--text-soft);
  font-size: clamp(17px, 4vw, 25px);
  line-height: 1;
  font-weight: 720;
  text-transform: uppercase;
}

.readout {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--text);
  font-size: clamp(24px, 7.5vw, 44px);
  line-height: .92;
  font-weight: 900;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.readout .unit {
  margin-left: .12em;
  font-size: .45em;
  font-weight: 900;
}

.scene {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 172px;
  margin: -4px 0 -2px;
}

.hint {
  position: relative;
  z-index: 2;
  min-height: 40px;
  color: var(--accent);
  text-align: center;
  font-size: clamp(27px, 7.5vw, 43px);
  line-height: .98;
  font-weight: 900;
  text-transform: uppercase;
  text-wrap: balance;
}

.hint.ok { color: #05a85a; }

.main-credit {
  margin: 18px 0 4px;
  text-align: center;
  color: color-mix(in srgb, var(--text-soft) 72%, transparent);
  font-size: 12px;
  font-weight: 750;
}

.main-credit a { color: inherit; text-decoration: none; }
.main-credit strong { color: color-mix(in srgb, var(--text) 42%, var(--text-soft)); font-weight: 850; }

.sheet-screen,
.wizard-shell,
.ota-screen {
  padding: 2px 0 18px;
}

.compact-header {
  margin: 4px 0 14px;
  text-align: center;
}

.compact-header .step-title {
  font-size: 1.55rem;
}

.compact-header .step-body {
  max-width: 38rem;
  margin: 7px auto 0;
  font-size: .93rem;
}

.settings-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 2px 0 16px;
}

.settings-row {
  min-height: 66px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft), inset 0 1px 0 color-mix(in srgb, white 42%, transparent);
}

.settings-row.control-row {
  min-height: 102px;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: start;
}

.settings-row.control-row .row-icon { grid-row: 1 / span 2; margin-top: 4px; }
.settings-row.control-row .control-stack { grid-column: 2; width: 100%; }

.row-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid color-mix(in srgb, #4197ea 26%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, #4197ea 10%, var(--surface-muted));
  color: #4197ea;
  font-size: 22px;
}

.row-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row-icon img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(58%) sepia(83%) saturate(1555%) hue-rotate(184deg) brightness(96%) contrast(90%) drop-shadow(0 2px 2px rgb(0 0 0 / 24%));
}

html[data-theme="light"] .row-icon img {
  filter: brightness(0) saturate(100%) invert(44%) sepia(95%) saturate(1344%) hue-rotate(183deg) brightness(91%) contrast(92%);
}

.row-language-badge {
  color: #4197ea;
  font-size: 15px;
  font-weight: 950;
  letter-spacing: .04em;
}

.row-vehicle-art img {
  width: 42px;
  height: 34px;
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 28%));
}

html[data-theme="light"] .row-vehicle-art img {
  filter: drop-shadow(0 2px 2px rgb(0 0 0 / 18%));
}

.row-app-icon img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 28%));
}

.installed-label {
  display: inline-grid;
  min-height: 44px;
  padding: 0 11px;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .78rem;
  font-weight: 850;
}

.row-copy { min-width: 0; }
.settings-row h3 { margin: 0; font-size: 16px; line-height: 1.08; font-weight: 780; }
.settings-row p { margin: 4px 0 0; color: var(--text-soft); font-size: 12px; line-height: 1.18; font-weight: 650; }

.select,
.toggle,
.mini-button,
.control-stack output {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: var(--surface-muted);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 820;
}

.select { width: min(158px, 39vw); padding: 0 24px 0 9px; text-align: center; }
.toggle { width: 72px; padding: 0; }
.toggle.on { background: var(--accent); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.mini-button { min-width: 74px; padding: 0 12px; cursor: pointer; }
.mini-button.danger { color: #e75858; }

.control-stack {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.control-stack output {
  display: grid;
  min-width: 74px;
  padding: 0 8px;
  place-items: center;
  font-variant-numeric: tabular-nums;
}

.control-stack input[type="range"] { width: 100%; accent-color: var(--accent); }

.settings-footer {
  padding: 8px 8px 14px;
  color: var(--text-soft);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 700;
}

.settings-footer a { color: var(--accent); text-decoration: none; font-weight: 850; }

.wizard-progress { margin-top: 2px; }
.wizard-shell .step-heading { margin-top: 18px; }
.wizard-shell .step-title { font-size: clamp(1.8rem, 8vw, 2.75rem); }
.wizard-shell .step-body { max-width: 44rem; }
.wizard-shell .form-panel,
.wizard-shell .range-field,
.wizard-shell .calibration-stage,
.wizard-shell .direction-board {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.vehicle-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: min(58dvh, 590px);
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--accent) transparent;
}

.vehicle-tile {
  position: relative;
  display: block;
  min-height: 126px;
  padding: 10px 8px 12px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.vehicle-tile[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow-soft);
}

.vehicle-tile img {
  position: absolute;
  top: calc(100% - 20px);
  left: 50%;
  z-index: 1;
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100% - 16px);
  max-height: clamp(50px, 14vw, 72px);
  object-fit: contain;
  transform: translate(-50%, var(--ground-shift, -97%));
}

.vehicle-tile-ground {
  position: absolute;
  z-index: 0;
  right: 9%;
  bottom: 18px;
  left: 9%;
  height: 2px;
  border-radius: 2px;
  background: var(--text-soft);
  opacity: .52;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wizard-nav {
  position: sticky;
  bottom: 0;
  z-index: 8;
  margin-top: 18px;
  padding: 10px 0 calc(4px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 78%, transparent);
}

.button {
  border-radius: 15px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 9px 22px color-mix(in srgb, var(--accent) 28%, transparent);
}

.button-secondary { border-color: var(--line); background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }

.toast-region { width: min(492px, calc(100% - 28px)); }

@media (max-width: 430px) {
  .app-header { padding-right: 10px; padding-left: 10px; }
  .app-root { padding-right: 10px; padding-left: 10px; }
  .topbar { grid-template-columns: 46px 46px minmax(0, 1fr) 46px 46px; gap: 6px; }
  .header-slot, .icon-button { width: 46px; min-width: 46px; height: 46px; }
  .level-card { padding-right: 14px; padding-left: 14px; }
  .scene { height: 164px; }
  .settings-row { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; padding-right: 9px; padding-left: 9px; }
  .settings-row.control-row { grid-template-columns: 44px minmax(0, 1fr); }
  .settings-row p { display: none; }
  .settings-row > .select,
  .settings-row > .mini-button { width: min(150px, 42vw); min-width: 0; }
  .settings-row > .mini-button { white-space: normal; overflow-wrap: anywhere; }
  .settings-row .row-copy h3 { overflow-wrap: anywhere; }
}

@media (max-width: 350px) {
  .brand-by { display: none; }
  .brand-name { font-size: .96rem; }
  .hint { font-size: 25px; }
}

/* Device icon and automatic orientation refinements. */
.topbar {
  grid-template-columns: 44px 44px minmax(92px, 1fr) 44px 44px;
  gap: 6px;
}

.header-slot:first-child { grid-column: 1; }
#calibrate-quick { grid-column: 2; }
.brand-lockup { grid-column: 3; }
#theme-toggle { grid-column: 4; }
#settings-button { grid-column: 5; }

.header-slot,
.icon-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
}

/* Stan jest pokazany przy jego opisie na ekranie głównym. Ten element
   pozostaje dostępny dla czytnika, ale nie udaje badge ustawień. */
.connection-status {
  position: absolute;
  width: 1px;
  min-width: 1px;
  height: 1px;
  min-height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.wifi-instructions {
  grid-column: 1 / -1;
  padding: 16px;
  border: 2px solid color-mix(in srgb, var(--accent) 54%, var(--line));
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent-soft) 68%, var(--surface));
  box-shadow: var(--shadow-soft);
  scroll-margin-top: calc(var(--header-height) + 18px);
}

.wifi-instructions-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.wifi-instructions-icon {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wifi-instructions h3 {
  margin: 1px 0 4px;
  font-size: 1.05rem;
  line-height: 1.15;
}

.wifi-instructions p {
  margin: 0;
  color: var(--text-soft);
  font-size: .86rem;
  line-height: 1.42;
}

.wifi-steps {
  display: grid;
  gap: 8px;
  margin: 15px 0;
  padding-left: 25px;
  color: var(--text);
  font-size: .92rem;
  font-weight: 700;
}

.wifi-steps li::marker {
  color: var(--accent);
  font-weight: 900;
}

.wifi-credentials {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.wifi-credentials > div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.wifi-credentials dt {
  color: var(--text-soft);
  font-size: .7rem;
  font-weight: 750;
}

.wifi-credentials dd {
  margin: 3px 0 0;
}

.wifi-credentials code {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .98rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.wifi-local-note { margin-top: 2px !important; }

.wifi-instructions-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(92px, .65fr);
  gap: 8px;
  margin-top: 14px;
}

.wifi-instructions-actions .button {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
}

.row-icon-svg,
.direction-arrow-icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.direction-arrow {
  display: grid;
  width: 32px;
  height: 32px;
  margin: 0 auto;
  place-items: center;
}

.direction-front .direction-arrow-icon { transform: rotate(0deg); }
.direction-left .direction-arrow-icon { transform: rotate(-90deg); }
.direction-right .direction-arrow-icon { transform: rotate(90deg); }
.direction-rear .direction-arrow-icon { transform: rotate(180deg); }

[data-layout-orientation="landscape"][data-app-view="home"] .app-header,
[data-layout-orientation="landscape"][data-app-view="home"] .app-root,
[data-layout-orientation="landscape"][data-app-view="settings"] .app-header,
[data-layout-orientation="landscape"][data-app-view="settings"] .app-root,
[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .app-header,
[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .app-root {
  width: min(960px, 100%);
}

[data-layout-orientation="landscape"][data-app-view="home"] .app-root,
[data-layout-orientation="landscape"][data-app-view="settings"] .app-root,
[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .app-root {
  padding-right: clamp(12px, 2vw, 24px);
  padding-left: clamp(12px, 2vw, 24px);
}

[data-layout-orientation="landscape"][data-app-view="home"] .home-screen {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 8px 12px;
}

[data-layout-orientation="landscape"][data-app-view="home"] .home-status,
[data-layout-orientation="landscape"][data-app-view="home"] .main-credit {
  grid-column: 1 / -1;
}

[data-layout-orientation="landscape"][data-app-view="home"] .home-status {
  margin-bottom: 0;
}

[data-layout-orientation="landscape"][data-app-view="home"] .level-card {
  min-height: 222px;
  margin: 0;
  padding: 14px 15px 12px;
  border-radius: 23px;
}

[data-layout-orientation="landscape"][data-app-view="home"] .scene {
  height: 137px;
  margin-top: -8px;
  margin-bottom: -4px;
}

[data-layout-orientation="landscape"][data-app-view="home"] .axis-label {
  font-size: clamp(15px, 2.2vw, 21px);
}

[data-layout-orientation="landscape"][data-app-view="home"] .readout {
  font-size: clamp(25px, 4.3vw, 38px);
}

[data-layout-orientation="landscape"][data-app-view="home"] .hint {
  min-height: 31px;
  font-size: clamp(22px, 3.7vw, 34px);
}

[data-layout-orientation="landscape"][data-app-view="home"] .main-credit {
  margin: 4px 0 0;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .compact-header {
  margin-bottom: 8px;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .settings-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 9px;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .settings-row {
  height: 100%;
  min-height: 70px;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .row-copy h3,
[data-layout-orientation="landscape"][data-app-view="settings"] .row-copy p {
  overflow-wrap: anywhere;
  hyphens: auto;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .settings-row > select.select {
  width: clamp(112px, 18vw, 150px);
  min-width: 0;
  max-width: none;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .settings-row > button.mini-button {
  width: clamp(118px, 17vw, 144px);
  min-width: 0;
  max-width: none;
  padding: 6px 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.05;
}

[data-layout-orientation="landscape"][data-app-view="settings"] .settings-row.control-row {
  min-height: 102px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .wizard-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .step-heading {
  margin-top: 8px;
  text-align: center;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .step-body {
  margin-right: auto;
  margin-left: auto;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .wizard-progress,
[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .step-name,
[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .step-body,
[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .selection-summary {
  display: none;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .step-heading {
  margin: 2px 0 7px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .step-title {
  max-width: none;
  font-size: clamp(1.35rem, 3.5vw, 1.8rem);
  line-height: 1.05;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .direction-board {
  grid-template-columns: minmax(62px, .55fr) minmax(110px, 1.3fr) minmax(62px, .55fr);
  grid-template-rows: 40px 90px 40px;
  width: min(100%, 510px);
  gap: 5px;
  padding: 6px;
  border-radius: 20px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .top-preview {
  min-height: 90px;
  padding-top: 14px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .top-preview img {
  max-height: 78px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .top-front-label {
  top: 0;
  font-size: .58rem;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .direction-button {
  min-height: 44px;
  padding: 2px 5px;
  border-radius: 11px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .direction-arrow {
  width: 21px;
  height: 21px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .direction-arrow-icon {
  width: 20px;
  height: 20px;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .direction-label {
  max-width: 13ch;
  font-size: .57rem;
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .wizard-nav {
  position: relative;
  bottom: auto;
  margin-top: 4px;
  padding: 2px 0 calc(2px + env(safe-area-inset-bottom));
}

[data-layout-orientation="landscape"][data-app-view="wizard"][data-parameter-edit="true"] .wizard-nav .button {
  min-height: 44px;
}

@media (max-width: 430px) {
  .topbar {
    grid-template-columns: 44px 44px minmax(88px, 1fr) 44px 44px;
    gap: 5px;
  }

  .header-slot,
  .icon-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }
}

@media (max-width: 350px) {
  .app-header { padding-right: 8px; padding-left: 8px; }
  .topbar {
    grid-template-columns: 38px 38px minmax(76px, 1fr) 38px 38px;
    gap: 3px;
  }
  .header-slot,
  .icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    border-radius: 13px;
  }
  .icon-button svg { width: 22px; height: 22px; }
  .wifi-credentials,
  .wifi-instructions-actions { grid-template-columns: 1fr; }
}

/*
 * Stare WebAPK zachowują natywną blokadę pionową zapisaną przy instalacji.
 * Interfejs obraca się wtedy wewnątrz istniejącego okna na podstawie grawitacji,
 * bez fullscreen i bez ScreenOrientation.lock(), więc nie powstaje pętla obrotu.
 */
:root[data-soft-rotation] {
  width: 100%;
  height: 100%;
  overflow: visible;
}

:root[data-soft-rotation] body {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 100dvh;
  height: 100dvw;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  transform-origin: center;
}

:root[data-soft-rotation="right"] body {
  transform: translate(-50%, -50%) rotate(-90deg);
}

:root[data-soft-rotation="left"] body {
  transform: translate(-50%, -50%) rotate(90deg);
}
