:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #0d0d0d;
  --line: #242424;
  --soft-line: #181818;
  --text: #eeede7;
  --muted: #7f807b;
  --dim: #4b4c48;
  --warm: #ffe9c4;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { height: 100vh; height: 100dvh; font-family: var(--sans); font-size: 13px; }
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
  height: 54px; padding: 0 26px; display: flex; align-items: center;
  flex-shrink: 0; justify-content: space-between; border-bottom: 1px solid var(--line);
  letter-spacing: .17em; font: 10px var(--mono);
}
.wordmark { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.wordmark > span { font: 600 13px var(--sans); letter-spacing: .34em; }
.wordmark i { color: var(--dim); font-style: normal; }
.wordmark small { color: #8d8e88; font-size: 9px; letter-spacing: .18em; }
.topnote, .credit { color: #969791; display: flex; align-items: center; gap: 8px; }
.credit { transition: color .2s; }
.credit:hover { color: var(--warm); }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: #a9d6a6; box-shadow: 0 0 9px #85d285; }

.studio {
  height: calc(100vh - 54px); height: calc(100dvh - 54px); min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
}
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 20px 22px 15px; }
.stage-topline, .stage-bottomline {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  color: var(--muted); font: 9px var(--mono); letter-spacing: .15em;
}
.stage-topline { padding: 0 2px 13px; }
.stage-bottomline { padding: 13px 2px 0; }
.stage-bottomline b { color: var(--dim); font-weight: 400; }
.stage {
  min-height: 0; flex: 1; position: relative; overflow: hidden;
  border: 1px solid #1d1d1d; background:
    radial-gradient(ellipse at 50% 48%, rgba(44, 43, 40, .18), transparent 42%),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    #060606;
  background-size: auto, 42px 42px, 42px 42px, auto;
}
.stage::before, .stage::after { content: ""; position: absolute; pointer-events: none; background: #2a2a28; opacity: .32; }
.stage::before { width: 1px; height: 100%; top: 0; left: 50%; }
.stage::after { height: 1px; width: 100%; left: 0; top: 50%; }
particle-cloud { position: absolute; inset: 0; display: block; outline: none; touch-action: none; }
particle-cloud:focus-visible { box-shadow: inset 0 0 0 1px var(--warm); }
.sample-state {
  position: absolute; z-index: 2; inset: auto 16px 16px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; pointer-events: none;
}
.sample-state[hidden] { display: none; }
.sample-state .button { pointer-events: auto; }
.eyebrow { margin: 0; color: #b4b1a8; font: 9px var(--mono); letter-spacing: .18em; }
.image-loader {
  position: absolute; z-index: 3; inset: 0; display: grid; place-items: center;
  padding: 16px; background: rgba(6, 6, 6, .46); pointer-events: none;
}
.image-loader[hidden] { display: none; }
.loader-panel {
  width: min(300px, 100%); display: grid; grid-template-columns: 18px minmax(0, 1fr);
  gap: 5px 12px; padding: 15px 16px; border: 1px solid #343430; background: #0d0d0c;
}
.loader-spinner {
  grid-row: 1 / 3; align-self: center; width: 18px; height: 18px;
  border: 1px solid #4a4a45; border-top-color: var(--warm); border-radius: 50%;
  animation: loader-spin .8s linear infinite;
}
.loader-step { color: #d8d6ce; font: 9px var(--mono); letter-spacing: .15em; }
.loader-detail { color: #777872; font: 8px var(--mono); letter-spacing: .09em; }
.loader-meter { grid-column: 1 / -1; display: block; height: 1px; margin-top: 7px; overflow: hidden; background: #292a28; }
.loader-meter span {
  display: block; width: 35%; height: 100%; background: var(--warm);
  animation: loader-sweep 1.25s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes loader-spin { to { transform: rotate(360deg); } }
@keyframes loader-sweep { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
@media (prefers-reduced-motion: reduce) {
  .loader-spinner, .loader-meter span { animation: none; }
  .loader-meter span { width: 100%; opacity: .5; }
}
.drag-hint {
  position: absolute; z-index: 3; inset: 12px; display: grid; place-items: center;
  border: 1px dashed var(--warm); background: rgba(8,8,8,.78); color: var(--warm);
  font: 11px var(--mono); letter-spacing: .25em; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.stage.dragging .drag-hint { opacity: 1; }
body.hide-ui .topbar, body.hide-ui .inspector, body.hide-ui .stage-topline, body.hide-ui .stage-bottomline { display: none; }
body.hide-ui .studio { display: grid; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 0; }
body.hide-ui .workspace { height: 100vh; height: 100dvh; min-height: 0; padding: 0; }
body.hide-ui .stage { border: 0; background: #050505; }
body.hide-ui .stage::before, body.hide-ui .stage::after { display: none; }

.inspector { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #353530 transparent; scrollbar-width: thin; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.panel { padding: 20px 18px 19px; border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 16px; color: #aaa99f; font: 9px var(--mono); letter-spacing: .16em; }
.panel-mark { color: var(--dim); font-size: 14px; }
.muted { color: #5f605b; font-size: 8px; }
.upload-box {
  min-height: 66px; display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid #2a2a28; cursor: pointer; transition: border-color .18s, background .18s;
}
.upload-box:hover { border-color: #6b675e; background: #10100f; }
.upload-plus { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #3c3c39; color: var(--warm); font-size: 17px; }
.upload-box strong, .upload-box small, .source-info strong, .source-info small { display: block; }
.upload-box strong { font: 10px var(--mono); letter-spacing: .12em; }
.upload-box small { margin-top: 6px; color: #696a65; font: 8px var(--mono); letter-spacing: .05em; }
.upload-arrow { margin-left: auto; color: #777871; font-size: 13px; }
.file-picker { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-picker:focus-visible + .source-row { outline: 1px solid var(--warm); }
.source-row { display: flex; align-items: center; gap: 10px; padding-top: 12px; }
.source-row[hidden] { display: none; }
.source-gallery { display: flex; gap: 7px; padding-top: 10px; }
.source-gallery[hidden], .gallery-nav[hidden] { display: none; }
.gallery-thumb { width: 34px; height: 34px; border: 1px solid #333; background-position: center; background-size: cover; color: white; cursor: pointer; font: 8px var(--mono); text-shadow: 0 1px 3px #000; opacity: .55; }
.gallery-thumb.active { border-color: var(--warm); opacity: 1; }
.gallery-thumb[data-state="queued"], .gallery-thumb[data-state="reading"], .gallery-thumb[data-state="depth"] { background-color: #181816; }
.gallery-thumb[data-state="failed"] { border-color: #9b5d5d; color: #ffd0c8; opacity: 1; }
.gallery-nav { display: flex; justify-content: space-between; align-items: center; padding-top: 9px; color: #71726c; font: 8px var(--mono); letter-spacing: .1em; }
.gallery-nav kbd { margin-left: 3px; }
.thumb { width: 42px; height: 42px; flex: 0 0 42px; background-size: cover; background-position: center; border: 1px solid #333; }
.source-info { flex: 1; min-width: 0; }
.source-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 500; }
.source-info small { margin-top: 5px; color: var(--muted); font: 9px var(--mono); }
.icon-button { width: 27px; height: 27px; border: 1px solid #30302d; background: transparent; color: #999; font-size: 18px; cursor: pointer; }
.icon-button:hover { color: var(--warm); border-color: #6b675e; }

.range-control { display: block; margin: 0 0 18px; }
.range-control > span { display: flex; justify-content: space-between; margin-bottom: 8px; color: #999a94; font: 9px var(--mono); letter-spacing: .13em; }
.range-control output { color: #dad9d1; }
input[type="range"] { display: block; width: 100%; height: 3px; margin: 0; appearance: none; background: #292a28; cursor: pointer; accent-color: var(--warm); }
input[type="range"]::-webkit-slider-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; appearance: none; background: var(--warm); box-shadow: 0 0 10px rgba(255,233,196,.16); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--warm); }
.line-control { display: flex; justify-content: space-between; align-items: flex-start; margin: -2px 0 12px; }
#line-pad { width: 82px; height: 82px; border: 1px solid #292a28; background: #090909; touch-action: none; cursor: crosshair; }
#line-pad:focus-visible { outline: 1px solid var(--warm); outline-offset: 3px; }
#line-side { fill: rgba(255,233,196,.08); }
.line-frame { fill: none; stroke: #4a4a45; stroke-width: .018; }
#line-axis { stroke: #a8a69f; stroke-width: .018; }
#line-stem { stroke: var(--warm); stroke-width: .026; }
#line-tip { fill: var(--warm); }
.line-end { fill: #0b0b0a; stroke: var(--warm); stroke-width: .025; }
.color-control { padding-top: 3px; }
.control-label { display: block; margin-bottom: 9px; color: #999a94; font: 9px var(--mono); letter-spacing: .13em; }
.swatches { display: flex; align-items: center; gap: 9px; }
.interaction-control, .mode-row { margin-top: 18px; }
.mode-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-pair .control-label { margin-bottom: 8px; }
.mode-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; }
.mode-button { border: 0; border-bottom: 1px solid transparent; padding: 0 0 4px; background: transparent; color: #777872; cursor: pointer; font: 8px var(--mono); letter-spacing: .14em; transition: color .16s, border-color .16s; }
.mode-button:hover, .mode-button.active { color: var(--text); }
.mode-button.active { border-bottom-color: #777872; }
.mode-button:focus-visible { outline: 1px solid var(--warm); outline-offset: 4px; }
.swatch, .custom-color { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); padding: 0; cursor: pointer; }
.swatch { background: var(--swatch); }
.swatch.selected { outline: 1px solid var(--swatch); outline-offset: 3px; }
.swatch[data-color="#ffe9c4"] { --swatch: #ffe9c4; }
.swatch[data-color="#d7eaff"] { --swatch: #d7eaff; }
.swatch[data-color="#ffb86a"] { --swatch: #ffb86a; }
.swatch[data-color="#9cddae"] { --swatch: #9cddae; }
.swatch[data-color="#d3a8ff"] { --swatch: #d3a8ff; }
.custom-color {
  width: 20px; height: 20px; padding: 3px; border: 0; border-radius: 50%; overflow: hidden;
  background: conic-gradient(#ff4c4c, #ffd84a, #6fdb78, #45d8d1, #5685f4, #a65ced, #ef5ba9, #ff4c4c);
}
.custom-color::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color::-webkit-color-swatch { border: 1px solid #111; border-radius: 50%; }
.button-row { display: flex; gap: 8px; margin-top: 21px; }
.button, .download-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 37px;
  border: 1px solid #30302d; padding: 0 12px; background: transparent; color: #aaa9a2;
  font: 9px var(--mono); letter-spacing: .1em; cursor: pointer; transition: .16s;
}
.button:hover:not(:disabled), .download-button:hover:not(:disabled) { border-color: #69675f; color: var(--text); }
.button-light { background: var(--warm); border-color: var(--warm); color: #181714; font-weight: 600; }
.button-light:hover:not(:disabled) { background: #fff5e1; color: #111; }
.button-quiet { flex: 1; padding: 0 7px; min-width: 0; }
.button:disabled, .download-button:disabled { cursor: not-allowed; opacity: .35; }
kbd { color: #74746d; font: 8px var(--mono); }

.export-copy { margin: -3px 0 14px; color: #777872; font-size: 11px; line-height: 1.6; }
.export-actions { display: grid; gap: 7px; }
.export-actions > .button { width: 100%; }
.download-button { width: 100%; justify-content: space-between; font-size: 8px; color: #777872; }
.download-button span { font-size: 14px; color: var(--warm); }
.code-details { margin-top: 12px; border-top: 1px solid var(--soft-line); }
.code-details summary { padding: 11px 0 0; list-style: none; cursor: pointer; color: #656660; font: 8px var(--mono); letter-spacing: .14em; }
.code-details summary::-webkit-details-marker { display: none; }
.code-details summary::after { content: "+"; float: right; font-size: 12px; }
.code-details[open] summary::after { content: "−"; }
#embed-code {
  width: 100%; height: 106px; margin-top: 10px; resize: vertical; border: 1px solid #252523;
  background: #090909; color: #aaa99f; padding: 9px; font: 8px/1.5 var(--mono);
}
.inspector-footer { margin-top: auto; padding: 13px 18px; display: flex; justify-content: space-between; gap: 8px; color: #50514c; font: 7px var(--mono); letter-spacing: .13em; }

.toast {
  position: fixed; z-index: 10; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  padding: 10px 14px; border: 1px solid #42423d; background: #121210; color: var(--text);
  font: 10px var(--mono); letter-spacing: .04em; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.warning-dialog {
  width: min(430px, calc(100vw - 32px)); max-width: none; padding: 0;
  border: 1px solid #383833; background: #0d0d0d; color: var(--text);
}
.warning-dialog::backdrop { background: rgba(0, 0, 0, .76); }
.warning-card { padding: 24px; }
.warning-kicker {
  display: flex; align-items: center; gap: 9px; margin: 0;
  color: #d3b582; font: 9px var(--mono); letter-spacing: .16em;
}
.warning-kicker::before { width: 5px; height: 5px; border-radius: 50%; background: #d3b582; content: ""; }
.warning-card h2 { margin: 19px 0 10px; font: 500 20px/1.2 var(--sans); letter-spacing: -.03em; }
.warning-copy { margin: 0; color: #aaa99f; font-size: 12px; line-height: 1.7; }
.warning-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.warning-actions .button { flex: 0 0 auto; }
@media (max-width: 980px) {
  .studio { grid-template-columns: minmax(0, 1fr) 300px; }
  .workspace { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 15px; }
  .topnote { display: none; }
  .studio { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(240px, 44%) minmax(0, 1fr); height: calc(100vh - 54px); height: calc(100dvh - 54px); }
  .workspace { min-height: 0; padding: 12px 12px 10px; }
  .stage { min-height: 0; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
  .panel { padding-left: 16px; padding-right: 16px; }
  .inspector-footer { padding: 13px 16px; }
}
@media (max-width: 420px) {
  .credit { font-size: 8px; }
  .wordmark { gap: 5px; }
  .wordmark > span { font-size: 12px; }
  .wordmark small { font-size: 8px; }
  .stage-bottomline { font-size: 7px; }
  .button-row { flex-direction: column; }
  .mode-pair { gap: 8px; }
  .warning-card { padding: 20px; }
  .warning-actions .button { padding: 0 8px; font-size: 8px; }
}
