* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #5d6972;
  --line: #c7d0d6;
  --panel: #f8fafb;
  --panel-strong: #ffffff;
  --accent: #1f7a8c;
  --accent-dark: #14566a;
  --rail: #dde5e9;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #eef2f4;
}

.workbench {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(360px, 1fr) 300px;
  grid-template-rows: auto minmax(280px, 1fr) minmax(230px, 34vh);
  gap: 1px;
  background: var(--line);
}

.command-bar,
.object-tree,
.viewport,
.pendant,
.editor,
.bottom-panel {
  background: var(--panel);
}

.command-bar {
  grid-column: 1 / 4;
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) repeat(7, auto) minmax(260px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-width: 0;
}

.station-title {
  display: grid;
  gap: 2px;
  min-width: 150px;
}

.station-title span,
.program-picker span,
.frame-control span {
  color: var(--muted);
  font-size: 12px;
}

.program-picker,
.frame-control {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.program-picker select,
.frame-control input {
  width: 100%;
  min-width: 0;
}

button,
select {
  min-height: 32px;
  border: 1px solid #9aa8b2;
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 4px;
  font: inherit;
}

button {
  padding: 0 10px;
  white-space: nowrap;
}

button:hover,
select:hover {
  border-color: var(--accent);
}

button[aria-pressed="true"] {
  background: var(--accent-dark);
  color: #ffffff;
  border-color: var(--accent-dark);
}

output {
  color: var(--muted);
  font-size: 12px;
}

.object-tree {
  padding: 12px;
  overflow: auto;
}

.object-tree h2,
.pendant h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.object-tree ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.75;
}

.object-tree li {
  overflow-wrap: anywhere;
}

.viewport {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  background: linear-gradient(#f8fafb, #dfe7eb);
}

.viewport svg {
  position: absolute;
  inset: auto 24px 24px 24px;
  height: 45%;
  width: calc(100% - 48px);
}

.viewport circle {
  fill: var(--accent-dark);
}

[data-path-current] {
  fill: #b8542f;
  stroke: #ffffff;
  stroke-width: 3;
}

.robot-arm {
  position: absolute;
  left: 12%;
  top: 18%;
  width: 62%;
  height: 48%;
}

.joint {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #334e68;
}

.link {
  position: absolute;
  height: 8px;
  border-radius: 4px;
  background: #627d98;
  transform-origin: left center;
}

.j1 { left: 20px; top: 150px; }
.l1 { left: 35px; top: 155px; width: 115px; transform: rotate(-45deg); }
.j2 { left: 122px; top: 72px; }
.l2 { left: 137px; top: 78px; width: 120px; transform: rotate(20deg); }
.j3 { left: 250px; top: 115px; }
.l3 { left: 265px; top: 120px; width: 95px; transform: rotate(-15deg); }
.j4 { left: 356px; top: 92px; }

.pendant {
  padding: 12px;
  overflow: auto;
}

.pendant dl {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  margin: 0;
}

.pendant dt {
  font-weight: 700;
}

.pendant dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.editor {
  grid-column: 1 / 3;
  padding: 12px;
  overflow: auto;
}

.editor nav {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.editor pre {
  margin: 0;
  padding: 12px;
  min-height: 150px;
  background: #202a33;
  color: #f8fafb;
  overflow: auto;
  line-height: 1.45;
  border-radius: 4px;
}

.bottom-panel {
  grid-column: 1 / 4;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(9, minmax(100px, 1fr));
  gap: 8px;
  overflow: auto;
}

.bottom-panel > div {
  border: 1px solid var(--line);
  padding: 8px;
  background: var(--panel-strong);
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}

.bottom-panel span {
  overflow-wrap: anywhere;
}

.bottom-panel progress {
  width: 100%;
  height: 8px;
}

.steps-panel,
.trajectory-panel {
  grid-column: 1 / -1;
  min-height: 150px;
}

.steps-table-wrap,
.trajectory-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  max-height: 260px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid #e1e7eb;
  border-right: 1px solid #e1e7eb;
  padding: 6px 7px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--rail);
}

tr[aria-current="true"] td {
  background: #e6f2f4;
  color: #0f4d5d;
  font-weight: 700;
}

tr[data-step-state="active"] td {
  background: #fff2cc;
  color: #6f4b00;
  font-weight: 700;
}

tr[data-step-state="complete"] td {
  background: #f4f7f8;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .command-bar {
    grid-template-columns: auto minmax(200px, 1fr) repeat(7, auto);
  }

  .frame-control {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .command-bar,
  .editor,
  .bottom-panel {
    grid-column: auto;
  }

  .command-bar {
    grid-template-columns: 1fr 1fr;
  }

  .station-title,
  .program-picker,
  .frame-control {
    grid-column: 1 / -1;
  }

  .bottom-panel {
    grid-template-columns: 1fr 1fr;
  }

  .viewport {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .command-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .command-bar button {
    padding: 0 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .station-title,
  .program-picker,
  .frame-control {
    grid-column: 1 / -1;
  }

  .bottom-panel {
    grid-template-columns: 1fr;
  }

  .robot-arm {
    left: 4%;
    width: 80%;
    transform: scale(0.85);
    transform-origin: left top;
  }
}
