:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #f0f4ef;
  --ink: #17211f;
  --muted: #64706d;
  --line: #dce3df;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #dff4ef;
  --accent: #b7791f;
  --danger: #b42318;
  --shadow: 0 14px 38px rgba(15, 38, 33, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0) 300px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: auto;
  height: clamp(48px, 4.4vw, 58px);
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 5px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-copy .eyebrow {
  margin: 0;
  font-size: 15px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  letter-spacing: 0;
}

.topbar-actions,
.action-row,
.output-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  --left-column: 54%;
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, var(--left-column)) minmax(390px, 1fr);
  gap: 18px;
  align-items: start;
}

.left-stack,
.right-stack {
  display: grid;
  gap: 18px;
}

.right-stack {
  position: sticky;
  top: 18px;
}

.splitter {
  position: absolute;
  top: 18px;
  left: calc(var(--left-column) + 9px);
  height: calc(100vh - 58px);
  width: 18px;
  transform: translateX(-9px);
  border-radius: 999px;
  cursor: col-resize;
  outline: none;
  z-index: 5;
}

.splitter::before {
  content: "";
  display: block;
  width: 2px;
  height: 100%;
  margin: 0 auto;
  border-radius: 999px;
  background: transparent;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.splitter:hover::before,
.splitter:focus-visible::before,
.workspace.resizing .splitter::before {
  background: var(--primary);
}

.workspace.resizing {
  cursor: col-resize;
  user-select: none;
}

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

.panel-header,
.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.required-note,
.hint,
.character-count,
.toggle-row small,
.safety-note,
.api-note p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.full-span {
  grid-column: 1 / -1;
}

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

.field span,
.control-label,
.toggle-row strong {
  color: #263331;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

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

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

textarea {
  resize: vertical;
  min-height: 132px;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 22px 0;
}

.scenario-fields {
  margin-top: 18px;
  border: 1px solid #d8e5df;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f7fbf8, #fff);
  padding: 15px;
}

.scenario-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.scenario-header h3 {
  font-size: 15px;
}

.scenario-header span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid #cfd8d4;
  border-radius: 999px;
  background: #fff;
  color: #31403d;
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.chip.active::before {
  background: currentColor;
}

.custom-feature {
  margin-top: 14px;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 43px;
  gap: 8px;
}

.button-icon {
  display: inline-grid;
  place-items: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  padding: 0 15px;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.primary-button.is-confirmed,
.ghost-button.is-confirmed {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.secondary-button,
.ghost-button,
.copy-button {
  border: 1px solid #cfd8d4;
  background: #fff;
  color: #263331;
  padding: 0 13px;
}

.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.copy-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.compact {
  min-height: 38px;
}

.icon-only {
  width: 43px;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #fff7e8;
  color: #87550f;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
}

.toggle-row span {
  display: grid;
  gap: 2px;
}

.toggle-row input {
  width: 42px;
  min-height: 22px;
  accent-color: var(--primary);
}

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

.segmented-group > div {
  display: grid;
  gap: 7px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #cfd8d4;
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  min-height: 39px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.segmented button + button {
  border-left: 1px solid #cfd8d4;
}

.segmented button.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.action-row {
  justify-content: space-between;
  margin-top: 18px;
}

.validation-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.generate-button {
  min-width: 208px;
}

.output-panel {
  min-height: 620px;
}

.empty-state,
.loading-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px dashed #cbd6d1;
  border-radius: var(--radius);
  background: var(--surface-muted);
  text-align: center;
  padding: 24px;
}

.empty-state h3 {
  margin-top: 13px;
  font-size: 17px;
}

.empty-state p,
.loading-state p {
  max-width: 390px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary);
  box-shadow: 0 8px 20px rgba(15, 38, 33, 0.08);
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #cce4de;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.small-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.generated-state {
  display: grid;
  gap: 12px;
}

.output-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 13px;
}

.output-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.copy-button {
  min-height: 31px;
  padding: 0 10px;
}

.editable-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.editable-body {
  min-height: 220px;
}

.compact-body {
  min-height: 92px;
}

.safety-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.toast {
  min-height: 20px;
  margin-top: 8px;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 800;
}

.api-note h2 {
  margin-bottom: 8px;
}

@media (max-width: 1060px) {
  .workspace {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .right-stack,
  .splitter {
    position: static;
  }

  .splitter {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 14px;
  }

  .topbar,
  .panel-header,
  .section-row,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .output-actions {
    width: 100%;
  }

  .topbar-actions button,
  .output-actions button,
  .generate-button {
    flex: 1;
    width: 100%;
  }

  .panel {
    padding: 16px;
  }

  .form-grid,
  .settings-grid,
  .segmented-group {
    grid-template-columns: 1fr;
  }

  .chip-grid {
    gap: 8px;
  }

  .chip {
    max-width: 100%;
    white-space: normal;
  }

  .output-panel {
    min-height: auto;
  }
}
