/* Vector Generator — styles */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Layout: white control sidebar on the left, canvas stage on the right; stacks on phones */
  :root {
    --page: #000; --frame: #8a8a8a;
    --side: #fff; --rule: #e8e8e8; --field-line: #d9d9d9; --field-focus: #111;
    --ink: #111; --ink-soft: #6b6b6b; --stage: #1e1e1e;
    --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    color-scheme: light;
  }
  html, body { height: 100%; }
  body {
    margin: 0; background: var(--side); color: var(--ink); font-family: var(--sans); font-size: 13px;
  }
  .app {
    height: 100%; display: grid; grid-template-columns: 300px minmax(0, 1fr);
    overflow: hidden; background: var(--stage);
  }

  /* Sidebar */
  .side { background: var(--side); border-right: 1px solid var(--rule); overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
  .sec { padding: 16px 20px; border-bottom: 1px solid var(--rule); display: grid; gap: 10px; }
  .side::after { content: ""; flex: none; min-height: 48px; } /* breathing room below the last section */
  .sec-title { font-size: 11px; font-weight: 500; color: var(--ink); }
  .field { display: grid; gap: 3px; min-width: 0; }
  .field > label, .field > .lab { font-weight: 400; font-size: 11px; color: #555555; }
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
  .input, .select {
    width: 100%; box-sizing: border-box; height: 28px; font: inherit; font-size: 13px; line-height: 26px; color: var(--ink);
    background: #fff; border: 1px solid var(--field-line); border-radius: 3px; padding: 0 8px;
    font-variant-numeric: tabular-nums;
  }
  .input:focus, .select:focus { outline: none; border-color: var(--field-focus); box-shadow: 0 0 0 1px var(--field-focus); }
  .input.num, .input.hex { text-align: right; }
  .select {
    appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 26px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 7px center; background-size: 12px;
  }
  .dims { display: flex; align-items: center; gap: 8px; }
  .dims span { color: var(--ink-soft); }
  .dims .input { flex: 1; min-width: 0; }
  .dims .num-wrap { flex: 1; }

  /* Number steppers. Hide native spinners in every engine, then draw our own. */
  .input[type=number] { -moz-appearance: textfield; appearance: textfield; }
  .input[type=number]::-webkit-inner-spin-button,
  .input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
  .num-wrap { position: relative; min-width: 0; }
  .num-wrap .input { display: block; padding-right: 27px; } /* block: no inline baseline gap, so the stepper lines up exactly */
  .stepper {
    position: absolute; top: 1px; right: 1px; bottom: 1px; width: 18px;
    display: flex; flex-direction: column; overflow: hidden;
    border-left: 1px solid var(--field-line); border-radius: 0 2px 2px 0; background: #fff;
  }
  .step-btn {
    flex: 1 1 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--ink-soft); cursor: pointer; font: inherit; line-height: 0;
    -webkit-appearance: none; appearance: none; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  }
  .step-btn::-moz-focus-inner { border: 0; padding: 0; }
  .step-btn + .step-btn { border-top: 1px solid var(--field-line); }
  .step-btn:hover { background: #f3f3f3; color: var(--ink); }
  .step-btn:active { background: #e9e9e9; }
  .step-btn svg { display: block; width: 10px; height: 10px; pointer-events: none; }
  .input.code { text-align: left; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11px; text-overflow: ellipsis; }
  .input.code.bad { border-color: #c62828; box-shadow: 0 0 0 1px #c62828; }
  .btn.mini { height: 28px; padding: 0 10px; font-size: 12px; flex: none; }
  .color-wrap { position: relative; }
  /* Figma-style color picker popover */
  .color-wrap .swatch {
    position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; padding: 0;
    border: 1px solid var(--field-line); border-radius: 3px; cursor: pointer; overflow: hidden;
    background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 8px 8px;
  }
  .color-wrap .swatch span { display: block; width: 100%; height: 100%; }
  .color-wrap .swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
  .cp {
    position: fixed; z-index: 30; width: 244px; box-sizing: border-box; padding: 12px; display: grid; gap: 12px;
    background: rgba(20,20,20,.85); border: 1px solid #333; border-radius: 4px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    color: #eee; font-size: 12px; user-select: none; -webkit-user-select: none;
  }
  .cp-sv {
    position: relative; height: 196px; border-radius: 6px; cursor: crosshair; touch-action: none;
    background-image: linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, rgba(255,255,255,0));
    background-color: hsl(var(--h, 0), 100%, 50%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); border-radius: 3px;
  }
  .cp-knob {
    position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-sizing: content-box;
    box-shadow: 0 0 0 1px rgba(0,0,0,.35), inset 0 0 0 1px rgba(0,0,0,.25); transform: translate(-50%, -50%); pointer-events: none;
  }
  .cp-row { display: flex; align-items: center; gap: 10px; }
  .cp-sliders { flex: 1; display: grid; gap: 12px; min-width: 0; }
  .cp-track { position: relative; height: 12px; border-radius: 6px; cursor: pointer; touch-action: none; margin: 0 7px; }
  .cp-track::before { content: ""; position: absolute; inset: 0 -7px; border-radius: 6px; background: inherit; }
  .cp-hue { background: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); }
  .cp-alpha { background: linear-gradient(to right, rgba(0,0,0,0), var(--c, #000)), repeating-conic-gradient(#444 0 25%, #262626 0 50%) 0 0 / 8px 8px; }
  .cp-track .cp-knob { top: 50%; z-index: 1; }
  .cp-eye { flex: none; width: 28px; height: 28px; border: 0; background: none; color: #ddd; border-radius: 3px; cursor: pointer; display: grid; place-items: center; padding: 0; }
  .cp-eye:hover { background: #333; }
  .cp-eye svg { width: 16px; height: 16px; }
  .cp-fields { display: flex; gap: 6px; }
  .cp-mode {
    flex: none; height: 28px; padding: 0 22px 0 8px; font: inherit; color: #eee; background-color: transparent; border: 1px solid #333; border-radius: 4px; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23eee' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 7px center;
  }
  .cp-inputs { flex: 1; min-width: 0; display: flex; background: #262626; border: 1px solid #333; border-radius: 4px; overflow: hidden; }
  .cp-inputs input {
    flex: 1 1 0; min-width: 0; width: 0; height: 26px; padding: 0 6px; border: 0; border-right: 1px solid #333; border-radius: 0;
    background: transparent; color: #eee; font: inherit; font-variant-numeric: tabular-nums;
  }
  .cp-inputs input.hex { flex: 2.4 1 0; text-transform: uppercase; }
  .cp-inputs input:last-of-type { border-right: 0; }
  .cp-inputs input:focus { outline: 1px solid #0d99ff; outline-offset: -1px; }
  .cp-inputs .pct { align-self: center; color: #999; padding-right: 7px; }
  .cp-mode:focus-visible, .cp-eye:focus-visible { outline: 1px solid #0d99ff; }
  .color-wrap .input { padding-left: 28px; text-transform: uppercase; }
  .toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 400; font-size: 11px; color: #555555; cursor: pointer; }
  .toggle input { appearance: none; -webkit-appearance: none; flex: none; width: 34px; height: 20px; margin: 0; border-radius: 10px; background: var(--field-line); position: relative; cursor: pointer; transition: background .15s; }
  .toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
  .toggle input:checked { background: var(--ink); }
  .toggle input:checked::after { transform: translateX(14px); }
  .toggle input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
  .btn {
    height: 32px; font: inherit; font-weight: 500; font-size: 13px; border-radius: 3px; cursor: pointer;
    border: 1px solid var(--field-line); background: #fff; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  }
  .btn:hover { border-color: #aaa; }
  .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
  .btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
  .btn.primary:hover { background: #333; }
  .btn.ghost { font-weight: 500; color: var(--ink-soft); }
  .btn svg { width: 14px; height: 14px; }
  .actions { display: grid; gap: 8px; }
  .actions.two { grid-template-columns: repeat(2, 1fr); }
  /* Action buttons: text on the left, icon on the right (markup is icon then text, so reverse the row). */
  .btn.icon { height: 28px; padding: 0 6px 0 10px; gap: 7px; white-space: nowrap; font-size: 12px; flex-direction: row-reverse; justify-content: space-between; }
  .btn.icon svg { width: 12px; height: 12px; flex: none; }
  .btn.icon.share { flex: none; }
  .tip {
    position: fixed; z-index: 40; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
    background: rgba(20,20,20,.85); border: 1px solid #333; border-radius: 4px; color: #eee; font-size: 11px; padding: 4px 8px;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  }


  /* Stage */
  .stage-wrap { position: relative; min-width: 0; min-height: 0; }
  #stage { position: absolute; inset: 0; overflow: auto; display: flex; align-items: safe center; justify-content: safe center; }
  #stage canvas { display: block; flex: none; box-shadow: 0 6px 16px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.3); } /* medium elevation */
  .zoombar {
    position: absolute; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 2px;
    background: rgba(20,20,20,.85); border: 1px solid #333; border-radius: 4px; padding: 3px; color: #eee;
    font-size: 12px; font-variant-numeric: tabular-nums; backdrop-filter: blur(4px);
  }
  .zoombar button { font: inherit; color: inherit; background: none; border: 0; border-radius: 3px; height: 26px; min-width: 26px; padding: 0 8px; cursor: pointer; }
  .zoombar button:hover { background: #333; }
  .zoombar button[aria-pressed=true] { background: #eee; color: #111; }
  .zoombar button:focus-visible { outline: 2px solid #fff; }
  #zoomPct { min-width: 5ch; text-align: center; }

  /* Modal */
  .modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 24px; z-index: 20; }
  .modal-card { background: #fff; border-radius: 6px; width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 22px 24px; display: grid; gap: 14px; box-sizing: border-box; }
  .modal-card h2 { margin: 0; font-size: 15px; font-weight: 600; }
  .modal-card p { margin: 0; color: var(--ink-soft); line-height: 1.5; }
  .modal-card img { width: 100%; height: auto; border: 1px solid var(--rule); background: #000; }
  .modal-card textarea { width: 100%; box-sizing: border-box; min-height: 220px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--field-line); border-radius: 3px; padding: 10px; resize: vertical; }
  .modal-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
  .modal-row .btn { padding: 0 16px; }
  .modal-msg { margin-right: auto; color: var(--ink-soft); font-size: 12px; }

  @media (max-width: 820px) {
    body { height: auto; }
    .app { height: auto; grid-template-columns: 1fr; }
    .stage-wrap { order: -1; height: 70vh; }
    .side { overflow: visible; }
  }
  @media (prefers-reduced-motion: reduce) { .toggle input, .toggle input::after { transition: none; } }
