:root {
  color-scheme: dark;
  --background: #050a09;
  --surface: #091311;
  --surface-raised: #0d1b18;
  --line: #1d3932;
  --line-bright: #2d5e50;
  --text: #e8fff7;
  --muted: #86a89d;
  --mint: #5fffc1;
  --mint-dark: #163d31;
  --yellow: #ffd866;
  --danger: #ff7187;
  --radius: 14px;
  --shadow: 0 24px 70px rgb(0 0 0 / 35%);
  --topbar-height: 68px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  background-image:
    radial-gradient(circle at 75% -10%, rgb(95 255 193 / 9%), transparent 32rem),
    linear-gradient(rgb(95 255 193 / 2%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(95 255 193 / 2%) 1px, transparent 1px);
  background-size: auto, 36px 36px, 36px 36px;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
[role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input[type="range"],
input[type="color"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  z-index: 100;
  padding: 10px 14px;
  border-radius: 9px;
  color: #03110c;
  background: var(--mint);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding:
    env(safe-area-inset-top)
    max(24px, env(safe-area-inset-right))
    0
    max(24px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgb(5 10 9 / 88%);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 5;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.install-button {
  min-height: 34px;
  color: var(--mint);
  border-color: var(--line-bright);
  background: rgb(95 255 193 / 7%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--mint);
  border-radius: 9px;
  color: var(--mint);
  font: 800 12px/1 ui-monospace, monospace;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 18px rgb(95 255 193 / 8%);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.privacy-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
}

.workspace {
  height: calc(100vh - var(--topbar-height) - env(safe-area-inset-top));
  height: calc(100dvh - var(--topbar-height) - env(safe-area-inset-top));
  display: grid;
  grid-template-columns: minmax(300px, 342px) 1fr;
}

.controls {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
  border-right: 1px solid var(--line);
  background: rgb(9 19 17 / 92%);
  scrollbar-color: var(--line-bright) transparent;
}

.control-section {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 16px;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading h2 {
  font-size: 13px;
  font-weight: 700;
}

.section-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.step {
  color: var(--mint);
  font: 700 10px/1.4 ui-monospace, monospace;
  letter-spacing: 0.08em;
}

.drop-zone {
  min-height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px dashed var(--line-bright);
  border-radius: var(--radius);
  background: rgb(95 255 193 / 2%);
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.drop-zone.dragging {
  border-color: var(--mint);
  background: rgb(95 255 193 / 6%);
  transform: translateY(-1px);
}

@media (hover: hover) {
  .drop-zone:hover {
    border-color: var(--mint);
    background: rgb(95 255 193 / 6%);
    transform: translateY(-1px);
  }
}

.drop-zone strong {
  font-size: 12px;
}

.drop-zone span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.drop-icon {
  color: var(--mint);
  font-size: 22px;
  font-weight: 300;
}

.source-buttons,
.export-grid,
.field-grid {
  display: grid;
  gap: 8px;
}

.source-buttons {
  grid-template-columns: 1fr 1fr auto;
  margin-top: 10px;
}

.text-source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.text-source .button {
  min-height: 38px;
}

.project-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.preset-actions {
  grid-template-columns: 1fr 1fr;
}

.project-status {
  min-height: 2.8em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.compact-source {
  margin-top: 2px;
}

.recent-source {
  grid-template-columns: minmax(0, 1fr) 62px;
}

.batch-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.batch-panel .project-actions {
  grid-template-columns: 1fr 1fr;
}

.field-label {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.button.primary {
  color: #03110c;
  background: var(--mint);
  border-color: var(--mint);
}

.button.accent {
  color: #181204;
  background: var(--yellow);
  border-color: var(--yellow);
}

.button.record {
  color: #fff1f4;
  border-color: rgb(255 113 135 / 48%);
  background: rgb(255 113 135 / 12%);
}

.button.record.recording {
  border-color: var(--danger);
  background: rgb(255 113 135 / 24%);
  box-shadow: 0 0 18px rgb(255 113 135 / 18%);
}

.button.secondary {
  background: var(--surface-raised);
  border-color: var(--line);
}

@media (hover: hover) {
  .button:not(:disabled):hover {
    transform: translateY(-1px);
  }

  .button.secondary:hover,
  .button.ghost:hover {
    border-color: var(--line-bright);
    background: var(--mint-dark);
  }
}

.button.ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.field > span,
.toggle-field > span:last-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field > span output {
  float: right;
  color: var(--mint);
  font-family: ui-monospace, monospace;
  text-transform: none;
}

.field select,
.field input[type="text"],
.field input[type="number"] {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  font-size: 12px;
}

@media (hover: hover) {
  .field select:hover,
  .field input[type="text"]:hover,
  .field input[type="number"]:hover {
    border-color: var(--line-bright);
  }
}

.dimension-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.dimension-mark {
  min-height: 38px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font: 700 12px/1 ui-monospace, monospace;
}

.field-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.range-field span {
  display: flex;
  justify-content: space-between;
}

.range-field output {
  color: var(--mint);
  font-family: ui-monospace, monospace;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--mint);
}

.field-grid {
  grid-template-columns: 1fr 58px 58px;
  align-items: end;
}

.color-field input {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
}

.toggle-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  cursor: pointer;
}

.compact-toggle {
  align-items: flex-start;
  line-height: 1.35;
}

.toggle-field input {
  position: absolute;
  z-index: 1;
  inset-inline-start: 0;
  top: 50%;
  width: 32px;
  height: 18px;
  margin: 0;
  transform: translateY(-50%);
  opacity: 0;
  cursor: pointer;
}

.compact-toggle input {
  top: 0;
  transform: none;
}

.toggle {
  width: 32px;
  height: 18px;
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  background: var(--surface-raised);
}

.toggle::after {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}

.toggle-field input:checked + .toggle::after {
  transform: translateX(14px);
  background: var(--mint);
}

.toggle-field input:focus-visible + .toggle {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

.toggle-field input:disabled ~ span {
  cursor: not-allowed;
  opacity: 0.48;
}

.export-grid {
  grid-template-columns: 1fr 1fr;
}

.export-grid .wide {
  grid-column: 1 / -1;
}

.stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 18px max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  gap: 12px;
}

.stage-toolbar,
.stage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.stage-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.fullscreen-button {
  min-height: 30px;
  padding-block: 5px;
  white-space: nowrap;
}

.source-name,
.source-meta {
  display: block;
}

.source-name {
  max-width: 50vw;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta,
.stage-footer {
  color: var(--muted);
  font-size: 10px;
}

.source-meta {
  margin-top: 2px;
}

.metrics {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font: 600 10px/1 ui-monospace, monospace;
  white-space: nowrap;
}

.metrics strong {
  color: var(--text);
}

.engine-badge {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--mint);
  background: var(--surface);
}

.canvas-shell {
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #030706;
  box-shadow: var(--shadow);
}

.canvas-shell:fullscreen,
.canvas-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
}

.canvas-shell:fullscreen #outputCanvas,
.canvas-shell:-webkit-full-screen #outputCanvas {
  width: 100vw;
  height: 100vh;
}

#outputCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgb(95 255 193 / 6%), transparent 42%),
    #030706;
}

.empty-state h1 {
  max-width: 640px;
  margin: 20px 0 8px;
  font-size: clamp(24px, 4vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.empty-state p {
  max-width: 560px;
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.empty-glyphs {
  color: var(--mint);
  font: 700 clamp(10px, 1.2vw, 14px)/1 ui-monospace, monospace;
  letter-spacing: 0.8em;
  text-indent: 0.8em;
  text-shadow: 0 0 18px rgb(95 255 193 / 45%);
}

.drop-overlay {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  z-index: 3;
  border: 2px dashed var(--mint);
  border-radius: 12px;
  color: var(--mint);
  background: rgb(5 20 16 / 92%);
  font-size: clamp(20px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.drop-overlay.visible {
  opacity: 1;
}

.stage-footer {
  min-height: 18px;
}

.hidden,
.empty-state.hidden {
  display: none;
}

.visually-hidden {
  position: fixed !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.noscript {
  position: fixed;
  inset: auto 16px calc(16px + env(safe-area-inset-bottom));
  z-index: 200;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-raised);
  text-align: center;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
    overscroll-behavior-y: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
  }

  .workspace {
    height: auto;
    min-height: calc(100vh - var(--topbar-height) - env(safe-area-inset-top));
    min-height: calc(100dvh - var(--topbar-height) - env(safe-area-inset-top));
    grid-template-columns: 1fr;
  }

  .controls {
    grid-row: 2;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    position: sticky;
    top: calc(var(--topbar-height) + env(safe-area-inset-top));
    z-index: 4;
    grid-row: 1;
    height: clamp(300px, 42vh, 520px);
    height: clamp(300px, 42dvh, 520px);
    min-height: 300px;
    border-bottom: 1px solid var(--line);
    background: rgb(5 10 9 / 98%);
    box-shadow: 0 18px 36px rgb(0 0 0 / 32%);
  }

  .canvas-shell {
    min-height: 0;
  }

  .fullscreen-button:disabled {
    display: none;
  }
}

@media (pointer: coarse) {
  .button,
  .text-source .button,
  .field select,
  .field input[type="text"],
  .field input[type="number"],
  .color-field input {
    min-height: 46px;
  }

  .toggle-field {
    min-height: 44px;
    margin-top: 8px;
  }

  .toggle {
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    padding: 3px;
  }

  .toggle-field input {
    width: 42px;
    height: 24px;
  }

  .toggle::after {
    width: 16px;
    height: 16px;
  }

  .toggle-field input:checked + .toggle::after {
    transform: translateX(18px);
  }

  input[type="range"] {
    height: 32px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .drop-zone {
    min-height: 126px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding:
      env(safe-area-inset-top)
      max(14px, env(safe-area-inset-right))
      0
      max(14px, env(safe-area-inset-left));
  }

  .privacy-pill {
    padding: 7px;
  }

  .privacy-pill:not(.privacy-dot) {
    font-size: 0;
  }

  .install-button {
    padding-inline: 10px;
  }

  .control-section,
  .stage {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .field select,
  .field input[type="text"],
  .field input[type="number"] {
    font-size: 16px;
  }

  .stage-toolbar,
  .stage-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .metrics {
    width: 100%;
    justify-content: space-between;
  }

  .stage-footer span:last-child {
    display: none;
  }

  .empty-state {
    padding: 16px;
  }

  .empty-state h1 {
    margin: 0 0 14px;
    font-size: clamp(20px, 7vw, 30px);
  }

  .empty-state p,
  .empty-glyphs {
    display: none;
  }
}

@media (max-width: 390px) {
  .brand small {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .source-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .source-buttons .ghost {
    grid-column: 1 / -1;
  }

  .text-source {
    grid-template-columns: 1fr;
  }

  .text-source .button {
    width: 100%;
  }
}

@media (display-mode: standalone) {
  .topbar {
    background: rgb(5 10 9 / 96%);
  }

  .install-button {
    display: none;
  }
}

@media (max-width: 900px) and (max-height: 560px) {
  .stage {
    position: relative;
    top: auto;
    height: 72vh;
    height: 72dvh;
    min-height: 250px;
  }
}

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