:root {
  --bg: #0b0d12;
  --panel: #11141b;
  --panel-2: #161a23;
  --card: #1a1f2a;
  --card-hover: #1f2532;
  --line: #262c39;
  --line-2: #323a4a;
  --text: #e6e9ef;
  --text-2: #a3abbb;
  --text-3: #6c7588;
  --primary: #6366f1;
  --primary-2: #818cf8;
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  --info: #60a5fa;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-name { font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: -.02em; }
.logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #22c55e, #0ea5e9); color: #03120a;
  font: 700 13px 'JetBrains Mono', monospace;
}
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer;
  font-weight: 500; font-size: 13px; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--card-hover); border-color: #3d4659; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-2); border-color: var(--primary-2); }
.btn.primary.active { background: #4f46e5; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--card); color: var(--text); }
.btn.danger:hover { color: var(--danger); }
.btn .ico { font-size: 11px; width: 12px; text-align: center; }

.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; flex-shrink: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--card-hover); color: var(--text); border-color: var(--line-2); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); }
.icon-btn.sm { width: 22px; height: 22px; font-size: 11px; }
.flow-bar .icon-btn { border-color: var(--line-2); background: var(--card); width: 34px; height: 34px; }

/* ---------- layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: minmax(360px, 460px) 1fr; min-height: 0; }
.panel { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tab {
  padding: 9px 12px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--primary-2); }
.tab-panel { display: none; overflow-y: auto; padding: 16px; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.tab-panel.active { display: block; }

h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 0; font-weight: 700; }
h3.section { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 20px 0 10px; font-weight: 700; }
h3.section:first-child { margin-top: 0; }

/* ---------- form controls ---------- */
input[type=text], input[type=number], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 9px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input[type=text]:focus, input[type=number]:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
textarea { resize: vertical; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; line-height: 1.5; }
select {
  cursor: pointer; -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 34px !important; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a3abbb' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; background-size: 14px;
}
select:hover { border-color: #3d4659; }
select::-ms-expand { display: none; }
option { background: var(--panel); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 20px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(99,102,241,.35); }

.mini { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.mini select { width: auto; min-width: 84px; padding: 4px 10px; height: 32px; border-radius: 8px; }

/* ---------- flows ---------- */
.flow-bar { display: flex; gap: 6px; margin-bottom: 10px; }
.flow-bar select { flex: 1; font-weight: 600; height: 34px; }
.flow-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }

/* ---------- steps ---------- */
.steps-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.steps { display: flex; flex-direction: column; gap: 6px; }
.empty { padding: 20px; text-align: center; color: var(--text-3); border: 1px dashed var(--line-2); border-radius: var(--radius); }

.step {
  --tc: var(--text-3);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 3px solid var(--tc); transition: border-color .15s, box-shadow .15s, opacity .15s; position: relative;
}
.step.running { border-color: var(--primary-2); border-left-color: var(--tc); box-shadow: 0 0 0 1px var(--primary-2), 0 0 18px -4px rgba(129,140,248,.55); }
.step.disabled { opacity: .45; }
.step.dragging { opacity: .35; }
.step.drop-before::before, .step.drop-after::after {
  content: ''; position: absolute; left: 0; right: 0; height: 2px; background: var(--primary-2); border-radius: 2px;
}
.step.drop-before::before { top: -5px; }
.step.drop-after::after { bottom: -5px; }

.step-head { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 4px; min-width: 0; }
.handle { cursor: grab; color: var(--text-3); padding: 0 3px; user-select: none; letter-spacing: -3px; font-size: 12px; }
.handle:active { cursor: grabbing; }
.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: color-mix(in srgb, var(--tc) 18%, transparent); color: var(--tc); font: 700 12px 'JetBrains Mono', monospace;
}
.step-num { font: 600 11px 'JetBrains Mono', monospace; color: var(--text-3); min-width: 14px; text-align: right; }
.type-select { width: auto !important; max-width: 140px; padding: 3px 22px 3px 6px !important; font-size: 12px; font-weight: 600; background-color: transparent !important; background-position: right 5px center !important; background-size: 12px !important; border-color: transparent !important; color: var(--tc); height: 26px; }
.type-select:hover { border-color: var(--line-2) !important; }
.step-summary {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2);
  font: 12px 'JetBrains Mono', monospace; cursor: pointer;
}
.step-actions { display: flex; gap: 0; opacity: .55; transition: opacity .12s; }
.step:hover .step-actions, .step:focus-within .step-actions { opacity: 1; }
.step-actions .icon-btn { width: 24px; height: 24px; font-size: 12px; }

.step-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 4px 12px 12px 12px; }
.step-body .field.wide { grid-column: 1 / -1; }
.step.collapsed .step-body { display: none; }
.color-inline { display: flex; align-items: center; gap: 6px; }
.color-inline .hint { font-size: 11.5px; color: var(--text-3); }

.t-command { --tc: #22c55e; }
.t-type { --tc: #e5e7eb; }
.t-question { --tc: #c084fc; }
.t-output { --tc: #94a3b8; }
.t-success { --tc: var(--ok); }
.t-error { --tc: var(--danger); }
.t-warning { --tc: var(--warn); }
.t-info { --tc: var(--info); }
.t-loading { --tc: #38bdf8; }
.t-progress { --tc: #2dd4bf; }
.t-retry { --tc: #fb923c; }
.t-wait, .t-blank, .t-clear, .t-flow { --tc: #8b93a7; }

/* ---------- palette ---------- */
.add-step { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.add-step h2 { margin-bottom: 10px; }
.palette { display: flex; flex-direction: column; gap: 10px; }
.pal-title { font-size: 11px; color: var(--text-3); margin-bottom: 5px; font-weight: 600; }
.pal-items { display: flex; flex-wrap: wrap; gap: 5px; }
.pal-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-size: 12.5px; font-weight: 500;
}
.pal-btn:hover { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, var(--panel-2)); }

.help { margin-top: 18px; color: var(--text-2); font-size: 12.5px; }
.help summary { cursor: pointer; color: var(--text-3); font-weight: 600; }
.help p { margin: 8px 0; line-height: 1.7; }

/* ---------- colors ---------- */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-swatch {
  display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: var(--panel-2); cursor: pointer; font-size: 12px; font-weight: 600; text-align: left;
}
.theme-swatch:hover { border-color: var(--primary-2); }
.theme-swatch .sw { display: flex; gap: 4px; padding: 10px 8px; border-radius: 6px; border: 1px solid; }
.theme-swatch .sw i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.colors { display: flex; flex-direction: column; gap: 6px; }
.color-row { display: grid; grid-template-columns: 32px 1fr 104px; align-items: center; gap: 10px; }
.color-row .clabel { cursor: pointer; }
.color-row .clabel { font-size: 13px; color: var(--text-2); }
.color-row .hex { font: 12px 'JetBrains Mono', monospace; padding: 5px 7px; }

/* ---------- settings ---------- */
.setting { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.setting > label { font-size: 13px; color: var(--text-2); }
.setting.inline { grid-template-columns: 1fr auto; }

/* ---------- preview ---------- */
.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.toolbar .group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage {
  flex: 1; overflow: auto; padding: 32px 32px 48px; display: flex; flex-direction: column; align-items: center; gap: 18px;
  transition: background .25s;
}
.terminal-mount { width: 100%; margin-bottom: auto; }
.stage > :first-child { margin-top: auto; }
.flow-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid rgba(127,127,127,.3); background: rgba(127,127,127,.12);
  color: inherit; cursor: pointer; font-size: 12.5px; font-weight: 500; mix-blend-mode: normal;
  color: #64748b;
}
.chip:hover { border-color: rgba(127,127,127,.6); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.statusbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 16px; border-top: 1px solid var(--line);
  background: var(--panel); color: var(--text-3); font-size: 12px; flex-shrink: 0;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status-dot[data-state=playing] { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,.2); }
.status-dot[data-state=paused], .status-dot[data-state=waiting] { background: var(--warn); }
.status-dot[data-state=done] { background: var(--info); }

/* ---------- presentation mode ---------- */
body.present .topbar, body.present .panel, body.present .toolbar, body.present .statusbar, body.present .flow-chips { display: none; }
body.present .layout { grid-template-columns: 1fr; }
body.present .stage { padding: 40px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1e2533; border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); color: #fecaca; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: minmax(0, 1fr); flex: none; min-height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .preview { order: 1; }
  .tab-panel { overflow: visible; }
  .stage { padding: 20px 16px 28px; flex: none; }
  .topbar { flex-wrap: wrap; }
  .setting { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 520px) {
  .flow-meta, .step-body { grid-template-columns: 1fr; }
  .step-head { flex-wrap: wrap; }
  .step-actions { order: 5; width: 100%; justify-content: flex-end; opacity: 1; }
  .themes { grid-template-columns: repeat(2, 1fr); }
  .top-actions .btn { padding: 0 8px; }
}

/* On pointer devices, reveal step actions as a hover overlay so summaries get the full width. */
@media (hover: hover) and (min-width: 521px) {
  .step-actions {
    position: absolute; right: 6px; top: 5px; opacity: 0; pointer-events: none;
    background: var(--card-hover); border: 1px solid var(--line-2); border-radius: 8px; padding: 1px;
    box-shadow: -12px 0 12px -4px var(--card);
  }
  .step:hover .step-actions, .step:focus-within .step-actions { opacity: 1; pointer-events: auto; }
}

/* ---------- your text ---------- */
.text-cta { display: flex; gap: 8px; margin-bottom: 18px; }
.text-cta .btn { flex: 1; justify-content: center; height: 36px; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }

.text-dialog {
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-2);
  border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.text-dialog::backdrop { background: rgba(3,6,12,.6); backdrop-filter: blur(3px); }
.td-inner { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.td-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.td-head h2 { font-size: 17px; text-transform: none; letter-spacing: -.01em; color: var(--text); }
.td-sub { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.td-modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 20px 14px; }
.td-modes label { cursor: pointer; }
.td-modes input { position: absolute; opacity: 0; pointer-events: none; }
.td-modes span {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel-2); height: 100%; transition: border-color .12s, background .12s;
}
.td-modes b { font-size: 13px; font-weight: 600; }
.td-modes small { font-size: 11.5px; color: var(--text-3); }
.td-modes input:checked + span { border-color: var(--primary-2); background: rgba(99,102,241,.14); }
.td-modes input:focus-visible + span { box-shadow: 0 0 0 3px rgba(99,102,241,.35); }
.td-body { display: grid; grid-template-columns: 1fr 300px; gap: 14px; padding: 0 20px; min-height: 0; flex: 1; }
.td-editor { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
.td-editor textarea { flex: 1; min-height: 340px; font-size: 13.5px; line-height: 1.6; resize: vertical; white-space: pre; overflow: auto; }
.td-foot-left { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.td-summary { flex: 1; min-width: 160px; font-size: 12.5px; color: var(--ok); font-family: 'JetBrains Mono', monospace; }
.td-help { overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); font-size: 12.5px; transition: opacity .15s; }
.td-help.dim { opacity: .4; }
.td-help h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.td-help table { width: 100%; border-collapse: collapse; }
.td-help td { padding: 4px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.td-help td:last-child { color: var(--text-2); padding-left: 8px; text-align: right; }
.td-help code { white-space: nowrap; font-size: 11.5px; }
.td-help p { margin: 10px 0 0; color: var(--text-2); line-height: 1.7; }
.td-actions { display: flex; align-items: center; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
.td-actions .grow { flex: 1; }

@media (max-width: 760px) {
  .td-modes { grid-template-columns: 1fr 1fr; }
  .td-body { grid-template-columns: 1fr; flex: none; }
  .td-editor textarea { white-space: pre-wrap; }
  .td-help { max-height: 220px; }
  .td-editor textarea { min-height: 220px; }
  .text-dialog { max-height: calc(100vh - 16px); width: calc(100vw - 16px); }
  .td-inner { max-height: calc(100vh - 18px); overflow: auto; }
}

/* ---------- pill slider ---------- */
.setting.slider-row { grid-template-columns: 1fr; }
.pslider {
  position: relative; height: 40px; border-radius: 12px; background: #1a1e28; overflow: hidden;
  user-select: none; touch-action: none; transition: box-shadow .12s, background .12s;
}
.pslider:hover { background: #1d2230; }
.pslider:focus-within { box-shadow: 0 0 0 2px rgba(129,140,248,.55); }
.ps-fill { position: absolute; inset: 0 auto 0 0; background: #2e3880; border-radius: 12px 0 0 12px; pointer-events: none; }
.ps-ticks { position: absolute; inset: 0; pointer-events: none; }
.ps-ticks i { position: absolute; top: 50%; width: 1px; height: 12px; margin-top: -6px; background: rgba(163,171,187,.28); }
.ps-label {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none;
  color: #a4acd6; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.pslider.ps-low .ps-label { color: var(--text-2); }
.ps-value {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none;
  color: #fff; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ps-thumb {
  position: absolute; top: 50%; width: 4px; height: 22px; margin: -11px 0 0 -2px; border-radius: 3px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 1px 4px rgba(0,0,0,.4); pointer-events: none;
}
.ps-input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize;
  -webkit-appearance: none; appearance: none;
}
.ps-input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 40px; }
.ps-input::-moz-range-thumb { width: 14px; height: 40px; border: 0; }

/* ---------- color swatch button ---------- */
.swatch-btn {
  width: 32px; height: 32px; padding: 3px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg);
  cursor: pointer; flex-shrink: 0; transition: border-color .12s, transform .12s;
}
.swatch-btn:hover { border-color: #4b5568; }
.swatch-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,.35); }
.swatch-btn span { display: block; width: 100%; height: 100%; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.swatch-btn.empty span {
  background: repeating-conic-gradient(#2a303d 0 25%, #1a1e28 0 50%) 50% / 10px 10px !important;
}
.color-inline .hint { font: 12px 'JetBrains Mono', monospace; }

/* ---------- color picker popover ---------- */
.cpick {
  position: fixed; z-index: 200; width: 268px; padding: 14px; display: none; flex-direction: column; gap: 12px;
  background: #161a23; border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3);
}
.cpick.open { display: flex; animation: cp-in .14s ease-out; }
@keyframes cp-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.cp-head { display: flex; align-items: center; gap: 12px; }
.cp-swatch { width: 40px; height: 40px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); flex-shrink: 0; }
.cp-title { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.cp-hex { font-size: 15px; font-weight: 700; letter-spacing: .02em; color: var(--text); margin-top: 1px; }
.cp-sv {
  position: relative; height: 140px; border-radius: 8px; cursor: crosshair; touch-action: none; outline: none;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue, red));
}
.cp-sv:focus-visible { box-shadow: 0 0 0 2px rgba(129,140,248,.6); }
.cp-sv-handle {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.4); pointer-events: none;
}
.cp-hue {
  position: relative; height: 16px; border-radius: 999px; cursor: ew-resize; touch-action: none; outline: none; margin: 0 2px;
  background: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);
}
.cp-hue:focus-visible { box-shadow: 0 0 0 2px rgba(129,140,248,.6); }
.cp-hue-handle {
  position: absolute; top: 50%; width: 10px; height: 20px; margin: -10px 0 0 -5px; border-radius: 4px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.4); pointer-events: none;
}
.cp-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.cp-sw { width: 18px; height: 18px; border-radius: 5px; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); padding: 0; }
.cp-sw:hover { transform: scale(1.12); }
.cp-row { display: flex; align-items: center; justify-content: space-between; }
.cp-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.cp-seg { display: flex; background: #1f2430; border-radius: 8px; padding: 2px; }
.cp-seg button { border: 0; background: transparent; color: var(--text-2); padding: 3px 9px; border-radius: 6px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.cp-seg button:hover { color: var(--text); }
.cp-seg button.active { background: #2b3256; color: #fff; }
.cp-input {
  width: 100%; height: 38px; padding: 0 12px !important; border-radius: 9px !important; font-size: 14px !important;
  background: #0e1117 !important; border: 1px solid #2b3256 !important;
}
.cp-input:focus { border-color: #4f5bd5 !important; box-shadow: 0 0 0 3px rgba(99,102,241,.2) !important; }
.cp-input.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(248,113,113,.18) !important; }
.cp-hint { margin: -4px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--text-3); }
.cp-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cp-btn { height: 34px; padding: 0 16px; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; border: 1px solid var(--line-2); background: #0e1117; color: var(--text-2); }
.cp-btn:hover { color: var(--text); border-color: #3d4659; }
.cp-apply { background: #2b3256; border-color: #3e4a99; color: #fff; }
.cp-apply:hover { background: #343c6b; border-color: #5361c4; }
