/* Website Prompt Builder — minimalist, accessible (AA contrast), responsive.
   Design tokens live as custom properties so the whole UI retheme is one block. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #1a2233;
  --ink-soft: #56617a;
  --line: #dfe3ea;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #eef0ff;
  --focus: #4f46e5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; }

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 18px;
}

.brand h1 { font-size: 18px; letter-spacing: -0.01em; }

.tagline { margin: 0; font-size: 13px; color: var(--ink-soft); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-template { border-radius: 999px; }

.mode-toggle {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 999px;
}

.mode-toggle button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-toggle button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px;
  align-items: start;
}

.form-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  min-height: 420px;
}

/* ---- Preview pane ---- */
.preview-pane {
  position: sticky;
  top: 24px;
  background: var(--ink);
  color: #e8ebf2;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-head h2 { font-size: 15px; letter-spacing: 0.02em; text-transform: uppercase; color: #aeb6c9; }

.preview-meta { font-size: 12px; color: #8f98ad; }

.style-toggle {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.style-toggle button {
  border: 0;
  background: transparent;
  color: #aeb6c9;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.style-toggle button.active { background: rgba(255, 255, 255, 0.18); color: #fff; }

.preview-text {
  flex: 1;
  overflow: auto;
  margin: 0 0 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

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

/* ---- Buttons ---- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.05s, filter 0.15s, background 0.15s;
}

.btn:hover { filter: brightness(0.98); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.7; cursor: default; }

.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

.btn-ghost { background: transparent; }

.preview-actions .btn { border-color: rgba(255, 255, 255, 0.18); }
.preview-actions .btn:not(.btn-primary) { background: rgba(255, 255, 255, 0.08); color: #e8ebf2; }
.preview-actions .btn-ghost { background: transparent; }

/* ---- Basic wizard ---- */
.wizard { max-width: 620px; margin: 0 auto; }

.progress { display: flex; gap: 8px; justify-content: center; margin-bottom: 28px; }

.dot { width: 9px; height: 9px; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.dot-on { background: var(--primary); }

.question { min-height: 260px; }

.q-title { font-size: 24px; letter-spacing: -0.02em; margin-bottom: 8px; }

.q-help { color: var(--ink-soft); margin: 0 0 22px; }

.q-input {
  width: 100%;
  font-size: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.q-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

.wizard-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 28px; }
.wizard-nav .btn-primary { margin-left: auto; }

/* ---- Chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  padding: 9px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover { border-color: var(--primary); }
.chip-on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip-custom { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

.chip-picker, .color-picker { display: flex; flex-direction: column; gap: 16px; }

.chip-adder { display: flex; gap: 8px; }
.chip-adder .q-input { flex: 1; }

/* ---- Vibe cards ---- */
.vibe-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.vibe-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 20px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.vibe-card:hover { border-color: var(--primary); }
.vibe-card:active { transform: translateY(1px); }
.vibe-on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.vibe-label { font-size: 16px; font-weight: 700; }
.vibe-blurb { font-size: 13px; color: var(--ink-soft); }

/* ---- Color picker ---- */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.swatch:hover { border-color: var(--primary); }
.swatch-on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.swatch-dot { width: 16px; height: 16px; border-radius: 999px; background: var(--swatch); border: 1px solid rgba(0,0,0,0.1); }

.color-input { width: 48px; height: 42px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }

/* ---- Result screen ---- */
.result-text {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow: auto;
}

/* ---- Advanced dashboard ---- */
.advanced { display: flex; flex-direction: column; gap: 12px; }

.adv-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.adv-section > summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.adv-section > summary::-webkit-details-marker { display: none; }
.adv-section > summary::before { content: "▸"; color: var(--ink-soft); transition: transform 0.15s; }
.adv-section[open] > summary::before { transform: rotate(90deg); }
.adv-section[open] > summary { border-bottom: 1px solid var(--line); }

.field { padding: 12px 16px; }
.field + .field { border-top: 1px solid var(--surface-2); }

.field > label,
.field-group > legend { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

/* fieldset carries its own default border/margin/padding — strip them so a
   checkgroup group reads identically to the other .field rows. */
.field-group { border: 0; margin: 0; min-width: 0; }
.field-group > legend { padding: 0; }

.field-check { display: flex; align-items: center; gap: 10px; }
.field-check > label { margin: 0; font-size: 14px; color: var(--ink); font-weight: 600; }
.field-check input { width: 18px; height: 18px; accent-color: var(--primary); }

.f-input {
  width: 100%;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.f-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

.f-area { resize: vertical; font-family: inherit; line-height: 1.5; }

select.f-input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---- Mobile preview fab / bottom sheet ---- */
.preview-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  border: 0;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 700;
  font-size: 14px;
  padding: 14px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ---- Templates modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 24, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  overflow: auto;
  padding: 24px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 { font-size: 20px; letter-spacing: -0.01em; }

.modal-close {
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
}

.modal-close:hover { filter: brightness(0.95); }

.modal-sub { margin: 6px 0 20px; color: var(--ink-soft); font-size: 14px; }

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

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.preset-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.preset-card:active { transform: translateY(1px); }

.preset-label { font-size: 15px; font-weight: 700; }
.preset-blurb { font-size: 13px; color: var(--ink-soft); line-height: 1.4; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }

  .preview-fab { display: block; }

  .preview-pane {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    max-height: 75vh;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(105%);
    transition: transform 0.25s ease;
    z-index: 30;
  }

  .preview-open .preview-pane { transform: translateY(0); }

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