:root {
  color-scheme: light;
  --background: #f4f6fa;
  --surface: #ffffff;
  --border: #e7ebf3;
  --text: #182135;
  --muted: #5e6c82;
  --subtle: #728098;
  --primary: #3d54e9;
  --primary-hover: #3045d7;
  --pale-blue: #edf0ff;
  --green: #07845b;
  --shadow: 0 1px 2px #14234a07, 0 3px 12px #3b4f8605;
  --mono: 'Cascadia Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --sidebar: 220px;
  --header: 64px;
  font-family: 'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-synthesis: none;
  background: var(--background);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
code, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.icon { width: 17px; height: 17px; flex: none; vertical-align: middle; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.muted { color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; height: var(--header);
  background: #fff; border-bottom: 1px solid var(--border); padding: 0 25px 0 21px; gap: 28px;
}
.wordmark { flex: 0 0 calc(var(--sidebar) - 48px); display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 18px; font-weight: 730; letter-spacing: -.55px; }
.wordmark-accent { color: #46536c; font-weight: 650; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: linear-gradient(146deg,#6374fb 2%,#3a52e7 56%,#3045d1 100%); box-shadow: 0 3px 7px #4057e32a, inset 0 1px 1px #ffffff52; }
.breadcrumbs { color: var(--subtle); display: flex; align-items: center; gap: 11px; font-size: 13px; }
.breadcrumbs strong { color: #26334c; font-weight: 650; }
.crumb-chevron .icon { width: 12px; height: 12px; color: #9aa6bb; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 13px; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; min-height: 24px; padding: 3px 9px; border-radius: 6px; color: #5a6782; border: 1px solid #e6eaf3; background: #f6f8fc; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.pill i, .sidebar-device small i, .status-dot { width: 6px; height: 6px; background: #8392a9; border-radius: 50%; display: inline-block; flex: none; }
.pill.demo { background: #f1efff; border-color: #e9e4ff; color: #6754b5; }
.pill.demo i { background: #7964d6; }
.pill.online { background: #e9f8f1; border-color: #d8f0e4; color: #087951; }
.pill.online i, .sidebar-device small.live i { background: #18a978; }
.pill.waiting { background: #fff6e6; border-color: #faeacb; color: #915c10; }
.pill.waiting i { background: #ce8d2a; }

.button { min-height: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 7px; background: transparent; font-weight: 650; font-size: 13px; line-height: 1.2; white-space: nowrap; transition: background-color .16s, color .16s, border-color .16s, box-shadow .16s; }
.button .icon { width: 15px; height: 15px; }
.button-outline { background: #fff; color: #34425d; border-color: #dfe5f0; box-shadow: 0 1px 1px #192d5010; }
.button-outline:not(:disabled):hover { color: var(--primary); border-color: #bfc9fa; background: #f9faff; }
.connect-button { color: var(--primary); min-height: 34px; }
.button-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 4px #3046cd21; padding-inline: 14px; }
.button-primary:not(:disabled):hover { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 3px 8px #3046cd36; }
.button-danger { background: #bd3145; color: #fff; border-color: #bd3145; }
.button-danger:not(:disabled):hover { background: #a92438; border-color: #a92438; }
.button-danger-quiet { color: #a42a47; }
.button-danger-quiet:not(:disabled):hover { background: #fff0f2; border-color: #f5d5dc; }
.button:disabled { opacity: .48; box-shadow: none; }
.button-quiet, .icon-button { color: #59677f; }
.button-quiet:not(:disabled):hover, .icon-button:not(:disabled):hover { color: var(--primary); background: #eef1ff; }
.icon-button { width: 30px; min-height: 30px; padding: 0; }
.text-link { color: var(--primary); font-weight: 650; display: inline-flex; gap: 5px; align-items: center; padding: 0; border: 0; background: none; white-space: nowrap; }
.text-link:hover { color: #2437c2; text-decoration: underline; text-underline-offset: 3px; }
.text-link .icon { height: 14px; width: 14px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100dvh - var(--header)); }
.sidebar { position: sticky; top: var(--header); align-self: start; height: calc(100dvh - var(--header)); display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--border); padding: 20px 12px 12px; gap: 12px; overflow: auto; }
.navigation { display: grid; gap: 23px; }
.nav-section { display: grid; gap: 3px; }
.nav-section > p { margin: 0 0 5px 11px; font-size: 11.5px; color: #748098; font-weight: 650; letter-spacing: .03em; }
.nav-section a, .nav-link { position: relative; min-height: 41px; display: flex; align-items: center; gap: 10px; padding: 0 11px; width: 100%; border-radius: 7px; color: #4a5870; font-size: 13px; font-weight: 600; border: 0; background: transparent; text-align: left; }
.nav-section a .icon, .nav-link .icon { width: 17px; height: 17px; }
.nav-section a:hover, .nav-link:hover { background: #f2f4fa; color: #2d3e63; }
.nav-section a[aria-current='page'] { color: #324ade; background: #edf0ff; font-weight: 700; }
.nav-section a[aria-current='page']::before { content: ''; position: absolute; left: 0; width: 3px; height: 16px; border-radius: 0 2px 2px 0; background: #5266f0; }
.nav-section a > small { margin-left: auto; color: #77839b; font-size: 10px; font-family: var(--mono); font-weight: 650; background: #f2f4f9; padding: 1px 5px; border-radius: 4px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.sidebar-device { width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px 8px; min-height: 58px; color: #25324d; background: #f8faff; border: 1px solid #e9edf7; border-radius: 8px; text-align: left; }
.sidebar-device:hover { background: #f0f3ff; border-color: #dbe2ff; }
.sidebar-device-icon { width: 29px; height: 29px; background: #eaeeff; color: #465bd8; border-radius: 7px; }
.sidebar-device-icon .icon { width: 15px; height: 15px; }
.sidebar-device strong, .sidebar-device small { display: block; white-space: nowrap; }
.sidebar-device strong { font-size: 11.75px; font-weight: 700; }
.sidebar-device small { font-size: 10.5px; color: #62738d; margin-top: 2px; }
.sidebar-device small i { width: 5px; height: 5px; margin-right: 2px; vertical-align: 2px; }
.sidebar-device-chevron { margin-left: auto; color: #8391ab; }
.sidebar-device-chevron .icon { width: 13px; height: 13px; }
.sidebar-version { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #edf0f6; margin: 0 2px; padding: 9px 5px 0; color: #74819a; font-size: 10.5px; }
.sidebar-version span:last-child { font-family: var(--mono); }

.workspace { padding: 27px clamp(19px,2.35vw,39px) 19px; width: 100%; max-width: 1660px; margin: 0 auto; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin-bottom: 21px; }
.page-eyebrow { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; color: #566de3; font-family: var(--mono); font-weight: 700; font-size: 10.5px; letter-spacing: .12em; }
.page-eyebrow::before { content: ''; width: 13px; height: 2px; border-radius: 2px; background: #6d7ef8; }
h1 { font-size: clamp(27px, 2.15vw, 35px); line-height: 1.2; letter-spacing: -.045em; font-weight: 750; color: #172039; }
.page-heading p { color: var(--muted); margin-top: 8px; font-size: 13px; }
.page-actions, .inline-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.page-actions { padding-bottom: 2px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 18px 14px; }
.card-head h2 { font-size: 16px; line-height: 1.25; font-weight: 720; letter-spacing: -.025em; }
.card-head p { margin-top: 5px; color: var(--subtle); font-size: 11.5px; }
.icon-heading { display: flex; align-items: center; gap: 8px; }
.icon-heading > .icon { color: #5b6fe4; }
.device-banner { position: relative; overflow: hidden; display: flex; align-items: center; min-height: 92px; padding: 15px 20px; gap: 14px; margin-bottom: 17px; border-color: #e0e6fa; background: linear-gradient(105deg,#f7faff,#edf1ff 57%,#e9f0ff); }
.device-banner::after { content: ''; position: absolute; inset: 0 0 0 44%; opacity: .66; pointer-events: none; background: radial-gradient(circle at 80% 110%,#e8deff 1%,transparent 56%), linear-gradient(90deg,transparent,#dce9fd5c); }
.device-traces { position: absolute; inset: 0 0 0 auto; width: 62%; height: 100%; opacity: .65; color: #aebdfa; pointer-events: none; }
.device-banner > :not(.device-traces) { position: relative; z-index: 1; }
.device-icon { width: 53px; height: 53px; background: linear-gradient(145deg,#6476ff,#3c52eb 75%); color: #fff; border-radius: 13px; box-shadow: 0 5px 14px #475ee340, inset 0 1px 1px #ffffff42; }
.device-icon .icon { width: 27px; height: 27px; stroke-width: 1.55; }
.device-name { min-width: 0; }
.device-name h2 { font-size: 20px; letter-spacing: -.035em; line-height: 1.15; font-weight: 750; white-space: nowrap; }
.device-name p { margin-top: 6px; font-size: 11.5px; color: #536587; }
.device-stats { padding: 0; margin: 0 0 0 auto; display: flex; align-items: center; }
.device-stats > div { min-width: 107px; padding: 0 14px; border-left: 1px solid #d8e1fa; }
.device-stats > div:last-of-type { padding-right: 0; min-width: 82px; }
.device-stats dt { color: #57698b; font-size: 11px; }
.device-stats dd { margin: 4px 0 0; color: #263860; font-size: 14px; font-weight: 720; font-variant-numeric: tabular-nums; }
.device-stats dd em { font-size: 10px; font-style: normal; color: #65769a; }
.device-stats [data-stat='state'] { min-width: 112px; }

.pin-layout { display: grid; grid-template-columns: minmax(0, 1fr) 326px; gap: 15px; align-items: stretch; }
.board-card, .palette-card { display: flex; flex-direction: column; }
.board-card .card-head { padding-bottom: 13px; }
.board-actions { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; }
.board-actions .button { min-height: 27px; padding-inline: 7px; font-size: 11px; }
.board-actions .button .icon { width: 13px; height: 13px; }
.board-scope { font: 650 11px var(--mono); color: #475bd1; background: #eef1ff; border-color: #e4e9ff; }
.stage { position: relative; margin: 0 15px; padding: 14px 11px 10px; border: 1px solid #e4eafa; border-radius: 9px; overflow: hidden; isolation: isolate; background: radial-gradient(ellipse at 47% 53%,#dfe8ff66,transparent 64%), radial-gradient(#d9e1f4 1px,transparent 1px), #f5f7fd; background-size: auto, 15px 15px, auto; }
.stage::before, .stage::after { content: '+'; position: absolute; font: 13px var(--mono); color: #94a6d2; }
.stage::before { top: 10px; left: 10px; }
.stage::after { bottom: 10px; right: 11px; }
.stage-meta { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin: 0 17px; color: #657597; font: 650 9.5px var(--mono); letter-spacing: .11em; }
.stage-meta span:last-child { color: #7182a6; }
.pin-diagram { --pcb-width: 174px; display: grid; grid-template-columns: minmax(0,1fr) var(--pcb-width) minmax(0,1fr); max-width: 592px; margin: 7px auto 0; align-items: center; }
.pcb { margin: 0; width: var(--pcb-width); display: block; height: auto; filter: drop-shadow(0 10px 12px #102b4d34); }
.pin-bank { display: grid; grid-auto-rows: 36px; align-content: center; z-index: 1; }
.pin-track { display: flex; align-items: center; min-width: 0; }
.pin-track.right { flex-direction: row-reverse; }
.pin-track::after { content: ''; flex: 1; height: 1px; min-width: 5px; background: #cbd7ee; }
.pin-track.active::after { background: color-mix(in srgb, var(--signal-strong), #dce5f7 64%); }
.indigo { --signal-strong:#4259da; --signal-bg:#edf0ff; --signal-border:#dce3ff; }
.teal { --signal-strong:#087e80; --signal-bg:#e8f7f6; --signal-border:#ceeae8; }
.violet { --signal-strong:#754dc6; --signal-bg:#f2edff; --signal-border:#e9ddfc; }
.amber { --signal-strong:#986315; --signal-bg:#fff4df; --signal-border:#f6e6c2; }
.pin { display: flex; align-items: center; gap: 6px; border-radius: 6px; min-height: 29px; min-width: 104px; padding: 0 6px; justify-content: flex-start; background: #fbfcff; border: 1px solid #e3e9f6; color: #4f6287; white-space: nowrap; transition: border-color .15s, box-shadow .15s, background .15s; }
.pin-left { flex-direction: row-reverse; }
.pin-id { min-width: 28px; font: 700 11px var(--mono); color: #475879; }
.pin-signal { border-radius: 4px; background: var(--signal-bg,#eef2f9); color: var(--signal-strong,#7b8ba8); padding: 2px 5px; min-width: 19px; text-align: center; font: 750 9px var(--mono); letter-spacing: -.02em; }
.pin:disabled { opacity: .38; }
.pin:not(:disabled):hover, .pin[aria-pressed='true'] { border-color: #8f9efc; box-shadow: 0 0 0 2px #a7b3ff43; }
.pin[aria-pressed='true'] { background: #f1f4ff; }
.pin.is-drop { border-color: #566cfa; box-shadow: 0 0 0 3px #7d8dfd67; background: #e5ebff; }
.pin.can-overwrite:hover, .pin.is-overwrite { border-color: #ce8d2a; box-shadow: 0 0 0 2px #ebbc6552; background: #fff4df; }
.pin[draggable='true'], .signal[draggable='true'] { cursor: grab; }
.pin[draggable='true']:active, .signal[draggable='true']:active { cursor: grabbing; }
.stage-caption { text-align: center; font-size: 10.5px; color: #637495; margin-top: 3px; }
.stage-caption span { padding: 0 5px; color: #97a7c5; }
.board-foot { display: flex; gap: 7px; justify-content: space-between; align-items: center; min-height: 61px; padding: 10px 16px; }
.pin-detail { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pin-detail-icon { width: 28px; height: 28px; color: #5469eb; background: #eef1ff; border-radius: 7px; display: inline-grid; place-items: center; }
.pin-detail-icon .icon { width: 14px; height: 14px; }
.pin-detail strong { display: block; font-size: 11.5px; line-height: 1.25; }
.pin-detail small { display: block; margin-top: 2px; color: var(--subtle); font-size: 10.5px; }
.pin-legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 5px 9px; color: #60708b; font-size: 10.5px; }
.pin-legend span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pin-legend i { display: block; width: 6px; height: 6px; border-radius: 2px; background: var(--signal-strong,#9cacbf); }
.pin-detail [data-action='remove-pin'] { padding-inline: 6px; font-size: 11px; min-height: 25px; }

.palette-card .card-head { padding-bottom: 12px; }
.palette-body { display: grid; gap: 8px; padding: 0 14px; }
.signal-group { padding: 7px; border: 1px solid #e9edf5; border-radius: 8px; background: #f9faff; }
.signal-group-head { display: flex; align-items: center; gap: 6px; margin: 0 0 5px; font-size: 11.5px; font-weight: 750; color: #3a4964; }
.signal-group-head i { width: 7px; height: 7px; border-radius: 2px; background: var(--signal-strong); }
.signal-group-head small { margin-left: auto; font-weight: 560; font-size: 10px; color: #67758e; }
.signal-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; }
.signal-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px; min-width: 0; }
.signal { display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 28px; padding: 0 5px; border: 1px solid #e6ebf5; border-radius: 5px; background: #fff; text-align: left; color: #3b4a68; }
.signal.is-assigned { border-color: var(--signal-border); }
.signal:hover, .signal[aria-pressed='true'] { border-color: var(--signal-strong); background: var(--signal-bg); }
.signal .icon { width: 11px; height: 11px; color: #95a2b9; }
.signal strong { font: 700 10.75px var(--mono); }
.signal small { margin-left: auto; color: var(--signal-strong); font: 700 10px var(--mono); padding: 1px 3px; border-radius: 3px; background: var(--signal-bg); min-width: 16px; text-align: center; }
.signal small.unmapped { background: #f3f5f9; color: #7b8ba5; }
.signal-remove { width: 26px; min-height: 28px; display: grid; place-items: center; padding: 0; border: 1px solid #ebe5eb; border-radius: 5px; background: #fff; color: #a42a47; }
.signal-remove .icon { width: 13px; height: 13px; }
.signal-remove:not(:disabled):hover { color: #902039; background: #fff0f2; border-color: #f5d5dc; }
.signal-remove:disabled { opacity: .48; }
.palette-foot { display: flex; gap: 7px; align-items: center; margin: auto 14px 0; min-height: 40px; padding: 7px 0; color: #5d6d8c; font-size: 11px; }
.palette-foot .icon { width: 13px; height: 13px; color: #6277ef; }

.pin-summary { margin-top: 14px; display: grid; grid-template-columns: minmax(148px,.9fr) repeat(3,minmax(0,1fr)); min-height: 64px; align-items: stretch; }
.summary-title, .summary-tool { display: flex; align-items: center; gap: 8px; padding: 10px 13px; }
.summary-title strong, .summary-tool strong { display: block; font-weight: 700; font-size: 11.5px; }
.summary-title small, .summary-tool small { display: block; color: #637492; font-size: 10px; margin-top: 2px; white-space: nowrap; }
.summary-tool { border-left: 1px solid var(--border); }
.summary-tool:hover { background: #f8faff; }
.summary-icon { width: 27px; height: 27px; border-radius: 6px; display: grid; place-items: center; background: var(--signal-bg,#eef1ff); color: var(--signal-strong,#4f63e8); }
.summary-icon .icon { width: 14px; height: 14px; }
.summary-tool > .icon { width: 13px; height: 13px; color: #9ba8c0; margin-left: auto; }
.map-note { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-height: 32px; padding: 8px 1px 0; font-size: 11px; color: #687991; }
.map-note .icon { width: 12px; height: 12px; }
.map-note .map-change { margin-left: auto; }
.map-note .warning { color: #916016; }
.map-note .saved { color: #40705f; }
.map-note .offline { color: #6d5aa8; }

.tool-grid { display: grid; grid-template-columns: minmax(0,1fr) 306px; gap: 15px; align-items: start; }
.tool-grid.equal { grid-template-columns: repeat(2,minmax(0,1fr)); }
.tool-card .card-head { border-bottom: 1px solid #edf0f6; }
.tool-body { padding: 17px 18px; display: grid; gap: 15px; }
.tool-foot { padding: 12px 18px; border-top: 1px solid #edf0f6; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tool-foot small { color: var(--muted); }
.field { display: grid; gap: 6px; min-width: 0; color: #4a5974; font-size: 12px; font-weight: 650; }
.input, .select { width: 100%; min-width: 0; min-height: 37px; border-radius: 7px; padding: 7px 9px; border: 1px solid #dfe5f1; background: #fff; color: #25334e; font-weight: 560; }
.input::placeholder { color: #77849b; }
.input:focus, .select:focus { outline: none; border-color: #798cf6; box-shadow: 0 0 0 3px #b0bcff4d; }
textarea.input { resize: vertical; min-height: 64px; }
.input:disabled, .select:disabled { background: #f5f7fb; color: #6c7993; }
.field-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; }
.hint { color: #61718e; font-size: 11.5px; }
.empty-info { border: 1px solid #e5eaff; background: #f5f7ff; color: #495d88; padding: 10px 11px; border-radius: 7px; font-size: 11.5px; line-height: 1.6; }
.pin-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.pin-tile { color: #536486; background: #f3f6fb; border: 1px solid #e8edf7; padding: 4px 7px; border-radius: 5px; font: 650 11px var(--mono); white-space: nowrap; }
.pin-tile b { color: #233c6c; margin-left: 4px; }
.segment { display: inline-flex; padding: 2px; gap: 2px; background: #f0f3fa; border: 1px solid #eaedf6; border-radius: 6px; }
.segment button { padding: 2px 9px; min-height: 24px; border: 0; border-radius: 4px; background: transparent; color: #62718d; font-size: 11px; font-weight: 700; }
.segment button[aria-pressed='true'] { background: #fff; color: #4157d5; box-shadow: 0 1px 2px #21366718; }
.terminal { height: 311px; margin: 13px 14px 0; padding: 10px 11px 14px; overflow: auto; border-radius: 8px; border: 1px solid #223351; background: #141e33; color: #e1e9fa; font: 11.5px/1.55 var(--mono); font-variant-numeric: tabular-nums; }
.terminal-head { display: flex; align-items: center; gap: 5px; color: #aec1e9; min-height: 24px; padding-bottom: 7px; margin-bottom: 8px; border-bottom: 1px solid #ffffff14; }
.terminal-head .icon { width: 13px; height: 13px; }
.terminal-head span:last-child { margin-left: auto; color: #9aaed1; font-size: 10px; }
.shell-terminal { height: auto; padding-bottom: 9px; margin-bottom: 13px; }
.shell-screen { height: clamp(265px, 53vh, 530px); overflow: auto; padding: 5px 4px; scrollbar-color: #526489 transparent; }
.shell-screen:focus-visible { outline: 1px solid #839cff; outline-offset: 1px; border-radius: 3px; }
.shell-line { width: max-content; min-width: 100%; min-height: 1lh; position: relative; white-space: pre; }
.shell-cursor { position: absolute; bottom: 1px; width: 1ch; height: 2px; background: #859acc; pointer-events: none; }
.shell-screen:focus .shell-cursor { background: #89efd2; }
.shell-buttons { gap: 2px; flex-wrap: wrap; justify-content: end; }
.shell-buttons .button { min-height: 30px; padding-inline: 7px; font-size: 11px; }
.shell-buttons .icon { width: 13px; height: 13px; }
.shell-commands { margin: 0; }
.shell-commands dt { color: #324ad3; font: 650 12px var(--mono); }
.shell-commands dd { margin: 4px 0 12px; color: var(--muted); font-size: 11.5px; }
.shell-commands dd:last-child { margin-bottom: 0; }
kbd { padding: 1px 4px; border: 1px solid #e4e9f4; border-radius: 4px; background: #f5f7fb; font: 600 10px var(--mono); }
.log-line { display: grid; grid-template-columns: 62px 27px minmax(0,1fr); gap: 6px; padding: 2px 1px; }
.log-line .timestamp { color: #a0afd1; }
.log-line .log-kind { color: #a3b7e7; font-weight: 750; }
.log-line.tx .log-kind { color: #a6b5ff; }
.log-line.rx .log-kind { color: #65dcc4; }
.log-line .log-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.log-line .log-text small { color: #a0afd1; }
.log-empty { color: #a4b5d8; padding: 3px; }
.serial-form { padding: 12px 14px 13px; display: grid; gap: 9px; }
.send-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.send-line .field { display: inline-flex; flex-direction: row; align-items: center; }
.send-line .select { min-height: 32px; width: auto; }
.send-line .button-primary { margin-left: auto; }
.meter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.meter { flex: 1; background: #f6f8fc; border: 1px solid #ecf0f7; border-radius: 7px; padding: 8px 9px; min-width: 88px; color: #60708c; font-size: 10.5px; }
.meter strong { display: block; color: #233656; margin-top: 2px; font: 750 14px var(--mono); }
.scope { background: radial-gradient(#dce6fa 1px,transparent 1px), #f8faff; background-size: 13px 13px; border: 1px solid #e6ecfa; border-radius: 8px; padding: 10px; }
.scope svg { width: 100%; height: auto; max-height: 170px; display: block; }
.spi-result { min-height: 64px; padding: 10px 11px; background: #f7f9fe; border: 1px solid #e7edf8; border-radius: 7px; color: #344b76; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: 650 12px/1.6 var(--mono); }
.spi-tabs { display: flex; align-items: center; gap: 3px; margin-bottom: 14px; padding: 3px; width: fit-content; background: #eaf0fa; border: 1px solid #e2e8f3; border-radius: 9px; }
.spi-tabs a { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; border-radius: 6px; padding: 7px 13px; color: #526581; font-size: 12px; font-weight: 650; white-space: nowrap; }
.spi-tabs a .icon { width: 15px; height: 15px; }
.spi-tabs a:hover { color: var(--primary); }
.spi-tabs a[aria-current='page'] { background: white; color: var(--primary); border-color: #dfe6f5; box-shadow: 0 1px 3px #23375c10; }
.flash-device { margin-bottom: 14px; }
.flash-device-body { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; justify-content: space-between; padding: 14px 18px; }
.flash-chip-data { display: grid; flex: 1 1 380px; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin: 0; }
.flash-chip-data div { background: #f6f8fd; border: 1px solid #ebeff8; border-radius: 7px; padding: 7px 10px; min-width: 0; }
.flash-chip-data dt { color: #647491; font-size: 10.5px; }
.flash-chip-data dd { margin: 3px 0 0; color: #23395e; font-weight: 700; font-size: 12px; overflow-wrap: anywhere; }
.flash-device-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; }
.flash-device-actions .select { min-width: 104px; }
.flash-bulk { padding-block: 10px; background: #f9faff; border-radius: 0 0 11px 11px; }
.flash-bulk strong, .flash-bulk small { display: block; }
.flash-bulk strong { color: #2e4163; font-size: 12px; }
.flash-bulk small { margin-top: 3px; font-size: 11px; }
.flash-bulk .inline-actions { flex-wrap: wrap; flex: 0 1 auto; }
.flash-bulk .button { min-height: 31px; font-size: 12px; }
.flash-grid { grid-template-columns: minmax(0,1fr) minmax(220px, 306px); }
.flash-alert { margin: -3px 0 12px; }
.flash-grid + .flash-alert { margin: 12px 2px 0; }
.flash-read-fields { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr) auto; gap: 9px; align-items: end; }
.flash-read-form { min-width: 0; }
.flash-memory, .flash-empty { border: 1px solid #e5ebf8; border-radius: 8px; background: #f7f9fd; }
.flash-memory { overflow: auto; max-height: 396px; scrollbar-color: #c2cce0 #f2f5fa; }
.flash-memory table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 515px; color: #344b74; font: 570 11.5px/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.flash-memory thead th { position: sticky; top: 0; background: #eaf0fd; font-weight: 750; color: #526790; border-bottom: 1px solid #dce6fa; }
.flash-memory th, .flash-memory td { height: 23px; padding: 3px 4px; text-align: center; white-space: nowrap; }
.flash-memory th:first-child { padding-inline: 9px; text-align: left; color: #566e9a; }
.flash-memory th:nth-child(10), .flash-memory td:nth-child(10) { border-left: 1px solid #e6ecf8; }
.flash-memory th:last-child, .flash-memory td:last-child { border-left: 1px solid #e1e8f7; text-align: left; padding-inline: 9px; }
.flash-memory tbody tr:nth-child(even) { background: #f1f5fc; }
.flash-memory tbody tr:hover { background: #e9efff; }
.flash-memory .flash-ascii { color: #176864; }
.flash-memory .flash-erased { color: #75849e; }
.flash-empty { min-height: 180px; display: grid; align-content: center; justify-items: center; gap: 6px; padding: 16px 10px; color: #485d85; font-size: 12px; text-align: center; }
.flash-empty > span, .flash-file-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #eaf0ff; color: #5165e1; flex: none; }
.flash-empty p { color: #647491; }
.flash-preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.flash-preview-footer .button { min-height: 29px; padding-inline: 9px; font-size: 11.5px; }
.flash-file { position: relative; display: flex; gap: 9px; align-items: center; min-height: 67px; padding: 8px 10px; border: 1px dashed #beccf1; border-radius: 8px; background: #f7f9ff; color: #314873; cursor: pointer; overflow: hidden; }
.flash-file input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.flash-file:has(input:disabled) { opacity: .66; cursor: not-allowed; }
.flash-file:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.flash-file strong, .flash-file small { display: block; overflow-wrap: anywhere; }
.flash-file strong { font-size: 12px; }
.flash-file small { color: #62749a; font-size: 11px; margin-top: 2px; }
.flash-write-actions { flex-wrap: wrap; }
.flash-warning { background: #fffbf1; border-color: #f4e5bf; color: #775424; }
.flash-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 9px 12px; background: #f1f5ff; border: 1px solid #dde6fc; border-radius: 8px; color: #405682; font-size: 12px; }
.flash-status[data-tone='success'] { background: #edf9f4; color: #245d4a; border-color: #d7f0e4; }
.flash-status[data-tone='error'] { background: #fff3ef; color: #934332; border-color: #f8e0d9; }
.flash-status-text { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.flash-status progress { height: 7px; width: 100%; accent-color: var(--primary); }
.flash-review { margin: 12px 0; padding: 7px 11px; border-radius: 8px; background: #f5f7fd; }
.flash-review div { display: grid; grid-template-columns: 65px minmax(0,1fr); gap: 7px; padding: 5px 1px; font-size: 12px; }
.flash-review dt { color: #667695; }
.flash-review dd { margin: 0; color: #2e4266; font-weight: 650; overflow-wrap: anywhere; }
.firmware-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.firmware-steps li { display: flex; align-items: center; gap: 7px; padding: 7px; color: #65738c; border: 1px solid #e8edf7; background: #f7f9fd; border-radius: 7px; font-size: 11.5px; font-weight: 650; }
.firmware-steps li span { display: grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 6px; background: #e9edf7; font: 700 11px var(--mono); }
.firmware-steps [aria-current='step'] { background: #eff2ff; border-color: #e0e7ff; color: #394fd0; }
.firmware-steps [aria-current='step'] span { background: #4059e8; color: #fff; }
.firmware-steps [data-complete='true'] { background: #f1faf6; border-color: #dcefe5; color: #287255; }
.firmware-steps [data-complete='true'] span { background: #dcf0e7; }
.firmware-controls { justify-content: flex-start; }
.firmware-status { margin: 0; }
.addresses { display: grid; grid-template-columns: repeat(16,minmax(0,1fr)); gap: 4px; font: 650 10px var(--mono); }
.addresses span { display: grid; aspect-ratio: 1.25; place-items: center; border: 1px solid #e7ecf4; border-radius: 4px; background: #f9fafd; color: #576b8f; }
.addresses span.reserved { opacity: .48; }
.addresses span.detected { color: #03745d; border-color: #9edeca; background: #dcf8ef; font-weight: 800; }
.probe-data { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; margin: 0; }
.probe-data > div { min-width: 0; min-height: 65px; padding: 8px 9px; background: #f7f9fc; border: 1px solid #e9edf6; border-radius: 7px; }
.probe-data dt { color: #647491; font-size: 11px; }
.probe-data dd { margin: 5px 0 0; color: #283a59; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.tool-copy h3 { font-size: 13px; margin-bottom: 4px; }

.connection-dialog { width: min(94vw,449px); border: 1px solid #dce4f4; border-radius: 15px; padding: 20px 21px; margin: auto; box-shadow: 0 24px 70px #23325940; color: var(--text); }
.connection-dialog::backdrop { background: #1823416b; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-icon { width: 38px; height: 38px; display: grid; place-items: center; background: #edf0ff; color: #485fe8; border-radius: 9px; margin-bottom: 10px; }
.connection-dialog h2 { font-size: 20px; }
.connection-dialog h2 + p { margin-top: 5px; font-size: 12px; }
.connection-port { display: flex; gap: 9px; align-items: center; padding: 10px; margin: 14px 0 12px; background: #f6f8fe; border: 1px solid #e7edfa; border-radius: 8px; }
.connection-port-icon { width: 27px; height: 27px; color: #5268e3; background: #e9eeff; border-radius: 6px; }
.connection-port strong { font-size: 12px; }
.connection-port p { color: #627392; font-size: 11px; }
.toggle-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 12px; color: #3b4a67; }
.toggle-row strong { display: block; }
.toggle-row small { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.switch { flex: none; appearance: none; width: 33px; height: 19px; margin: 0; background: #adb8cc; border: 0; border-radius: 12px; position: relative; cursor: pointer; }
.switch::after { content: ''; position: absolute; inset: 3px auto 3px 3px; width: 13px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px #233e5233; transition: transform .16s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(14px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.dialog-feedback { margin-top: 10px; color: #a14e1d; background: #fff4e8; border-radius: 6px; padding: 8px; font-size: 11.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
#pin-edit-dialog .dialog-icon { color: #a42a47; background: #fff0f2; }
.pin-edit-list { margin: 12px 0; border: 1px solid #e7edfa; border-radius: 8px; background: #f6f8fe; max-height: min(34vh,220px); overflow: auto; }
.pin-edit-list > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 9px; }
.pin-edit-list > div + div { border-top: 1px solid #e7edfa; }
.pin-edit-list dt { font: 700 12px var(--mono); }
.pin-edit-list dd { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 0; color: var(--muted); font: 600 12px var(--mono); }
.pin-edit-list dd strong { color: var(--text); }
.pin-edit-note { padding: 8px 10px; font-size: 12px; }
.toast { position: fixed; right: 23px; bottom: 20px; z-index: 25; max-width: min(91vw,390px); background: #fff; color: #273755; display: flex; align-items: center; gap: 8px; padding: 10px 11px; font-size: 12px; border: 1px solid #dce4f6; border-radius: 9px; box-shadow: 0 5px 24px #293a6630; }
.toast .icon { color: var(--green); }
.toast[data-tone='error'] .icon { color: #a95b13; }

@media (max-width: 1230px) {
  :root { --sidebar: 191px; }
  .pin-layout { grid-template-columns: minmax(0,1fr) 285px; }
  .signal > .icon { display: none; }
  .tool-grid { grid-template-columns: minmax(0,1fr) 278px; }
  .pin-diagram { --pcb-width: 150px; }
  .pin-bank { grid-auto-rows: 31px; }
  .pin { min-height: 27px; }
}

@media (max-width: 1020px) {
  :root { --sidebar: 160px; }
  .topbar { padding-inline: 14px; gap: 23px; }
  .wordmark { font-size: 16px; flex-basis: calc(var(--sidebar) - 32px); }
  .brand-mark { width: 31px; height: 31px; }
  .sidebar { padding-inline: 8px; }
  .sidebar-device { padding-inline: 5px; gap: 5px; }
  .sidebar-device strong { font-size: 11px; }
  .workspace { padding-inline: 16px; }
  .pin-layout { grid-template-columns: minmax(0,1fr) 246px; gap: 10px; }
  .card-head { padding-inline: 13px; }
  .stage { margin-inline: 10px; padding-inline: 6px; }
  .pin-diagram { --pcb-width: 130px; }
  .pin-bank { grid-auto-rows: 27px; }
  .pin { min-width: 79px; min-height: 23px; gap: 3px; padding-inline: 4px; }
  .pin-id { min-width: 22px; font-size: 10px; }
  .pin-signal { padding-inline: 3px; font-size: 8px; }
  .palette-body { padding-inline: 9px; gap: 7px; }
  .signal-group { padding: 6px; }
  .signal { gap: 2px; padding-inline: 3px; }
  .signal strong { font-size: 10px; }
  .signal small { padding-inline: 2px; }
  .signal-remove { width: 24px; }
  .board-foot { padding-inline: 10px; }
  .device-stats > div { min-width: 88px; padding-inline: 10px; }
  .pin-summary { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .summary-title, .summary-tool { padding-inline: 8px; gap: 5px; }
  .tool-grid { grid-template-columns: minmax(0,1fr) 232px; }
}

@media (max-width: 835px) {
  :root { --header: 53px; }
  .topbar { position: relative; }
  .breadcrumbs { display: none; }
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 15; height: auto; display: block; padding: 3px 8px; border: 0; border-bottom: 1px solid var(--border); }
  .navigation, .nav-section { display: flex; gap: 3px; }
  .nav-section { flex: none; }
  .nav-section > p, .nav-section a > small, .sidebar-footer { display: none; }
  .nav-section a { min-height: 36px; padding-inline: 8px; gap: 5px; width: auto; white-space: nowrap; }
  .nav-section a[aria-current='page']::before { width: 15px; height: 2px; bottom: 0; left: calc(50% - 7px); border-radius: 2px 2px 0 0; }
  .nav-section a .icon { width: 14px; height: 14px; }
  .workspace { padding-top: 20px; }
}

@media (max-width: 620px) {
  .workspace { padding: 15px 11px 14px; }
  .topbar { padding-inline: 10px; gap: 5px; }
  .wordmark { flex-basis: auto; font-size: 14px; gap: 6px; }
  .brand-mark { width: 27px; height: 27px; border-radius: 7px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .top-actions { gap: 6px; }
  .connect-button { min-height: 29px; font-size: 11px; padding-inline: 6px; }
  .connect-button .icon { width: 12px; height: 12px; }
  .top-status { font-size: 9.5px; min-height: 22px; padding: 2px 5px; gap: 4px; }
  .nav-section a { font-size: 11px; padding-inline: 6px; }
  .nav-section a .icon { width: 12px; height: 12px; }
  .page-heading { display: grid; margin-bottom: 13px; gap: 10px; }
  .page-heading p { font-size: 12px; }
  .page-actions { flex-wrap: wrap; }
  .device-banner { min-height: 75px; gap: 8px; padding: 9px; margin-bottom: 11px; }
  .device-name h2 { font-size: 15px; }
  .device-name p { font-size: 9.5px; margin-top: 4px; }
  .device-icon { width: 35px; height: 35px; border-radius: 8px; }
  .device-icon .icon { width: 21px; height: 21px; }
  .device-stats [data-stat='state'] { display: none; }
  .device-stats > div { padding-inline: 6px; min-width: 0; }
  .device-stats > div:last-of-type { min-width: 0; }
  .device-stats dt { font-size: 9px; }
  .device-stats dd { font-size: 11px; white-space: nowrap; }
  .device-stats dd em { display: none; }
  .pin-layout, .tool-grid, .tool-grid.equal { grid-template-columns: minmax(0,1fr); }
  .flash-chip-data { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .flash-device-body, .flash-read-form { padding-inline: 12px; }
  .flash-read-fields { gap: 6px; }
  .flash-read-fields button { padding-inline: 7px; }
  .pin-summary { grid-template-columns: repeat(2,minmax(0,1fr)); margin-top: 10px; }
  .summary-tool:nth-child(3) { border-left: 0; }
  .summary-tool:nth-child(n+3) { border-top: 1px solid var(--border); }
  .pin-diagram { --pcb-width: 137px; }
  .pin-bank { grid-auto-rows: 28.5px; }
  .pin-legend { font-size: 9px; gap: 3px 5px; }
  .palette-body { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .signal-grid { grid-template-columns: minmax(0,1fr); }
  .palette-foot { margin-inline: 10px; }
  .terminal { height: 270px; margin-inline: 10px; }
  .shell-terminal { height: auto; }
  .shell-buttons .button { padding-inline: 4px; gap: 4px; }
  .firmware-steps li { gap: 4px; padding-inline: 4px; }
  .addresses { grid-template-columns: repeat(8,minmax(0,1fr)); }
}

@media (max-width: 365px) {
  .nav-section a { padding-inline: 5px; }
  .nav-section a .icon { display: none; }
  .pin-diagram { --pcb-width: 117px; }
  .pin-bank { grid-auto-rows: 24px; }
  .pin { min-width: 67px; }
  .pin-legend { display: none; }
  .signal-group-head small, .desktop-device-detail { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
