/* ===== Advanced SVG Path Editor - Styles ===== */
:root {
  --bg-0: #0b1020;
  --bg-1: #111831;
  --bg-2: #161e3d;
  --bg-3: #1d2750;
  --line: #2a3566;
  --text: #e6ecff;
  --text-dim: #9aa6d6;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #22d3ee;
  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
  --bg-0: #f4f6fb;
  --bg-1: #ffffff;
  --bg-2: #eef1f8;
  --bg-3: #e2e7f3;
  --line: #cdd5e6;
  --text: #1a2240;
  --text-dim: #5a6790;
  --shadow: 0 6px 18px rgba(60, 70, 110, 0.12);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; padding: 0; }
body {
  background: linear-gradient(160deg, var(--bg-0), var(--bg-1));
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  overflow: hidden;
}

/* Layout */
.app {
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand svg { width: 26px; height: 26px; }
.brand-name {
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.topbar .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.topbar .divider { width: 1px; height: 28px; background: var(--line); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
  user-select: none;
}
.btn:hover { background: var(--bg-3); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: white;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: rgba(239,68,68,0.1); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 6px 8px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: white; }

.main {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  height: 100%;
  overflow: hidden;
}
@media (max-width: 1100px) {
  .main { grid-template-columns: 280px 1fr; }
  .panel.right { display: none; }
}
@media (max-width: 800px) {
  .main { grid-template-columns: 1fr; }
  .panel.left { display: none; }
}

.panel {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.panel.right { border-right: none; border-left: 1px solid var(--line); }
.panel-section {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.panel-section h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-section h3 .h-actions { display: flex; gap: 4px; }

/* Canvas */
.canvas-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, rgba(99,102,241,0.08), transparent 60%),
    var(--bg-0);
}
.canvas-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 5;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}
.canvas-toolbar .btn { padding: 6px 9px; font-size: 12px; }
.canvas-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  z-index: 5;
}
.canvas-zoom {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  z-index: 5;
}

svg.canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
svg.canvas.panning { cursor: grabbing; }
svg.canvas.tool-select { cursor: default; }
svg.canvas.tool-pan { cursor: grab; }

/* Path display */
.path-fill { fill-rule: nonzero; }
.path-preview { pointer-events: none; }

/* Handle styles */
.handle {
  cursor: grab;
  transition: transform 0.1s ease;
}
.handle:hover { transform: scale(1.25); transform-box: fill-box; transform-origin: center; }
.handle.point { fill: var(--accent); stroke: white; stroke-width: 2; }
.handle.point.selected { fill: var(--accent-3); stroke: white; }
.handle.point.start { fill: var(--good); }
.handle.control { fill: var(--warn); stroke: white; stroke-width: 1.5; }
.handle.control.selected { fill: var(--accent-3); }
.control-line {
  stroke: var(--warn);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.6;
  pointer-events: none;
}

/* Command list */
.cmd-list { display: flex; flex-direction: column; gap: 4px; }
.cmd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid transparent;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.cmd-row:hover { background: var(--bg-3); }
.cmd-row.selected { border-color: var(--accent); background: var(--bg-3); }
.cmd-row .idx {
  min-width: 22px;
  color: var(--text-dim);
  font-size: 10px;
  text-align: right;
}
.cmd-row .type {
  width: 26px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.cmd-row .type.relative { background: linear-gradient(135deg, var(--accent-3), var(--accent)); }
.cmd-row .args {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-row .row-actions { display: none; gap: 2px; }
.cmd-row:hover .row-actions, .cmd-row.selected .row-actions { display: flex; }
.cmd-row .row-actions .btn { padding: 2px 5px; font-size: 10px; }

/* Param editor */
.param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.param-grid.full { grid-template-columns: 1fr; }
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input[type="number"], .field input[type="text"], .field select, .field textarea {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 90px; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
}
.checkbox input { accent-color: var(--accent); }

/* Path text area */
.path-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.path-input-wrap textarea {
  font-family: var(--mono);
  font-size: 12px;
  min-height: 110px;
  word-break: break-all;
}
.path-error {
  font-size: 11px;
  color: var(--bad);
  font-family: var(--mono);
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}

/* Style controls */
.style-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.color-input {
  display: flex;
  gap: 4px;
  align-items: center;
}
.color-input input[type="color"] {
  width: 36px; height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}
.color-input input[type="text"] {
  flex: 1;
  font-size: 11px;
}

.range-row { display: flex; gap: 8px; align-items: center; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row .val { font-family: var(--mono); font-size: 11px; color: var(--text-dim); min-width: 36px; text-align: right; }

/* Add command button bar */
.cmd-add-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.cmd-add-grid .btn {
  padding: 6px 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  justify-content: center;
}

/* Tooltip */
.tip {
  position: relative;
}
.tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid var(--line);
  pointer-events: none;
  z-index: 100;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
}
.modal h2 { margin-top: 0; }
.modal .close-x {
  float: right;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  background: transparent;
  border: none;
}
.modal kbd {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}
.shortcut-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.shortcut-list .row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-1);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 200;
  font-size: 13px;
  animation: toast-in 0.2s ease;
}
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Subtle text */
.muted { color: var(--text-dim); font-size: 11px; }
.row-flex { display: flex; gap: 6px; align-items: center; }
.row-flex.between { justify-content: space-between; }
.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-dim);
  font-size: 10px;
  font-family: var(--mono);
}

/* Empty state */
.empty {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}

/* Tool buttons row */
.tool-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.tool-row .btn { flex: 1; justify-content: center; }
