:root {
  --paper: #f4efe2;
  --paper-deep: #e7dcc2;
  --ink: #1d2b2a;
  --forest: #2e5a4f;
  --forest-soft: #487768;
  --berry: #a24c3f;
  --sun: #d7a94f;
  --mist: rgba(255, 255, 255, 0.68);
  --shadow: 0 18px 45px rgba(22, 32, 30, 0.15);
  --border: rgba(31, 52, 47, 0.14);
  --headline: Georgia, "Times New Roman", serif;
  --body: "Trebuchet MS", Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(215, 169, 79, 0.28), transparent 28%),
    radial-gradient(circle at left center, rgba(72, 119, 104, 0.2), transparent 24%),
    linear-gradient(160deg, #fbf7ee 0%, #efe6d3 48%, #e3d6bc 100%);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.control-panel,
.chat-card,
.result-card {
  position: relative;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block,
.panel-card,
.chat-card,
.result-card {
  background: var(--mist);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand-block,
.panel-card,
.chat-card,
.result-card {
  padding: 22px;
}

.eyebrow,
.meta-label,
.message-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--forest-soft);
}

h1,
h2,
h3 {
  font-family: var(--headline);
  margin: 0 0 10px;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2rem, 3vw, 3.2rem);
}

h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

h3 {
  font-size: 1.25rem;
}

.lede,
.hint,
.result-empty,
.story-text,
#storySummary,
#storyId,
.message p,
.result-panel pre {
  line-height: 1.55;
}

.field,
.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.checkbox-row span {
  font-size: 0.92rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(46, 90, 79, 0.2);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.92);
}

.field textarea {
  resize: vertical;
  min-height: 140px;
}

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

.checkbox-row {
  margin-top: 14px;
  flex-direction: row;
  align-items: center;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.chat-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 24px;
}

.chat-card {
  display: flex;
  flex-direction: column;
  min-height: 64vh;
}

.chat-header,
.result-header,
.result-meta,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-pill {
  border-radius: 999px;
  background: rgba(72, 119, 104, 0.14);
  color: var(--forest);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
}

.message-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 0;
}

.message {
  max-width: 780px;
  padding: 16px 18px;
  border-radius: 18px;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(140deg, rgba(46, 90, 79, 0.14), rgba(72, 119, 104, 0.22));
}

.message.assistant {
  align-self: flex-start;
  background: rgba(255, 251, 241, 0.88);
  border: 1px solid rgba(46, 90, 79, 0.08);
}

.message pre,
.result-panel pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
}

.composer {
  padding-top: 12px;
  border-top: 1px solid rgba(46, 90, 79, 0.14);
}

.composer-field {
  margin-bottom: 14px;
}

.primary-button,
.ghost-button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--forest), var(--berry));
  color: #fffdf8;
  padding: 12px 18px;
  box-shadow: 0 12px 25px rgba(46, 90, 79, 0.24);
}

.ghost-button {
  background: rgba(255, 250, 242, 0.92);
  color: var(--ink);
  padding: 11px 16px;
  border: 1px solid rgba(46, 90, 79, 0.14);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

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

.result-card {
  min-height: 260px;
}

.result-content.is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

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

.result-panel {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 252, 245, 0.76);
  border: 1px solid rgba(46, 90, 79, 0.08);
}

.story-panel {
  margin-top: 16px;
}

.story-text {
  white-space: pre-wrap;
}

code {
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .result-columns {
    grid-template-columns: 1fr;
  }
}
