@import url("https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap");

/* "Clean": white ground, zinc greys, one ink for actions. Amber is kept for a
   single job — flagging what's missing — so it still means something. */
:root {
  color-scheme: light;
  --paper: #ffffff;
  --surface: #ffffff;
  --raised: #ffffff;
  --ink: #0a0a0a;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e4e4e7;
  --divider: rgba(10, 10, 10, 0.08);
  --line-strong: #0a0a0a;
  --accent: #0a0a0a;
  --focus: #2563eb;
  --cream: #f4f4f5;
  --yellow: #f5c542;
  --amber: #f5c542;
  --gold: #e9a635;
  --pink: #dd86a0;
  --gold-accent: #b45309;
  --blue: #2563eb;
  --green: #16a34a;
  --danger: #b91c1c;
  --radius: 10px;
  --radius-lg: 16px;

  --rule: #ececec;
  --field: #f4f4f5;

  /* Theme seams. Every colour below reads one of these, so the dark block only
     restates values — never rules. --on-ink sits on an ink fill, --on-gold on
     the amber card. */
  --panel: transparent;
  --card: #fafafa;
  --chip: #f4f4f5;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --on-ink: #fafafa;
  --on-accent: #0a0a0a;
  --on-gold: #0a0a0a;
  --shadow-rgb: 10, 10, 10;
  --logo-blend: normal;
  --logo-filter: none;

  --font-sans: Geist, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Dark. Set by theme.js before paint. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0a0a0a;
  --surface: #141414;
  --raised: #27272a;
  --ink: #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --line: #27272a;
  --divider: rgba(250, 250, 250, 0.08);
  --line-strong: #fafafa;
  --accent: #fafafa;
  --focus: #60a5fa;
  --cream: #1c1c1f;
  --gold-accent: #f5b84a;
  --blue: #60a5fa;
  --danger: #f87171;
  --rule: #222225;
  --field: #18181b;

  --card: #141414;
  --chip: rgba(250, 250, 250, 0.08);
  --topbar-bg: rgba(10, 10, 10, 0.85);
  --on-ink: #0a0a0a;
  --on-accent: #0a0a0a;
  --on-gold: #0a0a0a;
  --shadow-rgb: 0, 0, 0;
  /* The mark is a dark glyph on transparency, so inverting it is enough. */
  --logo-filter: invert(1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  /* Pins the footer to the bottom on short pages — home is just a hero now,
     so without this the footer floats halfway up the screen. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > main { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }

button, input, textarea { font: inherit; }
button { cursor: pointer; }

/* ── Topbar ─────────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 4vw, 40px);
  background: var(--topbar-bg);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(14px);
}

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

/* ── Theme toggle ───────────────────────────────────────────────────────────── */

.theme-toggle {
  display: grid;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.theme-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--field);
}

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

/* One glyph each way — the button shows where you're going, not where you are. */
.theme-toggle::before { content: "☾"; }
:root[data-theme="dark"] .theme-toggle::before { content: "☀"; }

.brand, .nav-links a { color: inherit; text-decoration: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-logo {
  display: block;
  flex-shrink: 0;
  mix-blend-mode: var(--logo-blend);
  filter: var(--logo-filter);
}

.brand-logo-full {
  height: 24px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.nav-links a:hover { color: var(--ink); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */

.ghost-button,
.primary-button,
.generate-button,
.html-export-button {
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--on-ink);
  background: var(--ink);
  font-weight: 500;
  text-decoration: none;
  transition: opacity 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.ghost-button {
  padding: 9px 14px;
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  white-space: nowrap;
}

.ghost-button:hover { background: var(--field); }

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 15px;
}

.generate-button, .html-export-button { padding: 14px 18px; }

/* The orb used to be a cream tile; now it's just the arrow riding along. */
.button-orb {
  display: inline-block;
  color: inherit;
  transition: transform 160ms ease;
}

.primary-button:hover { opacity: 0.88; }
.primary-button:hover .button-orb { transform: translateX(2px); }
.generate-button:hover:not(:disabled) { opacity: 0.88; }

/* A primary button without an orb — the sign-in call inside a dialog, where an
   arrow would promise a page that isn't where the click goes. */
.primary-button:not(:has(.button-orb)) {
  padding: 10px 20px;
  justify-content: center;
}

.sample-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background 160ms ease;
}

.sample-button:hover { background: var(--field); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.hero {
  padding: clamp(40px, 8vw, 104px) clamp(20px, 7vw, 112px) clamp(48px, 7vw, 96px);
  overflow: hidden;
}

.hero-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.6fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: center;
  max-width: 1200px;
  margin-inline: auto;
}

.hero-copy { max-width: 680px; }

h1, h2, h3, h4, p { margin-top: 0; }

h1 {
  max-width: 650px;
  margin-bottom: 30px;
  font-size: clamp(40px, 5vw, 62px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.hero-copy h2 {
  max-width: 680px;
  margin-bottom: 24px;
  font-size: clamp(38px, 5vw, 64px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.hero-copy p {
  max-width: 540px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.58;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 36px;
}

/* ── Hero stack ──────────────────────────────────────────────────────────────── */

.hero-stack {
  position: relative;
  justify-self: center;
  width: min(100%, 380px);
  min-height: 342px;
}

.messy-note-card, .generated-card, .missing-card { border-radius: var(--radius-lg); }

.messy-note-card {
  position: absolute;
  top: 0; left: 0;
  z-index: 1;
  width: min(100%, 230px);
  padding: 20px 26px 18px 18px;
  border: 1px solid var(--rule);
  background: var(--field);
  box-shadow: 0 12px 30px rgba(var(--shadow-rgb), 0.06);
  transform: rotate(-6deg);
}

.messy-note-card span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 500; }
.messy-note-card p { margin: 0 0 7px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; line-height: 1.4; }
.messy-note-card p:nth-child(3), .messy-note-card p:nth-child(5) { margin-left: 18px; }

.generated-card {
  position: absolute;
  top: 46px;
  left: clamp(26px, 5vw, 76px);
  z-index: 2;
  width: min(100%, 285px);
  padding: 20px 21px 22px;
  background: var(--ink);
  color: var(--on-ink);
  box-shadow: 0 24px 48px rgba(var(--shadow-rgb), 0.2);
  transform: rotate(4deg);
}

.generated-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.generated-topline span:first-child {
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--on-ink) 18%, transparent);
  border-radius: 999px;
  font-size: 11px;
}

.generated-card h2 {
  margin: 0 0 10px;
  color: var(--on-ink);
  font-size: clamp(22px, 2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.generated-card p {
  width: min(100%, 242px);
  color: color-mix(in srgb, var(--on-ink) 72%, transparent);
  font-size: clamp(12px, 1.05vw, 14px);
  line-height: 1.45;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.hero-metrics div {
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--on-ink) 10%, transparent);
}

.hero-metrics div:nth-child(2) { transform: translateY(8px); }

.hero-metrics span { display: block; color: color-mix(in srgb, var(--on-ink) 65%, transparent); font-size: 11px; }

.hero-metrics strong {
  display: block;
  margin-top: 3px;
  color: var(--on-ink);
  font-size: clamp(16px, 1.4vw, 19px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.missing-card {
  position: absolute;
  left: clamp(18px, 4vw, 52px);
  top: 248px;
  z-index: 3;
  width: min(100%, 250px);
  padding: 14px 16px;
  background: var(--amber);
  color: var(--on-gold);
  box-shadow: 0 18px 38px rgba(var(--shadow-rgb), 0.14);
}

.missing-card div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 500;
}

.alert-dot {
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border-radius: 50%;
  background: var(--on-gold);
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
}

.missing-card p {
  width: min(100%, 215px);
  margin: 0;
  color: var(--on-gold);
  font-size: clamp(15px, 1.25vw, 18px);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.28;
}

/* ── Typography helpers ──────────────────────────────────────────────────────── */

.mini-kicker, .eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Field labels read as plain sentence-case labels, not kickers. */
.field-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.wrw {
  display: inline;
  opacity: 0.1;
  transition: opacity 100ms linear;
}

@media (prefers-reduced-motion: reduce) { .wrw { opacity: 1 !important; transition: none; } }

/* ── App shell ──────────────────────────────────────────────────────────────── */

.app-shell {
  max-width: 840px;
  margin-inline: auto;
  padding: 48px clamp(16px, 5vw, 40px) 72px;
}

/* ── Workspace grid ──────────────────────────────────────────────────────────── */

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(16px, 2.5vw, 32px);
  align-items: start;
  width: 100%;
  max-width: 100%;
}

@keyframes slideInPanel {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.preview-column {
  display: none;
  gap: 22px;
}

.workspace-grid.preview-open .preview-column {
  display: grid;
  animation: slideInPanel 280ms ease forwards;
}

/* ── Builder panel ─────────────────────────────────────────────────────────── */

/* No card around the form — one centred column on the page ground, the same
   way the draft itself reads on /results. */
.builder-panel {
  width: 100%;
}

/* ── Builder workspace layout ─────────────────────────────────────────────── */

.draft-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.draft-head-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

/* The project title is the largest type on the page — what you're making is
   the headline, not a pitch for the tool. */
.title-input {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  height: auto;
  font-size: clamp(30px, 3.6vw, 40px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--ink);
}

.title-input::placeholder { color: var(--faint); }
.title-input:focus { outline: none; }
.title-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

.builder-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

.notes-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-col textarea {
  min-height: 260px;
  resize: vertical;
  padding: 18px 20px;
  border-color: transparent;
  border-radius: var(--radius-lg);
  background: var(--field);
  font-size: 16px;
  line-height: 26px;
}

.settings-col {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.group-hint {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}

.settings-col #styleInspo {
  padding: 12px 16px;
  border-color: transparent;
  border-radius: var(--radius);
  background: var(--field);
  font-size: 14px;
}

/* Audience and tone are optional, so they sit folded behind a "+" until asked for. */
.extras {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: -8px;
}

.extra summary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
  transition: color 140ms ease;
}

.extra summary::-webkit-details-marker { display: none; }
.extra summary::before { content: "+"; width: 10px; }
.extra[open] summary::before { content: "−"; }
.extra summary:hover, .extra[open] summary { color: var(--ink); }
.extra summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.extra summary small { color: var(--faint); font-size: 13px; font-weight: 400; }
.extra-body { padding: 6px 0 12px; }

.panel-header, .preview-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.panel-header h3 {
  margin: 5px 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.compact { margin-bottom: 12px; }

/* ── Form fields ─────────────────────────────────────────────────────────── */

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 17px;
}

.field > span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  transition: border 160ms ease, box-shadow 160ms ease;
}

input { height: 46px; padding: 0 12px; }

textarea {
  min-height: 200px;
  resize: vertical;
  padding: 13px;
  line-height: 1.55;
}

input:focus, textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent);
}

/* ── Upload ─────────────────────────────────────────────────────────────── */

.upload-area {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 4px 0 12px;
  padding: 18px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  background: transparent;
  transition: border 160ms ease, background 160ms ease;
  cursor: pointer;
}

.upload-area:hover, .upload-area.dragging {
  background: var(--field);
}

.upload-area input {
  position: absolute;
  inset: 0;
  height: auto;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font-size: 22px;
  font-weight: 400;
}

.upload-area p { color: var(--muted); line-height: 1.4; margin: 0; font-size: 13px; }
.upload-area strong { display: block; font-size: 14px; font-weight: 500; margin-bottom: 2px; }

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  margin-bottom: 4px;
}

.upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 6px 5px 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.upload-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-remove {
  display: grid;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--faint);
  font-size: 15px;
  line-height: 1;
  transition: background 140ms ease, color 140ms ease;
}

.upload-remove:hover {
  background: var(--field);
  color: var(--ink);
}

.upload-remove:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* Says what didn't make it, instead of dropping files in silence. */
.upload-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Info icons + tooltips ───────────────────────────────────────────────── */

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  transition: color 0.15s;
}

.info-icon:hover { color: var(--ink); }

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  text-align: left;
  white-space: normal;
}

.info-icon:hover::after,
.info-icon.tooltip-open::after {
  opacity: 1;
}

/* Opens downward instead. The sidebar is sticky, which makes its own stacking
   context, so a tooltip pointing up slides underneath the sticky header no
   matter how high its z-index goes. */
.info-icon--below::after {
  top: calc(100% + 8px);
  bottom: auto;
}

/* ── Chips / pills ────────────────────────────────────────────────────────── */

.save-chip, .status-pill, .critique-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--chip);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Goal tabs ────────────────────────────────────────────────────────────── */

.audience-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.audience-chip {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  transition: border-color 140ms ease, color 140ms ease;
}

.audience-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* A chosen chip is filled with ink; unchosen ones stay outlined. */
.audience-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
}

/* ── Structure picker ─────────────────────────────────────────────────────── */

/* A segmented control: four equal segments on a grey track, the chosen one
   raised onto the surface. */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--field);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab:hover { color: var(--ink); }

.tab-dot { display: none; }

.tab-note {
  color: var(--faint);
  font-size: 12px;
  font-weight: 400;
}

.tab.active {
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.1), 0 0 0 1px rgba(var(--shadow-rgb), 0.04);
}

.tab.active .tab-note { color: var(--muted); }

.tab .lock-tag {
  position: absolute;
  top: 5px;
  right: 5px;
  margin: 0;
}

@media (max-width: 640px) {
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Generate ─────────────────────────────────────────────────────────────── */

.generate-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding-top: 8px;
}

.generate-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 500;
}

.generate-note {
  flex: 1 1 260px;
  margin: 0;
  color: var(--faint);
  font-size: 13px;
}

/* Generation navigates away on success, so failures are the only thing left
   to report on this page. */
.generate-error {
  flex-basis: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid var(--gold-accent);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.empty-link {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Image slots ──────────────────────────────────────────────────────────── */

.visual-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.visual-slot { margin: 0; }

.visual-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 4 / 3;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--field);
  text-align: center;
}

/* A slot the designer already has the picture for: solid edge instead of the
   dashed "still to come" frame, and the image fills it. */
.visual-frame--filled {
  padding: 0;
  border: 1px solid var(--rule);
  overflow: hidden;
}

.visual-frame--filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.visual-plus {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  margin-bottom: 4px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
}

.visual-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.visual-hint {
  color: var(--faint);
  font-size: 11px;
}

.visual-slot figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 17px;
}

/* ── Results page ─────────────────────────────────────────────────────────── */

.results-shell {
  padding: 48px clamp(20px, 5vw, 40px) 64px;
}

.results-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 64px;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
}

.draft-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.draft-column .eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Actions live in the top bar on this page. */
.results-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.link-action {
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  transition: color 140ms ease;
}

.link-action:hover:not(:disabled) { color: var(--ink); }
.link-action:disabled { opacity: 0.4; cursor: default; }

/* Sidebar */
.clarity-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--field);
  position: sticky;
  top: 88px;
}

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

.clarity-count {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}

.clarity-column .score-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0;
  border: 0;
  background: none;
}

/* The display rule above outranks the [hidden] attribute's display:none, so
   the panel has to opt back out explicitly. */
.clarity-column .score-panel[hidden] { display: none; }

.clarity-column .score-number { font-size: 52px; letter-spacing: -0.05em; line-height: 52px; }

.clarity-column .critique-list {
  display: block;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: none;
  overflow: visible;
}

.clarity-column .critique-item {
  padding: 13px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 0;
  background: none;
  font-size: 12px;
  line-height: 18px;
}

.clarity-column .critique-item strong { font-size: 13px; }

@media (max-width: 1020px) {
  .results-cols { grid-template-columns: 1fr; gap: 28px; }
  .clarity-column { position: static; }
}

.model-select-label {
  position: relative;
  display: grid;
  min-width: 170px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: var(--field);
}

.model-select-label > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.model-select-label select {
  width: 100%;
  height: 52px;
  padding: 0 36px 0 14px;
  border: 0;
  border-radius: var(--radius);
  appearance: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  outline: 0;
}

.model-select-label::after {
  content: "⌄";
  position: absolute;
  right: 14px;
  top: 50%;
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
  transform: translateY(-55%);
}

.generate-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Preview toolbar ─────────────────────────────────────────────────────── */

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 0;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.copy-all-button {
  padding: 7px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 13px;
  font-weight: 500;
  transition: opacity 160ms ease;
}

.copy-all-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.export-button {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 160ms ease;
}

.export-button:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--ink);
}

.export-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Draft document ──────────────────────────────────────────────────────── */

.draft-empty {
  display: grid;
  min-height: 480px;
  place-items: center;
  border: 0;
  border-radius: var(--radius-lg);
  margin-top: 18px;
  background: var(--field);
}

.empty-draft {
  max-width: 380px;
  padding: 32px;
  text-align: center;
}

.empty-draft h4 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.15;
}

.empty-draft p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

/* Sections carry their own hairline separators now, so the wrapper no longer
   needs a border or the 1px-gap trick that used to draw them. */
.draft-doc {
  display: block;
  margin-top: 18px;
  border: 0;
  background: transparent;
  animation: riseIn 360ms ease both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes sectionReveal {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Label in a fixed left margin, copy beside it — the section names form one
   vertical lane down the draft rather than ten repeated card headers. */
.draft-section {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 28px;
  padding: 22px 0;
  border-top: 1px solid var(--rule);
  background: transparent;
  opacity: 0;
  animation: sectionReveal 0.28s ease forwards;
}

.draft-section:first-child { border-top: 0; padding-top: 0; }

/* Staggered reveal by position — was set as an inline animation-delay per
   element, which the CSP's style-src (no unsafe-inline) silently drops. No
   mode's schema renders anywhere near 20 sections. */
.draft-section:nth-child(1)  { animation-delay: 0ms; }
.draft-section:nth-child(2)  { animation-delay: 60ms; }
.draft-section:nth-child(3)  { animation-delay: 120ms; }
.draft-section:nth-child(4)  { animation-delay: 180ms; }
.draft-section:nth-child(5)  { animation-delay: 240ms; }
.draft-section:nth-child(6)  { animation-delay: 300ms; }
.draft-section:nth-child(7)  { animation-delay: 360ms; }
.draft-section:nth-child(8)  { animation-delay: 420ms; }
.draft-section:nth-child(9)  { animation-delay: 480ms; }
.draft-section:nth-child(10) { animation-delay: 540ms; }
.draft-section:nth-child(11) { animation-delay: 600ms; }
.draft-section:nth-child(12) { animation-delay: 660ms; }
.draft-section:nth-child(13) { animation-delay: 720ms; }
.draft-section:nth-child(14) { animation-delay: 780ms; }
.draft-section:nth-child(15) { animation-delay: 840ms; }
.draft-section:nth-child(n+16) { animation-delay: 900ms; }

@media (max-width: 720px) {
  .draft-section { grid-template-columns: 1fr; gap: 8px; }
}

/* ── Feedback bar ────────────────────────────────────────────────────────── */

.feedback-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--paper);
  font-size: 12px;
  color: var(--muted);
}

/* display:flex outranks the [hidden] attribute's display:none, so the bar has
   to opt back out explicitly — otherwise it asks whether a draft was useful on
   the page that has no draft. */
.feedback-bar[hidden] { display: none; }

/* Names the model that actually wrote the draft, which is not always the one
   that was requested. */
.engine-note {
  margin: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--paper);
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.engine-note strong {
  color: var(--ink);
  font-weight: 600;
}

.engine-note.is-fallback::before {
  content: "↻ ";
  opacity: 0.7;
}

.feedback-buttons { display: flex; gap: 6px; }

.feedback-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.feedback-btn:hover { background: var(--cream); border-color: var(--ink); }
.feedback-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Score panel ─────────────────────────────────────────────────────────── */

.score-panel {
  padding: 16px;
  border-bottom: 1px solid var(--divider);
  display: grid;
  gap: 12px;
}

.score-overall {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.score-number {
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

.score-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.score-badge {
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-strong { background: #d4f7d4; color: #1a6b1a; }
.badge-good   { background: #fff4cc; color: #7a5a00; }
.badge-weak   { background: #ffe4e4; color: #8b1a1a; }

/* Same three readings, dimmed to sit on a dark panel instead of glowing off it. */
:root[data-theme="dark"] .badge-strong { background: #1e3a1e; color: #9fe09f; }
:root[data-theme="dark"] .badge-good   { background: #3d3213; color: #f3d071; }
:root[data-theme="dark"] .badge-weak   { background: #3d1d1d; color: #f0a3a3; }

.score-bars { display: grid; gap: 8px; }

.score-row {
  display: grid;
  grid-template-columns: 80px 1fr 24px;
  align-items: center;
  gap: 10px;
}

.score-row-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.score-bar-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--ink);
  width: 0%;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scores are 1–10, so the fill only ever needs these ten steps. Classes
   instead of an inline style — the CSP's style-src has no unsafe-inline. */
.score-bar-fill.w-10  { width: 10%; }
.score-bar-fill.w-20  { width: 20%; }
.score-bar-fill.w-30  { width: 30%; }
.score-bar-fill.w-40  { width: 40%; }
.score-bar-fill.w-50  { width: 50%; }
.score-bar-fill.w-60  { width: 60%; }
.score-bar-fill.w-70  { width: 70%; }
.score-bar-fill.w-80  { width: 80%; }
.score-bar-fill.w-90  { width: 90%; }
.score-bar-fill.w-100 { width: 100%; }

.score-row-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

/* The single highest-value fix. Labelled, because an unheaded sentence sitting
   under the score bars reads as a stray fragment. */
.score-tip {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--raised);
}

.score-tip-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.score-tip p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
}

.draft-section-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 0;
  border-bottom: 0;
}

.draft-section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Actions stay quiet until the section is hovered or focused — they're
   secondary to reading the draft. */
.section-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 140ms ease;
}

.draft-section:hover .section-actions,
.draft-section:focus-within .section-actions { opacity: 1; }

@media (hover: none) {
  .section-actions { opacity: 1; }
}

.copy-section-btn,
.strengthen-btn {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.copy-section-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--cream);
}

.strengthen-btn { color: var(--ink); }

.strengthen-btn:hover {
  background: var(--field);
  border-color: var(--ink);
}

.strengthen-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.draft-section-body {
  padding: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 26px;
  white-space: pre-wrap;
  outline: none;
  min-height: 0;
}

/* The title is the loudest thing on the page; the summary sits just under it. */
.draft-section[data-key="title"] .draft-section-body {
  font-size: clamp(28px, 3.6vw, 44px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.13;
}

.draft-section[data-key="summary"] .draft-section-body {
  font-size: 18px;
  line-height: 28px;
  color: var(--muted);
}

.draft-section-body:focus {
  background: color-mix(in srgb, var(--focus) 6%, transparent);
}

/* ── Critique / gaps panel ──────────────────────────────────────────────── */

.critique-panel { padding-top: 2px; }

.critique-count {
  min-width: 28px;
  justify-content: center;
}

.critique-list {
  display: grid;
  gap: 1px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: var(--divider);
  overflow: hidden;
}

.critique-item {
  padding: 14px 16px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.critique-item strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 13px;
}

.critique-empty {
  padding: 18px 0;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.critique-empty p { color: var(--muted); line-height: 1.55; margin: 0; }

/* ── Export panel ──────────────────────────────────────────────────────── */

.export-panel {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.html-export-button {
  min-width: 150px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background 160ms ease, color 160ms ease;
}

.html-export-button:hover:not(:disabled) {
  background: var(--ink);
  color: var(--on-ink);
}

.html-export-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .hero-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-stack {
    width: min(100%, 380px);
    min-height: 342px;
    margin-inline: auto;
    margin-top: 12px;
    transform: scale(1.38);
    transform-origin: top center;
    margin-bottom: calc(342px * 0.38);
  }

  .preview-column {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
  }

  .nav-links { display: none; }

  .brand { font-size: 14px; }
  .brand-logo { width: 26px; height: 26px; }

  .results-actions { gap: 8px; }

  .link-action { font-size: 12px; }

  .status-pill { padding: 6px 8px; font-size: 11px; }

  .ghost-button {
    padding: 8px 10px;
    font-size: 13px;
  }

  .hero {
    padding: 30px 16px 32px;
  }

  .hero-copy h2 {
    font-size: clamp(34px, 9vw, 44px);
  }

  .hero-copy p { font-size: 16px; }

  .hero-actions {
    gap: 10px;
    margin-top: 24px;
  }

  .primary-button, .sample-button {
    justify-content: center;
  }

  .hero-stack {
    width: min(100%, 380px);
    min-height: 342px;
    margin-inline: auto;
    transform: scale(0.76);
    transform-origin: top center;
    margin-bottom: 24px;
  }

  .hero-metrics { grid-template-columns: 1fr; }
  .hero-metrics div:nth-child(2) { transform: none; }
  .missing-card p { font-size: 18px; }

  .app-shell {
    padding: 32px 16px 52px;
  }

  .builder-panel {
    max-width: 100%;
  }

  .panel-header { flex-wrap: wrap; }

  .generate-row { grid-template-columns: 1fr; }

  .generate-button { width: 100%; }

  .model-select-label { min-width: 0; }

  .export-panel { justify-content: stretch; }

  .html-export-button { width: 100%; }

  .preview-toolbar { flex-wrap: wrap; }

  .draft-section-body { font-size: 14px; }
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */

/* One footer on every page: the copyright and the two legal links. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 20px;
  padding: 28px 24px;
  border-top: 1px solid var(--divider);
  color: var(--faint);
  font-size: 13px;
}

.footer-links { display: flex; gap: 20px; }

/* Stacked on phones, links first, with room underneath so the fixed Feedback
   button never sits on top of them. */
@media (max-width: 760px) {
  .site-footer { flex-direction: column; gap: 10px; padding: 24px 16px 76px; }
  .footer-links { order: -1; }
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
}

/* Adding Share to the results toolbar pushed it past one line on phones
   narrower than ~390px. The status pill is the part that gives way: the eyebrow
   directly under the header already says the same thing ("Shared draft · STAR
   format"), so nothing is actually lost. */
@media (max-width: 420px) {
  .results-actions .status-pill { display: none; }
}

/* ── Story check ──────────────────────────────────────────────────────────────
   Sits above the Clarity check in the results sidebar. The draft is already
   written and on screen by the time this appears — it reports on the material,
   it never stands between the designer and their first draft. */

.story-panel {
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
}

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

.story-title {
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.story-count { color: var(--faint); font-size: 11px; }

.story-rows { display: flex; flex-direction: column; gap: 2px; }

.story-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}

.story-el { color: var(--muted); font-size: 13px; }

.story-status {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Status is carried by the word, with colour as reinforcement rather than the
   only signal — the row still reads correctly in greyscale. */
.is-clear .story-status { color: var(--faint); }
.is-thin .story-status { color: var(--gold-accent); }
.is-missing .story-status { color: var(--gold-accent); }

.is-clear .story-el { color: var(--faint); }
.is-thin .story-el,
.is-missing .story-el { color: var(--ink); font-weight: 600; }

.story-ask {
  margin: 2px 0 8px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ── Accounts and plans ─────────────────────────────────────────────────────
   Everything below reads the theme tokens above, so none of it needs a dark
   counterpart — the seams flip and these follow. */

.account { position: relative; display: flex; align-items: center; }

.account-button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s ease, transform 0.15s ease;
}
.account-button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.account-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.account-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.account-avatar--letter {
  display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink);
  font-size: 0.7rem; font-weight: 800;
}

/* The name is the first thing to go when the bar runs out of room — the avatar
   and the plan badge still identify the account without it. */
.account-name {
  max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 720px) { .account-name { display: none; } }

.plan-badge {
  padding: 1px 7px; border-radius: 999px;
  background: var(--ink); color: var(--on-ink);
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}

.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  min-width: 232px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(var(--shadow-rgb), 0.16);
  display: flex; flex-direction: column; gap: 2px;
}
.account-email { margin: 0 0 2px; font-size: 0.8rem; font-weight: 700; color: var(--ink); word-break: break-all; }
.account-usage { margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--divider); font-size: 0.74rem; color: var(--muted); }
.account-menu a {
  padding: 7px 8px; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: 0.82rem; font-weight: 600;
}
.account-menu a:hover { background: var(--chip); }

/* ── Usage meter on the builder ──────────────────────────────────────────── */

.usage-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  flex-basis: 100%; margin: 0; font-size: 0.8rem; color: var(--muted);
}
.usage-note[hidden] { display: none; }
.usage-note strong { color: var(--ink); font-weight: 700; }
.usage-note a { color: var(--ink); }
.usage-note--spent strong { color: var(--gold-accent); }

/* ── Locked controls ─────────────────────────────────────────────────────────
   A locked control stays visible and focusable. Hiding it would leave someone
   wondering where a structure went; dimming it and saying why is the whole
   argument for upgrading. */

.tab.is-locked, .upload-area.is-locked { opacity: 0.55; }
.tab.is-locked:hover { transform: none; }

.lock-tag {
  margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  background: var(--chip); color: var(--muted);
  font-size: 0.58rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  vertical-align: middle;
}

/* ── The plan wall ───────────────────────────────────────────────────────── */

.plan-wall {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background: rgba(var(--shadow-rgb), 0.45);
  animation: planWallIn 0.18s ease-out;
}
@keyframes planWallIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .plan-wall { animation: none; } }

.plan-wall-card {
  width: min(420px, 100%); padding: 26px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(var(--shadow-rgb), 0.28);
}
.plan-wall-card h3 { margin: 0 0 8px; font-size: 1.24rem; color: var(--ink); }
.plan-wall-card p { margin: 0 0 10px; font-size: 0.9rem; line-height: 1.5; color: var(--muted); }
.plan-wall-note { font-size: 0.82rem !important; color: var(--faint) !important; }
.plan-wall-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }

/* ── Pricing page ────────────────────────────────────────────────────────── */

.pricing-shell { max-width: 940px; margin: 0 auto; padding: 56px 24px 80px; }
.pricing-head { text-align: center; margin-bottom: 40px; }
.pricing-head h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 10px; color: var(--ink); }
.pricing-head p { margin: 0; color: var(--muted); font-size: 1rem; }

.plan-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: start;
}

.plan-card {
  display: flex; flex-direction: column; gap: 16px;
  padding: 26px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--card);
}
.plan-card--featured { border-color: var(--line-strong); border-width: 1.5px; background: var(--surface); }

.plan-card h3 { margin: 0; font-size: 1.06rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }
.plan-price { display: flex; align-items: baseline; gap: 6px; }
.plan-price strong { font-size: 2.4rem; line-height: 1; color: var(--ink); }
.plan-price span { font-size: 0.85rem; color: var(--faint); }

.plan-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.plan-features li { position: relative; padding-left: 22px; font-size: 0.88rem; line-height: 1.45; color: var(--ink); }
.plan-features li::before { content: "→"; position: absolute; left: 0; color: var(--muted); }
.plan-features li.is-off { color: var(--faint); }
.plan-features li.is-off::before { content: "·"; color: var(--faint); }

.plan-current {
  padding: 10px 0; text-align: center;
  font-size: 0.82rem; font-weight: 700; color: var(--muted);
}

.pricing-note { margin-top: 34px; text-align: center; font-size: 0.8rem; color: var(--faint); }

/* Staging only: the controls that fake a subscription so both sides of the
   paywall can be walked through without a card. Never rendered in production. */
.staging-bar {
  margin: 0 auto 28px; max-width: 940px; padding: 12px 16px;
  border: 1px dashed var(--gold-accent); border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--muted);
}
.staging-bar strong { color: var(--gold-accent); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.68rem; }

/* ── Email sign-in ───────────────────────────────────────────────────────────
   Lives inside the plan-wall dialog, so it only adds the form. */

.signin-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.signin-label { color: var(--ink); font-size: 13px; font-weight: 500; }

.signin-form input {
  height: 44px;
  padding: 0 14px;
  border-color: transparent;
  background: var(--field);
  font-size: 15px;
}

.signin-form .signin-code {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.4em;
  text-align: center;
}

.signin-form .primary-button { width: 100%; justify-content: center; margin-top: 6px; }
.signin-form .primary-button:disabled { opacity: 0.5; cursor: default; }

.plan-wall-card .signin-error { margin: 0; color: var(--gold-accent); font-size: 13px; }
.plan-wall-card .signin-error[hidden],
.plan-wall-card .signin-note[hidden] { display: none; }
.plan-wall-card .signin-email { color: var(--ink); font-weight: 500; }
.signin-note { margin-top: 12px !important; }

/* ── Top bar: sign in and the primary call ───────────────────────────────── */

.account-signin {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 140ms ease;
}

.account-signin:hover { background: var(--field); }
.account-signin:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.topbar .primary-button { padding: 9px 14px; font-size: 14px; }

/* The rule above sets display:flex, which outranks the hidden attribute. */
.account-menu[hidden] { display: none; }
.account-menu-name { margin: 0; font-size: 0.86rem; font-weight: 600; color: var(--ink); }
.account-menu-name:empty { display: none; }
.account-menu .account-email { font-weight: 400; color: var(--muted); }

.account-menu-item {
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
}

.account-menu-item:hover { background: var(--chip); }

/* ── Dialog extras: profile, feedback ────────────────────────────────────── */

/* A tall dialog on a short screen scrolls instead of losing its top edge. */
.plan-wall { overflow-y: auto; place-items: safe center; }

.signin-form textarea {
  min-height: 120px;
  padding: 12px 14px;
  border-color: transparent;
  background: var(--field);
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
}

.signin-form input[readonly] { color: var(--muted); cursor: default; }
.signin-form input[readonly]:focus { border-color: transparent; box-shadow: none; }
.signin-optional { color: var(--faint); font-weight: 400; }

.feedback-rating {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

.feedback-rating button {
  height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--field);
  font-size: 22px;
  line-height: 1;
  filter: grayscale(0.7);
  opacity: 0.7;
  transition: opacity 140ms ease, filter 140ms ease, border-color 140ms ease, background 140ms ease;
}

.feedback-rating button:hover { opacity: 1; filter: none; }

.feedback-rating button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--raised);
  opacity: 1;
  filter: none;
}

.profile-facts {
  display: grid;
  gap: 8px;
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.profile-facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 0.86rem; }
.profile-facts dt { color: var(--muted); }
.profile-facts dd { margin: 0; color: var(--ink); font-weight: 500; }
.profile-actions { justify-content: space-between; }

.danger-link { color: var(--danger); }
.danger-link:hover:not(:disabled) { color: var(--danger); text-decoration: underline; }

.danger-button {
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--danger);
  color: var(--on-ink);
  font-size: 14px;
  font-weight: 500;
  transition: opacity 140ms ease;
}

.danger-button:hover:not(:disabled) { opacity: 0.9; }
.danger-button:disabled { opacity: 0.6; cursor: default; }

/* ── Feedback button ─────────────────────────────────────────────────────── */

.feedback-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(var(--shadow-rgb), 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.feedback-fab:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(var(--shadow-rgb), 0.16); }
.feedback-fab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (max-width: 760px) {
  .feedback-fab { right: 12px; bottom: 12px; padding: 8px 14px; font-size: 13px; }
}

@media print { .feedback-fab { display: none; } }

/* ── Shared drafts ───────────────────────────────────────────────────────── */

/* Says whose words a shared draft is, since a link can carry any text. */
.shared-note {
  margin: 6px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.shared-note[hidden] { display: none; }
.shared-note a { color: var(--ink); font-weight: 500; white-space: nowrap; }
