:root {
  color-scheme: dark;
  font: 13px/1.45 Inter, "Segoe UI", system-ui, sans-serif;
  color: #eeedf4;
  background: #101214;
  --panel: #191b1e;
  --line: #33363a;
  --quiet: #a5aaaf;
  --accent: #ffab72;
  --mono: "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #211710;
  background: var(--accent);
  font-weight: 650;
  white-space: nowrap;
}
button:hover { background: #ffc398; }
button:disabled { opacity: .42; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.secondary {
  border-color: var(--line);
  background: #26242d;
  color: #f2edf9;
}
.secondary:hover { background: #34303c; }

.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
@media (min-width: 801px) and (min-height: 600px) {
  .app-shell { height: 100dvh; }
  .app-shell .workspace { min-height: 0; }
}
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.identity, .project-buttons { display: flex; align-items: center; gap: 8px; }
.identity { gap: 11px; }
.identity h1 { font-size: 19px; letter-spacing: -.06em; margin: 0; }
.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  background: var(--accent);
  display: grid;
  place-items: center;
}
.brand-mark::before {
  content: "";
  width: 15px;
  height: 11px;
  border: 2px solid #2c1e3b;
  border-radius: 50%;
  transform: rotate(-35deg);
  box-shadow: inset 0 0 0 2px #ffab72, inset 0 0 0 3px #2c1e3b;
}
#save-image { justify-self: end; }
#save-image span { margin-left: 4px; }

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 292px;
  grid-template-areas: "library stage inspector";
  min-height: min(690px, calc(100dvh - 95px));
  flex: 1;
}
.stage { grid-area: stage; min-width: 0; display: flex; flex-direction: column; }
.panel-heading {
  min-height: 50px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 650; }
.panel-heading span, .muted { color: var(--quiet); font-size: 11px; }
.stage-heading { display: grid; grid-template-columns: 1fr auto 1fr; background: #19181f; }
#canvas-info { justify-self: end; font-family: var(--mono); white-space: nowrap; }
.view-switch { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; }
.view-button { font-size: 11px; padding: 4px 9px; color: var(--quiet); background: transparent; }
.view-button[aria-pressed="true"] { color: #f6ecff; background: #3d304e; }
.view-button:not(:disabled):hover { background: #4a3a5b; color: #fff; }

.preset-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; }
.preset-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  white-space: normal;
  background: #24222b;
  border-color: var(--line);
  color: #f4f0fa;
  text-align: left;
}
.preset-card:hover { background: #302a3b; border-color: #846c9f; }
.preset-card[aria-pressed="true"] { border-color: var(--accent); background: #322741; }
.preset-swatch { width: 100%; aspect-ratio: 1.35; border-bottom: 1px solid #ffffff1f; }
.swatch-editorial {
  background:
    radial-gradient(circle, #211c27 1px, transparent 2px) 0 0 / 5px 5px,
    conic-gradient(from 130deg at 70% 40%, #e7c996, #8d4c43, #211c27, #e7c996);
}
.swatch-signal {
  background:
    repeating-linear-gradient(0deg, #08001645 0 2px, transparent 2px 5px),
    linear-gradient(149deg, #26235d 24%, #c152aa 24% 37%, #b3e8f7 37% 43%, #5423a0 43% 63%, #fa91a4 63%);
}
.swatch-dream { background: radial-gradient(ellipse at 26% 75%, #f2aece 0, #a767e6 28%, #4d467e 52%, #1b1732 76%); }
.swatch-retro { background: repeating-linear-gradient(90deg, #484164 0 12%, #7f6793 12% 27%, #f0ac94 27% 39%, #e9d8a5 39% 51%); }
.preset-copy { display: block; padding: 7px 6px 8px; }
.preset-copy strong { font-size: 11px; }

.canvas-container {
  position: relative;
  flex: 1;
  min-height: 380px;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #272130, #131216 76%);
}
.canvas-container::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(#aaa0bc44 1px, transparent 1px) 0 0 / 19px 19px;
  mask-image: radial-gradient(ellipse, black, transparent 82%);
}
.canvas-container.is-dragging { box-shadow: inset 0 0 0 2px var(--accent); }
canvas {
  position: relative;
  display: block;
  max-width: 100%;
  max-height: min(65dvh, max(280px, calc(100dvh - 254px)), 720px);
  object-fit: contain;
  box-shadow: 0 18px 55px #0009;
}
.canvas-container:has(.empty-message:not([hidden])) canvas { visibility: hidden; }
.empty-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 18px;
}
.empty-message[hidden] { display: none; }
.empty-message h2 { font-size: clamp(20px, 2.5vw, 27px); letter-spacing: -.045em; margin: 0; }
.empty-message p { color: var(--quiet); margin: 0 0 8px; }
.empty-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.empty-art {
  width: 140px;
  height: 76px;
  margin-bottom: 12px;
  transform: rotate(-14deg);
  border-radius: 50%;
  background: repeating-radial-gradient(ellipse at center, transparent 0 6px, #c69cfcbf 7px 8px, transparent 9px 12px);
  box-shadow: 0 0 54px #914ccb2d;
}

.transport {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: start;
  padding: 12px 15px;
  border-top: 1px solid var(--line);
  background: #19181f;
}
#play-toggle { min-width: 37px; padding: 6px; }
.timeline { padding-top: 2px; }
.timeline-ticks { display: flex; justify-content: space-between; color: var(--quiet); font: 10px var(--mono); }
#time-label, #loop-label { font-family: var(--mono); margin-top: 6px; white-space: nowrap; }
#time-label { color: var(--accent); min-width: 6ch; }

select {
  width: 100%;
  padding: 8px 9px;
  border-radius: 5px;
  border: 1px solid #45494e;
  background: #26292e;
  color: #eeeae6;
  font-weight: 600;
}
.control-label { display: flex; justify-content: space-between; gap: 8px; color: var(--quiet); font-size: 11px; }
.control-label output { color: var(--accent); font-family: var(--mono); }
input[type="range"] { display: block; width: 100%; height: 16px; margin: 0; cursor: ew-resize; }
input { accent-color: var(--accent); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 15px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--quiet);
  font-size: 11px;
}
#status-message { margin: 0; overflow-wrap: anywhere; }
#status-message.error { color: #ffb1c7; }
footer > span { flex: none; }


.workspace { grid-template-areas: "stage dock"; grid-template-columns: minmax(0, 1fr) 312px; }
.topbar { padding: 10px 18px; background: #181a1c; }
.identity h1 { font-family: "Archivo Black", Inter, system-ui, sans-serif; letter-spacing: -.065em; }
.brand-mark { border-radius: 50% 50% 50% 5px; transform: rotate(-8deg); }
.dock { grid-area: dock; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; overflow: auto; }
.dock-nav, .mode-switch { display:flex; gap: 4px; }
.dock-nav { position:sticky; z-index:2; top:0; padding:9px 12px; background:#191b1ef5; border-bottom:1px solid var(--line); }
.dock-nav button, .mode-switch button, #board-tools button { background:transparent; color:var(--quiet); }
.dock-nav button { flex:1; }
.dock-nav button[aria-pressed="true"], .mode-switch button[aria-pressed="true"], #board-tools button[aria-pressed="true"] {
  background:#37332f; color:#ffc397;
}
[hidden] { display:none !important; }
.stage-heading { grid-template-columns:auto 1fr auto; padding:6px 15px; background:#151719; min-height:46px; }
.view-switch { justify-self:end; }
.view-button[aria-pressed="true"] { background:#383b40; color:white; }
.mode-switch button { padding:5px 10px; }
.stage { min-height:0; }
.canvas-container { isolation:isolate; display:block; padding:0; min-height:240px; background-color:#101214; background-image:radial-gradient(circle, rgb(161 161 170 / var(--grid-opacity, .19)) var(--grid-dot, .65px), transparent calc(var(--grid-dot, .65px) + .3px)); background-size:var(--grid-size, 12px) var(--grid-size, 12px); background-position:var(--grid-x,0px) var(--grid-y,0px); touch-action:none; }
.canvas-container::before { display:none; }
.canvas-container[data-mode="focus"] { background:#101214; }
.canvas-container[data-tool="hand"][data-mode="canvas"] { cursor:grab; }
#artboard { position:absolute; left:50%; top:50%; user-select:none; outline:1px solid #d6a17b; box-shadow:0 12px 38px #0006; }
#artboard canvas { width:100%; height:100%; max-width:none; max-height:none; box-shadow:none; }
[data-tool="move"][data-mode="canvas"] #artboard { cursor:move; }
.frame-caption { color:#e7c6ad; font:11px var(--mono); position:absolute; bottom:100%; padding-bottom:7px; left:0; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#scale-frame { width:12px; height:12px; padding:0; border:2px solid #37281f; background:#ffbd89; position:absolute; bottom:-6px; right:-6px; border-radius:2px; cursor:nwse-resize; }
[data-mode="focus"] #artboard { outline:none; }
[data-mode="focus"] :is(.frame-caption,#scale-frame),[data-tool="hand"] #scale-frame { display:none; }
#board-tools { display:flex; align-items:center; gap:2px; position:absolute; bottom:12px; left:50%; transform:translateX(-50%); padding:4px; border:1px solid #484b50; border-radius:9px; background:#202225f8; box-shadow:0 4px 18px #0006; cursor:default; }
#board-tools button { padding:5px 8px; font-size:12px; }
#board-tools button:hover,.dock-nav button:hover,.mode-switch button:hover { background:#343639; }
#board-tools output { font:11px var(--mono); text-align:center; min-width:4ch; }
#board-tools i { width:1px; height:18px; background:var(--line); }
.transport { background:#191b1e; padding:9px 15px; }
.preset-swatch { aspect-ratio:1.8; }
.preset-copy { padding:8px; }
.preset-card[aria-pressed="true"] { background:#362d28; }
.control-row { padding:8px 10px; }
.secondary { background:#25272a; }
.secondary:hover { background:#313438; }
@media (max-width:850px) and (min-width:701px) {
  .workspace { grid-template-columns:minmax(0,1fr) 240px; }
}
@media (max-width:700px) {
  .workspace { grid-template-columns:minmax(0,1fr); grid-template-areas:"stage" "dock"; }
  .stage { height:clamp(390px,62dvh,620px); }
  .dock { border-left:0; border-top:1px solid var(--line); }
  .dock-nav { position:static; }
  .topbar { padding:8px 10px; gap:6px; }
  .project-buttons { gap:3px; }
  .topbar button { padding:6px; font-size:11px; }
  .identity { gap:5px; }
  .identity h1 { font-size:16px; }
  .brand-mark { width:22px; height:22px; }
  .stage-heading { padding-inline:8px; gap:4px; }
  #canvas-info { font-size:10px; }
  .mode-switch button,.view-button { padding:4px; }
  .transport { gap:6px; }
  footer { flex-wrap:wrap; }
}
@media (max-width:390px) {
  .topbar { grid-template-columns:1fr auto; }
  .project-buttons { grid-row:2; grid-column:1/-1; }
  .project-buttons button { flex:1; }
  #save-image { grid-row:1; grid-column:2; }
}

.dock { background: #191b1e; }
.dock-nav { padding: 0 14px; gap: 16px; }
.dock-nav button {
  flex: 0 1 auto;
  padding: 12px 3px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.dock-nav button[aria-pressed="true"] { background: transparent; border-color: var(--accent); color: #f8eee7; }
.dock-nav button:hover { background: transparent; color: #fff; }
.layer-page { padding: 14px; }
.layer-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.layer-actions select { background: #24272a; padding: 7px; }
#open-looks { padding: 6px 10px; }
#open-looks[aria-expanded="true"] { border-color: #a07b65; color: #ffc397; }
#looks-panel .preset-list { padding: 10px 0 0; }
.layer-heading, .control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 18px 0 9px;
}
.layer-heading h2 { margin: 0; font-size: 11px; font-weight: 650; color: #cac7c4; }
.layer-heading span, .control-heading span { font: 10px var(--mono); color: var(--quiet); white-space: nowrap; }
.layer-list { display: grid; gap: 4px; }
.layer-row {
  display: flex;
  gap: 2px;
  align-items: center;
  min-height: 37px;
  padding: 2px 5px;
  background: #222528;
  border: 1px solid #35393c;
  border-radius: 5px;
  color: #efeeeb;
}
.layer-row:hover { border-color: #63615e; }
.layer-row.is-selected, .source-layer[aria-pressed="true"] { border-color: #93705a; background: #2c2724; }
.layer-row.is-bypassed .layer-name { color: #a4a6a8; }
.layer-name {
  padding: 5px 4px;
  background: transparent;
  color: inherit;
  min-width: 0;
  flex: 1;
  text-align: left;
  text-overflow: ellipsis;
  overflow: hidden;
}
.layer-name:hover { background: #ffffff0d; }
.layer-name::before {
  content: "";
  display: inline-block;
  vertical-align: 1px;
  width: 5px;
  height: 5px;
  margin: 0 8px 1px 0;
  transform: rotate(45deg);
  background: #d8a583;
}
.layer-row.is-bypassed .layer-name::before { background: #777b7f; }
.layer-icon-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 23px;
  height: 26px;
  padding: 0;
  color: #bfc1c3;
  background: transparent;
}
.layer-icon-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.layer-icon-button:hover:not(:disabled) { background: #3b3d40; color: #fff; }
.layer-icon-button[aria-pressed="false"] { color: #989b9e; }
.layer-icon-button:disabled { opacity: .27; }
.source-heading { border-top: 1px solid var(--line); padding-top: 13px; }
.source-layer { padding: 4px 6px; width: 100%; gap: 8px; text-align: left; }
.source-layer:hover { background: #29292a; }
#source-thumb { width: 32px; height: 24px; border-radius: 3px; background: #0f1011; box-shadow: none; }
.source-layer:not(.has-source) #source-thumb { border: 1px dashed #626469; }
#source-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-chevron { color: var(--quiet); margin-right: 3px; }
.layer-empty { margin: 0; padding: 9px 0; font-size: 12px; color: var(--quiet); }
.control-heading { margin: 0 0 4px; }
.control-heading h2 { margin: 0; font-size: 16px; }
.layer-category { margin: 0 0 14px; color: var(--quiet); font-size: 11px; }
#controls-page .control-row { padding: 11px 0; border-top: 1px solid var(--line); }
#controls-page .control-label { margin-bottom: 6px; font-size: 12px; }
.remove-layer { width: auto; height: auto; padding: 6px 8px; margin-top: 12px; color: #f2aba7; border-color: #674542; }
#source-preview {
  width: 100%;
  height: auto;
  max-height: none;
  margin: 13px 0 10px;
  background: #101112;
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: none;
}
.replace-image { width: 100%; margin-top: 8px; }

.control-section-title { margin: 16px 0 8px; font-size: 11px; color: var(--quiet); font-weight: 650; }
.control-toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.control-choice { display: grid; gap: 6px; margin: 6px 0 16px; color: var(--quiet); font-size: 12px; }

/* Export runs on a separate WebGL canvas, leaving the editor preview untouched. */
.export-dialog {
  box-sizing: border-box;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px;
  color: #f8f4f1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 85px #000a;
}
.export-dialog::backdrop { background: rgb(0 0 0 / .72); backdrop-filter: blur(4px); }
.export-dialog h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.04em; }
.export-description { color: var(--quiet); font-size: 12px; line-height: 1.6; margin: 8px 0 16px; }
.export-dimensions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.export-dimensions label { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; color: var(--quiet); font-size: 12px; }
.export-dimensions label span { color: var(--quiet); font-size: 11px; }
.export-dimensions input { box-sizing: border-box; grid-column: 1 / -1; width: 100%; min-width: 0; padding: 10px 12px; color: #fff; border: 1px solid var(--line); border-radius: 7px; background: #101214; font: 13px var(--mono); }
.export-aspect { display: flex; align-items: center; gap: 8px; margin-top: 15px; color: #e4dfdb; font-size: 12px; }
.export-feedback { min-height: 18px; color: #95e2bd; font-size: 12px; line-height: 1.5; margin: 12px 0; }
.export-feedback.error { color: #ff9f9f; }
.export-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.control-choice select { padding: 6px 8px; font-size: 12px; }
.control-actions { display: flex; gap: 7px; }
.control-actions > button { flex: 1; min-width: 0; padding-inline: 5px; }
.source-edit { margin-top: 13px; }
.source-edit summary { cursor: pointer; padding: 9px; border: 1px solid var(--line); border-radius: 6px; }
.source-edit .control-row:first-of-type { margin-top: 6px; }
#source-parameters { margin-top: 12px; }

.source-layer.is-source-hidden #source-thumb { opacity: .35; }
