* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  background: #111;
  color: #eee;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 16px;
  padding: 16px;
  height: 100vh;
}

.panel {
  background: #1b1b1b;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
}

.center-panel {
  align-items: center;
}

.current-input {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.current-input .label {
  font-size: 11px;
  color: #aaa;
}

.current-input .value {
  margin-top: 4px;
  font-size: 28px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  background: #222;
  min-width: 60px;
  text-align: center;
}

.devices {
  font-size: 12px;
  background: #151515;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 12px;
}

.devices ul {
  list-style: none;
  padding-left: 16px;
  margin: 4px 0 0;
  font-size: 11px;
}

/* toggle ฝั่ง */
.side-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 12px;
}

.side-btn {
  background: #333;
  border: none;
  color: #eee;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  cursor: pointer;
}

.side-btn.active {
  background: #059669;
  color: #ecfdf5;
}

.legend {
  font-size: 12px;
  margin-top: auto;
}

.legend ul {
  padding-left: 16px;
}

#dummy-canvas {
  background: #000;
  border-radius: 12px;
  border: 1px solid #333;
}

.status-text {
  margin-top: 8px;
  font-size: 14px;
  text-align: center;
  color: #ccc;
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.history-controls button {
  background: #333;
  border: none;
  color: #eee;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.history-controls button:hover {
  background: #444;
}

.history-controls .hint {
  font-size: 11px;
  color: #777;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid #333;
}

.history-list li {
  padding: 4px 0;
  border-bottom: 1px solid #222;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-list .tag {
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
}

.tag-wgf {
  background: #1e3a8a;
  color: #bfdbfe;
}

.tag-ewgf {
  background: #991b1b;
  color: #fecaca;
}

/* สี direction */
.value.direction-f {
  background: #1e3a5f;
}

.value.direction-d {
  background: #3b1f5f;
}

.value.direction-df {
  background: #5f1e1e;
}

.value.direction-n {
  background: #222;
}

/* Mobile */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}
