:root {
  color-scheme: light;
  --bg: #f3f5f3;
  --panel: #ffffff;
  --panel-alt: #f8faf8;
  --line: #d9dfd8;
  --text: #18231a;
  --muted: #5b685d;
  --brand: #1f6a45;
  --brand-strong: #155437;
  --accent: #175a90;
  --warn: #a96816;
  --danger: #a43b2c;
  --success-bg: #e5f4eb;
  --warn-bg: #fff3df;
  --danger-bg: #fde9e6;
  --shadow: 0 18px 48px rgba(23, 35, 24, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
  background: #f7f8f5;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.workspace {
  padding: 24px 32px 36px;
}

.content-band {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-form {
  padding: 24px;
}

.panel-summary {
  padding: 20px;
  position: sticky;
  top: 20px;
}

.section-block + .section-block {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
}

.section-heading h2,
.summary-header h2,
.settings-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.section-heading p,
.summary-block p,
.muted,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

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

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

.field span {
  font-size: 14px;
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(23, 90, 144, 0.2);
  outline-offset: 1px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 6px;
}

.segment,
.secondary-action,
.primary-action,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.segment {
  min-height: 44px;
  padding: 10px 12px;
  font-weight: 600;
}

.segment.active {
  border-color: var(--brand);
  background: rgba(31, 106, 69, 0.08);
  color: var(--brand-strong);
}

.action-row,
.settings-actions,
.summary-header,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-row {
  margin-top: 30px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
  font-weight: 600;
}

.primary-action {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary-action:hover {
  background: var(--brand-strong);
}

.secondary-action {
  background: var(--panel-alt);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

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

.summary-block + .summary-block {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.live {
  background: var(--success-bg);
  color: var(--brand-strong);
}

.snapshot-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.snapshot-list div {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(0, 1.4fr);
  gap: 10px;
}

.snapshot-list dt {
  color: var(--muted);
  font-size: 13px;
}

.snapshot-list dd {
  margin: 0;
  font-size: 13px;
  word-break: break-word;
}

.recent-drafts {
  display: grid;
  gap: 10px;
}

.draft-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
}

.draft-item strong {
  font-size: 14px;
}

.draft-meta {
  color: var(--muted);
  font-size: 12px;
}

.result-panel {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  font-size: 14px;
  line-height: 1.5;
}

.result-panel.success {
  border-color: #bddbc8;
  background: var(--success-bg);
  color: var(--brand-strong);
}

.result-panel.warning {
  border-color: #ead2a2;
  background: var(--warn-bg);
  color: #8c5a12;
}

.result-panel.error {
  border-color: #e6b1a8;
  background: var(--danger-bg);
  color: var(--danger);
}

.settings-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(17, 25, 18, 0.35);
}

.settings-shell {
  display: grid;
  gap: 18px;
  padding: 20px;
}

@media (max-width: 1100px) {
  .content-band {
    grid-template-columns: 1fr;
  }

  .panel-summary {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .workspace {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    padding-top: 20px;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

  .segmented-control {
    width: 100%;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }
}
