:root {
  --bg: #101614;
  --panel: #18211e;
  --panel-2: #202a26;
  --ink: #e8eee9;
  --muted: #8ea099;
  --line: #2d3b36;
  --amber: #e6a23c;
  --amber-dim: #3a2e1c;
  --danger: #d4655d;
  --ok: #3dba8b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 "Segoe UI", "Helvetica Neue", sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}

button:hover { border-color: #4d645c; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

button.primary {
  background: var(--amber);
  color: #1c1408;
  border-color: #f0c27a;
  font-weight: 650;
}

button:disabled {
  opacity: 0.38;
  cursor: default;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 132px;
}

.brand strong { display: block; font-size: 16px; letter-spacing: 0.02em; }
.brand small { color: var(--muted); }

.mark {
  width: 22px;
  height: 22px;
  border: 3px solid var(--amber);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--panel), inset 0 0 0 6px #6d5a48;
}

.name { display: flex; flex-direction: column; gap: 2px; width: 220px; flex: 0 1 220px; }
.name span, .field span, .slider-row span { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.name input, .field input, .field select {
  background: #101614;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  width: 100%;
}

.mode { display: flex; background: #101614; border-radius: 9px; padding: 3px; border: 1px solid var(--line); }
.mode button { border: 0; background: transparent; border-radius: 7px; }
.mode button.active { background: var(--amber-dim); color: var(--amber); }

.top-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 300px;
}

.tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.tools button {
  text-align: left;
  padding: 8px;
  background: transparent;
}

.tools button.active {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: #6a5228;
}

.stage { min-width: 0; min-height: 0; position: relative; }
#map { width: 100%; height: 100%; display: block; cursor: crosshair; }

.props {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  padding: 12px;
}

.props h2 { margin: 0 0 8px; font-size: 15px; }
.props h3 { margin: 16px 0 8px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.props p.note { color: var(--muted); margin: 0 0 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; }
.slider-row input[type="range"] { width: 100%; }
.danger { color: #ffd0cc; border-color: #6a3532; }

.status {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #0d1311;
  font-size: 12px;
}

.status-right { display: flex; align-items: center; gap: 10px; }
#gridBtn { padding: 2px 8px; }
#gridBtn[aria-pressed="true"] { color: var(--amber); border-color: #6a5228; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 10, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.modal[hidden] { display: none; }
.sheet {
  width: min(420px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet h2 { margin: 0; }
.sheet p { margin: 0; color: var(--muted); }
.sheet .row button { padding: 10px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 78px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 220px; }
  .props { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
