:root {
  color-scheme: light;
  --page: #f4f1ea;
  --ink: #202020;
  --muted: #67635a;
  --panel: #fffdf8;
  --line: #d6d0c3;
  --accent: #0b7a75;
  --accent-strong: #075d5a;
  --warm: #f0b02f;
  --danger: #d8482f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fbfaf6;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: #aca28d;
  background: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: #fffaf0;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 720;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.primary-button {
  min-width: 112px;
  border-color: var(--accent-strong);
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  min-width: 104px;
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(680px, 1fr) 280px;
  height: calc(100vh - 76px);
}

.panel {
  overflow: auto;
  padding: 14px;
  background: var(--panel);
}

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

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

.control-section {
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--line);
}

.control-section:first-child {
  padding-top: 0;
}

.control-section h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 760;
  text-transform: uppercase;
  color: #4a463e;
  letter-spacing: 0.04em;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

label {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="number"],
input[type="text"],
input[type="color"],
select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--ink);
  background: #fff;
}

input[type="color"] {
  padding: 2px;
}

.toggle-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.object-list {
  display: grid;
  gap: 7px;
  max-height: 210px;
  overflow: auto;
}

.object-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
  text-align: left;
}

.object-list button.active {
  border-color: var(--accent);
  background: #e8f4f2;
}

.object-type-pill {
  color: var(--muted);
  font-size: 11px;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  background: #ffffff;
}

#figureSvg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.selection-title {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 660;
}

.inspector-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-top: 12px;
}

.inspector-fields label {
  margin: 0;
}

.inspector-fields .wide {
  grid-column: 1 / -1;
}

#svgSource {
  width: 100%;
  height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: #25221e;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
}

.selectable {
  cursor: grab;
}

.selectable:active {
  cursor: grabbing;
}

.selected-outline {
  fill: none;
  stroke: var(--warm);
  stroke-width: 2.4;
  stroke-dasharray: 7 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.figure-line {
  vector-effect: non-scaling-stroke;
}

@media (max-width: 1180px) {
  body {
    min-width: 980px;
  }

  .workspace {
    grid-template-columns: 210px minmax(560px, 1fr) 250px;
  }
}
