@charset "UTF-8";
/* V3: same palette; larger type and explicit information hierarchy. */
:root {
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Microsoft YaHei UI", "Microsoft YaHei", monospace;
  --bg: #101216;
  --surface: #171a20;
  --surface-alt: #1d2129;
  --surface-hover: #252b35;
  --border: #2c333e;
  --text: #e5e9f0;
  --muted: #a1aab9;
  --subtle: #8e98aa;
  --accent: #86acff;
  --accent-bg: #1e304e;
  --accent-border: #45689e;
  --primary: #97b8ff;
  --primary-text: #101f3c;
  --danger: #ffaea6;
  --danger-bg: #352321;
  --danger-border: #67413b;
  --warning: #e9c787;
  --warning-bg: #2e281d;
  --warning-border: #5c4c2d;
  --success: #94d6b4;
  --success-bg: #1d2e28;
  --success-border: #36594b;
  --shadow: 0 16px 45px #00000020;
  color-scheme: dark;
  color: var(--text);
  background: var(--bg);
}
:root[data-theme=light] {
  --bg: #f3f5f8;
  --surface: #fff;
  --surface-alt: #f5f7fa;
  --surface-hover: #eaf0f8;
  --border: #d7dfe9;
  --text: #202a39;
  --muted: #546276;
  --subtle: #68768a;
  --accent: #295db6;
  --accent-bg: #e9f0fc;
  --accent-border: #b0c7ee;
  --primary: #265ebc;
  --primary-text: #fff;
  --danger: #a5362c;
  --danger-bg: #fff0ec;
  --danger-border: #e6b8b2;
  --warning: #805b14;
  --warning-bg: #fff7e7;
  --warning-border: #dfceaa;
  --success: #216548;
  --success-bg: #eef8f2;
  --success-border: #afd1bf;
  --shadow: 0 16px 45px #253d5b08;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 104px; }
body { margin: 0; font-size: 16px; line-height: 1.65; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 32px; font-weight: 700; line-height: 1.3; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 700; line-height: 1.4; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
button:disabled { opacity: .4; cursor: not-allowed; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; outline-offset: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }

/* Navigation and connection actions */
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: 80px; padding: 0 max(28px, calc((100% - 1344px)/2));
  display: flex; align-items: center; gap: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 700; white-space: nowrap; }
.brand img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border); }
.brand > span { display: flex; align-items: center; gap: 14px; }
.brand-divider { font: 22px var(--mono); font-weight: 300; color: var(--border); }
.brand small { font-size: 15px; font-weight: 500; color: var(--muted); }
.main-nav { display: flex; align-items: center; gap: 30px; height: 100%; font-size: 15px; font-weight: 500; color: var(--muted); }
.main-nav a { display: flex; align-items: center; position: relative; height: 100%; gap: 8px; }
.main-nav a.active { color: var(--text); font-weight: 650; }
.main-nav a.active::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: var(--accent); }
.main-nav a:hover { color: var(--accent); }
#profileCount { font: 12px var(--mono); color: var(--subtle); border: 1px solid var(--border); background: var(--surface-alt); border-radius: 4px; padding: 2px 6px; }
.header-tools { display: flex; align-items: center; gap: 20px; margin-left: auto; }
.version { font: 12px var(--mono); color: var(--subtle); }
.theme-picker { display: flex; gap: 3px; padding: 3px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 7px; }
.theme-picker button { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; font-size: 13px; font-weight: 500; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 4px; }
.theme-picker button[aria-pressed=true] { color: var(--text); background: var(--surface); border-color: var(--border); }
.theme-picker button:hover { color: var(--accent); }
.theme-picker svg { width: 15px; height: 15px; }
main { max-width: 1344px; margin: 0 auto; padding: 32px 28px 26px; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.workspace-heading > div:first-child { display: flex; align-items: center; gap: 22px; }
.technical-label { font: 12px var(--mono); letter-spacing: .025em; color: var(--subtle); }
.technical-label > span { color: var(--border); margin: 0 6px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; font-size: 15px; font-weight: 600; line-height: 1.45; white-space: nowrap; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-alt); }
.button svg { width: 18px; height: 18px; }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 700; }
.button.primary:hover:not(:disabled) { filter: brightness(1.08); }
.button.secondary { background: var(--surface); color: var(--text); }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-border); background: var(--surface-hover); }
.text-button { padding: 5px 0; background: transparent; border: 0; font-size: 14px; font-weight: 500; white-space: nowrap; color: var(--muted); cursor: pointer; }
.text-button:hover { color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-alt); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; background: var(--subtle); border-radius: 50%; }
.pill.demo { color: var(--warning); border-color: var(--warning-border); background: var(--warning-bg); }
.pill.demo::before { background: var(--warning); }
.pill.serial { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }
.pill.serial::before { background: var(--success); }
.notice { margin-bottom: 18px; padding: 12px 16px; border: 1px solid var(--success-border); border-radius: 6px; background: var(--success-bg); color: var(--success); font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.notice.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.notice.warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.demo-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 10px 15px; background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); border-radius: 6px; font-size: 14px; }
.demo-tag { font: 12px var(--mono); padding: 2px 6px; border: 1px solid var(--warning-border); border-radius: 3px; }
.demo-banner .text-button { margin-left: auto; color: var(--warning); }

/* The complete handheld: one screen, three raised keycaps, one enclosure. */
.device-card { border: 1px solid var(--border); border-radius: 9px; background: var(--surface); margin-bottom: 26px; overflow: hidden; }
.device-card-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 28px 0; }
.device-identity { display: flex; align-items: baseline; gap: 15px; }
.device-identity h2 { font-size: 20px; font-weight: 650; }
.connection-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.connection-state i, .stat-dot { display: inline-block; width: 6px; height: 6px; flex-shrink: 0; background: var(--subtle); border-radius: 50%; }
.connection-state.on i, .stat-dot.on { background: var(--success); }
.device-stage { padding: 26px 40px 18px; display: flex; flex-direction: column; align-items: center; gap: 17px; }
.keyboard {
  display: grid; grid-template-columns: 1.24fr repeat(3, 1fr); align-items: center; gap: 16px;
  width: min(850px, 100%); padding: 24px 26px 28px;
  border: 1px solid var(--border); border-radius: 20px;
  background: linear-gradient(150deg, var(--surface-hover), var(--surface-alt));
  box-shadow: inset 0 2px 0 var(--surface-hover), inset 0 -9px 0 var(--border), 0 15px 24px #00000016;
}
.screen-bezel { padding: 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--border); }
.device-screen { display: flex; flex-direction: column; justify-content: space-between; width: 100%; aspect-ratio: 2 / 1; padding: 9px 11px 8px; border: 1px solid #33445b; border-radius: 3px; background: #0b1017; color: #c6ddff; }
.screen-top { display: flex; justify-content: space-between; font: 9px var(--mono); color: #90b8e8; }
#screenTime { font: 30px var(--mono); font-weight: 500; line-height: 1.2; letter-spacing: .045em; text-align: center; }
#screenCaption { font: 7px var(--mono); color: #90a9c7; text-align: center; letter-spacing: .035em; }
.screen-line { height: 2px; background: var(--accent-border); width: 45%; align-self: center; }
.physical-key {
  min-width: 0; height: 156px; padding: 18px 10px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 10px;
  background: linear-gradient(150deg, var(--surface), var(--surface-alt)); color: var(--muted);
  box-shadow: 0 6px 0 var(--border), 0 9px 10px #0000001c;
  position: relative; transform: translateY(-3px);
}
.physical-key:hover { border-color: var(--accent-border); color: var(--accent); }
.physical-key.selected { border-color: var(--accent-border); color: var(--accent); background: linear-gradient(150deg, var(--accent-bg), var(--surface-alt)); box-shadow: 0 6px 0 var(--accent-border), 0 9px 10px #0000001c, inset 0 2px 0 var(--accent-border); }
.physical-key.down { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-border); background: var(--accent-bg); border-color: var(--accent); }
.physical-key svg { width: 27px; height: 27px; margin-bottom: 3px; }
.key-symbol { font: 32px/1 var(--mono); height: 30px; margin-bottom: 3px; }
.physical-key strong { font: 600 18px var(--mono); color: var(--text); }
.physical-key.selected strong { color: var(--accent); }
.physical-key small { font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; overflow-wrap: anywhere; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.screen-description { font-size: 12px; color: var(--subtle); }
.screen-description > span { color: var(--subtle); }
.device-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 17px 28px; border-top: 1px solid var(--border); gap: 22px; }
.summary-stat { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; }
.summary-stat > span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--subtle); }
.summary-stat strong { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }

/* Editing hierarchy: section > current binding > field > helper. */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 24px; align-items: stretch; }
.panel { min-width: 0; padding: 26px 28px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.panel-heading h2 { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.section-index { font: 700 18px/1 var(--mono); color: var(--accent); }
.meta { font: 12px/1.6 var(--mono); color: var(--subtle); }
.key-selector { display: flex; gap: 7px; padding: 4px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 19px; }
.slot-tab { flex: 1; min-height: 40px; padding: 7px 12px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); font: 600 15px var(--mono); display: flex; align-items: center; justify-content: center; gap: 10px; }
.slot-tab span { font-size: 11px; font-weight: 400; color: var(--subtle); }
.slot-tab.selected { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.slot-tab:hover { color: var(--accent); }
.binding-preview { padding: 16px 19px; background: var(--surface-alt); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; position: relative; margin-bottom: 24px; }
.binding-preview > span { font-size: 14px; font-weight: 500; color: var(--muted); display: block; padding-right: 38px; }
.binding-preview strong { font: 650 28px/1.55 var(--mono); color: var(--accent); display: block; margin-top: 4px; overflow-wrap: anywhere; }
.binding-preview .text-button { position: absolute; right: 18px; top: 11px; }
fieldset { padding: 0; margin: 0; min-width: 0; border: 0; }
legend, .normal-key-field > label { display: block; padding: 0; margin-bottom: 12px; font-size: 16px; font-weight: 600; color: var(--text); }
legend > span, .normal-key-field > label > span { margin-left: 10px; font-size: 12px; font-weight: 400; color: var(--subtle); }
.modifier-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.modifier-chip { min-height: 40px; padding: 7px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; color: var(--muted); font-size: 14px; font-weight: 500; }
.modifier-chip[aria-pressed=true] { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-border); font-weight: 650; }
.modifier-chip:hover { border-color: var(--accent); color: var(--accent); }
.normal-key-field { margin-top: 23px; }
select { min-height: 44px; width: 100%; padding: 9px 12px; background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); border-radius: 5px; font-size: 15px; }
.presets { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.presets > span { font-size: 12px; color: var(--subtle); margin-right: 2px; }
.chip { min-height: 32px; padding: 5px 9px; background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border); border-radius: 4px; font: 13px var(--mono); }
.chip:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-border); }
.hint { font-size: 13px; line-height: 1.8; color: var(--subtle); }
.mapping-panel > .hint { font-size: 12px; margin-top: 21px; padding-top: 15px; border-top: 1px solid var(--border); }
.brightness-heading { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; }
.brightness-heading label { font-size: 16px; font-weight: 600; }
.brightness-heading output { padding: 3px 9px; font: 650 22px var(--mono); color: var(--accent); background: var(--accent-bg); border-radius: 4px; }
input[type=range] { width: 100%; height: 5px; margin: 27px 0 0; accent-color: var(--accent); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; margin: 12px 0 28px; font: 12px var(--mono); color: var(--subtle); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 28px 0; border-top: 1px solid var(--border); }
.setting-row label { font-size: 16px; font-weight: 600; }
.setting-row p { margin-top: 7px; font-size: 13px; color: var(--subtle); }
.inline-code { font: 12px var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 3px; padding: 2px 5px; margin-left: 7px; }
.switch { display: inline-flex; position: relative; flex-shrink: 0; width: 40px; height: 24px; }
.switch input { position: absolute; inset: 0; z-index: 1; margin: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.switch > span { width: 40px; height: 24px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-hover); }
.switch > span::after { content: ""; position: absolute; top: 5px; left: 5px; width: 14px; height: 14px; border-radius: 3px; background: var(--subtle); transition: transform .12s; }
.switch input:checked + span { background: var(--accent-bg); border-color: var(--accent-border); }
.switch input:checked + span::after { background: var(--accent); transform: translateX(16px); }
.switch input:disabled + span { opacity: .5; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Explicit device write actions remain separate from local schemes. */
.write-bar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 0 24px; }
.action-description { display: flex; align-items: center; gap: 10px; min-width: 0; }
.action-description strong { display: block; font-size: 15px; font-weight: 650; color: var(--text); }
.action-description div > span { display: block; margin-top: 3px; font-size: 12px; color: var(--subtle); }
.draft-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--warning); }
.draft-dot.verified { background: var(--success); }
.profiles-panel, .connection-panel { margin-bottom: 24px; }
.profiles-panel .panel-heading { margin-bottom: 22px; }
.profiles-panel .button { min-height: 38px; padding: 7px 11px; font-size: 14px; }
.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.profile-card { display: flex; flex-direction: column; min-width: 0; padding: 20px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px; }
.profile-card.loaded { border-color: var(--accent-border); }
.profile-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.profile-icon { font: 600 23px/1.2 var(--mono); color: var(--subtle); flex-shrink: 0; }
.profile-card h3 { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.loaded-tag { margin-left: auto; font-size: 12px; color: var(--accent); white-space: nowrap; }
.profile-bindings { margin-bottom: 16px; font: 14px/2.1 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.profile-bindings span { display: inline-block; min-width: 50px; font: 12px var(--mono); color: var(--subtle); }
.profile-card-actions { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: space-between; margin-top: auto; padding-top: 11px; border-top: 1px solid var(--border); }
.profile-card-actions .text-button { font-size: 13px; }
.profile-card-actions .load-profile { font-weight: 650; color: var(--accent); }
.profiles-empty { padding: 14px 0; color: var(--subtle); font-size: 14px; }
.diagnostics-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 15px; }
.diagnostics-toolbar .button { min-height: 38px; padding: 7px 12px; font-size: 14px; }
.diagnostics-toolbar > .meta { margin-left: auto; }
.log-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.log { height: 200px; overflow: auto; padding: 14px 17px; font: 13px/1.9 var(--mono); color: var(--muted); scrollbar-width: thin; overflow-wrap: anywhere; }
.log-line { display: flex; gap: 12px; }
.log-time { font-size: 12px; flex-shrink: 0; color: var(--subtle); }
.log-direction { flex-shrink: 0; color: var(--accent); }
.log-line.error { color: var(--danger); }
.log-empty { color: var(--subtle); font-size: 13px; }
.diagnostics-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 13px; }
.diagnostics-footer .hint, .diagnostics-footer a { font-size: 12px; }
.demo-keys { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 17px; padding-top: 18px; border-top: 1px solid var(--border); }
.demo-keys .hint { font-size: 12px; margin-left: 4px; }
.protocol-notes { padding: 15px 18px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 14px; }
.protocol-notes summary { display: flex; justify-content: space-between; list-style: none; cursor: pointer; font-weight: 550; }
.protocol-notes summary::-webkit-details-marker { display: none; }
.protocol-notes[open] summary { margin-bottom: 18px; }
.help-content { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 30px; font-size: 13px; line-height: 1.8; color: var(--subtle); }
.app-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding-top: 26px; font: 12px var(--mono); letter-spacing: .02em; color: var(--subtle); }
.footer-divider { margin: 0 6px; color: var(--border); }

/* Dialogs use the same readable text scale. */
.modal { width: calc(100% - 32px); max-width: 520px; padding: 30px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: #060b147a; backdrop-filter: blur(3px); }
.modal h2 { margin: 8px 0 15px; font-size: 24px; font-weight: 700; }
.modal p { font-size: 15px; color: var(--muted); line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }
.modal label { display: block; margin: 23px 0 8px; font-size: 16px; font-weight: 600; }
.modal input[type=text] { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-alt); color: var(--text); font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.modal .error-text { min-height: 20px; margin-top: 9px; font-size: 13px; color: var(--danger); }
.confirm-details { max-height: 260px; overflow: auto; margin-top: 18px; }
.confirm-entry { margin-bottom: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px; line-height: 1.8; color: var(--muted); overflow-wrap: anywhere; }
.confirm-entry strong { display: block; margin-bottom: 5px; font-size: 16px; font-weight: 650; color: var(--text); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; }

@media (max-width: 1150px) {
  .app-header { gap: 32px; padding: 0 24px; }
  .workspace-heading .technical-label { display: none; }
  .header-tools { gap: 12px; }
  .editor-grid { grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 20px; }
  .panel { padding: 24px; }
  .profile-grid { gap: 12px; }
  .profile-card { padding: 17px; }
  .profile-card-actions { justify-content: flex-start; gap: 5px 15px; }
  .profile-bindings { font-size: 13px; }
}
@media (max-width: 900px) {
  .brand small, .brand-divider, .version { display: none; }
  .brand > span { gap: 0; }
  .app-header { gap: 28px; }
  .main-nav { gap: 24px; }
  .editor-grid { grid-template-columns: 1fr; }
  .settings-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 30px; }
  .settings-panel .panel-heading { grid-column: 1 / -1; }
  .brightness-heading, .settings-panel > input, .range-labels { grid-column: 1; }
  .brightness-heading { margin-top: 0; }
  .settings-panel .setting-row { grid-column: 2; padding: 18px 0; }
  .settings-panel .setting-row:nth-last-child(2) { grid-row: 2 / 4; border-top: 0; }
  .settings-panel .setting-row:last-child { grid-row: 4 / 6; }
  .device-stage { padding: 26px 26px 18px; }
  .keyboard { padding: 20px 20px 25px; gap: 12px; }
  .physical-key { height: 145px; }
  .physical-key strong { font-size: 17px; }
  .device-stats { gap: 15px; }
  .summary-stat { flex-direction: column; align-items: flex-start; gap: 5px; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-card { padding: 20px; }
  .profile-card-top { margin-bottom: 10px; }
  .profile-bindings { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 14px; margin-bottom: 12px; }
  .profile-card-actions { justify-content: flex-start; gap: 8px 25px; }
  .diagnostics-toolbar { flex-wrap: wrap; }
  .diagnostics-toolbar > .meta { order: 3; width: 100%; }
  .diagnostics-toolbar > .text-button { margin-left: auto; }
}
@media (max-width: 700px) {
  html { scroll-padding-top: 132px; }
  .app-header { height: auto; min-height: 72px; padding: 13px 18px 0; gap: 12px; flex-wrap: wrap; }
  .brand { font-size: 23px; gap: 9px; }
  .brand img { width: 36px; height: 36px; border-radius: 10px; }
  .main-nav { order: 3; width: 100%; height: 39px; gap: 28px; font-size: 14px; }
  .main-nav a { padding-bottom: 8px; }
  .header-tools { margin-left: auto; }
  .theme-picker button { min-height: 30px; padding: 4px 8px; font-size: 12px; }
  .theme-picker svg { width: 14px; height: 14px; }
  main { padding: 24px 18px; }
  h1 { font-size: 26px; }
  .workspace-heading { flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
  .workspace-heading > .button-row { width: 100%; gap: 8px; }
  .workspace-heading .pill { margin-right: auto; }
  .workspace-heading .button { padding: 8px 10px; font-size: 14px; min-height: 40px; }
  .workspace-heading .button svg { width: 16px; height: 16px; }
  .device-card { margin-bottom: 22px; }
  .device-card-top { padding: 19px 18px 0; gap: 12px; }
  .device-identity { gap: 0; }
  .device-identity .technical-label { display: none; }
  .device-identity h2 { font-size: 20px; }
  .connection-state { font-size: 12px; }
  .device-stage { padding: 24px 12px 17px; gap: 16px; }
  .keyboard { gap: 7px; padding: 16px 10px 20px; border-radius: 12px; grid-template-columns: 1.22fr repeat(3, 1fr); }
  .screen-bezel { padding: 3px; border-radius: 4px; }
  .device-screen { aspect-ratio: auto; height: 58px; padding: 5px 4px; }
  .screen-top { font-size: 6px; }
  #screenTime { font-size: 20px; }
  #screenCaption { font-size: 4px; }
  .screen-line { height: 1px; }
  .physical-key { padding: 10px 3px 12px; height: 101px; gap: 5px; border-radius: 6px; box-shadow: 0 4px 0 var(--border), 0 6px 7px #0000001c; }
  .physical-key.selected { box-shadow: 0 4px 0 var(--accent-border), 0 6px 7px #0000001c, inset 0 1px 0 var(--accent-border); }
  .physical-key svg { width: 22px; height: 22px; margin-bottom: 0; }
  .physical-key .key-symbol { height: 22px; font-size: 24px; margin-bottom: 0; }
  .physical-key strong { font-size: 14px; }
  .physical-key small { font-size: 12px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .screen-description { font-size: 12px; }
  .device-stats { grid-template-columns: 1fr 1fr; gap: 16px 18px; padding: 17px 18px; }
  .summary-stat > span { font-size: 12px; }
  .summary-stat strong { font-size: 14px; }
  .panel { padding: 22px 20px; }
  .panel-heading { gap: 12px; margin-bottom: 22px; }
  .panel-heading h2 { font-size: 20px; gap: 10px; }
  .section-index { font-size: 18px; }
  .meta { font-size: 12px; }
  .slot-tab { min-height: 39px; padding: 7px 8px; font-size: 14px; gap: 7px; }
  .slot-tab span { font-size: 12px; }
  .binding-preview { padding: 15px 16px; }
  .binding-preview strong { font-size: 24px; }
  .binding-preview > span { font-size: 14px; }
  .binding-preview .text-button { right: 15px; }
  .modifier-grid { gap: 8px; }
  .modifier-chip { min-height: 40px; font-size: 14px; padding: 7px 4px; }
  .presets { gap: 8px; }
  .chip { font-size: 12px; padding: 5px 8px; }
  .mapping-panel > .hint { font-size: 12px; }
  .settings-panel { display: block; }
  .brightness-heading { margin-top: 3px; }
  .range-labels { margin-bottom: 24px; }
  .setting-row { padding: 25px 0; }
  .setting-row:last-child { padding-bottom: 2px; }
  .setting-row p { font-size: 13px; }
  .write-bar { flex-direction: column; align-items: stretch; gap: 15px; padding: 19px 0 23px; }
  .write-bar > .button-row { flex-wrap: nowrap; }
  .write-bar .button { flex: 1; }
  .action-description div { display: flex; gap: 5px 10px; flex-wrap: wrap; align-items: center; }
  .action-description div > span { margin-top: 0; font-size: 12px; }
  .profiles-panel .panel-heading { flex-direction: column; align-items: flex-start; gap: 17px; }
  .profiles-panel .button { padding: 7px 9px; font-size: 13px; }
  .profiles-panel .button-row { gap: 7px; }
  .profile-card { padding: 17px; }
  .profile-bindings { display: block; font-size: 14px; }
  .profile-bindings span { min-width: 47px; }
  .profile-card-actions { gap: 5px 17px; }
  .profile-card-actions .text-button { font-size: 13px; }
  .connection-panel .panel-heading { flex-wrap: wrap; }
  .diagnostics-toolbar { gap: 10px; }
  .diagnostics-toolbar .button { padding: 7px 10px; font-size: 13px; }
  .diagnostics-toolbar > .meta { font-size: 12px; }
  .log { padding: 12px 10px; font-size: 12px; height: 220px; }
  .log-time { font-size: 12px; }
  .log-line { gap: 7px; }
  .log-line > span:last-child { min-width: 0; }
  .diagnostics-footer { align-items: flex-start; }
  .demo-keys .hint { flex-basis: 100%; margin-left: 0; }
  .help-content { grid-template-columns: 1fr; font-size: 13px; }
  .app-footer { flex-direction: column; align-items: flex-start; gap: 8px; font-size: 12px; }
  .demo-banner { font-size: 13px; gap: 8px; }
  .demo-banner .text-button { font-size: 13px; }
  .notice { font-size: 14px; }
  .modal { padding: 25px; }
  .modal h2 { font-size: 23px; }
  .modal p { font-size: 14px; }
}
@media (max-width: 380px) {
  main { padding-left: 14px; padding-right: 14px; }
  .app-header { padding-left: 14px; padding-right: 14px; }
  .workspace-heading > .button-row { gap: 6px; }
  .workspace-heading .button { font-size: 13px; padding: 8px; }
  .workspace-heading .pill { font-size: 12px; padding: 4px 6px; }
  .keyboard { gap: 5px; padding-left: 7px; padding-right: 7px; }
  .physical-key { height: 98px; }
  .physical-key strong { font-size: 13px; }
  .physical-key small { font-size: 12px; }
  .physical-key svg { width: 20px; height: 20px; }
  .screen-top { font-size: 5px; }
  #screenTime { font-size: 17px; }
  #screenCaption { font-size: 4px; }
  .device-stage { padding-left: 8px; padding-right: 8px; }
  .device-card-top { padding-left: 16px; padding-right: 16px; }
  .connection-state { font-size: 12px; }
  .device-identity h2 { font-size: 19px; }
  .panel { padding-left: 17px; padding-right: 17px; }
  .panel-heading > .meta { max-width: 91px; text-align: right; }
  .modifier-chip { font-size: 13px; }
  .slot-tab { font-size: 14px; gap: 5px; }
  .profiles-panel .button { font-size: 12px; }
  .diagnostics-toolbar > .text-button { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
