:root {
  --nv-green: #76b900;
  --nv-green-bright: #8fd000;
  --nv-green-dim: rgba(118, 185, 0, 0.15);
  --bg: #0b0e0c;
  --bg-elev: #14181500;
  --surface: #161a16;
  --surface-2: #1d221d;
  --surface-3: #252b24;
  --border: #2c332b;
  --border-strong: #3a4338;
  --text: #e8ede6;
  --text-dim: #a7b0a3;
  --text-faint: #7c857a;
  --danger: #ff6b6b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #10130f 0%, var(--bg) 100%);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 10px;
  height: 40px;
  border-radius: 3px;
  background: var(--nv-green);
  box-shadow: 0 0 16px rgba(118, 185, 0, 0.6);
  display: inline-block;
}

.brand-eyebrow {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nv-green);
  font-weight: 600;
}

.brand-title {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-title .accent {
  color: var(--nv-green);
}

.brand-tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.picker-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.picker-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.picker-col {
  flex: 1 1 260px;
  min-width: 0;
}

.picker-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
  font-weight: 600;
}

.template-select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}

.template-select:focus {
  outline: none;
  border-color: var(--nv-green);
  box-shadow: 0 0 0 3px var(--nv-green-dim);
}

.template-blurb {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.pane-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.pane-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.pane-sub {
  margin: 4px 0 0;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------- Context callout ---------- */
.template-context {
  margin: 14px 20px 0;
  padding: 14px 16px;
  background: var(--nv-green-dim);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--nv-green);
  border-radius: var(--radius-sm);
}

.template-context .context-heading {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nv-green-bright);
}

.template-context p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.template-context p + p {
  margin-top: 8px;
}

.template-context ul {
  margin: 0;
  padding-left: 18px;
}

.template-context li {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.template-context li + li {
  margin-top: 4px;
}

/* ---------- Form ---------- */
.madlibs-form {
  padding: 8px 20px 20px;
}

.form-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.form-section:last-child {
  border-bottom: none;
}

.form-section--decision-brief {
  margin: 10px -10px 4px;
  padding: 16px 14px;
  border: 1px solid rgba(84, 230, 216, 0.34);
  border-radius: var(--radius-sm);
  background: rgba(84, 230, 216, 0.07);
}

.form-section--decision-brief .section-title {
  color: #54e6d8;
}

.form-section--decision-brief textarea {
  border-color: rgba(84, 230, 216, 0.3);
}

.section-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--nv-green);
  letter-spacing: 0.02em;
}

/* Optional horizontal bar above a section (used by "bonus" groups). */
.section-divider {
  border: none;
  border-top: 2px dashed var(--border-strong);
  margin: 4px 0 16px;
}

.form-section--divider .section-title {
  color: var(--nv-green-bright);
}

.section-help {
  margin: 0 0 14px;
  color: var(--text-faint);
  font-size: 13px;
}

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.optional-tag {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.field-help {
  margin: 0 0 8px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.field textarea {
  min-height: 78px;
  line-height: 1.5;
}

.field input[type="text"]:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--nv-green);
  box-shadow: 0 0 0 3px var(--nv-green-dim);
}

/* "Create your own..." escape hatch: write-in field revealed under a select. */
.custom-select .custom-input {
  margin-top: 8px;
}

.field.missing input[type="text"],
.field.missing textarea,
.field.missing select {
  border-color: var(--border-strong);
}

.field-flag {
  display: none;
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--nv-green);
}

.field.missing .field-flag {
  display: block;
}

/* Radio group */
.radio-group,
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.chip:hover {
  border-color: var(--nv-green);
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip.checked {
  background: var(--nv-green-dim);
  border-color: var(--nv-green);
  color: var(--nv-green-bright);
  font-weight: 600;
}

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--nv-green);
}

.slider-value {
  min-width: 44px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--nv-green-bright);
  font-weight: 600;
}

/* ---------- Preview ---------- */
.preview-pane {
  position: sticky;
  top: 20px;
}

.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.05s;
}

.btn:hover {
  border-color: var(--nv-green);
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--border-strong);
}

.btn:disabled:hover {
  border-color: var(--border-strong);
}

.btn-primary:disabled,
.btn-primary:disabled:hover {
  background: var(--surface-2);
  color: var(--text-faint);
}

.btn-primary {
  background: var(--nv-green);
  border-color: var(--nv-green);
  color: #0b0e0c;
}

.btn-primary:hover {
  background: var(--nv-green-bright);
  border-color: var(--nv-green-bright);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

.preview {
  margin: 0;
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.preview .filled {
  color: var(--nv-green-bright);
  background: var(--nv-green-dim);
  border-radius: 3px;
  padding: 0 3px;
}

.preview strong {
  font-weight: 700;
  color: var(--text);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  border: 1px solid var(--nv-green);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .panes { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  .preview { max-height: none; }
}

@media (max-width: 720px) {
  .layout,
  .header-inner {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 520px) {
  .brand-tagline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
