@font-face { font-family: "Another Sans"; src: url("fonts/AnotherSans.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Flexa Mono"; src: url("fonts/FlexaMono.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
    --bg: #010204; --stage: #060709; --panel: #101011; --border: #353538; --border-strong: #555559;
    --text: #f2f1ef; --muted: #aaa6a4; --blue-1: #4d819b; --blue-2: #bfe8fe;
    --panel-width: 270px; --panel-gap: 15px; --panel-margin: 32px;
    --mono: "Flexa Mono", "SFMono-Regular", Consolas, monospace;
    --sans: "Another Sans", Inter, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { color: var(--text); background: var(--bg); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.main-container { position: relative; width: 100%; height: 100%; }

.control-panel {
    position: fixed; z-index: 10; top: 50%; left: var(--panel-margin); width: var(--panel-width);
    padding: 20px; display: flex; flex-direction: column; gap: var(--panel-gap);
    background: var(--panel); border-radius: 10px; transform: translateY(-50%);
    max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: none;
}
.control-panel::-webkit-scrollbar { display: none; }
.panel-view { display: flex; flex-direction: column; gap: var(--panel-gap); }
.panel-section { display: flex; flex-direction: column; }
.section-title, .control-label {
    font-family: var(--mono); font-size: 10px; line-height: 1; font-weight: 400;
    letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted);
}
.section-title { margin-bottom: 7px; }
.presets-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.preset-btn {
    aspect-ratio: 1; padding: 4px; display: grid; place-items: center; overflow: hidden;
    background: transparent; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.preset-btn:hover { border-color: var(--border-strong); background: rgba(255,255,255,.02); }
.preset-btn.active { border-color: #5b99b6; background: rgba(77,129,155,.18); box-shadow: 0 5px 18px rgba(94,171,201,.1); }
.preset-btn svg { display: block; width: 100%; height: 100%; }

.controls-section { gap: 8px; }
.control-group { display: flex; flex-direction: column; gap: 7px; }
.nodes-input-row { display: grid; grid-template-columns: minmax(0, 1fr) 38px 38px; gap: 8px; }
.nodes-text-input, .btn-icon, .value-pill {
    height: 30px; color: var(--text); background: transparent; border: 1px solid var(--border); border-radius: 8px;
}
.nodes-text-input {
    min-width: 0; padding: 0 14px; font-family: var(--sans); font-size: 12px; letter-spacing: .72px;
    outline: none; transition: border-color 150ms ease, box-shadow 150ms ease;
}
.nodes-text-input:hover, .btn-icon:hover { border-color: var(--border-strong); }
.nodes-text-input:focus-visible, .btn-icon:focus-visible, .preset-btn:focus-visible, .colors-entry:focus-visible,
.btn-copy:focus-visible, .btn-export:focus-visible { outline: 1px solid var(--blue-2); outline-offset: 2px; }
.btn-icon {
    display: grid; place-items: center; color: var(--muted); cursor: pointer;
    transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}
.btn-icon:hover { color: var(--text); background: rgba(255,255,255,.02); }

.slider-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 17px; align-items: center; }
.alignment-toggle {
    margin: 7px 0 0 81px; display: flex; align-items: center; gap: 7px;
    color: var(--muted); font-size: 10px; line-height: 1;
}
.alignment-toggle input { width: 12px; height: 12px; accent-color: var(--blue-2); }
.nodes-symmetry-toggle { margin-left: 0; }
.value-pill {
    min-width: 54px; padding: 0 10px; display: grid; place-items: center; border-color: var(--border-strong);
    font-family: var(--mono); font-size: 10px; line-height: 1; letter-spacing: 1.2px; font-variant-numeric: tabular-nums;
}
.slider {
    grid-column: 2; grid-row: 1; width: 100%; height: 14px; appearance: none;
    -webkit-appearance: none; background: transparent; cursor: pointer; outline: none;
}
.slider::-webkit-slider-runnable-track {
    height: 2px; border-radius: 99px;
    background: linear-gradient(90deg, var(--blue-1) 0%, var(--blue-2) var(--progress,50%), rgba(77,129,155,.3) var(--progress,50%), rgba(191,232,254,.3) 100%);
}
.slider::-webkit-slider-thumb {
    width: 8px; height: 8px; margin-top: -3px; appearance: none; -webkit-appearance: none;
    border: 0; border-radius: 50%; background: var(--blue-2); box-shadow: 0 0 0 2px rgba(191,232,254,.08);
}
.slider::-moz-range-track { height: 2px; border-radius: 99px; background: rgba(191,232,254,.3); }
.slider::-moz-range-progress { height: 2px; border-radius: 99px; background: linear-gradient(90deg,var(--blue-1),var(--blue-2)); }
.slider::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--blue-2); }

.svg-actions { display: grid; grid-template-columns: 1fr 1.18fr; gap: 8px; }
.btn-copy, .btn-export {
    height: 42px; padding: 0 14px; border-radius: 7px; color: var(--text); font-family: var(--sans);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.btn-copy { background: #0b0b0c; border: 1px solid var(--border); }
.btn-copy:hover { background: #121214; border-color: var(--border-strong); }
.btn-export {
    overflow: hidden; background: #1b1a23; border: .5px solid #a9e4f9;
    box-shadow: 0 7px 24px rgba(94,171,201,.1), inset 0 .6px 19px 4.7px #b6e0f6,
        inset 0 4.4px 22px 7px #77a0b6, inset 0 0 29px 20px #42697d, inset 0 .6px 38px 29px #0d191f;
}
.btn-export:hover {
    border-color: #d3f2ff;
    box-shadow: 0 7px 24px rgba(94,171,201,.16), inset 0 .6px 19px 4.7px #c6ebff,
        inset 0 4.4px 22px 7px #83abc0, inset 0 0 29px 20px #496f82, inset 0 .6px 38px 29px #101d23;
}

.export-view { min-height: 490px; }
.export-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.export-eyebrow, .format-options legend {
    color: var(--muted); font: 9px/1 var(--mono); letter-spacing: 1.2px; text-transform: uppercase;
}
.export-header h2 { margin-top: 7px; font-size: 24px; line-height: 1; font-weight: 600; letter-spacing: -.3px; }
.export-close {
    width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto;
    color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 7px;
    font-size: 20px; line-height: 1; cursor: pointer;
}
.export-close:hover { color: var(--text); border-color: var(--border-strong); }
.export-close:focus-visible, .format-option:has(input:focus-visible), .export-actions button:focus-visible {
    outline: 1px solid var(--blue-2); outline-offset: 2px;
}
.format-options { display: flex; flex-direction: column; gap: 8px; border: 0; }
.format-options legend { margin-bottom: 10px; }
.format-option {
    min-height: 68px; padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
    color: var(--text); background: #0b0b0c; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.format-option:hover { border-color: var(--border-strong); }
.format-option:has(input:checked) {
    background: rgba(77,129,155,.14); border-color: #5b99b6; box-shadow: 0 6px 18px rgba(94,171,201,.08);
}
.format-option input { position: absolute; opacity: 0; pointer-events: none; }
.format-copy { display: flex; flex-direction: column; gap: 5px; }
.format-copy strong { font-size: 14px; line-height: 1; font-weight: 600; text-transform: uppercase; }
.format-copy small { color: var(--muted); font-size: 10px; line-height: 1.2; }
.format-mark { width: 12px; height: 12px; border: 1px solid var(--border-strong); border-radius: 50%; }
.format-option:has(input:checked) .format-mark { border: 3px solid var(--blue-2); box-shadow: 0 0 0 2px rgba(191,232,254,.08); }
.format-option.is-disabled { cursor: not-allowed; opacity: .48; }
.format-badge {
    padding: 4px 6px; color: var(--muted); background: rgba(255,255,255,.05); border-radius: 99px;
    font: 8px/1 var(--mono); letter-spacing: .6px; text-transform: uppercase;
}
.export-summary {
    padding-top: 12px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border);
    color: var(--muted); font: 9px/1.35 var(--mono); letter-spacing: .5px;
}
.export-summary span:first-child { color: var(--text); text-transform: uppercase; }
.export-actions { margin-top: auto; display: grid; grid-template-columns: 1fr 1.18fr; gap: 8px; }
.export-actions button:disabled { cursor: wait; opacity: .72; }

.colors-entry {
    width: 100%; height: 30px; padding: 0 9px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px;
    color: var(--muted); background: #0b0b0c; border: 1px solid var(--border); border-radius: 7px;
    font: 9px/1 var(--mono); letter-spacing: .8px; text-align: left; text-transform: uppercase; cursor: pointer;
}
.colors-entry:hover { color: var(--text); border-color: var(--border-strong); }
.colors-entry-preview { display: flex; align-items: center; }
.colors-entry-preview i {
    width: 13px; height: 13px; margin-left: -3px; display: block; background: var(--swatch);
    border: 1px solid rgba(255,255,255,.18); border-radius: 3px;
}
.colors-entry-preview i:first-child { margin-left: 0; }
.colors-entry-arrow { font: 18px/1 var(--sans); transform: translateY(-1px); }
.color-view { min-height: 490px; }
.color-mode { border: 0; }
.color-mode legend { margin-bottom: 10px; color: var(--muted); font: 9px/1 var(--mono); letter-spacing: 1.2px; text-transform: uppercase; }
.segmented-control { padding: 3px; display: grid; grid-template-columns: repeat(3,1fr); background: #0b0b0c; border: 1px solid var(--border); border-radius: 8px; }
.segmented-control label { cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { height: 30px; display: grid; place-items: center; color: var(--muted); border-radius: 5px; font-size: 11px; }
.segmented-control input:checked + span { color: var(--text); background: rgba(77,129,155,.22); box-shadow: inset 0 0 0 1px rgba(191,232,254,.32); }
.segmented-control input:focus-visible + span { outline: 1px solid var(--blue-2); outline-offset: 1px; }
.color-fields, .uniform-color-fields, .connection-color-fields, .vibrant-color-fields { display: flex; flex-direction: column; gap: 8px; }
.color-field {
    min-height: 54px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: #0b0b0c; border: 1px solid var(--border); border-radius: 8px;
}
.color-field > span { display: flex; flex-direction: column; gap: 4px; }
.color-field strong { color: var(--text); font-size: 11px; font-weight: 500; }
.color-field small { color: var(--muted); font-size: 9px; }
.color-field input[type="color"] { width: 34px; height: 30px; padding: 3px; flex: 0 0 auto; background: transparent; border: 1px solid var(--border-strong); border-radius: 6px; cursor: pointer; }
.connection-gradient { height: 12px; border: 1px solid var(--border); border-radius: 99px; background: linear-gradient(90deg,#30394A,#AFF3F8); }
.gradient-labels { display: flex; justify-content: space-between; color: var(--muted); font: 8px/1 var(--mono); letter-spacing: .8px; text-transform: uppercase; }
.vibrant-palette { padding: 10px 8px; display: grid; grid-template-columns: repeat(8,1fr); gap: 4px; background: #0b0b0c; border: 1px solid var(--border); border-radius: 8px; }
.vibrant-palette i { display: flex; justify-content: center; font-style: normal; }
.vibrant-palette i::before { content: ""; width: 14px; height: 14px; display: block; background: var(--tone); border-radius: 50%; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.vibrant-note { color: var(--muted); font: 9px/1.3 var(--mono); letter-spacing: .3px; }
.color-actions { margin-top: auto; }
.color-actions .btn-export { width: 100%; }

.motion-section { display: flex; flex-direction: column; gap: 8px; }
.motion-title {
    color: var(--muted);
    font-family: var(--mono); font-size: 10px; line-height: 1; font-weight: 400;
    letter-spacing: 1.2px; text-transform: uppercase;
}
.motion-controls { display: flex; flex-direction: column; gap: 7px; }
.motion-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.motion-check { display: flex; align-items: center; gap: 7px; color: var(--text); font-size: 11px; cursor: pointer; }
.motion-check input { accent-color: var(--blue-2); }
.motion-actions { display: flex; gap: 5px; }
.motion-actions button {
    height: 25px; padding: 0 8px; color: var(--muted); background: transparent;
    border: 1px solid var(--border); border-radius: 6px; font-size: 10px; cursor: pointer;
}
.motion-actions button:last-child { width: 27px; padding: 0; font-size: 14px; }
.motion-row { display: grid; grid-template-columns: 48px minmax(0,1fr) 38px; gap: 10px; align-items: center; }
.motion-row label, .motion-field > span {
    color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .8px; text-transform: uppercase;
}
.motion-row input[type="range"] { width: 100%; height: 14px; appearance: none; background: transparent; cursor: pointer; }
.motion-row input[type="range"]::-webkit-slider-runnable-track {
    height: 2px; border-radius: 99px;
    background: linear-gradient(90deg, var(--blue-1) 0%, var(--blue-2) var(--progress,50%), rgba(77,129,155,.3) var(--progress,50%), rgba(191,232,254,.3) 100%);
}
.motion-row input[type="range"]::-webkit-slider-thumb { width: 8px; height: 8px; margin-top: -3px; appearance: none; border: 0; border-radius: 50%; background: var(--blue-2); }
.motion-row input[type="range"]::-moz-range-track { height: 2px; border-radius: 99px; background: rgba(191,232,254,.3); }
.motion-row input[type="range"]::-moz-range-progress { height: 2px; border-radius: 99px; background: linear-gradient(90deg,var(--blue-1),var(--blue-2)); }
.motion-row input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--blue-2); }
.motion-row output { color: var(--text); font-family: var(--mono); font-size: 9px; text-align: right; }
.motion-field { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; }
.motion-field select {
    min-width: 0; height: 29px; padding: 0 8px; color: var(--text); background: #0b0b0c;
    border: 1px solid var(--border); border-radius: 7px; font: 10px var(--mono);
}
.graph-node { will-change: fill; }

.canvas-area {
    position: absolute; inset: 0; padding: 48px 48px 48px calc(var(--panel-width) + var(--panel-margin) * 2 + 48px);
    display: grid; place-items: center; background: var(--bg);
}
.canvas-wrapper { width: 100%; height: 100%; min-width: 0; min-height: 0; display: grid; place-items: center; }
.preview {
    width: min(100%, calc(100vh - 48px)); aspect-ratio: 1; min-width: 0; min-height: 0;
    padding: 8%; display: grid; place-items: center; background: var(--stage);
}
.preview svg { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; }

@media (max-width: 900px), (max-height: 620px) {
    :root { --panel-width: 236px; --panel-gap: 10px; --panel-margin: 16px; }
    .control-panel { padding: 16px; }
    .canvas-area { padding: 24px 24px 24px calc(var(--panel-width) + var(--panel-margin) * 2 + 24px); }
    .nodes-input-row { grid-template-columns: minmax(0,1fr) 34px 34px; gap: 7px; }
    .slider-row { grid-template-columns: 58px minmax(0,1fr) auto; gap: 10px; }
}

@media (max-width: 680px) and (orientation: portrait) {
    html, body { overflow: auto; }
    .main-container { min-height: 760px; }
    .control-panel {
        position: absolute; top: 24px; left: 50%; width: min(270px,calc(100vw - 32px)); transform: translateX(-50%);
    }
    .canvas-area { top: 440px; min-height: 320px; padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
