:root {
  color-scheme: light dark;
  --bg: #f5f0e8;
  --bg-2: #ebe1d5;
  --panel: rgba(255, 252, 246, 0.86);
  --text: #1b1720;
  --muted: #746a76;
  --line: rgba(38, 30, 44, 0.14);
  --accent: #6a4cff;
  --accent-2: #ff7cba;
  --shadow: 0 18px 55px rgba(47, 33, 67, 0.14);
  --radius: 22px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 124, 186, 0.16), transparent 34rem),
    radial-gradient(circle at 100% 15%, rgba(106, 76, 255, 0.14), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: var(--sans);
}

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

button,
select,
input,
textarea,
canvas {
  border-radius: 14px;
}

button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
  padding: 0.78rem 0.95rem;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(106, 76, 255, 0.42);
  box-shadow: 0 10px 26px rgba(48, 35, 75, 0.14);
  outline: none;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: 0;
  font-weight: 700;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header,
.site-footer {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 22px 0 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: #17131d;
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.08em;
  box-shadow: var(--shadow);
}

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

.brand small,
.eyebrow,
.lead,
.site-footer,
#sceneMeta,
summary,
details p {
  color: var(--muted);
}

.top-nav {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.top-nav a {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto 40px;
}

.hero-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 18px 0;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.36));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  margin: 0 0 0.6rem;
}

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

h1 {
  max-width: 850px;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
  margin-bottom: 0.9rem;
}

h2 {
  font-size: 1rem;
  margin-bottom: 0.85rem;
}

.lead {
  max-width: 780px;
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.8;
  margin-bottom: 0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr) minmax(300px, 390px);
  grid-template-areas:
    "controls preview prompt"
    "controls preview history";
  gap: 18px;
  align-items: start;
}

.control-panel {
  grid-area: controls;
  display: grid;
  gap: 14px;
}

.preview-panel {
  grid-area: preview;
  min-width: 0;
}

.prompt-panel {
  grid-area: prompt;
}

.history-panel {
  grid-area: history;
}

.card,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card {
  padding: 1rem;
}

.field {
  display: grid;
  gap: 0.46rem;
  margin-bottom: 0.86rem;
}

.field span,
.check-field,
summary {
  font-size: 0.9rem;
  font-weight: 650;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  padding: 0.72rem 0.82rem;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.double-field,
.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.field.compact {
  margin-bottom: 0;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.8rem 0;
}

.check-field input {
  width: auto;
}

.button-grid button {
  width: 100%;
}

.preview-toolbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.preview-toolbar {
  padding: 1rem 1rem 0;
}

.preview-toolbar h2,
.preview-toolbar p,
.panel-head h2 {
  margin-bottom: 0;
}

#sceneMeta {
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

.canvas-frame {
  margin: 1rem;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: calc(var(--radius) - 4px);
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.045) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

#compositionCanvas {
  max-width: 100%;
  max-height: min(76vh, 820px);
  width: auto;
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.20);
}

textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.65;
  font-family: var(--mono);
  font-size: 0.88rem;
}

#copyStatus {
  min-height: 1em;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

details {
  margin-top: 0.9rem;
}

summary {
  cursor: pointer;
}

details p {
  margin: 0.6rem 0 0;
  line-height: 1.7;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.46);
  padding: 0.5rem;
  cursor: pointer;
  text-align: left;
}

.history-item img {
  width: 100%;
  display: block;
  border-radius: 10px;
  margin-bottom: 0.42rem;
  background: #fff;
}

.history-item span {
  display: block;
  color: var(--muted);
  font: 0.74rem/1.35 var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  padding: 0 0 32px;
  font-size: 0.86rem;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
    grid-template-areas:
      "controls preview"
      "prompt prompt"
      "history history";
  }
}

@media (max-width: 820px) {
  .site-header,
  .hero-panel,
  .preview-toolbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header {
    gap: 0.8rem;
  }

  .top-nav,
  .quick-actions {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "preview"
      "controls"
      "prompt"
      "history";
  }

  .double-field,
  .button-grid,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .canvas-frame {
    min-height: 260px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111018;
    --bg-2: #1d1827;
    --panel: rgba(31, 27, 40, 0.82);
    --text: #f5efff;
    --muted: #b8abbf;
    --line: rgba(255, 255, 255, 0.13);
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.36);
  }

  button,
  select,
  input,
  textarea,
  .top-nav a,
  .history-item {
    background: rgba(255, 255, 255, 0.08);
  }
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.78rem 0.95rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.primary-link:hover {
  text-decoration: none;
}
