:root {
  --bg: #241f1b;
  --panel: #312b26;
  --panel-2: #3a342e;
  --ink: #f3ece3;
  --muted: #b3a79b;
  --line: #5a5148;
  --accent: #e07a3d;
  --accent-ink: #2a140c;
  --paper: #f6f1e6;
  --danger: #e07a72;
  --ok: #7dcea0;
  color-scheme: dark;
  font-family: "Liberation Sans", "Source Sans 3", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
select,
input,
textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: #8a7d70;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

textarea {
  width: 100%;
  resize: vertical;
}

header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.8rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
}

.plot-actions {
  display: flex;
  gap: 0.4rem;
  justify-self: center;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 11rem;
}

.brand span,
.hint,
.mono {
  color: var(--muted);
}

.brand a {
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
}

.machine-name {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  margin: 0.15rem 0;
  padding: 0.1rem 0.15rem;
  background: transparent;
  border: none;
  color: var(--ink);
  font-weight: 650;
}

.machine-name:hover {
  color: var(--accent);
}

.connect-modal {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.15rem;
  width: min(28rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.connect-modal::backdrop {
  background: rgba(18, 14, 11, 0.72);
}

.connect-modal h2 {
  margin: 0 0 0.6rem;
}

.hint {
  font-size: 0.82rem;
  line-height: 1.35;
  margin: 0.35rem 0;
}

.header-actions {
  justify-self: end;
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.toast {
  margin: 0;
  padding: 0.35rem 0.7rem;
  background: #4a3424;
  border-radius: 999px;
  color: #f6d7bf;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr) minmax(250px, 310px);
}

.panel {
  overflow: auto;
  padding: 0.8rem 0.9rem 1.4rem;
  background: var(--panel);
}

.panel.left {
  border-right: 1px solid var(--line);
}

.panel.right {
  border-left: 1px solid var(--line);
}

section {
  margin-bottom: 1.1rem;
}

h2 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 0.4rem;
}

.row.wrap {
  flex-wrap: wrap;
}

.row>button,
.row>.primary {
  flex: 1;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0;
}

.field input,
.field select,
.field textarea {
  color: var(--ink);
}

.check {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin: 0.3rem 0;
  font-size: 0.92rem;
}

.check.pulse {
  border-radius: 0.35rem;
  animation: soft-pulse 1.8s ease-in-out infinite;
}

@keyframes soft-pulse {
  0%, 100% { background: transparent; }
  50% { background: rgba(215, 38, 61, 0.16); }
}

.modes {
  display: flex;
  gap: 1rem;
  margin-top: 0.3rem;
}

#layers {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  max-height: 180px;
  overflow: auto;
}

#layers button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

#layers button.active {
  background: #4a3428;
}

#layers .tag {
  color: var(--muted);
  font-size: 0.75rem;
}

main {
  position: relative;
  min-width: 0;
  background: #1a1613;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
}

.lamp {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: #6d645c;
  display: inline-block;
}

.lamp.on {
  background: var(--ok);
}

.lamp.busy {
  background: var(--accent);
}

.lamp.bad {
  background: var(--danger);
}

.error {
  color: var(--danger);
  margin: 0.3rem 0;
  white-space: pre-wrap;
}

.mono {
  font-family: "Liberation Mono", ui-monospace, monospace;
}

.jog {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  margin: 0.4rem 0 0.6rem;
}

.jog-mid {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.jog button {
  width: 2.4rem;
  height: 2.2rem;
}

.progress {
  height: 6px;
  background: #1a1613;
  border-radius: 99px;
  overflow: hidden;
  margin: 0.4rem 0;
}

#bar {
  height: 100%;
  width: 0;
  background: var(--accent);
}

#gray-props[hidden],
#text-props[hidden] {
  display: none;
}

@media (max-width: 860px) {
  header {
    grid-template-columns: 1fr auto;
  }

  .plot-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .layout {
    display: flex;
    flex-direction: column;
    height: auto;
    flex: none;
  }

  .panel {
    overflow: visible;
  }

  main {
    height: 70vh;
    flex: none;
  }
}