:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #fffdf8;
  --surface-2: #ece5d8;
  --ink: #27221d;
  --muted: #7d7469;
  --line: #ddd3c5;
  --accent: #7a8b62;
  --accent-2: #a45f43;
  --brass: #b78b43;
  --wood: #7c5738;
  --shadow: 0 22px 60px rgba(70, 55, 34, 0.12);
  --radius: 8px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

body.dark {
  color-scheme: dark;
  --bg: #171512;
  --surface: #211e19;
  --surface-2: #2d2923;
  --ink: #f4eadc;
  --muted: #b7aa98;
  --line: #3b352d;
  --accent: #a2b17f;
  --accent-2: #d0835f;
  --brass: #d0a65f;
  --wood: #a77a50;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(122, 139, 98, 0.14), transparent 25%),
    var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  padding: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  border-radius: 8px;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.hero-strip h3,
.preview-head h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 16px;
}

.brand p,
.topbar p,
.hero-strip p,
.preview-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
}

.search-box input {
  border: 0;
  outline: 0;
  min-width: 0;
  width: 100%;
  background: transparent;
  color: var(--ink);
}

.nav-block {
  display: grid;
  gap: 8px;
  margin: 22px 0;
}

.nav-item,
.preset-card,
.tool-button,
.chip,
.icon-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.nav-item {
  text-align: left;
  padding: 11px 12px;
}

.nav-item.active,
.tool-button.active,
.chip.active {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.section-title small {
  color: var(--muted);
  font-weight: 500;
}

#presetList {
  display: grid;
  gap: 10px;
}

.preset-card {
  width: 100%;
  padding: 12px;
  text-align: left;
}

.preset-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.preset-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.preset-card.active {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
}

.topbar h2 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.12;
}

.top-actions {
  display: flex;
  gap: 10px;
}

select,
.icon-button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
}

.builder-panel,
.preview-panel {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.builder-panel {
  padding: 18px;
}

.preview-panel {
  padding: 16px;
  position: sticky;
  top: 20px;
}

.hero-strip {
  min-height: 126px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--surface-2) 74%, transparent), transparent),
    linear-gradient(100deg, rgba(122, 87, 56, 0.16), rgba(122, 139, 98, 0.12));
  border: 1px solid var(--line);
}

.hero-strip h3 {
  font-size: 22px;
}

.hero-strip p {
  max-width: 620px;
  line-height: 1.7;
}

.style-swatches {
  display: flex;
  align-items: end;
  gap: 8px;
}

.swatch {
  width: 38px;
  height: 70px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.field-toolbar,
.render-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field-toolbar {
  margin: 16px 0;
}

.tool-button,
.primary-button,
.secondary-button {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.secondary-button {
  background: var(--surface-2);
}

.field-groups {
  display: grid;
  gap: 14px;
}

.field-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  overflow: hidden;
}

.group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.group-head h4 {
  margin: 0;
  font-size: 15px;
}

.group-head small {
  color: var(--muted);
}

.fields {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.field-row {
  display: grid;
  gap: 10px;
}

.field-row label {
  font-size: 13px;
  font-weight: 700;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.field-row textarea,
.field-row input,
#promptOutput {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--ink);
  outline: none;
}

.field-row input {
  height: 38px;
  padding: 0 11px;
}

.field-row textarea {
  min-height: 76px;
  padding: 11px;
  resize: vertical;
}

.preview-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.model-card {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-2) 42%, transparent);
}

.model-card label {
  font-size: 12px;
  color: var(--muted);
}

.model-options {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.model-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

#promptOutput {
  width: 100%;
  min-height: 300px;
  padding: 14px;
  resize: vertical;
  line-height: 1.68;
  font-size: 13px;
}

.render-actions {
  margin: 12px 0;
}

.render-actions button {
  flex: 1;
}

.image-preview {
  height: 162px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.interior-scene {
  width: 100%;
  height: 100%;
  position: relative;
  background:
    linear-gradient(90deg, rgba(39, 34, 29, 0.12) 0 12%, transparent 12%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(0, 0, 0, 0.12)),
    linear-gradient(120deg, var(--scene-a, #d9cfbd), var(--scene-b, #8b7f66));
}

.interior-scene::before {
  content: "";
  position: absolute;
  left: 15%;
  bottom: 18%;
  width: 42%;
  height: 26%;
  border-radius: 42px 42px 8px 8px;
  background: color-mix(in srgb, var(--scene-c, #efe7dc) 82%, white);
  box-shadow: 58px 34px 0 -10px rgba(60, 44, 31, 0.28);
}

.interior-scene::after {
  content: "";
  position: absolute;
  right: 12%;
  top: 18%;
  width: 20%;
  height: 48%;
  border-radius: 80px 80px 6px 6px;
  background: rgba(255, 249, 232, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.interior-scene span {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 12%;
  height: 12%;
  border-radius: 50%;
  background: rgba(52, 43, 33, 0.18);
  filter: blur(6px);
}

#requestOutput {
  max-height: 190px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: var(--radius);
  background: #15130f;
  color: #e8dccb;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .preview-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .hero-strip,
  .preview-head {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions select {
    flex: 1;
    min-width: 0;
  }

  .style-swatches {
    align-items: start;
  }

  .swatch {
    width: 32px;
    height: 46px;
  }
}
