* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f4f4f4;
  color: #1f1f1f;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

h1 {
  font-size: 24px;
  margin: 0;
}

.controls-main {
  display: flex;
  gap: 10px;
}

.btn {
  min-width: 120px;
  min-height: 52px;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  color: white;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.22);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.22);
}

.icon {
  font-size: 22px;
  line-height: 1;
}

.btn-start { background: #16843a; }
.btn-start:hover { background: #126d30; }

.btn-stop { background: #bd2525; }
.btn-stop:hover { background: #9f1d1d; }

.btn-reset { background: #d16018; }
.btn-reset:hover { background: #b24f11; }

.layout {
  display: grid;
  grid-template-columns: minmax(500px, 1fr) 360px;
  gap: 14px;
}

.viewer,
.panel {
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  padding: 12px;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #ffffff;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.label {
  font-weight: 700;
}

textarea {
  width: 100%;
  font-family: Consolas, monospace;
}

.small-actions {
  display: flex;
  gap: 8px;
}

.btn-light,
.btn-jog {
  border: 1px solid #a8a8a8;
  background: #eeeeee;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
}

.btn-light:hover,
.btn-jog:hover {
  background: #e0e0e0;
}

.small-actions button {
  flex: 1;
}

details {
  border: 1px solid #d5d5d5;
  border-radius: 8px;
  padding: 10px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.grid,
.jog {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.span2 {
  grid-column: 1 / -1;
}

input[type="number"] {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid #c8c8c8;
  border-radius: 6px;
}

input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.dro {
  font-family: Consolas, monospace;
  background: #111;
  color: #e8e8e8;
  border-radius: 8px;
  padding: 10px;
  white-space: pre-line;
  line-height: 1.35;
}

.status {
  min-height: 38px;
  padding: 9px;
  background: #f7f7f7;
  border-radius: 8px;
  border: 1px solid #d5d5d5;
}

@media (max-width: 1000px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls-main {
    width: 100%;
  }

  .btn {
    min-width: 0;
    flex: 1;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    order: -1;
  }
}

@media (max-width: 560px) {
  .controls-main {
    flex-direction: column;
  }
}


.code-wrap {
  position: relative;
  width: 100%;
  height: 330px;
  border: 1px solid #c9c9c9;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

#gcodeHighlight,
#gcode {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 10px;
  border: 0;
  font-family: Consolas, monospace;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  tab-size: 4;
}

#gcodeHighlight {
  pointer-events: none;
  color: transparent;
  z-index: 1;
}

#gcode {
  z-index: 2;
  resize: none;
  background: transparent;
  color: #111;
  outline: none;
}

.active-code-line {
  display: block;
  background: rgba(50, 255, 50, 0.32);
  border-radius: 4px;
  box-shadow: inset 3px 0 rgba(25, 210, 25, 0.75);
}
