* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font: 14px/1.4 system-ui, sans-serif; background: #0f172a; color: #e2e8f0; }
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; gap: 8px; padding: 8px; }
.workspace { display: grid; grid-template-columns: 52px 1fr 280px; gap: 8px; min-height: 0; }
.toolbox {
  display: flex; flex-direction: column; gap: 4px; align-self: stretch;
  padding: 6px; background: #1e293b; border-radius: 8px;
}
.tool-btn {
  width: 40px; height: 40px; padding: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; border-radius: 6px;
}
.tool-btn.active { background: #2563eb; border-color: #3b82f6; box-shadow: 0 0 0 1px #60a5fa; }
.toolbox-sep { height: 1px; background: #475569; margin: 2px 4px; }
.toolbox-label {
  font-size: 10px; color: #64748b; text-align: center; padding: 2px 0 4px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.toolbar, .status {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px; background: #1e293b; border-radius: 8px;
}
.back-home {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  text-decoration: none;
  white-space: nowrap;
  padding-right: 0.55rem;
  margin-right: 0.15rem;
  border-right: 1px solid #475569;
}
.back-home:hover {
  color: #e2e8f0;
  text-decoration: underline;
}
.stage { position: relative; min-height: 0; background: #020617; border-radius: 8px; overflow: hidden; }
svg, canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
canvas { touch-action: none; }
.hint { color: #94a3b8; font-size: 12px; }
button, select, input[type="number"], input[type="color"] {
  background: #334155; color: inherit; border: 1px solid #475569;
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font: inherit;
}
button:hover { background: #475569; }
button.active { background: #2563eb; border-color: #3b82f6; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #cbd5e1; }
input[type="number"] { width: 64px; padding: 4px 6px; }
input[type="number"].narrow { width: 52px; }
select { background: #334155; color: inherit; border: 1px solid #475569; border-radius: 6px; padding: 5px 8px; font: inherit; cursor: pointer; }
select:hover { background: #475569; }
input[type="color"] { width: 36px; height: 32px; padding: 2px; }
.sep { width: 1px; height: 24px; background: #475569; margin: 0 2px; }
.tool-group { display: inline-flex; gap: 4px; }
kbd {
  display: inline-block; padding: 1px 5px; border-radius: 4px;
  background: #0f172a; border: 1px solid #475569; font-size: 11px; color: #94a3b8;
}
.layers-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: #1e293b; border-radius: 8px; overflow: hidden;
}
.side-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: #1e293b; border-radius: 8px; overflow: hidden;
}
.side-tabs {
  display: flex; flex-shrink: 0; border-bottom: 1px solid #334155;
  background: #172033;
}
.side-tab {
  flex: 1; padding: 9px 6px; margin: 0; border: none; border-radius: 0;
  background: transparent; color: #94a3b8; font-size: 12px; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.side-tab:hover { color: #e2e8f0; background: #1e293b; }
.side-tab.active {
  color: #e2e8f0; background: #1e293b;
  border-bottom-color: #3b82f6;
}
.side-tab-panels { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-tab-panel {
  display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}
.side-tab-panel.active { display: flex; }
.side-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid #334155;
  font-size: 12px; font-weight: 600; color: #94a3b8;
}
.side-form {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.side-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #94a3b8;
}
.side-field-row {
  display: flex; align-items: center; gap: 8px;
}
.side-field-row input[type="color"] { flex-shrink: 0; }
.side-field-row input[type="range"] { flex: 1; min-width: 0; width: auto; }
.side-field-row select { flex: 1; min-width: 0; }
.side-field-row input[type="number"] { width: 72px; }
.side-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: #64748b; margin-top: 4px;
}
label.side-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #cbd5e1; cursor: pointer;
}
.layers-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid #334155;
  font-size: 13px; font-weight: 600; color: #cbd5e1;
}
.layers-list { flex: 1; overflow-y: auto; padding: 6px; min-height: 0; }
.layer-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; margin-bottom: 4px;
  border: 1px solid transparent;
}
.layer-item:hover { background: #334155; }
.layer-item.selected { background: #1e3a5f; border-color: #3b82f6; }
.layer-item.hidden-layer { opacity: 0.55; }
.layer-eye {
  width: 28px; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid #475569; font-size: 14px;
}
.layer-eye.off { color: #64748b; }
.layer-name {
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layer-name-input {
  width: 100%; background: #0f172a; border: 1px solid #3b82f6; border-radius: 4px;
  color: inherit; font: inherit; padding: 2px 4px;
}
.layer-actions { display: flex; gap: 2px; }
.layer-actions button {
  width: 26px; height: 26px; padding: 0; font-size: 11px; line-height: 1;
}
.layers-empty { padding: 16px 12px; color: #64748b; font-size: 13px; text-align: center; }
input[type="range"] { width: 88px; vertical-align: middle; accent-color: #3b82f6; }
.opacity-val { min-width: 36px; font-size: 12px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.menu-wrap { position: relative; display: inline-block; }
.menu-popover {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 200;
  min-width: 140px; padding: 6px; background: #1e293b; border: 1px solid #475569;
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.menu-popover.open { display: block; }
.menu-popover button.menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; margin: 0;
  border: none; border-radius: 4px; background: transparent;
}
.menu-popover button.menu-item:hover:not(:disabled) { background: #334155; }
.menu-sep { height: 1px; background: #475569; margin: 4px 0; }
.menu-field {
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 2px; font-size: 12px; color: #94a3b8;
}
.menu-field-row {
  display: flex; gap: 4px; align-items: center;
}
.menu-field-row input[type="number"] {
  width: 64px; flex: 1; min-width: 0; padding: 4px 6px;
}
.menu-field-row button {
  padding: 4px 8px; font-size: 12px; flex-shrink: 0;
}
.menu-field-row button.menu-item {
  width: auto; text-align: center;
}
.align-rows { display: flex; flex-direction: column; gap: 6px; }
.align-row { display: flex; gap: 4px; align-items: center; }
.align-row-label { font-size: 11px; color: #94a3b8; width: 14px; text-align: center; flex-shrink: 0; }
.align-row button {
  width: 36px; height: 32px; padding: 0; font-size: 14px; line-height: 1;
}
.status .hint { flex: 1; min-width: 120px; }
