:root {
  color: #1f2937;
  background: #ffffff;
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.app { height: 100vh; display: grid; grid-template-rows: 48px minmax(0, 1fr); }

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid #d1d5db;
  background: #ffffff;
  min-width: 0;
}
.bar-group { display: flex; align-items: center; gap: 2px; }
.bar-end { margin-left: auto; }
.icon-button, .text-button, .tool, .tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.icon-button, .tool {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 7px;
}
.text-button { height: 34px; display: flex; align-items: center; gap: 6px; padding: 0 9px; }
.icon-button svg, .tool svg, .text-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool[data-tool="point"] svg { fill: currentColor; stroke: none; }
.icon-button:hover, .text-button:hover, .tool:hover, .tab:hover { background: #f3f4f6; }
.icon-button:focus-visible, .text-button:focus-visible, .tool:focus-visible, .tab:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }
.icon-button:disabled { opacity: .3; cursor: default; background: transparent; }
.tool.active { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.tool[hidden], .icon-button[hidden] { display: none; }

.canvas-tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; margin-left: 10px; }
.tab { height: 32px; padding: 0 10px; white-space: nowrap; color: #4b5563; }
.tab.active { color: #111827; border-color: #d1d5db; background: #f9fafb; }
.canvas-create { position: relative; }
.canvas-dimensions { position: absolute; top: 36px; left: 0; z-index: 10; display: flex; border: 1px solid #d1d5db; background: #ffffff; }
.canvas-dimensions[hidden] { display: none; }

.workbench { min-height: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr) 232px; }
.toolbar { border-right: 1px solid #d1d5db; padding: 7px; display: flex; flex-direction: column; gap: 3px; background: #ffffff; }
.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #ffffff; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; outline: none; cursor: default; }
#canvas[data-tool]:not([data-tool="select"]) { cursor: crosshair; }
#scene [data-id] { cursor: move; }
#scene .object-label { pointer-events: bounding-box; }
#canvas[data-tool]:not([data-tool="select"]) #scene [data-id] { cursor: crosshair; }
.text-editor {
  position: absolute; z-index: 2; transform: translate(-50%, -50%); margin: 0; padding: 4px;
  resize: none; overflow: auto; border: 1px solid #2563eb; border-radius: 0; outline: none;
  background: #ffffff; color: #1f2937; text-align: center; line-height: 1.25;
  font-family: Arial, sans-serif; white-space: pre-wrap;
}
.text-editor[hidden] { display: none; }
.zoom-reset {
  position: absolute; right: 10px; bottom: 10px; min-width: 50px; height: 28px; padding: 0 7px;
  border: 1px solid #d1d5db; border-radius: 4px; background: #ffffff; color: #4b5563;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.zoom-reset:hover { background: #f3f4f6; }
.zoom-reset:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }

.properties { border-left: 1px solid #d1d5db; background: #ffffff; overflow-y: auto; padding: 12px; }
.property-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; font-weight: 600; color: #111827; }
.property-row { display: grid; grid-template-columns: 54px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 36px; }
.property-row > label { color: #4b5563; }
.property-row input[type="text"], .property-row input[type="number"], .property-row select {
  width: 100%; min-width: 0; height: 28px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; padding: 2px 6px; color: #111827;
}
.property-row input[type="color"] { width: 100%; height: 28px; padding: 1px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; }
.property-row input[type="range"] { width: 100%; accent-color: #2563eb; }
.property-row input[type="checkbox"] { justify-self: start; width: 16px; height: 16px; accent-color: #2563eb; }
.property-row input:disabled, .property-row select:disabled { opacity: .4; }
.property-actions { display: flex; gap: 4px; padding-top: 10px; margin-top: 10px; border-top: 1px solid #e5e7eb; }
.property-actions .icon-button { border-color: #e5e7eb; }
.rotation-actions .icon-button, .flip-actions .icon-button { padding: 0 4px; white-space: nowrap; }
.translate-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: center; }
.translate-actions input { width: 100%; min-width: 0; height: 28px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; padding: 2px 4px; color: #111827; }
.translate-actions .icon-button { width: auto; padding: 0 6px; white-space: nowrap; }
.section-rule { border: 0; border-top: 1px solid #e5e7eb; margin: 12px 0 6px; }

.selection-box { fill: none; stroke: #2563eb; stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.endpoint-handle { fill: #ffffff; stroke: #2563eb; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: all; cursor: crosshair; }
.text-resize-handle { fill: #ffffff; stroke: #2563eb; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: all; cursor: nwse-resize; }
.curve-control-handle { fill: #2563eb; stroke: #ffffff; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: all; cursor: crosshair; }
.curve-handle-line { fill: none; stroke: #2563eb; stroke-width: 1; stroke-opacity: .55; pointer-events: none; }
.snap-ring { fill: none; stroke: #2563eb; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.grid-line { fill: none; stroke: #64748b; stroke-width: .7; stroke-opacity: .32; }
.scaffold-line { stroke: #64748b; stroke-width: 1; stroke-opacity: .32; }
.scaffold-tick { fill: #64748b; fill-opacity: .62; }
.view-axis { stroke-width: 1.5; }
.view-label { font-size: 11px; text-anchor: middle; dominant-baseline: middle; }
.marquee { fill: rgba(37, 99, 235, .08); stroke: #2563eb; stroke-width: 1; stroke-dasharray: 4 3; }
.draft { pointer-events: none; }
.export-measure { position: fixed; left: -100000px; top: 0; pointer-events: none; }

@media (max-width: 900px) {
  .workbench { grid-template-columns: 44px minmax(0, 1fr) 200px; }
  .properties { padding: 8px; }
  .text-button span { display: none; }
}
