:root {
  color-scheme: light;
  --shell-bg:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 30%),
    linear-gradient(180deg, #f7f0e5 0%, #ede3d5 100%);
  --card-bg: rgba(255, 250, 242, 0.88);
  --card-border: rgba(87, 69, 45, 0.12);
  --shadow: 0 24px 46px rgba(61, 43, 18, 0.11);
  --text-strong: #23180d;
  --text-soft: rgba(35, 24, 13, 0.72);
  --accent: #111111;
  --accent-soft: #eef5ff;
  --ice-border: rgba(181, 205, 240, 0.92);
}

html,
body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  background: var(--shell-bg);
}

body {
  overflow: hidden;
  color: var(--text-strong);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100vw;
  height: 100vh;
  padding: 22px 26px 92px;
  box-sizing: border-box;
  gap: 18px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.app-kicker {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.app-header h1 {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.05;
}

.app-lede {
  margin: 12px 0 0;
  max-width: 880px;
  color: var(--text-soft);
  line-height: 1.55;
}

.back-link {
  align-self: center;
  padding: 12px 16px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-strong);
  font-weight: 700;
  text-decoration: none;
  backdrop-filter: blur(12px);
}

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 312px;
  gap: 18px;
  min-height: 0;
}

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

.control-card {
  min-height: 0;
  overflow: auto;
}

.control-stack {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.control-section {
  display: grid;
  gap: 12px;
}

.control-section h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.control-field,
.number-field,
.choice-field {
  display: grid;
  gap: 8px;
}

.control-field span,
.number-field span,
.choice-field span,
.export-label,
.chat-label,
.preview-note {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

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

input[type="number"],
.export-select,
.chat-prompt {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid rgba(53, 41, 24, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-strong);
  font: inherit;
}

.choice-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.choice-field input {
  margin: 0;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.preset-reset {
  grid-column: 1 / -1;
}

.button {
  appearance: none;
  border: 1px solid rgba(53, 41, 24, 0.14);
  border-radius: 16px;
  padding: 12px 16px;
  font: 800 14px/1 "Manrope", "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(40, 31, 16, 0.1);
}

.button-primary {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-strong);
}

.button-wide {
  width: 100%;
}

.preview-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  padding: 18px;
  gap: 14px;
}

.preview-note {
  padding: 12px 14px;
  border: 1px solid rgba(53, 41, 24, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.stage {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
}

.sheet {
  width: min(100%, calc((100vh - 260px) * var(--page-ratio)));
  max-height: 100%;
}

.export-dock {
  position: fixed;
  right: 34px;
  bottom: 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: 0 22px 38px rgba(47, 35, 18, 0.16);
  backdrop-filter: blur(18px);
  z-index: 25;
}

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

.export-select {
  min-width: 132px;
}

.status-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 40;
  transform: translateX(-50%);
  min-width: 280px;
  max-width: min(90vw, 620px);
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.92);
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 20px 36px rgba(17, 17, 17, 0.22);
}

.status-toast[data-severity="warning"] {
  background: rgba(122, 54, 15, 0.94);
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr) auto;
  }

  .control-card {
    max-height: 320px;
  }

  .sheet {
    width: min(100%, calc((100vh - 320px) * var(--page-ratio)));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px 16px 90px;
  }

  .app-header {
    flex-direction: column;
  }

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

  .export-dock {
    left: 16px;
    right: 16px;
    justify-content: space-between;
  }

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