* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #080b10;
  color: #dfe6ee;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  background: #0e141b;
  border-bottom: 1px solid #2a3947;
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
  color: #65f4d1;
}
.brand .subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: #8b98a7;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  background: #14202b;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: #65f4d1; color: #65f4d1; }
button:disabled { opacity: 0.45; cursor: default; }
#btn-rebuild { border-color: #65f4d1; }
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}
.sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: #0e141b;
  border-right: 1px solid #2a3947;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sidebar section {
  border: 1px solid #2a3947;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar h2 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #65f4d1;
}
.sidebar section.collapsible > h2 { cursor: pointer; user-select: none; }
.sidebar section.collapsible > h2::after { content: ' ▾'; color: #8b98a7; }
.sidebar section.collapsible.collapsed > h2::after { content: ' ▸'; }
.sidebar section.collapsible.collapsed > :not(h2) { display: none; }
.sidebar label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #dfe6ee;
}
.sidebar label.check { justify-content: flex-start; }
.sidebar input[type="number"], .sidebar select {
  width: 120px;
  background: #080b10;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 5px;
  padding: 5px 7px;
  font: inherit;
  font-size: 13px;
}
.sidebar input[type="checkbox"] { accent-color: #65f4d1; width: 16px; height: 16px; }
.sidebar input[type="range"] { width: 120px; accent-color: #65f4d1; }
#status {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #2a3947;
  border-radius: 8px;
  font-size: 13px;
  color: #8b98a7;
  min-height: 38px;
  white-space: pre-wrap;
}
.viewport-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 60vh;
}
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }
#hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(14, 20, 27, 0.88);
  border: 1px solid #2a3947;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #8b98a7;
  pointer-events: none;
  max-width: calc(100% - 24px);
}
#hud b { color: #65f4d1; font-weight: 600; }
#viewbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60%;
}
#viewbar button {
  background: rgba(14, 20, 27, 0.88);
  padding: 6px 9px;
  font-size: 12px;
}
#viewbar button.on { border-color: #65f4d1; color: #65f4d1; }
#viewbar-tools {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 40%;
}
#viewbar-tools button {
  background: rgba(14, 20, 27, 0.88);
  padding: 6px 9px;
  font-size: 12px;
}
#viewbar-tools button.on { border-color: #65f4d1; color: #65f4d1; }
#custom-holes { display: flex; flex-direction: column; gap: 8px; }
#custom-labels { display: flex; flex-direction: column; gap: 8px; }
.hole-row {
  border: 1px solid #2a3947;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hole-row .r1 { display: flex; gap: 6px; }
.hole-row .r1 select {
  flex: 1;
  min-width: 0;
  background: #080b10;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 5px;
  padding: 5px 7px;
  font: inherit;
  font-size: 13px;
}
.hole-row .custom-del {
  flex: 0 0 28px;
  padding: 5px 0;
  text-align: center;
}
.hole-row .lab-del {
  flex: 0 0 28px;
  padding: 5px 0;
  text-align: center;
}
.hole-row .r1 input[type="text"] {
  flex: 2;
  min-width: 0;
  background: #080b10;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 5px;
  padding: 5px 7px;
  font: inherit;
  font-size: 13px;
}
.hole-row .r2 { display: flex; gap: 6px; }
.hole-row .r3 { display: flex; gap: 6px; }
.hole-row .r3 input {
  flex: 1;
  min-width: 0;
  background: #080b10;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 5px;
  padding: 5px 6px;
  font: inherit;
  font-size: 13px;
}
.hole-row .r2 label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #8b98a7;
}
.hole-row .r2 input {
  width: 100%;
  background: #080b10;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 5px;
  padding: 5px 6px;
  font: inherit;
  font-size: 13px;
}
.hint { font-size: 11px; line-height: 1.45; color: #8b98a7; margin: 4px 0 0; }
#alerts {
  background: #2a1215;
  border-bottom: 1px solid #ff5d5d;
  color: #ffb3b3;
  font-size: 13px;
  padding: 8px 16px;
  white-space: pre-wrap;
}
#alerts[hidden] { display: none; }
.preset-row { display: flex; gap: 8px; }
.preset-row button { flex: 1; }
.upload-btn {
  flex: 1;
  background: #14202b;
  color: #dfe6ee;
  border: 1px solid #2a3947;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
}
.upload-btn:hover { border-color: #65f4d1; color: #65f4d1; }
