:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #647067;
  --paper: #f6f2ea;
  --panel: #fffdf8;
  --line: #d8d0c2;
  --accent: #1f7a68;
  --accent-dark: #14584c;
  --blue: #244b75;
  --coral: #c25744;
  --shadow: 0 18px 45px rgba(41, 34, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 122, 104, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 75, 117, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(360px, 1fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.editor {
  padding: 22px;
}

.masthead {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
  max-width: 8ch;
}

h2 {
  font-size: 1.35rem;
}

.controls {
  display: grid;
  gap: 15px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  min-height: 142px;
  padding: 13px 14px;
  resize: vertical;
  line-height: 1.45;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 104, 0.16);
}

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

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.primary:hover {
  background: var(--accent-dark);
}

.primary:active {
  transform: translateY(1px);
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 640px;
  padding: 18px;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 14px;
}

#modelStats {
  max-width: 260px;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 750;
  text-align: right;
}

#preview {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ef;
}

.status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status.error {
  color: #a33a2b;
  font-weight: 700;
}

@media (max-width: 860px) {
  .app {
    width: min(100% - 20px, 680px);
    padding: 10px 0;
  }

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

  h1 {
    max-width: none;
    font-size: 2.35rem;
  }

  .preview-panel {
    min-height: 520px;
  }

  #preview {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .editor,
  .preview-panel {
    padding: 14px;
  }

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

  .preview-toolbar {
    display: grid;
  }

  #modelStats {
    text-align: left;
  }
}
