@charset "UTF-8";

:root {
  color-scheme: dark;
  --bg: #111216;
  --panel: #1a1b20;
  --panel-raised: #212228;
  --panel-soft: #16171c;
  --line: #303138;
  --line-soft: #27282f;
  --text: #f1eee9;
  --muted: #92939f;
  --subtle: #8b8d99;
  --accent: #ff8a44;
  --accent-bright: #ffac70;
  --accent-soft: #35251e;
  --green: #8ed8ad;
  --red: #ff8177;
  --red-bg: #3a2224;
  --radius: 20px;
  font-family: Inter, "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; background: radial-gradient(ellipse at 10% 0, #30231e55, transparent 38rem), var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button, select, summary, input[type="range"], input[type="checkbox"] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, select, .axis-pad { -webkit-user-select: none; user-select: none; }
button, select, input { color: inherit; }
button { border: 0; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible, .axis-pad:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 4px; }
button:disabled, select:disabled { opacity: .42; }
[hidden] { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 30; top: 8px; left: 16px; padding: 10px 16px; background: var(--accent); color: #21150e; border-radius: 8px; transform: translateY(-150%); clip-path: inset(100%); }
.skip-link:focus { transform: none; clip-path: none; }
.app-shell { max-width: 1180px; margin: 0 auto; padding: 24px 28px max(20px, env(safe-area-inset-bottom)); }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid #ff8a4436; background: linear-gradient(145deg, #3d2a20, #241d1a); border-radius: 14px; color: var(--accent); }
.brand-mark svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-type { display: flex; align-items: baseline; gap: 13px; }
.brand-type strong { font-size: 27px; font-weight: 750; letter-spacing: -.8px; }
.brand-dot { color: var(--accent); }
.brand-type > span { color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.header-tools, .session-actions, .safety-actions, .log-actions { display: flex; align-items: center; gap: 10px; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 9px 16px; font-weight: 600; font-size: 13px; line-height: 1.25; white-space: nowrap; transition: background .16s, border-color .16s, color .16s, box-shadow .16s; }
.button-primary { background: var(--accent); color: #281b12; box-shadow: 0 3px 14px #ff8a4411; }
.button-primary:hover:not(:disabled) { background: var(--accent-bright); }
.button-quiet { background: transparent; color: #b6b5bd; }
.button-quiet:hover:not(:disabled) { background: #ffffff09; color: var(--text); }
.button-icon { width: 42px; padding: 9px; background: var(--panel-raised); border-color: var(--line); color: #c0c0c8; }
.button-icon:hover:not(:disabled) { background: #2b2c34; color: var(--text); }
.button-small { min-height: 33px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.button-icon.button-small { width: 33px; }
.button-small .icon { width: 16px; height: 16px; }
.button-accent-soft { color: var(--accent-bright); background: var(--accent-soft); border-color: #ff8a4425; }
.button-accent-soft:hover:not(:disabled) { background: #493022; border-color: #ff8a4455; }
.preview-button[aria-pressed="true"], .preview-button.active { color: var(--accent-bright); background: var(--accent-soft); border-color: #ff8a4440; }
.notice { margin-bottom: 16px; border: 1px solid #a96f3855; border-radius: 12px; padding: 13px 16px; background: #2d251b; color: #e9c6a3; font-size: 13px; }
.app-shell:has(#preview-btn[aria-pressed="true"]) #compatibility-notice { display: none; }
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; border: 1px solid var(--line-soft); border-radius: 16px; padding: 14px 18px; background: #1a1b20c9; }
.device-status { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #666976; box-shadow: 0 0 0 5px #66697612; }
.status-dot.connected, .status-dot.is-connected, .status-dot[data-state="connected"], body[data-connection="connected"] .status-dot { background: var(--green); box-shadow: 0 0 0 5px #8ed8ad12, 0 0 16px #8ed8ad25; }
.status-dot.preview, .status-dot[data-state="preview"] { background: var(--accent); box-shadow: 0 0 0 5px #ff8a4412; }
.status-dot.error, .status-dot[data-state="error"] { background: var(--red); }
.device-copy { display: grid; gap: 1px; min-width: 0; }
.device-copy strong { font-size: 14px; font-weight: 650; letter-spacing: .02em; overflow-wrap: anywhere; }
#connection-status { color: var(--muted); font-size: 11px; }
.mode-badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: #ffffff03; padding: 3px 8px; color: var(--muted); font-size: 10px; letter-spacing: .06em; white-space: nowrap; }
.battery-status { display: flex; gap: 8px; align-items: center; min-width: 72px; padding: 0 10px; color: #b3b6bf; font-variant-numeric: tabular-nums; font-size: 13px; }
.battery-status .icon { width: 23px; }
.controller-card { border: 1px solid #34343a; border-radius: var(--radius); background: linear-gradient(120deg, #20212666, transparent 40%), var(--panel); box-shadow: 0 18px 60px #00000020; overflow: hidden; }
.controller-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px 15px; border-bottom: 1px solid var(--line-soft); }
.section-kicker { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: .08em; }
.page-switcher { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.page-cycle-button { width: 31px; min-height: 35px; padding: 6px; border-color: var(--line); background: #222329; }
.page-cycle-button .icon { width: 15px; height: 15px; }
.controller-heading p { color: var(--muted); font-size: 11px; margin: 3px 0 0; }
.mode-select { display: inline-flex; align-items: center; position: relative; flex: 0 0 auto; }
.mode-select select { appearance: none; border: 1px solid #3b3b43; border-radius: 9px; min-height: 37px; padding: 7px 35px 7px 13px; background: #25262d; font-size: 12px; font-weight: 600; cursor: pointer; }
.mode-select > .icon { width: 15px; height: 15px; position: absolute; right: 12px; pointer-events: none; color: var(--muted); }
.control-fieldset { margin: 0; border: 0; min-width: 0; padding: 18px 24px 0; }
.drive-controls { display: grid; grid-template-columns: minmax(0, 1fr) 112px minmax(0, 1fr); align-items: center; column-gap: 24px; }
.function-controls { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 14px; align-self: center; }
.function-button { min-height: 88px; min-width: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 14px; color: #c2c1c9; background: #222329; touch-action: none; }
.function-button > .icon { width: 26px; height: 26px; }
.function-button > span { display: grid; gap: 1px; text-align: center; }
.function-button strong { font-size: 11px; font-weight: 600; }
.function-button small { color: var(--subtle); font-size: 10px; }
.function-button:hover:not(:disabled) { border-color: #525059; }
.function-button[aria-pressed="true"], .function-button.is-pressed, .function-button.pressed, .function-button.active, .function-button[data-active="true"] { background: var(--accent-soft); border-color: #ff8a4480; color: var(--accent-bright); box-shadow: 0 0 0 3px #ff8a4409; }
.joystick-controls, .direction-controls { display: contents; }
.axis-column, .direction-group { grid-row: 1; min-width: 0; }
.joystick-controls > .axis-column:first-child, .direction-controls > .direction-group:first-child { grid-column: 1; }
.joystick-controls > .axis-column:last-child, .direction-controls > .direction-group:last-child { grid-column: 3; }
.axis-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; padding: 0 4px; }
.axis-heading h1, .axis-heading h2, .direction-heading h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; }
.axis-value { font-size: 20px; font-weight: 600; line-height: 1; color: var(--accent-bright); letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.axis-value > span { color: var(--subtle); font-size: 10px; letter-spacing: 0; margin-left: 4px; }
.axis-pad { --knob-x: 0px; --knob-y: 0px; width: 100%; height: 224px; position: relative; overflow: hidden; border: 1px solid #35363e; border-radius: 15px; background: radial-gradient(circle at center, #2d2927 0, #242427 24%, transparent 61%), repeating-linear-gradient(0deg, transparent 0 25px, #ffffff02 25px 26px), repeating-linear-gradient(90deg, transparent 0 25px, #ffffff02 25px 26px), #14151a; box-shadow: inset 0 1px 12px #00000024; touch-action: none; cursor: grab; isolation: isolate; }
.axis-pad:active { cursor: grabbing; }
.axis-pad:focus-visible { outline-offset: 3px; }
.pad-guide { position: absolute; z-index: -1; border-radius: 8px; background: #ffffff05; border: 1px solid #ffffff04; }
.throttle-pad .pad-guide { width: 12px; height: calc(100% - 56px); left: 50%; top: 28px; transform: translateX(-50%); }
.steering-pad .pad-guide { height: 12px; width: calc(100% - 56px); top: 50%; left: 28px; transform: translateY(-50%); }
.pad-ticks { position: absolute; opacity: .6; z-index: -1; }
.throttle-pad .pad-ticks { top: 35px; bottom: 35px; width: 8px; left: calc(50% + 31px); background: repeating-linear-gradient(to bottom, #77767d 0 1px, transparent 1px 15px); }
.steering-pad .pad-ticks { left: 35px; right: 35px; height: 8px; top: calc(50% + 31px); background: repeating-linear-gradient(to right, #77767d 0 1px, transparent 1px 15px); }
.pad-center { width: 86px; height: 86px; border: 1px solid #ffffff0a; border-radius: 50%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: -1; }
.pad-center::before, .pad-center::after { content: ""; position: absolute; background: #ffffff14; }
.pad-center::before { width: 6px; height: 1px; left: -13px; top: 50%; box-shadow: 104px 0 #ffffff14; }
.pad-center::after { width: 1px; height: 6px; left: 50%; top: -13px; box-shadow: 0 104px #ffffff14; }
.axis-knob { width: 64px; height: 64px; position: absolute; top: 50%; left: 50%; transform: translate(calc(-50% + var(--knob-x)), calc(-50% + var(--knob-y))); border-radius: 50%; border: 2px solid #ffba8444; background: linear-gradient(150deg, #ffac6b, #fa843f 50%, #e66a29); box-shadow: 0 5px 12px #00000060, inset 0 1px 2px #ffffff55, 0 0 0 7px #ff8a4408; display: grid; place-items: center; pointer-events: none; will-change: transform; }
.knob-grip { display: block; width: 22px; height: 14px; opacity: .65; }
.knob-grip-horizontal { background: repeating-linear-gradient(to bottom, #5c2e1b 0 2px, transparent 2px 6px); }
.knob-grip-vertical { width: 14px; height: 22px; background: repeating-linear-gradient(to right, #5c2e1b 0 2px, transparent 2px 6px); }
.axis-pad.is-active, .axis-pad.active, .axis-pad[data-active="true"] { border-color: #ff8a4477; box-shadow: inset 0 1px 12px #00000024, 0 0 0 3px #ff8a4407; }
.pad-caption { position: absolute; display: flex; align-items: center; justify-content: center; gap: 5px; color: #82838e; font-size: 10px; pointer-events: none; }
.pad-caption .icon { width: 12px; height: 12px; }
.pad-caption-top { top: 12px; left: 12px; flex-direction: row; }
.pad-caption-bottom { bottom: 12px; left: 12px; }
.pad-caption-left { top: 12px; left: 12px; }
.pad-caption-right { top: 12px; right: 12px; }
.axis-help { display: flex; justify-content: space-between; gap: 8px; margin: 8px 4px 0; color: var(--subtle); font-size: 10px; }
.axis-help span { color: #90929e; }
.control-fieldset:disabled .axis-pad { pointer-events: none; opacity: .65; }
.control-fieldset:disabled .axis-knob { background: linear-gradient(145deg, #8a7364, #66554b); border-color: #a38b7a55; box-shadow: 0 4px 12px #00000040, inset 0 1px 2px #ffffff18; }
.control-fieldset:disabled .axis-value { color: #a38d7e; }
.direction-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin: 0 4px 9px; }
.direction-heading > span { color: var(--subtle); font-size: 10px; }
.direction-pair { height: 224px; display: grid; gap: 12px; touch-action: none; }
.direction-pair-vertical { grid-template-rows: 1fr 1fr; }
.direction-pair-horizontal { grid-template-columns: 1fr 1fr; }
.direction-button { display: flex; align-items: center; justify-content: center; gap: 12px; border: 1px solid #3b3b43; border-radius: 13px; background: linear-gradient(145deg, #2d2e34, #222329); color: #cdcad0; font-weight: 600; touch-action: none; box-shadow: 0 3px 0 #101115, inset 0 1px #ffffff06; }
.direction-button .icon { width: 29px; height: 29px; }
.direction-pair-horizontal .direction-button { flex-direction: column; }
.direction-button:hover:not(:disabled) { border-color: #62616b; }
.direction-button[aria-pressed="true"], .direction-button.pressed, .direction-button.is-pressed, .direction-button.active, .direction-button[data-active="true"] { background: #493022; color: var(--accent-bright); border-color: var(--accent); box-shadow: 0 1px 0 #101115, inset 0 0 18px #ff8a4409; }
.adjustments { border-top: 1px solid var(--line-soft); padding-top: 16px; margin-top: 20px; }
.adjustments-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.adjustments-header h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.adjustments-header > span { color: var(--subtle); font-size: 10px; }
.adjustment-selectors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.adjustment-selector { position: relative; min-width: 0; min-height: 65px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 11px; border: 1px solid #36363e; background: #222329; text-align: left; transition: border-color .15s, background .15s; }
.adjustment-selector > .icon { color: #a8a4a3; width: 22px; height: 22px; }
.adjustment-name { display: grid; gap: 3px; color: #cfccd0; font-size: 12px; font-weight: 600; white-space: nowrap; }
.adjustment-name small { font-size: 10px; font-weight: 400; color: var(--subtle); }
.adjustment-current { margin-left: auto; color: #c4c0be; font-size: 20px; font-weight: 550; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.adjustment-selector:hover:not(:disabled) { border-color: #64564d; }
.adjustment-selector[aria-pressed="true"], .adjustment-selector.is-active, .adjustment-selector.active, .adjustment-selector.selected { background: #30251f; border-color: #ad693d; }
.adjustment-selector[aria-pressed="true"] .icon, .adjustment-selector[aria-pressed="true"] .adjustment-current, .adjustment-selector.is-active .icon, .adjustment-selector.active .adjustment-current { color: var(--accent-bright); }
.adjustment-panel { margin-top: 10px; border: 1px solid #604332; border-radius: 12px; padding: 10px 16px 9px; background: linear-gradient(180deg, #32271f, #28221e); }
.adjustment-panel-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.adjustment-panel-heading label { font-size: 12px; font-weight: 600; }
.adjustment-panel-heading output { margin-left: auto; font-size: 19px; line-height: 1; color: var(--accent-bright); font-variant-numeric: tabular-nums; }
.adjustment-panel-heading .button { background: transparent; color: #b29b8a; border-color: transparent; }
.adjustment-slider { appearance: none; display: block; width: 100%; height: 30px; padding: 0; margin: 0; background: transparent; cursor: ew-resize; touch-action: pan-y; accent-color: var(--accent); }
.adjustment-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 5px; background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--range-progress, 50%), #5a493d var(--range-progress, 50%), #5a493d 100%); }
.adjustment-slider::-moz-range-track { height: 6px; border-radius: 5px; background: #5a493d; }
.adjustment-slider::-moz-range-progress { height: 6px; border-radius: 5px; background: var(--accent); }
.adjustment-slider::-webkit-slider-thumb { appearance: none; width: 25px; height: 25px; margin-top: -9.5px; border-radius: 50%; border: 3px solid #ffe2cb; background: var(--accent); box-shadow: 0 2px 7px #00000045; }
.adjustment-slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #ffe2cb; background: var(--accent); box-shadow: 0 2px 7px #00000045; }
.range-labels { display: flex; justify-content: space-between; font-size: 9px; color: #ad9481; font-variant-numeric: tabular-nums; }
.adjustment-hint { color: #a58c7a; font-size: 10px; margin: 6px 0 0; }
.adjustment-presets { display: flex; justify-content: flex-end; gap: 9px; margin: 10px 0 15px; }
.adjustment-presets b { font: inherit; font-variant-numeric: tabular-nums; margin-left: 3px; }
.safety-strip { display: flex; justify-content: space-between; align-items: center; gap: 15px; min-height: 76px; padding: 15px 24px; background: #17181d; border-top: 1px solid #2e2d33; }
.safety-copy { display: flex; align-items: center; gap: 10px; color: #b4b2bb; font-size: 11px; }
.safety-copy > span:last-child { display: grid; gap: 2px; }
.safety-copy small { color: var(--subtle); font-size: 10px; }
.safety-indicator { width: 7px; height: 7px; border-radius: 50%; border: 1px solid #d58c8266; box-shadow: 0 0 0 4px #c67c7210; }
.button-stop { min-width: 174px; color: var(--red); border: 1px solid #864841; background: var(--red-bg); }
.button-stop:hover:not(:disabled) { background: #52302f; border-color: #d47b70; }
.button-stop .icon { width: 18px; height: 18px; }
.button-stop kbd { margin-left: 6px; border-color: #9b635550; color: #cf9d92; background: #211719; }
body.emergency .safety-strip, body[data-emergency="true"] .safety-strip, .controller-card:has(#resume-btn:not([hidden])) .safety-strip { background: #2c1d20; border-top-color: #653b39; }
body.emergency .safety-indicator, body[data-emergency="true"] .safety-indicator, .controller-card:has(#resume-btn:not([hidden])) .safety-indicator { background: var(--red); box-shadow: 0 0 0 4px #ff817712; }
.below-controller { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 12px 3px 16px; }
.keyboard-hint { display: flex; flex-wrap: wrap; gap: 18px; margin: 0; color: var(--subtle); font-size: 10px; }
.keyboard-hint > span { display: flex; align-items: center; gap: 4px; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px; padding: 0 4px; background: #1c1d23; border: 1px solid #36373e; border-radius: 4px; color: #9697a2; font: 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace; box-shadow: 0 1px #0b0c0f; }
.help-panel { position: relative; flex: 0 0 auto; font-size: 11px; }
.help-panel summary { display: flex; align-items: center; justify-content: flex-end; gap: 5px; color: #9e9eaa; cursor: pointer; list-style: none; }
.help-panel summary::-webkit-details-marker, .settings-summary::-webkit-details-marker { display: none; }
.help-panel summary .icon { width: 15px; height: 15px; }
.help-content { position: absolute; top: 28px; right: 0; z-index: 8; width: min(360px, calc(100vw - 36px)); padding: 12px 16px; background: #26272e; border: 1px solid #46464f; border-radius: 12px; box-shadow: 0 14px 35px #00000050; color: #bbb9c1; }
.help-content p { margin: 7px 0; }
.settings-panel { border: 1px solid var(--line-soft); border-radius: 15px; background: #191a1f; }
.settings-summary { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 17px 20px; cursor: pointer; list-style: none; }
.settings-summary > span { display: flex; align-items: center; gap: 10px; }
.settings-summary > span > .icon { width: 18px; height: 18px; color: #a39c97; }
.settings-summary strong { font-size: 12px; font-weight: 600; color: #c8c5ca; }
.settings-summary small { font-size: 10px; color: var(--subtle); margin-left: 4px; }
.details-chevron { width: 17px; height: 17px; color: var(--subtle); transition: transform .2s; }
.settings-panel[open] .details-chevron { transform: rotate(180deg); }
.settings-content { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--line-soft); }
.settings-section { min-width: 0; padding: 20px; }
.settings-section + .settings-section { border-left: 1px solid var(--line-soft); }
.settings-section h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 12px; font-weight: 600; color: #c8c5ca; }
.settings-section h2 .icon { width: 17px; height: 17px; color: #97909a; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 46px; cursor: pointer; }
.toggle-row > span:first-child { display: grid; gap: 3px; }
.toggle-row strong { font-size: 12px; font-weight: 500; color: #bdbbc4; }
.toggle-row small { font-size: 10px; color: var(--subtle); }
.switch { position: relative; width: 36px; height: 21px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 20px; background: #393a43; border: 1px solid #4d4d57; transition: background .2s; }
.switch-track::after { content: ""; position: absolute; width: 13px; height: 13px; top: 3px; left: 3px; border-radius: 50%; background: #c5c2c8; transition: transform .2s; }
.switch input:checked + .switch-track { background: #c66c36; border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(15px); background: #fff1e5; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent-bright); outline-offset: 4px; }
.switch input:disabled + .switch-track { opacity: .4; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0; }
.settings-fields label, .readout-field { display: grid; gap: 7px; font-size: 10px; color: var(--muted); }
.settings-fields select { width: 100%; min-height: 35px; padding: 7px 10px; background: #24252b; border: 1px solid #3b3c44; border-radius: 8px; font-size: 12px; }
.readout-field output { display: flex; align-items: center; min-height: 35px; font: 15px/1 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--accent-bright); }
.field-note { margin: 12px 0 0; color: var(--subtle); font-size: 10px; line-height: 1.7; }
.packet-status-line { display: flex; align-items: center; gap: 7px; color: #8f9691; margin-top: 15px; font-size: 10px; }
.mini-dot { width: 5px; height: 5px; flex: 0 0 auto; border-radius: 50%; background: #768c7f; }
.monitor-section, .log-section { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); border-left: 0 !important; }
.monitor-heading, .log-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.monitor-heading h2, .log-heading h2 { margin: 0; }
.monitor-tag { color: var(--subtle); font-size: 10px; }
.transport-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 12px 0 16px; }
.transport-stats > div { display: grid; gap: 5px; border-left: 1px solid #36363c; padding-left: 16px; }
.transport-stats > div:first-child { padding-left: 0; border: 0; }
.transport-stats span { color: var(--subtle); font-size: 10px; }
.transport-stats output { font: 19px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; color: #d9d0c8; }
.frame-block { padding: 11px 13px; border: 1px solid #2c2d34; border-radius: 9px; background: #141519; }
.frame-block + .frame-block { margin-top: 9px; }
.frame-label { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.frame-label strong { font-size: 9px; font-weight: 650; color: #bd997f; letter-spacing: .1em; }
.frame-label span { font-size: 9px; color: var(--subtle); }
.frame-value { display: block; min-height: 19px; font: 12px/1.8 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; color: #c7c7ce; overflow-wrap: anywhere; word-spacing: .12em; }
.log-list { max-height: 200px; min-height: 40px; overflow: auto; margin: 0; padding: 0; list-style: none; font: 11px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; scrollbar-width: thin; scrollbar-color: #41424c transparent; }
.log-list:empty::before { display: block; content: "連線、控制狀態與錯誤會顯示於此。"; padding: 8px 0; color: var(--subtle); font: 11px/1.7 Inter, "Noto Sans TC", sans-serif; }
.log-list li { border-bottom: 1px solid #ffffff04; padding: 7px 0; color: #a5a6b0; overflow-wrap: anywhere; }
.log-list time { color: var(--subtle); margin-right: 10px; }
.log-list .error, .log-list [data-level="error"] { color: var(--red); }
.log-list .warning, .log-list [data-level="warn"] { color: var(--accent-bright); }
.app-footer { display: flex; justify-content: space-between; gap: 16px; padding: 18px 3px 0; color: #777a88; font-size: 9px; letter-spacing: .04em; }

@media (min-width: 1000px) {
  .app-shell { padding-top: 30px; }
  .drive-controls { grid-template-columns: minmax(0, 1fr) 118px minmax(0, 1fr); column-gap: 30px; }
  .axis-pad { height: 230px; }
  .control-fieldset { padding: 20px 28px 0; }
  .function-button { min-height: 94px; }
  .adjustment-selectors { gap: 14px; }
}

@media (max-width: 700px) {
  .app-shell { padding: 18px 16px max(18px, env(safe-area-inset-bottom)); }
  .app-header { margin-bottom: 16px; gap: 10px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand-mark svg { width: 30px; height: 30px; }
  .brand-type { display: grid; gap: 0; }
  .brand-type strong { font-size: 24px; line-height: 1.15; }
  .brand-type > span { font-size: 9px; letter-spacing: .04em; }
  .header-tools { gap: 5px; }
  .preview-button { padding-inline: 9px; font-size: 11px; gap: 5px; }
  .preview-button .icon { width: 16px; height: 16px; }
  .button-icon { width: 37px; min-height: 37px; padding: 8px; }
  .session-bar { padding: 12px 13px; border-radius: 13px; gap: 10px; }
  .device-status { gap: 9px; }
  .device-copy strong { font-size: 12px; }
  #connection-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mode-badge { display: none; }
  .session-actions { gap: 6px; flex: 0 0 auto; }
  .battery-status { padding: 0 4px; gap: 5px; min-width: 50px; font-size: 11px; }
  .battery-status .icon { width: 18px; height: 18px; }
  #connect-btn { min-height: 37px; padding: 9px 11px; font-size: 11px; }
  #connect-btn .icon { display: none; }
  .disconnect-button { width: 31px; min-height: 35px; padding: 6px; }
  .controller-card { border-radius: 16px; }
  .controller-toolbar { padding: 15px 16px 12px; gap: 10px; }
  .section-kicker { font-size: 12px; }
  .controller-heading p { font-size: 10px; max-width: 200px; }
  .mode-select select { font-size: 11px; min-height: 34px; padding: 7px 28px 7px 10px; }
  .mode-select > .icon { right: 8px; }
  .page-switcher { gap: 4px; }
  .page-cycle-button { width: 25px; min-height: 32px; padding: 5px; }
  .page-cycle-button .icon { width: 13px; height: 13px; }
  .control-fieldset { padding: 14px 16px 0; }
  .drive-controls { grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); column-gap: 8px; }
  .function-controls { gap: 12px; }
  .function-button { min-height: 80px; gap: 6px; padding: 8px 3px; border-radius: 12px; }
  .function-button > .icon { width: 22px; height: 22px; }
  .function-button strong { font-size: 10px; }
  .function-button small { font-size: 8px; }
  .axis-pad { height: 208px; border-radius: 12px; }
  .axis-heading { padding-inline: 1px; }
  .axis-heading h1, .axis-heading h2 { font-size: 12px; }
  .axis-value { font-size: 18px; }
  .axis-knob { width: 56px; height: 56px; }
  .pad-center { width: 76px; height: 76px; }
  .pad-center::before { box-shadow: 94px 0 #ffffff14; }
  .pad-center::after { box-shadow: 0 94px #ffffff14; }
  .pad-caption { font-size: 9px; gap: 3px; }
  .pad-caption-top, .pad-caption-left { top: 10px; left: 9px; }
  .pad-caption-right { top: 10px; right: 9px; }
  .pad-caption-bottom { bottom: 10px; left: 9px; }
  .axis-help { font-size: 9px; gap: 3px; margin-inline: 0; }
  .axis-help > span { display: none; }
  .direction-heading { display: block; }
  .direction-heading > span { display: block; font-size: 9px; margin-top: 3px; }
  .direction-pair { height: 204px; gap: 9px; }
  .direction-button { font-size: 11px; gap: 8px; }
  .direction-button .icon { width: 24px; height: 24px; }
  .adjustments { margin-top: 16px; padding-top: 14px; }
  .adjustment-selectors { gap: 7px; }
  .adjustment-selector { min-height: 94px; padding: 9px 8px; display: grid; grid-template-columns: 1fr auto; gap: 6px 3px; }
  .adjustment-selector > .icon { width: 18px; height: 18px; }
  .adjustment-current { grid-column: 2; grid-row: 1; font-size: 18px; }
  .adjustment-name { grid-column: 1 / -1; font-size: 11px; gap: 2px; }
  .adjustment-name small { font-size: 9px; }
  .adjustment-presets { justify-content: space-between; gap: 5px; margin-bottom: 12px; }
  .adjustment-presets .button { padding-inline: 8px; font-size: 10px; gap: 5px; }
  .adjustment-presets .icon { width: 14px; height: 14px; }
  .adjustment-panel { padding: 8px 11px; }
  .safety-strip { min-height: 69px; padding: 12px 16px; gap: 9px; }
  .safety-copy { font-size: 10px; gap: 8px; }
  .safety-copy small { font-size: 8px; }
  .button-stop { min-width: 116px; min-height: 40px; padding: 10px 12px; font-size: 12px; }
  .button-stop kbd { display: none; }
  #resume-btn { min-height: 40px; padding-inline: 11px; font-size: 11px; }
  #resume-btn .icon { display: none; }
  .safety-actions:has(#resume-btn:not([hidden])) { flex: 1; justify-content: flex-end; }
  .below-controller { margin: 11px 2px 14px; }
  .keyboard-hint { gap: 10px; font-size: 9px; }
  .keyboard-hint kbd { height: 17px; min-width: 15px; padding: 0 3px; font-size: 8px; }
  .keyboard-hint > span:last-child { display: none; }
  .help-panel { font-size: 10px; }
  .settings-summary { padding: 15px 16px; }
  .settings-summary small { display: none; }
  .settings-content { grid-template-columns: 1fr; }
  .settings-section { padding: 16px; }
  .settings-section + .settings-section { border-left: 0; border-top: 1px solid var(--line-soft); }
  .transport-stats output { font-size: 17px; }
  .frame-value { font-size: 11px; }
  .app-footer { font-size: 8px; }
}

@media (max-width: 370px) {
  .app-shell { padding-inline: 10px; }
  .controller-toolbar, .control-fieldset, .safety-strip { padding-inline: 12px; }
  .brand { gap: 8px; }
  .preview-button { font-size: 10px; }
  .drive-controls { grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr); column-gap: 6px; }
  .function-button strong { font-size: 9px; }
  .session-bar { padding-inline: 11px; }
  .battery-status { min-width: 39px; gap: 3px; padding-inline: 0; }
  .battery-status .icon { width: 16px; }
  .safety-copy small { display: none; }
}

@media (pointer: coarse) {
  .keyboard-hint { visibility: hidden; }
  .adjustment-slider { height: 38px; }
  .adjustment-slider::-webkit-slider-thumb { width: 29px; height: 29px; margin-top: -11.5px; }
  .adjustment-slider::-moz-range-thumb { width: 23px; height: 23px; }
}

@media (orientation: landscape) and (max-height: 570px) and (min-width: 600px) {
  .app-shell { max-width: 1100px; padding: max(9px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .app-header { margin-bottom: 9px; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; }
  .brand-mark svg { width: 26px; height: 26px; }
  .brand-type { display: flex; gap: 10px; }
  .brand-type strong { font-size: 22px; }
  .brand-type > span { font-size: 9px; }
  .header-tools .button { min-height: 31px; font-size: 10px; padding-block: 5px; }
  .header-tools .button-icon { width: 31px; padding: 6px; }
  .session-bar { padding: 7px 13px; margin-bottom: 9px; border-radius: 11px; }
  .device-copy { display: flex; gap: 10px; align-items: center; }
  .device-copy strong { font-size: 11px; }
  #connection-status { font-size: 10px; }
  .mode-badge { font-size: 9px; padding: 2px 6px; }
  .session-actions { gap: 7px; }
  .session-actions .button { min-height: 29px; font-size: 10px; padding: 5px 10px; }
  .session-actions .button-icon { width: 30px; padding: 5px; }
  .session-actions .icon { width: 16px; height: 16px; }
  .battery-status { font-size: 10px; }
  .controller-toolbar { padding: 9px 15px; }
  .controller-heading { display: flex; align-items: baseline; gap: 12px; }
  .section-kicker { font-size: 11px; }
  .controller-heading p { font-size: 9px; margin: 0; }
  .mode-select select { min-height: 29px; font-size: 10px; padding-block: 5px; }
  .page-cycle-button { min-height: 27px; width: 27px; padding: 5px; }
  .control-fieldset { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, .48fr); align-items: start; column-gap: 17px; padding: 11px 15px 10px; }
  .drive-controls { grid-column: 1; grid-row: 1; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); column-gap: 10px; }
  .function-controls { gap: 8px; }
  .function-button { min-height: 65px; padding: 6px 3px; gap: 3px; border-radius: 11px; }
  .function-button > .icon { width: 21px; height: 21px; }
  .function-button strong { font-size: 9px; }
  .function-button small { font-size: 8px; }
  .axis-heading { margin-bottom: 5px; }
  .axis-heading h1, .axis-heading h2 { font-size: 10px; }
  .axis-value { font-size: 15px; }
  .axis-pad { height: 156px; border-radius: 10px; }
  .axis-knob { width: 48px; height: 48px; }
  .pad-center { width: 64px; height: 64px; }
  .pad-center::before, .pad-center::after { display: none; }
  .pad-caption { font-size: 8px; gap: 3px; }
  .pad-caption .icon { width: 10px; height: 10px; }
  .pad-caption-top, .pad-caption-left { top: 8px; left: 8px; }
  .pad-caption-right { top: 8px; right: 8px; }
  .pad-caption-bottom { bottom: 8px; left: 8px; }
  .throttle-pad .pad-ticks { top: 22px; bottom: 22px; left: calc(50% + 26px); }
  .steering-pad .pad-ticks { left: 22px; right: 22px; top: calc(50% + 26px); }
  .axis-help { display: none; }
  .direction-heading { margin-bottom: 6px; }
  .direction-heading h2 { font-size: 10px; }
  .direction-heading > span { display: none; }
  .direction-pair { height: 156px; gap: 8px; }
  .direction-button { border-radius: 9px; font-size: 10px; }
  .direction-button .icon { width: 21px; height: 21px; }
  .adjustments { grid-column: 2; grid-row: 1; margin: 0; padding: 0 0 0 16px; border-top: 0; border-left: 1px solid var(--line-soft); }
  .adjustments-header { margin-bottom: 8px; }
  .adjustments-header h2 { font-size: 10px; }
  .adjustments-header > span { font-size: 8px; }
  .adjustment-selectors { gap: 5px; }
  .adjustment-selector { min-height: 76px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 7px; }
  .adjustment-selector > .icon { width: 15px; height: 15px; }
  .adjustment-current { position: absolute; top: 7px; right: 7px; font-size: 13px; }
  .adjustment-name { white-space: normal; font-size: 9px; }
  .adjustment-name small { display: none; }
  .adjustment-presets { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 7px 0 0; }
  .adjustment-presets .button { min-height: 25px; padding-block: 4px; font-size: 9px; }
  .adjustment-presets .button .icon { width: 12px; height: 12px; }
  .adjustment-panel { padding: 6px 9px; margin-top: 6px; border-radius: 8px; }
  .adjustment-panel-heading { margin-bottom: 0; gap: 5px; }
  .adjustment-panel-heading label { font-size: 9px; }
  .adjustment-panel-heading output { font-size: 14px; }
  .adjustment-panel-heading .button { min-height: 21px; width: 21px; padding: 3px; }
  .adjustment-slider { height: 28px; }
  .adjustment-hint { font-size: 8px; margin-top: 3px; }
  .range-labels { font-size: 8px; }
  .safety-strip { min-height: 48px; padding: 8px 15px; }
  .safety-copy { font-size: 9px; }
  .safety-copy > span:last-child { display: flex; align-items: baseline; gap: 9px; }
  .safety-copy small { font-size: 8px; }
  .safety-actions .button { min-height: 30px; font-size: 10px; padding: 6px 12px; }
  .button-stop { min-width: 125px; }
  .button-stop kbd { display: none; }
  .below-controller { margin: 8px 3px; }
  .keyboard-hint { font-size: 8px; }
  .help-panel { font-size: 9px; }
  .settings-summary { padding: 10px 14px; }
  .settings-summary strong { font-size: 10px; }
  .settings-summary small { font-size: 9px; }
  .app-footer { padding-top: 10px; font-size: 8px; }
}

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

@media (orientation: landscape) and (max-height: 430px) and (min-width: 600px) {
  .app-shell { padding-top: max(6px, env(safe-area-inset-top)); }
  .app-header { margin-bottom: 6px; }
  .brand-mark { width: 28px; height: 28px; }
  .header-tools .button { min-height: 28px; }
  .header-tools .button-icon { width: 28px; }
  .session-bar { padding-block: 4px; margin-bottom: 6px; }
  .controller-toolbar { padding-block: 7px; }
  .axis-pad, .direction-pair { height: clamp(116px, calc(100dvh - 236px), 156px); }
  .adjustments-header { margin-bottom: 5px; }
  .adjustment-selector { min-height: 51px; padding: 6px; gap: 3px; }
  .adjustment-selector > .icon { width: 13px; height: 13px; }
  .adjustment-current { top: 5px; right: 6px; font-size: 13px; }
  .adjustment-name { font-size: 8px; }
  .adjustment-presets { grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 5px; }
  .adjustment-presets .button { padding-inline: 4px; font-size: 8px; gap: 4px; }
  .adjustment-presets .button .icon { width: 11px; height: 11px; }
  .adjustment-panel { padding: 4px 7px; margin-top: 5px; }
  .adjustment-panel-heading { line-height: 1; }
  .adjustment-slider { height: 25px; }
  .adjustment-hint { display: none; }
  .range-labels { line-height: 1.2; }
  .safety-strip { min-height: 42px; padding-block: 6px; }
}
