:root {
  color-scheme: dark;
  --ink: #06080b;
  --surface: #0b0e12;
  --surface-raised: #11161c;
  --surface-soft: #171d24;
  --line: #252c35;
  --line-soft: #1a2027;
  --paper: #edf4fb;
  --muted: #7f8a97;
  --blue: #3498ff;
  --blue-bright: #6bb9ff;
  --blue-soft: rgba(52, 152, 255, 0.13);
  --success: #69d4a6;
  --warning: #e8c36e;
  --editor-topbar-height: 2.5rem;
  --editor-rail-width: 4.75rem;
  --editor-inspector-width: 16rem;
  --artboard-checker-size: 1.2rem;
  --artboard-view-scale: 1;
  font-family: Inter, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--paper);
  background: var(--ink);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 20rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

.editor-topbar {
  position: relative;
  z-index: 40;
  display: grid;
  height: var(--editor-topbar-height);
  grid-template-columns: 10.75rem auto minmax(16rem, 1fr) 8.75rem auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 8, 11, 0.98);
}

.editor-brand {
  display: flex;
  height: 100%;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.65rem;
  border-right: 1px solid var(--line);
  color: #f5f5f5;
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-decoration: none;
}

.editor-brand > span:last-child > span {
  color: #aaa;
}

.editor-brand-mark {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  border: 0;
  background: linear-gradient(#fff, #fff) center / calc(100% - 4px) calc(100% - 4px) no-repeat;
  color: #000;
  font: 0.76rem Georgia, "Times New Roman", serif;
}

.editor-menu {
  display: flex;
  height: 100%;
  align-items: center;
  border-right: 1px solid var(--line);
}

.editor-menu button {
  height: 100%;
  padding: 0 0.62rem;
  border: 0;
  border-right: 1px solid var(--line-soft);
  color: #8a96a3;
  background: transparent;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.editor-toolbar {
  display: flex;
  min-width: 0;
  height: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 0.42rem;
  padding: 0 0.5rem;
  border-right: 1px solid var(--line);
}

.editor-categories {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  height: 100%;
  align-items: stretch;
}

.editor-categories button {
  flex-shrink: 0;
  min-width: 0;
  padding: 0 clamp(0.42rem, 0.62vw, 0.72rem);
  border: 0;
  border-right: 1px solid var(--line-soft);
  color: #8895a2;
  background: transparent;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 720;
}

.editor-categories button:first-child {
  border-left: 1px solid var(--line-soft);
}

.editor-categories button[data-state="active"]:hover {
  color: #dceaf6;
  background: #10161c;
}

.editor-categories button[data-state="dormant"] {
  color: #596571;
  background: rgba(12, 16, 21, 0.45);
}

.editor-menu button:hover:not(:disabled) {
  color: #dce9f5;
  background: #10151b;
}

#open-local:target {
  color: #e8f5ff;
  background: #17466f;
  box-shadow: inset 0 -2px var(--blue-bright);
}

.editor-menu button:disabled {
  color: #596571;
}

.document-title {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0 0.62rem;
}

.document-title span {
  overflow: hidden;
  color: #b9c2cb;
  font-size: 0.56rem;
  font-weight: 830;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-title small {
  color: #4d5864;
  font-size: 0.5rem;
}

.topbar-actions {
  display: flex;
  height: 100%;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.62rem;
}

.save-policy {
  color: #53606d;
  font-size: 0.5rem;
  font-weight: 720;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Autosave text changes must not resize the header's automatic action column. */
.editor-page .save-policy {
  flex: 0 0 12rem;
  width: 12rem;
  overflow-wrap: anywhere;
}

.toolbar-credit-actions {
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-credit-actions .billing-control {
  flex-shrink: 0;
}

.billing-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.65rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid #34404d;
  border-radius: 0.25rem;
  color: #c0cedc;
  background: #111820;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.billing-control:hover {
  border-color: var(--blue-bright);
  color: var(--paper);
}

.billing-control-primary {
  border-color: #2e6d9e;
  color: #cae6ff;
  background: #142d43;
}

.credit-dialog {
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 1.4rem;
  border: 1px solid #34485b;
  border-radius: 0.65rem;
  color: var(--paper);
  background: linear-gradient(145deg, #132231, #0b1017 65%);
  box-shadow: 0 1.5rem 6rem #0009;
}

.credit-dialog::backdrop {
  background: #03070cbb;
  backdrop-filter: blur(4px);
}

.credit-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.credit-dialog-eyebrow {
  color: var(--blue-bright);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.credit-dialog-close {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.25rem;
  color: #adc0d2;
  background: #ffffff08;
  font-size: 1.25rem;
  cursor: pointer;
}

.credit-dialog h2 {
  margin: 1rem 0 0.7rem;
  font-size: 1.4rem;
}

.credit-dialog p {
  color: #b8c5d2;
  font-size: 0.86rem;
  line-height: 1.6;
}

.credit-dialog .credit-dialog-note {
  color: #8295a7;
  font-size: 0.75rem;
}

.credit-dialog-amounts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: #050a0f88;
  font-size: 0.8rem;
}

.credit-dialog-amounts dd {
  margin: 0;
  font-weight: 800;
}

.credit-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.4rem;
}

.credit-dialog-actions .billing-control {
  min-height: 2.3rem;
  font-size: 0.64rem;
}

.editor-shell {
  display: grid;
  height: calc(100vh - var(--editor-topbar-height));
  height: calc(100dvh - var(--editor-topbar-height));
  grid-template-columns: var(--editor-rail-width) minmax(0, 1fr) var(
    --editor-inspector-width
  );
}

.tool-rail {
  display: flex;
  min-height: 0;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  background: #000;
}

.rail-group {
  display: grid;
}

.rail-group-bottom {
  border-top: 1px solid var(--line);
}

.rail-button,
.rail-home {
  display: grid;
  height: 4rem;
  place-items: center;
  align-content: center;
  gap: 0.28rem;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: #66717d;
  background: transparent;
  text-decoration: none;
}

.rail-button {
  cursor: pointer;
}

.rail-button span,
.rail-home span {
  font-size: 1rem;
}

.rail-button small,
.rail-home small {
  font-size: 0.5rem;
  font-weight: 780;
}

.rail-button:hover:not(:disabled),
.rail-home:hover {
  color: #b9cfe1;
  background: #10161d;
}

.rail-button:disabled {
  color: #343c45;
}

.rail-button-active {
  color: var(--blue-bright);
  background: var(--blue-soft);
  box-shadow: inset 2px 0 var(--blue);
}

.rail-ai-button {
  color: var(--blue-bright);
  background: rgba(52, 152, 255, 0.08);
}

.workspace {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #000;
}

.workspace-context-bar {
  display: none;
}

.workspace-properties-bar {
  min-height: 1.6rem;
  display: grid;
  align-items: center;
  padding: 0 0.6rem;
  border-bottom: 1px solid var(--line);
  background: #020406;
  color: #4f5d6c;
  font-size: 0.44rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.workspace-properties-label {
  opacity: 0.85;
}

.workspace-meta {
  display: none;
}

.workspace-stage {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  align-content: center;
  gap: 0.65rem;
  overflow: hidden;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  touch-action: none;
}

.floating-ai-launcher {
  position: absolute;
  z-index: 12;
  right: clamp(0.75rem, 1.5vw, 1.25rem);
  bottom: clamp(0.75rem, 1.5vw, 1.25rem);
  display: grid;
  width: 3.35rem;
  min-width: 3.35rem;
  height: 3.35rem;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(76, 164, 242, 0.62);
  border-radius: 50%;
  color: #e7f3fd;
  background: linear-gradient(145deg, rgba(18, 29, 40, 0.94), rgba(7, 12, 18, 0.88));
  box-shadow:
    0 0.7rem 1.8rem rgba(0, 0, 0, 0.42),
    0 0 1.2rem rgba(52, 152, 255, 0.14),
    inset 0 0 1rem rgba(74, 169, 255, 0.08);
  backdrop-filter: blur(0.7rem);
  -webkit-backdrop-filter: blur(0.7rem);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.floating-ai-launcher:hover {
  border-color: rgba(107, 185, 255, 0.9);
  background: linear-gradient(145deg, rgba(23, 39, 54, 0.96), rgba(9, 18, 27, 0.9));
  box-shadow:
    0 0.8rem 2rem rgba(0, 0, 0, 0.46),
    0 0 1.45rem rgba(52, 152, 255, 0.2),
    inset 0 0 1.1rem rgba(74, 169, 255, 0.11);
}

.floating-ai-launcher[data-dragging="true"] {
  cursor: grabbing;
  transition: none;
}

.prometheus-launcher-mark {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  color: #dff1ff;
  font: 1.18rem Georgia, "Times New Roman", serif;
  text-shadow: 0 0 0.8rem rgba(107, 185, 255, 0.34);
}

.prometheus-launcher-mark::before {
  position: absolute;
  z-index: -1;
  inset: 0.12rem 0.18rem;
  border: 1px solid rgba(103, 184, 255, 0.5);
  border-radius: 55% 45% 54% 46% / 63% 58% 42% 37%;
  background: rgba(23, 70, 111, 0.22);
  content: "";
  transform: rotate(8deg);
}

.prometheus-launcher-mark::after {
  position: absolute;
  right: 0.28rem;
  bottom: 0.15rem;
  width: 0.18rem;
  height: 0.72rem;
  border: 1px solid rgba(173, 218, 255, 0.72);
  background: #102333;
  box-shadow: 0 0 0.55rem rgba(52, 152, 255, 0.22);
  clip-path: polygon(0 0, 100% 0, 100% 82%, 50% 100%, 0 82%);
  content: "";
  transform: rotate(38deg);
  transform-origin: center;
}

.floating-ai-tooltip {
  position: absolute;
  top: 50%;
  right: calc(100% + 0.6rem);
  width: max-content;
  max-width: 12rem;
  padding: 0.52rem 0.65rem;
  visibility: hidden;
  border: 1px solid rgba(76, 164, 242, 0.42);
  color: #c7d8e6;
  background: rgba(7, 12, 17, 0.94);
  box-shadow: 0 0.7rem 1.6rem rgba(0, 0, 0, 0.4);
  font-size: 0.66rem;
  font-weight: 720;
  line-height: 1.3;
  letter-spacing: 0.025em;
  opacity: 0;
  pointer-events: none;
  transform: translate(0.25rem, -50%);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  white-space: nowrap;
}

.floating-ai-launcher[data-tooltip-side="right"] .floating-ai-tooltip {
  right: auto;
  left: calc(100% + 0.6rem);
  transform: translate(-0.25rem, -50%);
}

.floating-ai-launcher:hover .floating-ai-tooltip,
.floating-ai-launcher:focus .floating-ai-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translate(0, -50%);
}

.floating-ai-launcher[data-dragging="true"] .floating-ai-tooltip {
  visibility: hidden;
  opacity: 0;
}

.workspace-stage[data-pan-enabled="true"] {
  cursor: grab;
}

.workspace-stage[data-panning="true"] {
  cursor: grabbing;
  user-select: none;
}

.artboard {
  position: relative;
  display: grid;
  width: min(72vh, calc(100vw - 24rem));
  width: min(72dvh, calc(100vw - 24rem));
  min-width: 18rem;
  max-width: 48rem;
  aspect-ratio: 1;
  overflow: hidden;
  place-items: center;
  border: 1px solid #3a4550;
  background: #000;
  box-shadow: 0 1.4rem 4rem rgba(0, 0, 0, 0.42);
  --artboard-view-scale: 1;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center;
  will-change: transform;
}

.artboard::before {
  --checker-size: calc(
    var(--artboard-checker-size) / var(--artboard-view-scale)
  );
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.12) 75%);
  background-size: var(--checker-size) var(--checker-size);
  background-position: 0 0,
    0 calc(var(--checker-size) / 2),
    calc(var(--checker-size) / 2) calc(-1 * (var(--checker-size) / 2)),
    calc(-1 * (var(--checker-size) / 2)) 0;
  pointer-events: none;
  content: "";
}

#editor-canvas,
#mask-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

#editor-canvas {
  z-index: 1;
  pointer-events: none;
  background-color: transparent;
}

#mask-canvas {
  z-index: 3;
  pointer-events: none;
}

.artboard[data-mask-active="true"] #mask-canvas {
  cursor: crosshair;
  pointer-events: auto;
  touch-action: none;
}

.artboard[data-frame-shape="circle"]::after {
  position: absolute;
  z-index: 4;
  inset: 0.45%;
  border: 1px solid rgba(92, 177, 255, 0.82);
  border-radius: 50%;
  box-shadow: 0 0 1.25rem rgba(23, 103, 170, 0.2);
  content: "";
  pointer-events: none;
}

.workspace-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: grid;
  width: min(28rem, calc(100% - 2rem));
  justify-items: center;
  padding: 2rem;
  color: #6a7987;
  text-align: center;
}

.empty-glyph {
  display: grid;
  width: 3.8rem;
  height: 3.8rem;
  margin-bottom: 0.9rem;
  place-items: center;
  border: 1px solid #aab7c4;
  color: #287fc9;
  font: 1.45rem Georgia, "Times New Roman", serif;
}

.workspace-empty strong {
  color: #ecf4ff;
  font-size: 0.95rem;
}

.workspace-empty p {
  max-width: 23rem;
  margin: 0.4rem 0 1rem;
  color: #a6b5c5;
  font-size: 0.68rem;
  line-height: 1.5;
}

.workspace-empty > div {
  display: flex;
  gap: 0.45rem;
}

.workspace-empty button {
  min-height: 2.25rem;
  padding: 0 0.7rem;
  border: 1px solid #566676;
  color: #24313d;
  background: rgba(244, 248, 251, 0.72);
  cursor: pointer;
  font-size: 0.55rem;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.workspace-empty button:hover {
  border-color: #1d6fad;
  color: #0d4d7d;
  background: #fff;
}

.mask-canvas-label {
  position: absolute;
  z-index: 4;
  top: 0.55rem;
  left: 0.55rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(52, 152, 255, 0.7);
  color: #d8edff;
  background: rgba(7, 29, 47, 0.84);
  font-size: 0.48rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.canvas-caption {
  display: flex;
  width: min(72vh, calc(100vw - 24rem));
  width: min(72dvh, calc(100vw - 24rem));
  min-width: 18rem;
  max-width: 48rem;
  justify-content: space-between;
  margin: 0;
  color: #53606d;
  font-size: 0.48rem;
  font-weight: 820;
  letter-spacing: 0.09em;
}

.inspector-panel {
  display: grid;
  min-height: 0;
  grid-template-rows: minmax(10rem, 1.25fr) minmax(10rem, 1.2fr) minmax(8rem, 0.9fr);
  overflow-x: hidden;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #000;
  scrollbar-color: #364453 #000;
  scrollbar-width: thin;
}

.panel-heading,
.panel-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-heading {
  padding: 0 0.8rem;
  border-bottom: 1px solid var(--line);
  color: #9ca7b2;
  font-size: 0.56rem;
  font-weight: 850;
  letter-spacing: 0.11em;
}

.panel-heading small {
  color: #46515c;
  font-size: 0.46rem;
}

.navigator-panel {
  display: grid;
  justify-items: stretch;
  gap: 0.5rem;
  background: transparent;
}

.navigator-panel:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: -2px;
}

.navigator-panel .panel-section-heading {
  width: 100%;
  margin: 0;
}

.navigator-panel .panel-section-heading output {
  color: var(--blue-bright);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.54rem;
}

.navigator-preview {
  position: relative;
  width: 8.4rem;
  max-width: 100%;
  aspect-ratio: 1;
  justify-self: center;
  overflow: hidden;
  border: 1px solid #3a4652;
  background: #dce3e8;
  box-shadow: 0 0.7rem 1.7rem rgba(0, 0, 0, 0.28);
  cursor: crosshair;
  touch-action: none;
}

.navigator-preview:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
}

.navigator-hint {
  justify-self: center;
  color: #536170;
  font-size: 0.48rem;
  letter-spacing: 0.035em;
}

#navigator-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.navigator-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px solid #8ac9ff;
  background: rgba(52, 152, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(4, 12, 20, 0.72), 0 0 0.65rem rgba(52, 152, 255, 0.38);
  pointer-events: none;
}

.navigator-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: #64717e;
  font-size: 0.53rem;
}

.navigator-readout output {
  color: #a9cbe7;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.navigator-controls {
  display: grid;
  grid-template-columns: 2.35rem 1.8rem minmax(0, 1fr) 1.8rem;
  gap: 0.3rem;
}

.navigator-controls button {
  min-height: 1.8rem;
  padding: 0;
  border: 1px solid #303b46;
  color: #8e9aa6;
  background: #11171d;
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 780;
}

#zoom-out,
#zoom-in {
  font-size: 1.08rem;
  font-weight: 620;
  line-height: 1;
}

.navigator-controls button:hover {
  border-color: var(--blue);
  color: var(--blue-bright);
}

#zoom-control {
  height: 1.8rem;
  min-width: 0;
  margin: 0;
  appearance: none;
  background: transparent;
  accent-color: var(--blue);
}

#zoom-control::-webkit-slider-runnable-track {
  height: 2px;
  background: #354655;
}

#zoom-control::-webkit-slider-thumb {
  width: 0.68rem;
  height: 0.68rem;
  margin-top: -0.29rem;
  appearance: none;
  border: 1px solid #79bfff;
  border-radius: 50%;
  background: #1d6da9;
}

#zoom-control::-moz-range-track {
  height: 2px;
  border: 0;
  background: #354655;
}

#zoom-control::-moz-range-thumb {
  width: 0.68rem;
  height: 0.68rem;
  border: 1px solid #79bfff;
  border-radius: 50%;
  background: #1d6da9;
}

.inspector-panel section {
  min-height: 0;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.layers-panel,
.history-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-section-heading {
  margin-bottom: 0.55rem;
}

.panel-section-heading h2 {
  margin: 0;
  color: #a9b4be;
  font-size: 0.57rem;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.panel-section-heading span {
  color: #52606d;
  font-size: 0.47rem;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.layer-list,
.history-list {
  min-height: 0;
  overflow-y: auto;
  scrollbar-color: #364453 #11161b;
  scrollbar-width: thin;
}

.panel-empty {
  margin: 0;
  padding: 1.2rem 0.65rem;
  border: 1px dashed #26303a;
  color: #4b5662;
  font-size: 0.58rem;
  line-height: 1.5;
  text-align: center;
}

.layers-panel .layer-row {
  position: relative;
  display: grid;
  cursor: grab;
  touch-action: none;
  user-select: none;
  grid-template-columns: 1.1rem 1.35rem minmax(0, 1fr);
  margin-bottom: 0.35rem;
  border: 1px solid #192733;
  border-radius: 3px;
  background: linear-gradient(110deg, #091119, #05090d);
}

.layers-panel .layer-row[data-active="true"] {
  border-color: #3e7199;
  box-shadow: inset 2px 0 #6ca4d0;
}

.layers-panel .layer-visibility,
.layers-panel .layer-drag-handle {
  border: 0;
  padding: 0;
  color: #8e9eac;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
}

.layers-panel .layer-visibility[data-visible="false"] {
  color: #6c7781;
}

.layers-panel .layer-visibility { display: grid; place-items: center; }
.layers-panel .layer-visibility svg { display: block; width: 18px; height: 18px; }

.layers-panel .layer-select {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.35rem;
  border: 0;
  color: #c6d1db;
  background: transparent;
  cursor: grab;
  text-align: left;
}

.layers-panel .layer-select strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layers-panel .layer-select small {
  display: block;
  color: #8294a5;
  font-size: 0.53rem;
  margin-top: 0.2rem;
}

/* Confined to Layers: navigator, history and the rest of the editor retain their layout. */
.inspector-panel .layers-panel {
  position: relative;
  padding: 0;
  border-top: 1px solid #15232e;
  background: linear-gradient(135deg, #050b10, #020406 70%);
}

.layers-panel .panel-section-heading {
  min-height: 2.1rem;
  padding: 0.3rem 0.65rem;
  margin: 0;
  border-bottom: 1px solid #15212b;
}

.layers-panel .panel-section-heading h2 { color: #c4d0db; }
.layers-panel .layer-heading-actions { display: flex; gap: 0.45rem; align-items: center; }
.layers-panel .layer-heading-actions > button,
.layers-panel .layer-actions-menu > summary {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: #8ba8c0;
  background: transparent;
  font-size: 1rem;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}
.layers-panel .layer-actions-menu > summary::-webkit-details-marker { display: none; }
.layers-panel .layer-actions-menu { position: relative; }
.layers-panel .layer-order-actions {
  position: absolute;
  z-index: 5;
  right: 0;
  top: calc(100% + 0.35rem);
  display: grid;
  width: 9.5rem;
  padding: 0.3rem;
  border: 1px solid #30485b;
  border-radius: 4px;
  background: #090f15;
  box-shadow: 0 7px 18px #000a;
}
.layers-panel .layer-order-actions button {
  padding: 0.5rem;
  border: 0;
  color: #c3d2df;
  background: transparent;
  font-size: 0.65rem;
  text-align: left;
  cursor: pointer;
}
.layers-panel button:hover:not(:disabled),
.layers-panel summary:hover { color: #e1f1ff; background-color: #13212d; }
.layers-panel button:focus-visible,
.layers-panel summary:focus-visible { outline: 2px solid #8ac6ef; outline-offset: -2px; }
.layers-panel button:disabled { opacity: 0.4; cursor: default; }
.layers-panel .layer-list { padding: 0.5rem; overscroll-behavior: contain; }
.layers-panel .layer-text { min-width: 0; }
.layers-panel .layer-thumbnail {
  flex: 0 0 1.85rem;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid #263846;
  border-radius: 2px;
  background: #111a21;
}
.layers-panel .layers-empty {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem 0.65rem;
  text-align: center;
}
.layers-panel .layers-empty strong { color: #bccbd7; font-size: 0.7rem; }
.layers-panel .layers-empty p { max-width: 11rem; margin: 0.45rem 0 0; color: #8196a8; font-size: 0.6rem; line-height: 1.6; }
.layers-panel .layers-empty-icon {
  position: relative;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0 0 1.15rem;
  transform: rotateX(55deg) rotateZ(45deg);
  border: 1.5px solid #85bce3;
}
.layers-panel .layers-empty-icon::before,
.layers-panel .layers-empty-icon::after {
  position: absolute;
  content: "";
  inset: 0;
  border: 1.5px solid #6196bb;
  transform: translate(5px, 5px);
}
.layers-panel .layers-empty-icon::after { transform: translate(10px, 10px); border-color: #476c88; }
.layers-panel .layer-drag-handle { cursor: grab; touch-action: none; user-select: none; }
.layers-panel .layer-list[data-dragging] .layer-row,
.layers-panel .layer-list[data-dragging] .layer-select,
.layers-panel .layer-list[data-dragging] .layer-drag-handle { cursor: grabbing; }
.layers-panel .layer-row[data-dragging] { opacity: 0.55; }
.layers-panel .layer-row[data-drop-position]::after {
  position: absolute;
  z-index: 2;
  content: "";
  left: 0;
  right: 0;
  height: 3px;
  background: #90cdf8;
  box-shadow: 0 0 0 1px var(--ink);
  pointer-events: none;
}
.layers-panel .layer-row[data-drop-position="before"]::after { top: -4px; }
.layers-panel .layer-row[data-drop-position="after"]::after { bottom: -4px; }
.layers-panel .layer-order-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Body-level presentation portal: never clipped by the Layers scrollport. */
.layer-drag-preview {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid #73acd4;
  border-radius: 4px;
  color: #dce8f1;
  background: var(--surface-raised);
  box-shadow: 0 8px 24px #0009, 0 1px 4px #0008;
  opacity: 0.92;
  pointer-events: none;
  user-select: none;
  will-change: transform;
}
.layer-drag-preview .layer-thumbnail {
  flex: 0 0 1.85rem;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid #35414c;
  border-radius: 2px;
  background: var(--surface-soft);
}
.layer-drag-preview .layer-text { min-width: 0; }
.layer-drag-preview strong {
  display: block;
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-drag-preview small { display: block; margin-top: 0.2rem; color: #97a9b8; font-size: 0.53rem; }

.history-list {
  display: grid;
  align-content: start;
  gap: 0.28rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-left: 1px solid #2a3540;
  color: #77838f;
  background: #0e1318;
  font-size: 0.51rem;
}

.history-list small {
  color: #444f5a;
  font-size: 0.45rem;
  text-align: right;
}

.generator-overlay {
  position: fixed;
  z-index: 50;
  inset: calc(var(--editor-topbar-height) + 0.75rem) 0.75rem 0.75rem
    calc(var(--editor-rail-width) + 0.75rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
  padding-left: 2.7rem;
  pointer-events: none;
}

.generator-overlay[data-gallery-open="true"] {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 3.2rem;
  padding-left: 0;
}

.generator-overlay[data-gallery-open="true"] .generator-window {
  width: 100%;
}

.generator-window {
  position: relative;
  display: grid;
  width: min(100%, 52rem);
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 4.7rem minmax(0, 1fr);
  border: 1px solid #34495b;
  border-radius: 0.65rem;
  background: linear-gradient(145deg, var(--surface), var(--ink) 60%);
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.58);
  pointer-events: auto;
  animation: window-in 160ms ease-out;
}

@keyframes window-in {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.generator-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--line);
  border-radius: 0.65rem 0.65rem 0 0;
  background: transparent;
}

.generator-title-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
}

.generator-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(52, 152, 255, 0.65);
  color: var(--blue-bright);
  background: var(--blue-soft);
  font-size: 0.85rem;
}

.generator-title-group p {
  margin: 0 0 0.1rem;
  color: var(--blue-bright);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.generator-title-group h1 {
  overflow: hidden;
  margin: 0;
  color: #dbe7f2;
  font-size: 1rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.25rem;
}

.window-actions button {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid #28313a;
  color: #7a8794;
  background: #10151b;
  cursor: pointer;
}

.window-actions button:hover {
  border-color: var(--blue);
  color: var(--blue-bright);
}

.generator-body {
  display: block;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #3a4856 #0e1318;
  scrollbar-width: thin;
}

.generate-form {
  padding: 1.25rem 1.4rem;
}

.prompt-heading,
.results-heading,
.results-heading > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prompt-heading {
  margin-bottom: 0.45rem;
}

.prompt-heading label,
.results-heading h2 {
  margin: 0;
  color: #a7b2bd;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.prompt-heading > span,
.results-heading span {
  color: #4d5965;
  font-size: 0.54rem;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.prompt-field {
  position: relative;
}

.prompt-action-row {
  display: block;
}

textarea {
  display: block;
  width: 100%;
  min-height: 10rem;
  max-height: 22rem;
  resize: vertical;
  padding: 0.9rem 1rem 4rem;
  border: 1px solid #367da7;
  border-radius: 0.3rem;
  outline: none;
  color: #e4edf5;
  background: linear-gradient(135deg, var(--surface-raised), var(--surface));
  font-size: 0.79rem;
  line-height: 1.5;
}

textarea::placeholder {
  color: #53606c;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

textarea:disabled {
  color: #65717c;
  background: #0f141a;
}

.generate-button {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  display: flex;
  width: auto;
  min-width: 0;
  min-height: 2.6rem;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 1.3rem;
  border: 1px solid var(--blue);
  color: #eef7ff;
  background: rgba(23, 75, 118, 0.46);
  box-shadow: inset 0 0 1.25rem rgba(52, 152, 255, 0.06);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.generate-button:hover:not(:disabled) {
  border-color: var(--blue-bright);
  background: rgba(29, 96, 150, 0.62);
  box-shadow: inset 0 0 1.5rem rgba(52, 152, 255, 0.12);
}

.generate-button:active:not(:disabled) {
  background: rgba(35, 109, 169, 0.78);
}

.generate-button:disabled {
  border-color: #2b4052;
  color: #8da3b5;
  background: rgba(21, 43, 61, 0.5);
  box-shadow: none;
}

.resolution-option {
  display: grid;
  justify-items: end;
  gap: 0.2rem;
}

.resolution-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  color: #f0f0f0;
  background: transparent;
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
}

.resolution-toggle span {
  font-size: 0.62rem;
  text-transform: uppercase;
}

.resolution-toggle:disabled {
  cursor: default;
}

select {
  width: 100%;
  height: 2.35rem;
  padding: 0 0.55rem;
  border: 1px solid #2f3944;
  border-radius: 0;
  outline: none;
  color: #cbd6df;
  background: #121820;
  font-size: 0.76rem;
}

select:focus {
  border-color: var(--blue);
}

.format-note {
  color: #74818d;
  font-size: 0.68rem;
  line-height: 1.45;
}

.generation-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

.status-message,
.credit-note {
  margin: 0;
  font-size: 0.66rem;
  line-height: 1.45;
}

.status-message {
  min-height: 0.9rem;
  color: #84919d;
}

.status-message[data-state="loading"] {
  color: #bfd5e8;
}

.status-message[data-state="success"] {
  color: var(--success);
}

.status-message[data-state="partial"] {
  color: var(--warning);
}

.status-message[data-state="error"] {
  color: #ff9a91;
}

.credit-note {
  flex: 0 0 auto;
  color: #74818d;
}

.results-section {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  padding: 1.1rem;
  background: linear-gradient(145deg, var(--surface), var(--ink) 60%);
}

.session-gallery {
  width: 100%;
  min-width: 0;
  border: 1px solid #34495b;
  border-radius: 0.65rem;
  box-shadow: 0 1rem 4rem #0007;
  pointer-events: auto;
  padding: 1rem;
  background: linear-gradient(145deg, var(--surface), var(--ink) 65%);
}

.session-gallery .results-heading { margin-bottom: 0.35rem; }
.session-gallery .results-heading h2 { letter-spacing: 0.15em; }
.session-gallery .results-heading > div:first-child { gap: 0.3rem 0.6rem; }
.session-gallery .gallery-window-actions { gap: 0.45rem; flex-wrap: nowrap; }
.session-gallery .gallery-window-actions button {
  min-height: 2.3rem;
  border-radius: 0.2rem;
}
.session-gallery #gallery-upload {
  padding: 0 0.85rem;
  border-color: #218cce;
  color: #d4eaff;
  background: linear-gradient(135deg, #073c60, #082238);
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.session-gallery #close-session-gallery { min-width: 2rem; }
.session-gallery > .gallery-helper { font-size: 0.66rem; margin-bottom: 0.8rem; }
.session-gallery .results-grid { gap: 0.85rem 0.8rem; padding: 0.2rem 0.4rem 0.8rem 0.15rem; }
.session-gallery .results-empty {
  padding: 2rem 1rem;
  border-radius: 0.25rem;
  color: #8095a7;
  background: var(--surface);
  line-height: 1.5;
}
.session-gallery .artifact { border: 0; background: transparent; overflow: visible; }
.session-gallery .artifact-select {
  overflow: hidden;
  border: 1px solid #263c4b;
  border-radius: 0.25rem;
}
.session-gallery .artifact img,
.session-gallery .artifact canvas { aspect-ratio: 4 / 3; }
.session-gallery .artifact[data-selected="true"] { box-shadow: none; }
.session-gallery .artifact[data-selected="true"] .artifact-select {
  border-color: #27b7ff;
  box-shadow: 0 0 0 1px #27b7ff, 0 0 0.75rem #159fe955;
}
.session-gallery .artifact[data-selected="true"]::after {
  display: grid;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  place-items: center;
  font-size: 0.85rem;
  background: #259ef2;
}
.session-gallery .artifact figcaption { min-height: 2.2rem; padding: 0.35rem 0 0; border: 0; align-items: flex-start; }
.session-gallery .artifact-identity strong { color: #c4d3df; font-size: 0.6rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.session-gallery .artifact-identity small { color: #86a2b8; font-size: 0.55rem; }
.session-gallery .gallery-footer {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem 0.7rem;
  padding-top: 0.65rem;
}
.session-gallery .gallery-selection { min-width: 0; gap: 0.65rem; }
.session-gallery .gallery-selection canvas { flex: 0 0 auto; width: 2.8rem; height: 2.8rem; }
.session-gallery .gallery-selection p { font-size: 0.66rem; }
.session-gallery .gallery-actions { gap: 0.45rem; flex-wrap: nowrap; }
.session-gallery .gallery-actions > button { min-height: 2.4rem; padding: 0 0.7rem; font-size: 0.53rem; letter-spacing: 0.08em; }
.session-gallery .gallery-footer > .gallery-helper { grid-column: 1 / -1; font-size: 0.59rem; line-height: 1.4; color: #8095a7; }
.session-gallery .gallery-actions-menu { position: relative; }
.session-gallery .gallery-actions-menu summary {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  list-style: none;
  border: 1px solid #314959;
  border-radius: 0.2rem;
  color: #bfd8e9;
  background: var(--surface-raised);
  cursor: pointer;
  font-weight: 700;
}
.session-gallery .gallery-actions-menu summary::-webkit-details-marker { display: none; }
.session-gallery .gallery-actions-menu summary:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 2px; }
.session-gallery .gallery-actions-menu[open] summary,
.session-gallery .gallery-actions-menu summary:hover { border-color: var(--blue); background: #102b3e; }
.session-gallery .gallery-secondary-actions {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  z-index: 3;
  display: grid;
  min-width: 11rem;
  gap: 0.3rem;
  padding: 0.4rem;
  border: 1px solid #344f62;
  border-radius: 0.3rem;
  background: var(--surface);
  box-shadow: 0 0.5rem 1.5rem #0009;
}
.session-gallery .gallery-actions-menu:not([open]) .gallery-secondary-actions { display: none; }
.session-gallery .gallery-secondary-actions button {
  width: 100%;
  min-height: 2rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid #263c4b;
  border-radius: 0.2rem;
  color: #c0d6e6;
  background: var(--surface-raised);
  text-align: left;
  font-size: 0.6rem;
  cursor: pointer;
}
.session-gallery .gallery-secondary-actions button:hover:not(:disabled) { border-color: var(--blue); background: #12324a; }
.session-gallery .gallery-secondary-actions button:disabled { color: #607485; cursor: default; }

@media (max-width: 35rem) {
  .session-gallery .gallery-footer { grid-template-columns: minmax(0, 1fr); }
  .session-gallery .gallery-actions { justify-self: end; }
  .session-gallery .results-grid { gap: 0.65rem 0.5rem; }
}

.session-gallery-tab {
  position: absolute;
  top: 1rem;
  left: -2.7rem;
  display: flex;
  width: 2.7rem;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 0.65rem;
  border: 1px solid #34495b;
  border-right-color: var(--blue);
  border-radius: 0.65rem 0 0 0.65rem;
  color: #cfdfed;
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
}

.session-gallery-tab[aria-expanded="true"] {
  color: #dcefff;
  background: #13334d;
}

.gallery-window-actions,
.gallery-actions,
.gallery-selection {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.gallery-window-actions { flex: 0 0 auto; }
.gallery-actions { flex-wrap: wrap; }
.gallery-helper {
  margin: 0 0 0.8rem;
  color: #8ca3b8;
  font-size: 0.7rem;
  line-height: 1.5;
}
#gallery-status:empty { margin: 0; }
.gallery-footer {
  display: grid;
  gap: 0.8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.gallery-footer .gallery-helper { margin: 0; }
.gallery-selection canvas {
  width: 3rem;
  height: 3rem;
  object-fit: cover;
  border: 1px solid #34495b;
  border-radius: 0.25rem;
}
.gallery-selection p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #bacddd;
  font-size: 0.72rem;
  line-height: 1.5;
}
.generation-progress {
  margin-top: 1.4rem;
  padding: 1rem;
  border: 1px solid #2b4356;
  border-radius: 0.4rem;
  background: var(--surface);
}
.progress-heading { display: flex; align-items: center; gap: 0.7rem; }
.progress-heading strong { color: #dce9f4; font-size: 0.9rem; }
.generation-progress p { color: #8da5bb; font-size: 0.75rem; }
.generation-progress progress { width: 100%; height: 0.4rem; accent-color: var(--blue); }
.progress-spinner {
  width: 1.6rem;
  height: 1.6rem;
  flex: 0 0 auto;
  border: 3px solid #15374f;
  border-top-color: var(--blue-bright);
  border-radius: 50%;
  animation: progress-spin 1s linear infinite;
}
@keyframes progress-spin { to { transform: rotate(360deg); } }
.generation-tip {
  margin: 1.1rem 0 0;
  padding: 0.8rem;
  border: 1px solid #263b4c;
  border-radius: 0.3rem;
  color: #8da8bf;
  background: var(--surface-raised);
  font-size: 0.72rem;
  line-height: 1.5;
}
.generation-tip span { color: var(--blue-bright); }

.results-heading {
  gap: 0.7rem;
  margin-bottom: 0.45rem;
}

.results-heading > div {
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.results-heading button {
  min-height: 1.8rem;
  padding: 0 0.65rem;
  border: 1px solid #34414e;
  color: #aebbc7;
  background: #121820;
  cursor: pointer;
  font-size: 0.5rem;
  font-weight: 820;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.results-heading button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue-bright);
}

.results-heading button:disabled {
  color: #404a54;
}

.results-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  grid-auto-rows: max-content;
  gap: 0.55rem;
  overflow-y: auto;
  padding: 1px;
  scrollbar-color: #3a4856 #0e1318;
  scrollbar-width: thin;
}

.results-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 2rem 1rem;
  border: 1px dashed #28333e;
  color: #4c5864;
  font-size: 0.6rem;
  text-align: center;
}

.artifact {
  position: relative;
  overflow: hidden;
  margin: 0;
  border: 1px solid #29343e;
  background: var(--ink);
}

.artifact[data-selected="true"] {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue), 0 0 0.7rem #3498ff44;
}

.artifact[data-selected="true"]::after {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.15rem 0.35rem;
  border-radius: 50%;
  color: white;
  background: var(--blue);
  content: "✓";
  pointer-events: none;
}

.artifact-select {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.artifact img,
.artifact canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #dce3e8;
}

.artifact figcaption {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid #29343e;
}

.artifact-identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.15rem;
}

.artifact-identity strong {
  overflow: hidden;
  color: #aeb9c3;
  font-size: 0.51rem;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.artifact-identity small {
  overflow: hidden;
  color: #4c5863;
  font-size: 0.45rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-state {
  flex: 0 0 auto;
  color: #536170;
  font-size: 0.43rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.artifact-caption-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  flex-direction: column;
  gap: 0.3rem;
}

.artifact-feedback-controls {
  display: flex;
  gap: 0.18rem;
}

.artifact-feedback-button {
  width: 1.3rem;
  height: 1.2rem;
  padding: 0;
  border: 1px solid #2a3641;
  border-radius: 0.2rem;
  background: #10161c;
  color: #6d7984;
  cursor: pointer;
  font-size: 0.62rem;
  line-height: 1;
}

.artifact-feedback-button:hover:not(:disabled) {
  border-color: #536272;
  color: #aeb9c3;
}

.artifact-feedback-button[aria-pressed="true"] {
  border-color: var(--blue);
  background: rgba(50, 139, 255, 0.14);
  color: var(--blue-bright);
}

.artifact-feedback-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.artifact[data-selected="true"] .artifact-state {
  color: var(--blue-bright);
}

.artifact[data-on-canvas="true"] .artifact-state {
  color: var(--success);
}

.generator-overlay[data-window-state="maximized"] {
  inset: var(--editor-topbar-height) 0 0 var(--editor-rail-width);
  padding: 0.6rem 0.6rem 0.6rem 2.7rem;
  background: var(--ink);
}

.generator-overlay[data-window-state="maximized"][data-gallery-open="true"] { padding-left: 0.6rem; }

.generator-overlay[data-window-state="maximized"] .generator-window {
  width: 100%;
  height: 100%;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
}

.generator-overlay[data-window-state="maximized"] .results-grid {
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}

.generator-overlay[data-window-state="minimized"] {
  inset: auto 16.75rem 0.75rem auto;
  width: 20rem;
  height: 3.1rem;
  padding: 0;
}

.generator-overlay[data-window-state="minimized"] .generator-window {
  width: 100%;
  height: 3.1rem;
  grid-template-rows: 3.1rem;
  animation: none;
}

.generator-overlay[data-window-state="minimized"] .generator-body,
.generator-overlay[data-window-state="minimized"] #maximize-generator {
  display: none;
}

@media (max-width: 72rem) {
  .editor-topbar {
    grid-template-columns: 10.5rem auto minmax(0, 1fr) auto;
  }

  .document-title {
    display: none;
  }

  .editor-categories button[data-state="dormant"] {
    display: none;
  }

  .save-policy {
    display: none;
  }

  .editor-shell {
    grid-template-columns: 3.75rem minmax(0, 1fr) 14rem;
  }

  .generator-overlay {
    right: 0.6rem;
    left: 4.35rem;
  }

  .generator-overlay[data-window-state="maximized"] {
    left: 3.75rem;
  }

  .generator-overlay[data-window-state="minimized"] {
    right: 14.75rem;
    left: auto;
  }

  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .artboard,
  .canvas-caption {
    width: min(70vh, calc(100vw - 22rem));
    width: min(70dvh, calc(100vw - 22rem));
  }
}

@media (max-width: 54rem) {
  .editor-topbar {
    grid-template-columns: 3.75rem auto minmax(0, 1fr);
  }

  .editor-brand {
    justify-content: center;
    padding: 0;
  }

  .editor-brand > span:last-child,
  .document-title small,
  .topbar-actions {
    display: none;
  }

  .editor-categories {
    display: none;
  }

  .editor-shell {
    grid-template-columns: 3.75rem minmax(0, 1fr);
  }

  .inspector-panel {
    display: none;
  }

  .generator-overlay,
  .generator-overlay[data-window-state="maximized"] {
    inset: calc(var(--editor-topbar-height) + 0.5rem) 0.5rem 0.5rem 4.25rem;
  }

  .generator-overlay[data-gallery-open="true"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(11rem, 0.8fr) minmax(0, 1.2fr);
    gap: 0.65rem;
    padding-left: 2.7rem;
  }

  .session-gallery .results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: 1 0 9rem;
    min-height: 9rem;
  }

  .session-gallery { display: flex; flex-direction: column; overflow-y: auto; gap: 0.3rem; }
  .session-gallery .results-heading { flex-wrap: wrap; }
  .session-gallery > * { flex-shrink: 0; }
  .gallery-footer { gap: 0.4rem; padding-top: 0.4rem; }
  .gallery-selection canvas { width: 2rem; height: 2rem; }
  .gallery-helper { font-size: 0.62rem; margin-bottom: 0.4rem; }
  .generate-form { padding: 1rem; }

  .generator-overlay[data-window-state="minimized"] {
    inset: auto 0.75rem 0.75rem auto;
  }

  .artboard,
  .canvas-caption {
    width: min(72vh, calc(100vw - 6.75rem));
    width: min(72dvh, calc(100vw - 6.75rem));
  }
}

@media (max-width: 38rem) {
  .editor-menu button {
    padding: 0 0.55rem;
  }

  .document-title {
    display: none;
  }

  .editor-topbar {
    grid-template-columns: 3.5rem auto 1fr;
  }

  .floating-ai-launcher {
    width: 3.1rem;
    min-width: 3.1rem;
    height: 3.1rem;
    border-radius: 50%;
  }

  .floating-ai-tooltip {
    max-width: calc(100vw - 5.25rem);
    font-size: 0.62rem;
  }

  .editor-shell {
    grid-template-columns: 3.5rem minmax(0, 1fr);
  }

  .rail-button,
  .rail-home {
    height: 3.75rem;
  }

  .generator-overlay,
  .generator-overlay[data-window-state="maximized"] {
    inset: calc(var(--editor-topbar-height) + 0.35rem) 0.35rem 0.35rem;
    padding: 0 0 0 2.5rem;
  }

  .generator-window {
    width: 100%;
    height: 100%;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }

  .generator-body {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: #3a4856 #0e1318;
    scrollbar-width: thin;
  }

  .generator-overlay[data-window-state="minimized"] {
    inset: auto 0.5rem 0.5rem auto;
    width: calc(100vw - 1rem);
  }

  .generate-button {
    min-height: 2.8rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .workspace-stage {
    padding: 0.75rem 0.5rem;
  }

  .artboard,
  .canvas-caption {
    width: calc(100vw - 5rem);
    min-width: 0;
  }

  .workspace-empty {
    padding: 1rem;
  }

  .workspace-empty > div {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-spinner { animation: none; }
  .floating-ai-launcher,
  .floating-ai-tooltip,
  .generate-button {
    transition: none;
  }

  .generator-window {
    animation: none;
  }
}

/* Whole-row layer dragging uses the same hand feedback as canvas objects. */
.editor-page .layers-panel .layer-select { cursor: grab; }
.editor-page .layers-panel .layer-list[data-dragging] .layer-select { cursor: grabbing; }
