/* =========================================================================
   PORCHLYTE FORM TOOLS — SHARED DESIGN SYSTEM
   -------------------------------------------------------------------------
   This stylesheet is the cohesive base for every form tool in the suite.
   The shared base below is identical across the suite. Tool-specific rules
   for Script Studio live in the clearly marked block at the bottom and only
   build on the tokens above; they never change them.

   Palette: white + cream surfaces, dark brown type, rust as an accent only.
   Type:    Chapza (display, falls back to Playfair Display) + Inter (body/UI).
   ========================================================================= */

:root {
  /* Brand palette */
  --cream: #efeae3;      /* page + section backgrounds */
  --white: #ffffff;      /* cards, tool surfaces, form fields */
  --tan: #d7c8ba;        /* secondary panels, hover, dividers, pills */
  --brown: #2b1f1b;      /* body text + headings, dark modules */
  --rust: #80441e;       /* accent only: buttons, active state, underlines */

  --text: var(--brown);
  --text-soft: #6f6157;  /* muted brown for sub text */
  --border: #e4dacd;     /* soft warm border */
  --error: #80441e;

  --font-display: "Chapza", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(43, 31, 27, 0.04), 0 6px 20px rgba(43, 31, 27, 0.05);

  --content-width: 760px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules like flex/grid. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 40px 24px 96px;
}

.screen { display: none; }
.screen.active {
  display: block;
  animation: fadein 0.35s var(--ease);
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== TOOL HEADER (reusable shell — same on every form) ===== */
.tool-header {
  text-align: center;
  margin: 0 0 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.tool-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--brown);
  margin: 0 0 12px;
}
.tool-tagline {
  margin: 0 auto;
  max-width: 540px;
  color: var(--text-soft);
  font-size: 16px;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--rust);
  color: #fff;
  border: 1px solid var(--rust);
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.01em;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: 0 2px 8px rgba(128, 68, 30, 0.18);
}
.btn-primary:hover {
  background: #6c3818;
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(128, 68, 30, 0.24);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--brown);
  color: #fff;
  border: 1px solid var(--brown);
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease);
}
.btn-secondary:hover { background: #1c1512; transform: translateY(-1px); }

/* Quiet Copy button — tan pill */
.btn-copy {
  background: var(--tan);
  color: var(--brown);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.btn-copy:hover { background: #cbb9a8; }
.btn-copy.is-copied { background: var(--rust); color: #fff; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ===== FORM ===== */
#form, #loading, #results {
  margin: 0 auto;
}
.form-note {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rust);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 0 0 28px;
  color: var(--text-soft);
  font-size: 14.5px;
}
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.form-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-margin-top: 96px;
}
.form-section-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--rust);
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.field-row {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field.span-2 { grid-column: span 2; }
.field > span,
.field > legend {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-soft);
  text-align: left;
  padding-left: 2px;
}
.field > span em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--tan);
  margin-left: 6px;
}
.field input,
.field select,
.field textarea {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  font: inherit;
  color: inherit;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--rust);
  box-shadow: 0 0 0 3px rgba(128, 68, 30, 0.15);
}

.form-actions {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 4px;
}
.form-actions .microcopy { text-align: center; }
.microcopy {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0;
}
.form-error {
  color: var(--error);
  font-size: 14px;
  margin: 8px 0 0;
  font-weight: 500;
  background: #fbf1ea;
  border: 1px solid #e7c9b6;
  border-left: 3px solid var(--rust);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

/* ===== SCREEN HEADERS (used on the results screen) ===== */
.screen-header {
  text-align: left;
  margin: 8px 0 28px;
}
.screen-header.center { text-align: center; }
.screen-header h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1.05;
  color: var(--brown);
  margin: 0 0 12px;
}
.screen-header.center h2.underline { display: inline-block; }
.screen-header.center h2.underline::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  background: var(--rust);
  border-radius: 2px;
  margin: 14px auto 0;
}
.screen-sub {
  margin: 0;
  color: var(--text-soft);
  font-size: 16px;
}

/* ===== LOADING ===== */
.loader {
  text-align: center;
  padding: 72px 0;
}
.loader h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 3.5vw, 32px);
  color: var(--brown);
  margin: 0 0 8px;
}

/* ===== RESULTS ===== */
.result-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.result-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--brown);
  color: #fff;
  padding: 12px 22px;
}
.result-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--tan);
}
.result-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: #fff;
}
.result-body { padding: 22px 22px 8px; }
.content-body {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--brown);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.result-card .card-actions { padding: 0 22px 20px; }

.results-again {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.card-error-msg {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
}

.result-card.just-arrived { animation: card-in 0.35s var(--ease); }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== COLLAPSIBLE CARDS (deeper sections, collapsed by default) ===== */
.result-card.is-collapsible .result-bar {
  cursor: pointer;
  user-select: none;
  transition: background 0.16s var(--ease);
}
.result-card.is-collapsible .result-bar:hover { background: #241a16; }
.collapse-ctrl { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.collapse-hint {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  font-weight: 600; color: var(--tan);
}
.collapse-chevron { color: var(--tan); font-size: 12px; line-height: 1; }
.result-card.is-collapsed .result-body,
.result-card.is-collapsed > .card-actions { display: none; }

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 56px;
  padding: 26px 0 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer-disclaimer {
  font-size: 12px;
  color: var(--text-soft);
  margin: 0 auto;
  max-width: 620px;
  opacity: 0.9;
  line-height: 1.55;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== RESPONSIVE (shared) ===== */
@media (max-width: 520px) {
  .app { padding: 28px 18px 80px; }
  .result-bar { padding: 11px 18px; }
  .result-body { padding: 18px 18px 6px; }
  .result-card .card-actions { padding: 0 18px 18px; }
  .field.span-2 { grid-column: auto; }
}


/* =========================================================================
   SHARED SUITE PATTERNS (header badge, pills, reveals, progressive load)
   These match the rest of the PorchLyte suite exactly and only reuse tokens.
   ========================================================================= */

.tool-badge-cat {
  display: inline-block;
  background: var(--brown);
  color: var(--tan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
}
.tool-subhead {
  margin: 0 auto;
  max-width: 560px;
  color: var(--rust);
  font-size: clamp(16px, 2.4vw, 19px);
  font-weight: 600;
}
.tool-support {
  margin: 12px auto 0;
  max-width: 560px;
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.6;
}
.tool-support em { font-style: italic; }
.tool-header-cta { margin-top: 22px; }

.help-text {
  font-size: 13.5px;
  color: var(--text-soft);
  margin: 0;
  line-height: 1.55;
}
.help-text strong { color: var(--brown); font-weight: 600; }
.help-text ul { margin: 6px 0 0; padding-left: 18px; }
.help-text li { margin-bottom: 3px; }

textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
textarea.tall { min-height: 130px; }

/* ---- Pill option groups (shared suite pattern) ---- */
.pill-group {
  border: 0; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 10px;
}
.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 14.5px;
  color: var(--brown);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
  user-select: none;
}
.pill:hover { border-color: var(--tan); background: #faf7f2; }
.pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill:has(input:focus-visible) {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px rgba(128, 68, 30, 0.15);
}
.pill:has(input:checked) {
  background: var(--rust);
  border-color: var(--rust);
  color: #fff;
  box-shadow: 0 2px 8px rgba(128, 68, 30, 0.2);
}

/* ---- Conditional reveal blocks (shared suite pattern) ---- */
.conditional {
  margin-top: 4px;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rust);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadein 0.3s var(--ease);
}

/* ---- Small actions (shared suite pattern) ---- */
.options-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-mini {
  background: var(--tan); color: var(--brown);
  border: 1px solid transparent; padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.03em; cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.btn-mini:hover { background: #cbb9a8; }
.btn-mini:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-mini.ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn-mini.ghost:hover { background: var(--white); }
.btn-mini.is-active { background: var(--rust); color: #fff; }

/* ---- Results toolbar (shared suite pattern) ---- */
.results-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 0 0 14px; padding-bottom: 22px; border-bottom: 1px solid var(--border);
}

/* ---- Inline edit mode (shared suite pattern) ---- */
.edit-note {
  max-width: 560px; margin: 0 auto 22px; padding: 11px 16px;
  background: #f6efe7; border: 1px solid var(--border); border-left: 3px solid var(--rust);
  border-radius: var(--radius-md); color: var(--text-soft); font-size: 13.5px;
  line-height: 1.5; text-align: center;
}
.edit-note strong { color: var(--rust); }
#results.is-editing .result-body { outline: 1px dashed var(--rust); outline-offset: 6px; border-radius: var(--radius-sm); }
[contenteditable="true"]:focus { outline: 2px solid var(--rust); outline-offset: 4px; }
@media print { #results.is-editing .result-body { outline: none !important; } }

/* ---- Progressive loading: shimmer placeholders + writing indicator ---- */
.result-card + .result-card { margin-top: 16px; }
.result-card.is-pending { opacity: 0.85; }
.shimmer { display: flex; flex-direction: column; gap: 10px; padding: 10px 0 16px; }
.shimmer span {
  height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, var(--cream) 25%, #e7ddd0 37%, var(--cream) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.shimmer span:nth-child(1) { width: 100%; }
.shimmer span:nth-child(2) { width: 92%; }
.shimmer span:nth-child(3) { width: 68%; }
@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
.results-writing {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 20px 0 0; color: var(--text-soft); font-size: 14px;
}
.writing-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--rust);
  animation: writing-pulse 1s ease-in-out infinite;
}
@keyframes writing-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .shimmer span, .writing-dot { animation: none; }
}

.section-intro { margin: 0 0 16px; font-size: 15px; color: var(--text-soft); line-height: 1.55; }
.mini-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.mini-list li { font-size: 14.5px; color: var(--brown); line-height: 1.5; }
.callout {
  background: #f6efe7; border: 1px solid var(--border); border-left: 3px solid var(--rust);
  border-radius: var(--radius-md); padding: 12px 16px; margin-top: 4px;
}
.callout-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--rust); margin: 0 0 4px; }
.callout-text { margin: 0; font-size: 14.5px; color: var(--brown); line-height: 1.55; }
.sub-block { padding: 14px 0; border-top: 1px solid var(--border); }
.sub-block:first-child { border-top: none; padding-top: 2px; }
.sub-title { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 700; color: var(--rust); margin: 0 0 10px; }
.line-copy, .q-copy {
  background: none; border: 0; cursor: pointer; font-family: inherit;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--rust); padding: 2px 4px; flex: 0 0 auto; align-self: flex-start; margin-top: 2px;
}
.line-copy.is-copied, .q-copy.is-copied { color: var(--brown); }

/* =========================================================================
   TOOL-SPECIFIC ADDITIONS (Script Studio only)
   Builds on the shared system above and reuses its tokens. Nothing here
   changes the shared components; it only adds the pieces this tool needs.
   ========================================================================= */

/* Fieldsets default to min-inline-size:min-content, which stops a grid or flex
   fieldset shrinking on a narrow phone. */
fieldset { min-inline-size: 0; }

/* ---- Format toggle: the first decision, and the biggest control on the form ---- */
.format-question {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(22px, 3.2vw, 28px);
  color: var(--brown);
  margin: 0 0 4px;
  text-align: center;
}
.format-toggle {
  border: 0; margin: 0; padding: 0;
  display: grid; gap: 12px;
  grid-template-columns: repeat(3, 1fr);
}
.format-opt {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 8px; text-align: center;
  padding: 22px 14px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-card);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease),
              box-shadow 0.16s var(--ease), transform 0.12s var(--ease);
}
.format-opt:hover { border-color: var(--tan); transform: translateY(-2px); }
.format-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.format-opt:has(input:focus-visible) { border-color: var(--rust); box-shadow: 0 0 0 3px rgba(128, 68, 30, 0.15); }
.format-icon { width: 34px; height: 34px; stroke: var(--rust); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.format-copy { display: flex; flex-direction: column; gap: 4px; }
.format-name {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--brown); line-height: 1.3;
}
.format-blurb { font-size: 12.5px; color: var(--text-soft); line-height: 1.45; }
.format-opt:has(input:checked) {
  background: var(--brown); border-color: var(--brown);
  box-shadow: 0 6px 18px rgba(43, 31, 27, 0.18);
}
.format-opt:has(input:checked) .format-icon { stroke: var(--tan); }
.format-opt:has(input:checked) .format-name { color: #fff; }
.format-opt:has(input:checked) .format-blurb { color: var(--tan); }
@media (max-width: 560px) {
  .format-toggle { grid-template-columns: 1fr; }
  .format-opt { flex-direction: row; text-align: left; align-items: center; padding: 16px 18px; gap: 14px; }
  .format-icon { flex: 0 0 auto; }
}

/* ---- Tone cards: selectable, with an explanation on each ---- */
.tone-grid {
  border: 0; margin: 0; padding: 0;
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
}
.tone-card {
  position: relative;
  display: flex; flex-direction: column; gap: 5px;
  padding: 15px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer; user-select: none;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.tone-card:hover { border-color: var(--tan); background: #faf7f2; }
.tone-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.tone-card:has(input:focus-visible) { border-color: var(--rust); box-shadow: 0 0 0 3px rgba(128, 68, 30, 0.15); }
.tone-name { font-size: 15px; font-weight: 700; color: var(--brown); line-height: 1.2; }
.tone-desc { font-size: 13px; color: var(--text-soft); line-height: 1.45; }
.tone-card:has(input:checked) { background: var(--rust); border-color: var(--rust); box-shadow: 0 2px 10px rgba(128, 68, 30, 0.2); }
.tone-card:has(input:checked) .tone-name { color: #fff; }
.tone-card:has(input:checked) .tone-desc { color: #f0ded1; }

/* ---- Topic finder ---- */
.topic-status {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: var(--text-soft); margin: 0;
}
.topic-status .writing-dot { width: 8px; height: 8px; }
.research-note {
  background: var(--cream); border: 1px solid var(--border); border-left: 3px solid var(--tan);
  border-radius: var(--radius-md); padding: 12px 15px; margin: 0;
}
.research-label {
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 700; color: var(--rust); margin: 0 0 4px;
}
.research-text { margin: 0; font-size: 13.5px; color: var(--text-soft); line-height: 1.55; }
.research-sources { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.research-sources a {
  font-size: 11.5px; color: var(--brown); background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 3px 10px; text-decoration: none; max-width: 260px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block;
}
.research-sources a:hover { border-color: var(--rust); color: var(--rust); }

.topic-list { display: flex; flex-direction: column; gap: 12px; }
.topic-card {
  position: relative; display: block; text-align: left;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 18px;
  cursor: pointer; user-select: none;
  animation: card-in 0.3s var(--ease);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.12s var(--ease);
}
.topic-card:hover { border-color: var(--tan); transform: translateY(-1px); }
.topic-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.topic-card:has(input:focus-visible) { border-color: var(--rust); box-shadow: 0 0 0 3px rgba(128, 68, 30, 0.15); }
.topic-card:has(input:checked) { border-color: var(--rust); box-shadow: 0 0 0 2px rgba(128, 68, 30, 0.18); background: #fdfaf6; }
.topic-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.topic-title { flex: 1; font-size: 16px; font-weight: 700; color: var(--brown); line-height: 1.3; margin: 0; }
.topic-flag {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 3px 9px; border-radius: var(--radius-pill);
  background: var(--tan); color: var(--brown); margin-top: 2px;
}
.topic-flag.is-timely { background: var(--rust); color: #fff; }
.topic-why { margin: 0 0 12px; font-size: 14px; color: var(--text-soft); line-height: 1.55; }
.topic-meta { display: grid; gap: 8px 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); padding-top: 11px; border-top: 1px solid var(--border); }
.topic-meta div { display: flex; flex-direction: column; gap: 2px; }
.topic-key { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--rust); }
.topic-val { font-size: 13.5px; color: var(--brown); line-height: 1.4; }
.topic-source { margin: 10px 0 0; font-size: 12.5px; color: var(--text-soft); font-style: italic; line-height: 1.45; }
.topic-foot {
  display: flex; justify-content: flex-end;
  margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--border);
}
.topic-pick {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--brown); background: var(--tan);
  border-radius: var(--radius-pill); padding: 6px 14px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.topic-card:hover .topic-pick { background: #cbb9a8; }
.topic-card:has(input:checked) .topic-pick { background: var(--rust); color: #fff; }
.topic-card:has(input:checked) .topic-pick::before { content: "\2713  "; }

/* ---- The angle: on screen first, while the script is still being written ---- */
.plan-card .result-bar { background: var(--tan); color: var(--brown); }
.plan-card .result-label { color: var(--brown); }
.plan-card.is-collapsible .result-bar:hover { background: #cbb9a8; }
.plan-card .collapse-hint, .plan-card .collapse-chevron { color: var(--rust); }
.plan-lead { margin: 0 0 16px; font-size: 16px; line-height: 1.6; color: var(--brown); }
.plan-row {
  display: grid; grid-template-columns: 150px 1fr; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.plan-key { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--rust); padding-top: 2px; }
.plan-val { font-size: 14.5px; color: var(--brown); line-height: 1.55; }
@media (max-width: 520px) { .plan-row { grid-template-columns: 1fr; gap: 2px; } }

.plan-outline { display: flex; flex-direction: column; gap: 2px; }
.plan-step {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.plan-step:last-child { border-bottom: none; }
.plan-step-num {
  flex: 0 0 auto; font-family: var(--font-display); font-weight: 600;
  color: var(--rust); font-size: 14px; min-width: 20px; margin-top: 1px;
}
.plan-step-main { flex: 1; min-width: 0; }
.plan-step-name { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--brown); line-height: 1.4; }
.plan-step-covers { margin: 3px 0 0; font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.plan-step .script-part-time { flex: 0 0 auto; margin-top: 2px; }
@media (max-width: 520px) { .plan-step .script-part-time { display: none; } }

.chip.ph { font-weight: 600; }

/* ---- The script itself: the primary result ---- */
.script-card .result-bar { background: var(--rust); }
.script-card .result-num { color: #fff; }
.script-meta {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: baseline;
  padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--border);
}
.script-meta div { display: flex; align-items: baseline; gap: 7px; }
.script-meta .m-label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--rust); }
.script-meta .m-value { font-size: 14px; color: var(--brown); font-weight: 600; }

.script-doc { display: flex; flex-direction: column; gap: 4px; }
.script-part { padding: 18px 0; border-top: 1px solid var(--border); }
.script-part:first-child { border-top: none; padding-top: 0; }
.script-part-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.script-part-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700; color: var(--rust);
}
.script-part-name { font-size: 15px; font-weight: 700; color: var(--brown); line-height: 1.3; }
.script-part-time {
  font-size: 11.5px; color: var(--text-soft); font-variant-numeric: tabular-nums;
  background: var(--cream); border-radius: var(--radius-pill); padding: 2px 9px;
}
.script-say {
  margin: 0; font-size: 16px; line-height: 1.72; color: var(--brown);
  white-space: pre-wrap; word-wrap: break-word;
}
.script-say + .script-say { margin-top: 12px; }
.script-part.is-hook { background: var(--cream); border-radius: var(--radius-md); padding: 18px 20px; border-top: none; margin-bottom: 6px; }
.script-part.is-hook .script-say { font-size: 17px; }
.script-note { margin: 10px 0 0; font-size: 13px; color: var(--text-soft); font-style: italic; line-height: 1.5; }

/* Production notes: clearly separated from anything spoken out loud. */
.visual-list { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.visual-list li {
  font-size: 12.5px; letter-spacing: 0.02em; font-weight: 600; color: var(--text-soft);
  background: #f6efe7; border: 1px dashed var(--tan); border-radius: var(--radius-sm);
  padding: 7px 11px; line-height: 1.4;
}
.script-prompt {
  margin: 14px 0 0; padding: 11px 14px;
  background: var(--white); border: 1px solid var(--border); border-left: 3px solid var(--tan);
  border-radius: var(--radius-md);
}
.script-prompt .callout-label { color: var(--text-soft); }
.script-prompt p { margin: 0; font-size: 13.5px; color: var(--brown); line-height: 1.55; }

/* Anything the agent still has to fill in, impossible to miss. */
.ph {
  background: #f6e4d6; color: #7a3f1b; font-weight: 700;
  border-radius: 3px; padding: 0 3px; box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---- Short-form: hook options + beat-by-beat script ---- */
.hook-list { display: flex; flex-direction: column; gap: 10px; }
.hook-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; background: var(--cream);
  border-radius: var(--radius-md); border-left: 3px solid var(--tan);
}
.hook-row.is-chosen { border-left-color: var(--rust); background: #f6efe7; }
.hook-main { flex: 1; }
.hook-text { margin: 0; font-size: 15px; color: var(--brown); line-height: 1.55; font-weight: 500; }
.hook-approach { margin: 4px 0 0; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--rust); }
.hook-row.is-chosen .hook-approach::after { content: " \00b7 used below"; color: var(--text-soft); }

.beat-list { display: flex; flex-direction: column; gap: 2px; }
.beat {
  display: grid; grid-template-columns: 1fr 190px; gap: 16px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.beat:first-child { border-top: none; padding-top: 0; }
.beat-say { margin: 0; font-size: 16px; line-height: 1.65; color: var(--brown); }
.beat-side { display: flex; flex-direction: column; gap: 9px; }
.beat-onscreen {
  background: var(--brown); color: #fff; border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.03em; line-height: 1.35;
}
.beat-onscreen::before {
  content: "On screen"; display: block; font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--tan); font-weight: 700; margin-bottom: 3px;
}
.beat-shot { font-size: 12.5px; color: var(--text-soft); line-height: 1.45; }
.beat-shot::before {
  content: "Shot"; display: block; font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--rust); font-weight: 700; margin-bottom: 3px;
}
@media (max-width: 620px) {
  .beat { grid-template-columns: 1fr; gap: 10px; }
}

/* ---- Refine bar: the four things an agent reaches for first ---- */
.refine-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 14px 0 18px; padding: 14px 16px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.refine-label {
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 700; color: var(--rust); margin-right: 4px;
}
.refine-tones { width: 100%; margin-top: 4px; }
.refine-tones .pill-group { gap: 8px; }
.refine-tones .pill { padding: 8px 14px; font-size: 13px; }
.refine-status { font-size: 13px; color: var(--text-soft); margin: 0; width: 100%; }

/* ---- Keep This Topic Going ---- */
.idea-list { display: flex; flex-direction: column; gap: 12px; }
.idea {
  background: var(--cream); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
}
.idea-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.idea-format {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700;
  background: var(--tan); color: var(--brown); padding: 3px 9px; border-radius: var(--radius-pill);
}
.idea-title { font-size: 15px; font-weight: 700; color: var(--brown); margin: 0; line-height: 1.3; }
.idea-what { margin: 0 0 6px; font-size: 14px; color: var(--brown); line-height: 1.55; }
.idea-why { margin: 0 0 12px; font-size: 13px; color: var(--text-soft); line-height: 1.5; font-style: italic; }
.idea-out { margin-top: 12px; }
.piece-doc {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 15px 17px; animation: card-in 0.3s var(--ease);
}
.piece-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--brown); margin: 0 0 10px; }
.piece-body { margin: 0; font-size: 15px; line-height: 1.65; color: var(--brown); white-space: pre-wrap; word-wrap: break-word; }
.piece-notes { margin: 12px 0 0; font-size: 13px; color: var(--text-soft); font-style: italic; line-height: 1.5; }

/* ---- Numbered option lists (titles, thumbnail text, keywords, quotes) ---- */
.opt-list { display: flex; flex-direction: column; gap: 2px; }
.opt-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.opt-item:last-child { border-bottom: none; }
.opt-num { flex: 0 0 auto; font-family: var(--font-display); font-weight: 600; color: var(--rust); font-size: 14px; min-width: 20px; margin-top: 1px; }
.opt-text { flex: 1; font-size: 15px; color: var(--brown); line-height: 1.5; }
.opt-sub { display: block; font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--cream); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 6px 13px;
  font-size: 13px; color: var(--brown);
}

.chapter-list { display: flex; flex-direction: column; gap: 2px; }
.chapter-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.chapter-row:last-child { border-bottom: none; }
.chapter-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; color: var(--rust); }
.chapter-title { font-size: 14.5px; color: var(--brown); line-height: 1.45; }

.frame-list { display: flex; flex-direction: column; gap: 12px; }
.frame {
  background: var(--cream); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 13px 15px;
}
.frame-label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; color: var(--rust); margin: 0 0 5px; }
.frame-text { margin: 0 0 7px; font-size: 15px; font-weight: 600; color: var(--brown); line-height: 1.4; }
.frame-visual { margin: 0; font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.frame-note { margin: 5px 0 0; font-size: 12.5px; color: var(--text-soft); font-style: italic; }

.email-doc { display: flex; flex-direction: column; gap: 10px; }
.email-line { display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: baseline; }
.email-key { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--rust); }
.email-val { font-size: 14.5px; color: var(--brown); line-height: 1.5; }
.email-body { margin: 4px 0 0; font-size: 15px; line-height: 1.65; color: var(--brown); white-space: pre-wrap; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 520px) { .email-line { grid-template-columns: 1fr; gap: 2px; } }

/* ---- Teleprompter ---- */
.teleprompter {
  position: fixed; inset: 0; z-index: 60;
  background: var(--brown); color: #f6f1ea;
  display: flex; flex-direction: column;
}
.tp-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 16px; background: #1c1512; border-bottom: 1px solid #382a24;
}
.tp-title { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; color: var(--tan); margin-right: auto; }
.tp-btn {
  background: transparent; color: var(--tan); border: 1px solid #4a382f;
  border-radius: var(--radius-pill); padding: 7px 14px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.tp-btn:hover { background: var(--rust); border-color: var(--rust); color: #fff; }
.tp-btn.is-on { background: var(--rust); border-color: var(--rust); color: #fff; }
.tp-scroll { flex: 1; overflow-y: auto; scroll-behavior: auto; }
.tp-inner {
  max-width: 820px; margin: 0 auto;
  padding: 12vh 28px 80vh;
  font-size: var(--tp-size, 34px); line-height: 1.55; font-weight: 500;
}
.tp-line { margin: 0 0 1em; white-space: pre-wrap; }
.tp-head {
  font-size: 0.45em; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--tan); font-weight: 700; margin: 1.6em 0 0.5em;
}
.tp-inner .ph { background: #6b3417; color: #ffe6d3; }
@media (max-width: 560px) { .tp-inner { padding: 10vh 20px 80vh; } }

/* ---- Loader: microphone -> camera -> script pages -> record button ---- */
.studio-loader { display: flex; justify-content: center; margin: 0 auto 32px; }
.studio-svg { width: 210px; height: auto; overflow: visible; }

.sl-body { fill: var(--brown); }
.sl-accent { fill: var(--rust); }
.sl-soft { fill: var(--tan); }
.sl-paper { fill: var(--white); stroke: var(--tan); stroke-width: 2; }
.sl-rule { stroke: var(--tan); stroke-width: 3; stroke-linecap: round; }
.sl-rule-title { stroke: var(--rust); stroke-width: 5; }
.sl-stroke { fill: none; stroke: var(--brown); stroke-width: 4; stroke-linecap: round; }

/* view-box, not fill-box, so the origin below is read in viewBox coordinates
   and every phase pivots around the same point at the centre of the scene. */
.sl-mic, .sl-cam, .sl-pages, .sl-rec {
  opacity: 0;
  transform-box: view-box;
  transform-origin: 110px 95px;
}
.sl-mic   { animation: sl-mic 10s ease-in-out infinite; }
.sl-cam   { animation: sl-cam 10s ease-in-out infinite; }
.sl-pages { animation: sl-pages 10s ease-in-out infinite; }
.sl-rec   { animation: sl-rec 10s ease-in-out infinite; }

@keyframes sl-mic {
  0%   { opacity: 0; transform: scale(0.86) translateY(10px); }
  5%   { opacity: 1; transform: scale(1) translateY(0); }
  20%  { opacity: 1; transform: scale(1) translateY(0); }
  25%, 100% { opacity: 0; transform: scale(0.94) translateY(-14px); }
}
@keyframes sl-cam {
  0%, 25%  { opacity: 0; transform: scale(0.86) translateY(10px); }
  30%      { opacity: 1; transform: scale(1) translateY(0); }
  45%      { opacity: 1; transform: scale(1) translateY(0); }
  50%, 100% { opacity: 0; transform: scale(0.94) translateY(-14px); }
}
@keyframes sl-pages {
  0%, 50%  { opacity: 0; transform: scale(0.86) translateY(10px); }
  55%      { opacity: 1; transform: scale(1) translateY(0); }
  70%      { opacity: 1; transform: scale(1) translateY(0); }
  75%, 100% { opacity: 0; transform: scale(0.94) translateY(-14px); }
}
@keyframes sl-rec {
  0%, 75%  { opacity: 0; transform: scale(0.8); }
  81%      { opacity: 1; transform: scale(1); }
  96%      { opacity: 1; transform: scale(1); }
  100%     { opacity: 0; transform: scale(1.06); }
}
/* The sound waves beside the microphone, and the pulse on the record button. */
.sl-wave { animation: sl-wave 1.5s ease-in-out infinite; }
.sl-wave-2 { animation-delay: 0.2s; }
@keyframes sl-wave {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1; }
}
.sl-rec-ring { animation: sl-ring 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes sl-ring {
  0%   { opacity: 0.55; transform: scale(0.8); }
  100% { opacity: 0; transform: scale(1.5); }
}
.sl-page-2 { animation: sl-page 10s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom left; }
@keyframes sl-page {
  0%, 57% { transform: rotate(0deg); }
  63%     { transform: rotate(-7deg); }
  70%     { transform: rotate(-7deg); }
  100%    { transform: rotate(-7deg); }
}
@media (prefers-reduced-motion: reduce) {
  .sl-mic, .sl-cam, .sl-pages, .sl-rec, .sl-wave, .sl-rec-ring, .sl-page-2 {
    animation: none !important; transform: none !important;
  }
  .sl-cam, .sl-pages, .sl-rec { opacity: 0 !important; }
  .sl-mic { opacity: 1 !important; }
}

/* =========================================================================
   PRINT / SAVE AS PDF
   Default: print the whole results screen. Document mode (body[data-print]):
   print only the composed document staged in #print-stage.
   ========================================================================= */
#print-stage { display: none; }

.print-doc { color: #2b1f1b; font-family: var(--font-body); }
.print-doc .pd-brand { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 700; color: var(--rust); margin: 0 0 4px; }
.print-doc .pd-title { font-family: var(--font-display); font-weight: 600; font-size: 26px; margin: 0 0 2px; }
.print-doc .pd-sub { font-size: 13px; color: var(--text-soft); margin: 0 0 18px; }
.print-doc .pd-h { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 18px 0 4px; }
.print-doc .pd-label { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; color: var(--rust); margin: 16px 0 4px; }
.print-doc .pd-p { font-size: 14px; line-height: 1.75; margin: 0 0 10px; white-space: pre-wrap; }
.print-doc .pd-note { font-size: 12px; font-style: italic; color: var(--text-soft); margin: 0 0 10px; }
.print-doc .pd-vis { font-size: 11.5px; font-weight: 600; color: var(--text-soft); margin: 0 0 4px; }
.print-doc .pd-foot { margin-top: 22px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 10.5px; color: var(--text-soft); line-height: 1.5; }

@media print {
  .tool-header, .results-toolbar, .results-again, .refine-bar,
  #form, #loading, .card-actions, .line-copy, .q-copy,
  .collapse-ctrl, .teleprompter { display: none !important; }
  body { background: #fff; }
  .app { padding: 0; max-width: 100%; }
  .result-card, .idea, .frame, .piece-doc { box-shadow: none; }

  /* Keep-together only on blocks that can actually fit on a page. A whole
     result card, or one section of a long script, is taller than a sheet, and
     telling the browser not to break it invites stray blank pages. */
  .idea, .frame, .piece-doc, .hook-row, .beat, .chapter-row,
  .opt-item, .plan-step, .email-line, .script-prompt, .visual-list li, .q-item {
    break-inside: avoid; page-break-inside: avoid;
  }
  /* A heading never sits alone at the foot of a page. */
  .result-bar, .script-part-head, .sub-title, .analysis-sub, .frame-label, .plan-key {
    break-after: avoid; page-break-after: avoid;
  }
  .script-say, .beat-say, .content-body, .plan-val, .email-body, .piece-body,
  .tl-note, .script-note { orphans: 3; widows: 3; }

  .result-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ph { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .result-card.is-collapsed .result-body { display: block !important; }
  .screen { display: block !important; }
  #form, #loading { display: none !important; }

  body[data-print] #results { display: none !important; }
  body[data-print] #print-stage { display: block !important; }
  body[data-print] .tool-header { display: none !important; }
}
