:root {
  color-scheme: light dark;
  --page: #f3f3ef;
  --surface: #ffffff;
  --surface-warm: #f1f5f0;
  --surface-dark: #23282e;
  --surface-muted: #f7f8f6;
  --surface-inset: #e8ebe6;
  --header-bg: rgba(255, 255, 255, 0.94);
  --text: #20252a;
  --text-muted: #66706b;
  --line: #dfe2dc;
  --line-strong: #c7cdc5;
  --accent: #2f6749;
  --accent-dark: #204b34;
  --accent-soft: #e3eee7;
  --accent-light: #9bc9ae;
  --accent-text: #204b34;
  --on-accent: #ffffff;
  --green: #2f6749;
  --green-soft: #e3eee7;
  --blue: #2e6382;
  --blue-soft: #eaf3f8;
  --red: #aa3d3d;
  --red-soft: #fae8e8;
  --log-line: #ecefeb;
  --shadow: 0 12px 36px rgba(25, 33, 28, 0.08);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101512;
    --surface: #18201b;
    --surface-warm: #1b261f;
    --surface-dark: #0b100d;
    --surface-muted: #222c26;
    --surface-inset: #111814;
    --header-bg: rgba(18, 25, 21, 0.94);
    --text: #eef3ef;
    --text-muted: #a4b0a8;
    --line: #334139;
    --line-strong: #46554c;
    --accent: #3f7958;
    --accent-dark: #2f6749;
    --accent-soft: #21382a;
    --accent-light: #9bc9ae;
    --accent-text: #a8d2b7;
    --green: #79ae8c;
    --green-soft: #21382a;
    --blue: #8dbbd6;
    --blue-soft: #213440;
    --red: #f0a0a0;
    --red-soft: #422626;
    --log-line: #2b3730;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label,
select,
input[type="range"] {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

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

.app-header {
  min-height: 76px;
  padding: 12px max(20px, env(safe-area-inset-left)) 12px max(20px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

.brand-block,
.brand-block > span:last-child,
.connection-actions,
.activity-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 11px;
  border-radius: 12px;
}

.brand-block > span:last-child {
  flex-direction: column;
  align-items: flex-start;
}

.brand-block strong {
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.brand-block small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.brand-mark svg {
  width: 25px;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 3.5;
  stroke-linecap: round;
}

.connection-actions {
  justify-content: flex-end;
  gap: 8px;
}

.button,
.icon-text-button,
.tab,
.profile-tab,
.filter-button,
.segment {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 720;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:active:not(:disabled),
.segment:active:not(:disabled),
.profile-tab:active:not(:disabled) {
  transform: scale(0.98);
}

.button:hover:not(:disabled),
.icon-text-button:hover:not(:disabled),
.segment:hover:not(:disabled),
.profile-tab:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.button.primary {
  border-color: var(--accent-dark);
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button.quiet {
  background: var(--surface-muted);
}

.button.full {
  width: 100%;
  margin-top: 16px;
}

.status-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status-badge i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line-strong);
}

.status-badge.connected {
  color: var(--green);
  border-color: var(--accent);
  background: var(--green-soft);
}

.status-badge.connected i {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 103, 73, 0.16);
}

.status-badge.connecting {
  color: var(--accent-text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.status-badge.connecting i {
  background: var(--accent-dark);
  animation: pulse 1.1s infinite;
}

.status-badge.error {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-soft);
}

.status-badge.error i {
  background: var(--red);
}

@keyframes pulse {
  50% { opacity: 0.35; }
}

.browser-banner {
  padding: 11px 20px;
  border-bottom: 1px solid var(--red);
  color: var(--red);
  background: var(--red-soft);
  text-align: center;
  font-size: 13px;
  font-weight: 650;
}

.workspace {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 26px clamp(16px, 3vw, 38px) max(48px, env(safe-area-inset-bottom));
}

.control-column {
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.bike-card {
  min-height: 210px;
  padding: 25px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(270px, 0.8fr);
  gap: 18px 28px;
  align-items: center;
  border-radius: var(--radius);
  color: white;
  background:
    radial-gradient(circle at 8% 2%, rgba(74, 139, 98, 0.28), transparent 36%),
    linear-gradient(145deg, #252c31, #181d21);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bike-card-copy .eyebrow {
  color: var(--accent-light);
}

.bike-card-copy h1 {
  max-width: 480px;
  margin-top: 7px;
  font-size: clamp(27px, 3vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.bike-card-copy p {
  max-width: 530px;
  margin-top: 11px;
  color: #bac1bc;
  line-height: 1.55;
}

.bike-device {
  min-width: 0;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.bike-device-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--accent-light);
  background: rgba(74, 139, 98, 0.16);
}

.bike-device-icon svg {
  width: 43px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bike-device > div:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.bike-device .field-label {
  color: #98a19b;
}

.bike-device strong {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.device-subtitle {
  margin-top: 3px;
  color: #b9c0bc;
  font-size: 12px;
}

.telemetry-strip {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(25, 33, 28, 0.045);
  overflow: hidden;
}

.telemetry-item {
  min-width: 0;
  min-height: 74px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}

.telemetry-item:last-child {
  border-right: 0;
}

.telemetry-item strong {
  margin-top: 5px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.telemetry-item.featured strong {
  font-size: 21px;
}

.field-label,
.eyebrow {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  margin-top: 22px;
  display: flex;
  gap: 7px;
  border-bottom: 1px solid var(--line-strong);
}

.tab {
  min-width: 130px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 12px 12px 0 0;
  color: var(--text-muted);
  background: transparent;
}

.tab svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel {
  padding-top: 25px;
}

.section-heading,
.activity-header,
.group-title,
.profile-summary,
.range-control > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 18px;
}

.section-heading h2,
.activity-header h2 {
  margin-top: 4px;
  font-size: 23px;
  letter-spacing: -0.025em;
}

.section-heading p,
.activity-header p {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.setting-group,
.tuning-editor,
.packet-reference {
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(25, 33, 28, 0.035);
}

.setting-group.span-two {
  grid-column: 1 / -1;
}

.mode-card {
  background: var(--surface-warm);
}

.group-title {
  align-items: flex-start;
  margin-bottom: 16px;
}

.group-title h3,
.packet-reference summary {
  font-size: 15px;
  font-weight: 780;
}

.group-title p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.group-title > span {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-muted);
  font-size: 10px;
  font-weight: 750;
}

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

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

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

.segment {
  width: 100%;
  padding-inline: 8px;
  background: var(--surface-muted);
}

.segment.selected {
  color: var(--on-accent);
  border-color: var(--accent-dark);
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

label > span,
.stacked-field > span,
.apply-row label > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 680;
}

input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 103, 73, 0.4);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 80px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.apply-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
}

.apply-row:first-of-type {
  margin-top: 0;
}

.apply-row label,
.stacked-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.switch-row {
  min-height: 45px;
  align-items: center;
}

.switch-control {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  cursor: pointer;
}

.switch-control.standalone {
  min-height: 45px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 45px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 150ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.19);
  transition: transform 150ms ease;
}

.switch-control input:checked + .switch-track {
  background: var(--accent-dark);
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(19px);
}

.helper {
  margin-top: 13px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.helper.warning {
  padding: 10px 11px;
  border-radius: 10px;
  color: var(--accent-text);
  background: var(--accent-soft);
}

.class-picker {
  margin-bottom: 15px;
}

.range-control {
  display: block;
  padding: 19px 0;
  border-bottom: 1px solid var(--line);
}

.range-control output {
  min-width: 48px;
  padding: 5px 8px;
  border-radius: 9px;
  color: var(--accent-text);
  background: var(--accent-soft);
  text-align: center;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 30px;
  margin: 13px 0 0;
  accent-color: var(--accent-dark);
}

.speed-range small {
  margin-top: -2px;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.speed-range.is-disabled {
  opacity: 0.42;
}

.profile-tabs {
  margin: 4px 0 10px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-inset);
}

.profile-tab {
  border-color: transparent;
  background: transparent;
}

.profile-tab.active {
  border-color: var(--surface-dark);
  color: white;
  background: var(--surface-dark);
}

.tuning-editor {
  padding: 22px;
}

.profile-summary {
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.profile-summary span {
  font-size: 18px;
  font-weight: 780;
}

.profile-summary strong {
  color: var(--text-muted);
  font-size: 12px;
}

#send-tuning {
  width: 100%;
  margin-top: 20px;
}

.command-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.command-bar.compact .button {
  flex: 1 1 150px;
}

.read-command {
  color: var(--blue);
  border-color: #bdd0dc;
  background: var(--blue-soft);
}

.raw-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.validation-output {
  min-height: 20px;
  margin-top: 10px;
  display: block;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.validation-output.valid {
  color: var(--green);
}

.validation-output.invalid {
  color: var(--red);
}

.packet-reference {
  margin-top: 14px;
}

.packet-reference summary {
  cursor: pointer;
}

.packet-reference dl {
  margin: 13px 0 0;
}

.packet-reference dl div {
  padding: 9px 0;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
}

.packet-reference dt {
  color: var(--text-muted);
}

.packet-reference dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.activity-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(25, 33, 28, 0.035);
  overflow: hidden;
}

.activity-panel > summary {
  min-height: 78px;
  padding: 17px 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
  list-style: none;
}

.activity-panel > summary::-webkit-details-marker {
  display: none;
}

.activity-panel > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border: solid var(--text-muted);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
}

.activity-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.activity-panel[open] > summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.activity-panel > summary > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activity-panel > summary strong {
  font-size: 17px;
}

.activity-panel > summary #last-response {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

.activity-content {
  display: flex;
  flex-direction: column;
}

.activity-header {
  padding: 18px 18px 13px;
}

.activity-header h3 {
  font-size: 15px;
}

.activity-header p {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-actions {
  gap: 6px;
}

.icon-text-button {
  min-height: 36px;
  padding: 7px 10px;
  color: var(--text-muted);
  background: var(--surface-muted);
  font-size: 11px;
}

.log-filter {
  padding: 0 13px 11px;
  display: flex;
  gap: 3px;
  border-bottom: 1px solid var(--line);
}

.filter-button {
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  color: var(--text-muted);
  background: transparent;
  font-size: 10px;
}

.filter-button.active {
  color: var(--text);
  background: var(--surface-muted);
}

.activity-log {
  min-height: 260px;
  max-height: 430px;
  overflow: auto;
}

.log-entry {
  padding: 12px 15px;
  border-bottom: 1px solid var(--log-line);
}

.log-entry.hidden {
  display: none;
}

.log-meta {
  display: grid;
  grid-template-columns: 50px 52px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.log-time {
  color: var(--text-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.log-direction {
  padding: 3px 5px;
  display: inline-flex;
  justify-content: center;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 850;
}

.log-entry.tx .log-direction {
  color: var(--blue);
  background: var(--blue-soft);
}

.log-entry.rx .log-direction {
  color: var(--green);
  background: var(--green-soft);
}

.log-entry.system .log-direction {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.log-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 750;
}

.log-hex,
.log-detail {
  margin: 7px 0 0 109px;
  overflow-wrap: anywhere;
  font-size: 10px;
  line-height: 1.5;
}

.log-hex {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.log-detail {
  color: var(--text-muted);
}

.empty-log {
  margin: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  text-align: center;
}

.empty-log strong {
  color: var(--text);
}

.empty-log span {
  margin-top: 5px;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 50;
  max-width: min(390px, calc(100vw - 40px));
  padding: 12px 15px;
  border-radius: 13px;
  color: white;
  background: var(--surface-dark);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(9px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--red);
}

@media (max-width: 1160px) {
  .bike-card {
    grid-template-columns: 1fr;
  }

  .bike-device {
    max-width: 420px;
  }

  .telemetry-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .telemetry-item:nth-child(3),
  .telemetry-item:nth-child(6) {
    border-right: 0;
  }

  .telemetry-item:nth-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  .bike-card {
    grid-template-columns: minmax(0, 1.2fr) minmax(250px, 0.8fr);
  }
}

@media (max-width: 680px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .app-header {
    min-height: 66px;
    padding: 10px 14px;
    gap: 10px;
  }

  .brand-block {
    gap: 8px;
  }

  .brand-mark {
    width: 37px;
    height: 37px;
  }

  .brand-block strong {
    font-size: 18px;
  }

  .connection-actions {
    gap: 6px;
  }

  .connection-actions .status-badge {
    display: none !important;
  }

  #install-button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 11px;
  }

  .connection-actions .primary {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .workspace {
    padding: 13px 11px 30px;
  }

  .bike-card {
    min-height: 0;
    padding: 20px;
    grid-template-columns: 1fr;
    gap: 17px;
    border-radius: 24px;
  }

  .bike-card-copy h1 {
    font-size: 28px;
  }

  .bike-card-copy p {
    font-size: 13px;
  }

  .bike-device {
    max-width: none;
    padding: 12px;
  }

  .bike-device-icon {
    width: 51px;
    height: 51px;
  }

  .telemetry-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 19px;
  }

  .telemetry-item {
    min-height: 68px;
    padding: 11px 13px;
  }

  .telemetry-item:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .telemetry-item:nth-child(2n) {
    border-right: 0;
  }

  .telemetry-item:nth-child(-n + 4) {
    border-bottom: 1px solid var(--line);
  }

  .telemetry-item.featured strong {
    font-size: 20px;
  }

  .tabs {
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 5px 7px env(safe-area-inset-bottom);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: var(--header-bg);
    backdrop-filter: blur(16px);
  }

  .tab {
    min-width: 0;
    min-height: 54px;
    padding: 6px 5px;
    flex-direction: column;
    gap: 3px;
    border: 0;
    border-radius: 12px;
    font-size: 10px;
  }

  .tab svg {
    width: 20px;
  }

  .tab.active {
    border: 0;
    background: var(--accent-soft);
  }

  .tab-panel {
    padding-top: 22px;
  }

  .section-heading {
    margin-bottom: 15px;
    align-items: flex-start;
  }

  .section-heading h2 {
    font-size: 22px;
  }

  .section-heading > .button {
    min-height: 40px;
    padding: 7px 10px;
    font-size: 11px;
  }

  .settings-grid,
  .protocol-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .setting-group,
  .tuning-editor,
  .packet-reference {
    padding: 17px;
    border-radius: 21px;
  }

  .setting-group.span-two {
    grid-column: auto;
  }

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

  .brightness-card .segmented.six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .brightness-card .segment {
    min-height: 44px;
    padding-inline: 2px;
    font-size: 12px;
    white-space: nowrap;
  }

  .segment {
    min-height: 48px;
  }

  .profile-tabs {
    position: sticky;
    top: 73px;
    z-index: 8;
  }

  .profile-tab {
    min-height: 44px;
    padding-inline: 5px;
  }

  .profile-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .activity-panel {
    border-radius: 21px;
  }

  .activity-panel > summary {
    min-height: 70px;
    padding: 15px 17px;
  }

  .activity-log {
    min-height: 230px;
    max-height: 380px;
  }

  .log-hex,
  .log-detail {
    margin-left: 0;
  }

  .toast {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 390px) {
  .brand-block small {
    display: none;
  }

  .bike-card-copy h1 {
    font-size: 25px;
  }

  .section-heading {
    flex-direction: column;
  }

  .section-heading > .button {
    width: 100%;
  }

  .segmented.three.class-picker .segment {
    padding-inline: 3px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
