:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fbfb;
  --line: #dfe6ea;
  --line-strong: #cfd9de;
  --text: #202733;
  --muted: #687481;
  --teal: #12a79a;
  --teal-dark: #0a8478;
  --green: #20b05b;
  --blue: #2d6cdf;
  --amber: #e38d15;
  --red: #de3d3d;
  --shadow: 0 12px 32px rgba(39, 55, 71, 0.08);
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

svg {
  display: block;
}

svg use {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon-sprite symbol * {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.console-shell {
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  grid-template-rows: 68px minmax(0, 1fr) 72px;
  min-height: 100vh;
  border: 1px solid #d4dde2;
  background: var(--surface);
}

.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand-area,
.header-tools,
.card-title,
.buzzer-actions,
.detect-actions,
.log-title,
.status-footer,
.token-box {
  display: flex;
  align-items: center;
}

.brand-area {
  gap: 16px;
  min-width: 0;
}

.brand-area strong {
  font-size: 20px;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-icon,
.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-icon {
  width: 42px;
  height: 42px;
  color: #27313d;
}

.brand-icon svg {
  width: 34px;
  height: 34px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4b5967;
  cursor: pointer;
}

.icon-button:hover {
  background: #eef4f6;
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.header-tools {
  justify-content: flex-end;
  gap: 16px;
  min-width: 0;
}

.device-name {
  max-width: 300px;
  overflow: hidden;
  color: #505b68;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid #bce8d2;
  border-radius: 8px;
  background: #edfff6;
  color: #13834c;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.waiting {
  border-color: #f2ddb6;
  background: #fff8ea;
  color: #9b6414;
}

.status-sidebar {
  display: flex;
  flex-direction: column;
  grid-row: 2;
  gap: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, #ffffff 0%, #fbfcfd 100%);
}

.status-backdrop {
  display: none;
}

.status-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 92px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.status-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.status-card strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #26313d;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-card small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-card.metric strong {
  color: var(--teal);
}

.status-card.metric b {
  font-size: 30px;
  font-weight: 800;
}

.status-card em {
  color: #607080;
  font-size: 15px;
  font-style: normal;
  font-weight: 500;
}

.status-card .accent {
  color: var(--teal-dark);
}

.status-card .warning {
  color: var(--amber);
}

.status-icon {
  width: 30px;
  height: 30px;
  color: #323d49;
}

.status-icon.teal {
  color: var(--teal);
}

.status-icon.green {
  color: var(--green);
}

.status-icon.blue {
  color: var(--blue);
}

.status-icon.amber {
  color: var(--amber);
}

.status-icon.dark {
  color: #34404c;
}

.control-area {
  display: grid;
  grid-template-columns: minmax(540px, 1fr) 476px;
  gap: 14px;
  grid-row: 2;
  min-width: 0;
  padding: 16px;
  background: var(--bg);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.vehicle-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 26px 24px 30px;
}

.drive-pad {
  display: grid;
  grid-template-columns: repeat(3, 132px);
  grid-template-rows: repeat(3, 104px);
  gap: 16px 22px;
  justify-content: center;
  padding: 26px 0 16px;
}

.drive-button,
.stop-button {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.drive-button {
  color: var(--teal);
  font-size: 66px;
  font-weight: 400;
  line-height: 1;
}

.drive-button:hover,
.stop-button:hover,
.mini-button:hover,
.primary-button:hover,
.clear-button:hover,
.switch-button:hover,
.mode-tabs button:hover {
  border-color: #88cfc6;
  box-shadow: 0 9px 22px rgba(23, 112, 101, 0.12);
  transform: translateY(-1px);
}

.drive-button:active,
.stop-button:active,
.mini-button:active,
.primary-button:active,
.clear-button:active,
.switch-button:active,
.mode-tabs button:active {
  transform: translateY(0);
}

.drive-button.up {
  grid-column: 2;
  grid-row: 1;
}

.drive-button.left {
  grid-column: 1;
  grid-row: 2;
}

.stop-button {
  grid-column: 2;
  grid-row: 2;
  color: var(--red);
  font-size: 28px;
  font-weight: 800;
}

.stop-button::before {
  content: "";
  position: absolute;
}

.drive-button.right {
  grid-column: 3;
  grid-row: 2;
}

.drive-button.down {
  grid-column: 2;
  grid-row: 3;
}

.press-mode-row {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}

.press-mode-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.press-mode-toggle button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: #fff;
  color: #52606d;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.press-mode-toggle button:last-child {
  border-right: 0;
}

.press-mode-toggle button:hover {
  background: #f3f8f9;
}

.press-mode-toggle button.selected {
  box-shadow: inset 0 0 0 1px var(--teal);
  background: #effcfa;
  color: var(--teal-dark);
}

.press-mode-toggle button[data-press-mode="hold"].selected {
  box-shadow: inset 0 0 0 1px #ff5962;
  background: #fff3f4;
  color: var(--red);
}

.speed-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 84px;
  padding: 24px 4px 20px;
  border-bottom: 1px solid var(--line);
}

.speed-row label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  color: #515f6d;
}

.speed-row span {
  font-size: 15px;
}

.speed-row output {
  min-width: 42px;
  text-align: center;
  font-size: 18px;
  line-height: 1;
}

.speed-row input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--teal);
}

.speed-row small {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  color: #6b7681;
  font-size: 13px;
}

.speed-row small b {
  font-weight: 500;
}

.speed-row small b:nth-child(2) {
  text-align: center;
}

.speed-row small b:nth-child(3) {
  text-align: right;
}

.mode-block {
  display: grid;
  gap: 12px;
  padding-top: 22px;
}

.mode-block > span {
  color: #515f6d;
  font-size: 16px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.mode-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: #fff;
  color: #44515f;
  cursor: pointer;
}

.mode-tabs button:last-child {
  border-right: 0;
}

.mode-tabs button.selected {
  box-shadow: inset 0 0 0 1px var(--teal);
  color: var(--teal-dark);
  font-weight: 750;
}

.mode-tabs svg {
  width: 22px;
  height: 22px;
}

.path-icon {
  display: inline-block;
  width: 26px;
  height: 22px;
  border-right: 3px dotted #66727e;
  border-radius: 50%;
  transform: rotate(18deg);
}

.right-stack {
  display: grid;
  grid-template-rows: 72px 210px 72px minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.compact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  padding: 20px;
}

.card-title {
  gap: 14px;
  min-width: 0;
}

.card-title svg {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.card-title h2 {
  white-space: nowrap;
}

.buzzer-actions {
  gap: 10px;
  flex: 0 0 auto;
}

.buzzer-actions strong {
  min-width: 48px;
  color: var(--teal-dark);
  font-size: 14px;
  white-space: nowrap;
}

.mini-button,
.primary-button,
.clear-button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.mini-button {
  min-height: 34px;
  padding: 0 12px;
  color: #4f5c68;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.mini-button.active {
  border-color: #94d4cd;
  background: #effcfa;
  color: var(--teal-dark);
}

.switch-button {
  position: relative;
  width: 54px;
  height: 30px;
  border: 1px solid #d7e2e5;
  border-radius: 999px;
  background: var(--teal);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.switch-button span {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(30, 44, 58, 0.22);
  transition: left 0.14s ease, right 0.14s ease;
}

.switch-button.off {
  background: #c4cdd4;
}

.switch-button.off span {
  right: 27px;
}

.switch-button.on {
  background: var(--teal);
}

.temp-card {
  display: grid;
  align-items: start;
  justify-content: normal;
  gap: 16px;
}

.temp-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.temp-inputs label {
  display: grid;
  gap: 8px;
}

.temp-inputs span {
  color: #66727e;
  font-size: 14px;
}

.temp-inputs input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #293441;
}

.primary-button {
  justify-self: end;
  min-height: 38px;
  padding: 0 18px;
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 750;
}

.detect-actions {
  gap: 14px;
}

.detect-actions strong {
  min-width: 48px;
  color: var(--teal-dark);
  font-size: 14px;
  white-space: nowrap;
}

.log-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 16px;
}

.log-title {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.clear-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  color: #596673;
  font-size: 13px;
}

.clear-button svg {
  width: 17px;
  height: 17px;
}

.log-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.log-list:empty::before {
  content: "暂无命令日志";
  display: grid;
  place-items: center;
  min-height: 160px;
  color: #7a8591;
  border: 1px dashed #cfd9de;
  border-radius: 8px;
  background: #fbfcfd;
}

.log-item {
  display: grid;
  grid-template-columns: 102px minmax(0, 1fr) 10px;
  gap: 10px;
  align-items: center;
  min-height: 33px;
  padding: 6px 10px;
  border: 1px solid #edf1f3;
  border-radius: 6px;
  background: #fbfcfd;
  color: #374250;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 13px;
}

.log-item span {
  color: #5d6975;
}

.log-item strong {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-item::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #12b84f;
}

.log-item.error::after {
  background: var(--red);
}

.log-item.system::after {
  background: var(--amber);
}

.log-item.rx::after {
  background: var(--blue);
}

.status-footer {
  grid-column: 1 / -1;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  background: #ffffff;
  color: #4d5b68;
  font-size: 14px;
}

.status-footer > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.status-footer > span i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
}

.token-box {
  gap: 8px;
  min-width: 270px;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.token-box svg {
  width: 18px;
  height: 18px;
  color: #65717d;
  flex: 0 0 auto;
}

.token-box input {
  width: 128px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 10px;
}

.token-box button {
  min-width: 52px;
  height: 34px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: #effcfa;
  color: var(--teal-dark);
  font-weight: 750;
  cursor: pointer;
}

.token-box.required input {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(227, 141, 21, 0.15);
}

@media (max-width: 1180px) {
  .console-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .control-area {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .right-stack {
    grid-template-rows: auto auto auto 360px;
  }

  .status-footer {
    flex-wrap: wrap;
    justify-content: flex-start;
    min-height: 72px;
    padding-block: 10px;
  }
}

@media (max-width: 820px) {
  .console-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 64px minmax(0, 1fr) auto;
    min-height: 100svh;
    border: 0;
  }

  .app-header {
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: 64px;
    padding: 0 14px;
  }

  .brand-area {
    gap: 10px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-icon svg {
    width: 28px;
    height: 28px;
  }

  .brand-area strong {
    max-width: calc(100vw - 220px);
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
  }

  .header-tools {
    gap: 8px;
  }

  .device-name {
    display: none;
  }

  .header-tools .icon-button {
    display: none;
  }

  .status-pill {
    min-height: 26px;
    padding: 0 9px;
    font-size: 12px;
  }

  .status-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 36;
    display: flex;
    max-height: calc(100svh - 64px);
    overflow-y: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 24px 44px rgba(24, 38, 52, 0.18);
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(-100% - 14px));
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .status-backdrop {
    position: fixed;
    inset: 64px 0 0;
    z-index: 35;
    display: block;
    background: rgba(26, 39, 52, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  body.status-panel-open {
    overflow: hidden;
  }

  body.status-panel-open .status-sidebar {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  body.status-panel-open .status-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .status-card {
    min-height: 92px;
    padding: 15px 22px;
  }

  .control-area {
    grid-row: 2;
    padding: 12px;
    overflow: visible;
  }

  .drive-pad {
    grid-template-columns: repeat(3, minmax(86px, 112px));
    grid-template-rows: repeat(3, 86px);
    gap: 12px;
  }

  .press-mode-row {
    justify-content: stretch;
  }

  .press-mode-toggle {
    width: 100%;
  }

  .drive-button {
    font-size: 52px;
  }

  .speed-row,
  .temp-inputs {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .status-footer {
    grid-row: 3;
  }
}

@media (max-width: 560px) {
  .app-header {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    min-height: 60px;
    padding: 0 10px;
  }

  .brand-area {
    flex: 1 1 auto;
    gap: 8px;
  }

  .brand-icon {
    display: none;
  }

  .brand-area strong {
    max-width: calc(100vw - 156px);
    font-size: 15px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .status-sidebar {
    top: 60px;
    max-height: calc(100svh - 60px);
  }

  .status-backdrop {
    inset: 60px 0 0;
  }

  .status-card {
    grid-template-columns: 40px minmax(0, 1fr);
    min-height: 90px;
    padding: 16px 20px;
  }

  .status-card.metric b {
    font-size: 28px;
  }

  .control-area {
    gap: 12px;
    padding: 10px;
  }

  .vehicle-panel,
  .compact-card,
  .log-card {
    padding: 16px;
  }

  .drive-pad {
    grid-template-columns: repeat(3, minmax(66px, 1fr));
    grid-template-rows: repeat(3, minmax(72px, 21vw));
    gap: 10px;
    padding: 16px 0 12px;
  }

  .press-mode-row {
    padding-bottom: 12px;
  }

  .press-mode-toggle {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .press-mode-toggle button {
    min-height: 42px;
    font-size: 14px;
  }

  .drive-button {
    font-size: 42px;
  }

  .stop-button {
    font-size: 22px;
  }

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

  .mode-tabs button {
    gap: 6px;
    min-height: 48px;
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
    font-size: 13px;
  }

  .mode-tabs button:nth-child(2n) {
    border-right: 0;
  }

  .mode-tabs button:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .mode-tabs button:last-child {
    border-right: 0;
  }

  .mode-tabs svg {
    width: 18px;
    height: 18px;
  }

  .path-icon {
    width: 18px;
    height: 18px;
  }

  .compact-card {
    align-items: stretch;
    flex-direction: column;
  }

  .right-stack {
    grid-template-rows: auto auto auto 360px;
  }

  .buzzer-actions,
  .detect-actions {
    justify-content: space-between;
  }

  .status-footer {
    gap: 10px;
  }

  .token-box {
    width: 100%;
    min-width: 0;
    border-left: 0;
    padding-left: 0;
  }

  .token-box input {
    flex: 1;
    width: auto;
  }
}
