:root {
  color-scheme: dark;
  --bg: #07080b;
  --panel: #0c0e13;
  --panel-high: #12151c;
  --line: #262a33;
  --line-strong: #3a404c;
  --text: #f6f7f9;
  --muted: #9299a8;
  --red: #ff3b0a;
  --blue: #7892f3;
  --cyan: #25b6ff;
  --yellow: #f6cb42;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-width: 320px;
  overflow: hidden;
  background: var(--bg);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgb(37 182 255 / 8%), transparent 29rem),
    radial-gradient(circle at 88% 5%, rgb(255 59 10 / 7%), transparent 25rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(450px, 480px);
  height: 100vh;
  min-height: 0;
}

.preview-panel {
  position: relative;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 3vh, 36px) clamp(24px, 4vw, 52px);
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.panel-heading,
.controls-heading,
.export-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading {
  position: absolute;
  top: clamp(18px, 3vh, 36px);
  right: clamp(24px, 4vw, 52px);
  z-index: 2;
  justify-content: flex-end;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font: 650 0.72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.14em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 2.55rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 13px;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.view-switches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.82rem;
}

.switch-label:has(input:checked) {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--panel-high);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.stage-shell {
  position: relative;
  align-self: center;
  width: min(100%, 620px, calc(100vh - 132px));
  aspect-ratio: 1;
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--panel-high);
  box-shadow: 0 34px 90px rgb(0 0 0 / 42%);
}

.stage-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.16;
  background-image:
    linear-gradient(rgb(255 255 255 / 18%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 18%) 1px, transparent 1px);
  background-size: 10% 10%;
  pointer-events: none;
}

#maru-icon {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

.controls-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  padding: 0;
  overflow: hidden;
  background: rgb(10 12 16 / 88%);
}

.controls-scroll {
  min-height: 0;
  padding: 22px 24px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.controls-heading {
  align-items: baseline;
  margin-bottom: 10px;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  line-height: 1.2;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--text);
}

.control-section {
  display: block;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

select {
  min-height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-high);
}

.layer-list {
  display: grid;
  gap: 4px;
}

.layer-row {
  display: grid;
  grid-template-columns: 18px 12px 1fr auto;
  align-items: center;
  min-height: 32px;
  gap: 10px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 0.88rem;
}

.layer-row:hover {
  background: var(--panel-high);
}

.layer-row small {
  color: #68707f;
  font: 500 0.67rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.layer-swatch,
.dot {
  display: inline-block;
  border-radius: 50%;
}

.layer-swatch {
  width: 10px;
  height: 10px;
  box-shadow: 0 0 7px currentColor;
}

.swatch-black { color: #565b64; background: #050505; border: 1px solid #565b64; }
.swatch-red { color: var(--red); background: var(--red); }
.swatch-blue { color: var(--cyan); background: var(--blue); }
.swatch-white { color: #fff; background: #fff; }

details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::after {
  content: "+";
  color: var(--muted);
  font: 400 1.1rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

details[open] summary {
  margin-bottom: 13px;
}

details[open] summary::after {
  content: "−";
}

.field-grid {
  display: grid;
  gap: 8px;
}

.color-grid {
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 18px;
}

.color-grid label {
  display: grid;
  grid-template-rows: 2.5em 33px;
  align-items: end;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.25;
  text-align: center;
}

input[type="color"] {
  width: 100%;
  height: 33px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel-high);
}

.range-field {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.range-field > span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.77rem;
}

.range-field output {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  accent-color: var(--blue);
}

.range-group + .range-group {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px dashed var(--line);
}

.geometry-note {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.range-group p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.78rem;
  font-weight: 650;
}

.dot {
  width: 8px;
  height: 8px;
}

.dot-blue { background: var(--blue); box-shadow: 0 0 7px var(--cyan); }
.dot-red { background: var(--red); box-shadow: 0 0 7px var(--red); }

.export-section {
  margin: 0;
  padding: 16px 24px 18px;
  border-top: 1px solid var(--line-strong);
  background: rgb(14 16 22 / 78%);
}

.export-heading {
  align-items: center;
}

.transparent-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.75rem;
}

.export-options {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
  margin-top: 14px;
}

.button {
  min-height: 42px;
  border-radius: 7px;
  font-weight: 720;
  white-space: nowrap;
}

.button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.button-primary {
  border: 1px solid #91a4ff;
  color: #081022;
  background: #91a4ff;
  box-shadow: 0 0 24px rgb(120 146 243 / 18%);
}

.button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.size-select,
.format-select {
  min-width: 0;
}

.size-select select,
.format-select select {
  width: 100%;
  height: 42px;
}

.size-select select:disabled {
  cursor: not-allowed;
  color: #6f7684;
  opacity: 0.7;
}

.export-button {
  width: 100%;
  margin-top: 8px;
}

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: #737b8b;
  font-size: 0.7rem;
}

.status.is-error {
  color: #ff8c72;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

@media (max-width: 1000px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .preview-panel {
    min-height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading {
    position: static;
  }

  .stage-shell {
    width: min(100%, 620px);
    margin: clamp(12px, 2vh, 24px) auto;
  }

  .controls-panel {
    display: block;
    height: auto;
    overflow: visible;
  }

  .controls-scroll {
    padding-bottom: 12px;
    overflow: visible;
  }

  .export-section {
    position: static;
    margin-top: 8px;
  }
}

@media (max-width: 560px) {
  .workspace {
    min-height: 100vh;
  }

  .preview-panel {
    padding: 24px 16px;
  }

  .panel-heading {
    display: grid;
  }

  .view-switches {
    justify-content: flex-start;
  }

  .stage-shell {
    margin-top: 22px;
  }

  .controls-panel {
    padding: 0;
  }

  .controls-scroll {
    padding: 25px 16px 12px;
  }

  .export-section {
    padding-right: 16px;
    padding-left: 16px;
  }

}

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