:root {
  --ink: #17130d;
  --muted: #766d61;
  --line: rgba(31, 24, 15, 0.14);
  --panel: rgba(255, 252, 244, 0.86);
  --accent-dark: #9f421d;
  --field: #211c17;
  --field-line: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 80px rgba(49, 33, 16, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(217, 111, 50, 0.22), transparent 28rem),
    radial-gradient(circle at 84% 4%, rgba(71, 102, 87, 0.2), transparent 30rem),
    linear-gradient(135deg, #f5ead5 0%, #f9f3e6 45%, #ead8bd 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  max-width: 720px;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.55rem;
  letter-spacing: 0;
}

.primary-action {
  min-width: 168px;
  border: 0;
  border-radius: 999px;
  padding: 16px 24px;
  color: #fff9ed;
  background: linear-gradient(135deg, var(--ink), #5f321d);
  box-shadow: 0 16px 38px rgba(61, 34, 17, 0.28);
  cursor: pointer;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.62;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(520px, 1.18fr);
  gap: 18px;
  min-height: 720px;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.editor-panel,
.result-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: inline-flex;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.44);
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tab.is-active {
  color: #fffaf0;
  background: var(--ink);
}

.editor-pane,
.result-pane {
  display: none;
}

.editor-pane.is-active,
.result-pane.is-active {
  display: block;
}

.editor-pane {
  flex: 1;
  padding: 18px;
}

.field-label {
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  height: 585px;
  resize: none;
  border: 1px solid var(--field-line);
  border-radius: 22px;
  padding: 18px;
  color: #f7ead7;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 50%, transparent 50%) 0 0 / 100% 48px,
    var(--field);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(217, 111, 50, 0.8);
  box-shadow: 0 0 0 4px rgba(217, 111, 50, 0.14);
}

.options-pane {
  height: 624px;
  overflow: auto;
}

.option-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.option-section:last-child {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.78rem;
  line-height: 1.35;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.control {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.control-wide {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  outline: none;
}

input[type="color"] {
  height: 46px;
  padding: 5px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent-dark);
}

.compact-textarea {
  height: 104px;
  min-height: 104px;
  border-color: var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.45;
}

.small-action {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  color: #fff9ed;
  background: var(--ink);
  cursor: pointer;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  color: var(--muted);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-dark);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.preview-tools {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
}

.tool-button.is-active {
  color: #fffaf0;
  background: var(--ink);
}

.status-row .is-error {
  color: #b93b24;
}

.preview-stage,
.image-stage {
  position: relative;
  height: 626px;
  margin: 18px;
  border: 1px solid rgba(23, 19, 13, 0.1);
  border-radius: 24px;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(23, 19, 13, 0.045) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(-45deg, rgba(23, 19, 13, 0.045) 25%, transparent 25%) 0 14px / 28px 28px,
    #fffdf6;
}

.preview-stage.is-fit {
  overflow: hidden;
}

.preview-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fffdf6;
}

iframe {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  background: #fff;
}

.image-stage {
  display: grid;
  place-items: center;
  position: relative;
  padding: 22px;
}

.image-stage img {
  display: none;
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  box-shadow: 0 18px 55px rgba(23, 19, 13, 0.22);
}

.image-stage.has-image img {
  display: block;
}

.empty-state {
  display: grid;
  gap: 8px;
  max-width: 320px;
  color: var(--muted);
  text-align: center;
}

.image-stage.has-image .empty-state {
  display: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.download-link {
  display: inline-flex;
  margin: 0 18px 18px;
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--ink);
  background: #fff8df;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

@media (max-width: 980px) {
  .hero,
  .panel-top,
  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  textarea,
  .preview-stage,
  .image-stage {
    height: 520px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1560px);
    padding: 18px 0;
  }

  h1 {
    font-size: 2rem;
  }

  .panel {
    border-radius: 22px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    padding: 9px 10px;
  }

  .options-grid.is-active {
    grid-template-columns: 1fr;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }
}
