/* ---------- Growth Plays tokens ---------- */
:root {
  --violet: #5e2bff;
  --violet-deep: #491c96;
  --violet-tint: #ece9fe;
  --violet-wash: #fbfaff;
  --gp-green: #5cf976;
  --ink: #131316;
  --body: #2e2e33;
  --muted: #616169;
  --line: #e5e3ec;
  --line-strong: #cbc7d8;
  --grey-bg: #f4f4f4;
  --ok: #157145;
  --warn: #9a6700;
  --bad: #c0262c;
  --warn-fill: #d97706;
  --bad-fill: #dc2626;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --shadow-focus: 0 0 0 3px rgba(94, 43, 255, 0.25);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Poppins, sans-serif;
  color: var(--body);
  background: #fff;
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header (carries the page title: no hero section) ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2.5vw, 32px);
  padding: 12px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.logo-link { display: inline-flex; flex: none; }
.logo-link img { display: block; height: 20px; width: auto; }

.header-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding-left: clamp(16px, 2.5vw, 32px);
}
.header-title h1 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
}
.header-title mark {
  background: var(--gp-green);
  color: var(--ink);
  padding: 0.02em 0.16em;
  border-radius: 2px;
}
.header-title p {
  margin: 0;
  font-size: 0.78125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ---------- Layout ---------- */
.tool {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(400px, 700px);
  justify-content: center;
  gap: clamp(28px, 4vw, 64px);
  padding: clamp(18px, 2.5vw, 28px) clamp(20px, 4vw, 48px) 40px;
}

/* Desktop app shell: the page never scrolls; columns scroll internally if needed */
@media (min-width: 981px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .tool {
    flex: 1;
    min-height: 0;
    grid-template-rows: minmax(0, 100%);
    padding-bottom: clamp(18px, 2.5vw, 28px);
  }
  .editor, .preview-pane {
    overflow-y: auto;
    min-height: 0;
    /* breathing room so focus rings aren't clipped by the scroll container */
    padding: 4px;
    margin: -4px;
  }
  .site-footer { flex: none; }
}

/* ---------- Editor ---------- */
.editor { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-row .field { flex: 1; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; }

label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.005em;
}
.optional { font-weight: 400; color: var(--muted); font-size: 0.75rem; }

input[type="text"], input[type="url"], input[type="date"], textarea {
  font-family: Poppins, sans-serif;
  font-size: 0.875rem;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  width: 100%;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #6d6d76; opacity: 1; }
input:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--violet);
  box-shadow: var(--shadow-focus);
}
input:disabled { background: var(--grey-bg); color: var(--muted); cursor: not-allowed; border-color: var(--line); }

.btn-copy {
  font-family: var(--mono);
  font-size: 0.71875rem;
  font-weight: 500;
  color: var(--violet);
  background: none;
  border: 1px solid transparent;
  padding: 5px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn-copy:hover { background: var(--violet-tint); border-color: var(--violet-tint); }
.btn-copy:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn-copy.copied { color: var(--ok); }

.field-actions { display: flex; gap: 2px; }

/* ---------- Title variants ---------- */
.variant-list { display: flex; flex-direction: column; gap: 12px; }
.variant { display: flex; flex-direction: column; gap: 6px; }
.variant-row { display: flex; align-items: center; gap: 9px; }
.variant-row .title-input { flex: 1; min-width: 0; }
.variant-radio {
  accent-color: var(--violet);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex: none;
  margin: 0;
}
.variant-radio:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 50%; }
.variant.is-active .title-input { border-color: var(--violet); }
.variant-remove {
  flex: none;
  width: 26px;
  height: 26px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.variant-remove:hover { color: var(--bad); border-color: var(--bad-fill); }
.variant-remove:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
/* With a single variant there is nothing to pick or remove */
.variant-list[data-count="1"] .variant-radio,
.variant-list[data-count="1"] .variant-remove { display: none; }
.variant-list:not([data-count="1"]) .variant .meter { margin-left: 24px; margin-right: 35px; }

.cut-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.71875rem;
  color: var(--bad);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-row { display: flex; gap: 16px; }
.date-row { align-items: center; }
.date-row input[type="date"] { width: auto; font-family: var(--mono); font-size: 0.8125rem; }

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--body);
  cursor: pointer;
  user-select: none;
}
.check-label input {
  accent-color: var(--violet);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.check-label input:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 2px; }

/* ---------- Meters: segmented ruler tracks, mono numerals ---------- */
.meter { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.meter-track {
  height: 8px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--line-strong) calc(10% - 1px) 10%),
    var(--grey-bg);
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--violet);
  transition: transform 0.18s var(--ease), background-color 0.18s var(--ease);
}
.meter-text {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.71875rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.meter-text .status { font-weight: 600; }
.meter.is-ok .meter-fill { background: var(--violet); }
.meter.is-ok .status { color: var(--ok); }
.meter.is-warn .meter-fill { background: var(--warn-fill); }
.meter.is-warn .status { color: var(--warn); }
.meter.is-over .meter-fill { background: var(--bad-fill); }
.meter.is-over .status { color: var(--bad); }

/* ---------- Checklist ---------- */
.checklist {
  border-top: 1px solid var(--line-strong);
  padding-top: 14px;
  margin-top: 8px;
}
.checklist h2 {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
}
.checklist ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--body);
}
.check-icon {
  flex: none;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
  transform: translateY(2px);
}
li.pass .check-icon { background: #d8f3e3; color: var(--ok); }
li.warn .check-icon { background: #fbeeca; color: var(--warn); }
li.fail .check-icon { background: #fbdcdd; color: var(--bad); }

/* ---------- Preview pane: instrument shell ---------- */
.preview-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 24px;
  align-self: start;
  min-width: 0;
}

.preview-shell {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--violet-wash);
  border-bottom: 1px solid var(--line);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 2px;
  background: #fff;
}
.seg button {
  font-family: Poppins, sans-serif;
  font-size: 0.78125rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 4px;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.seg button:hover:not([aria-checked="true"]) { color: var(--ink); }
.seg button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.context-toggle { margin-left: auto; font-size: 0.78125rem; }

/* ---------- SERP stage (Google fidelity zone: Arial + Google's own px sizes/colors) ---------- */
.serp-stage {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  font-family: Arial, sans-serif;
  background: #fff;
  overflow-x: auto;
  transition: background 0.2s var(--ease);
}
.serp-stage[data-theme="dark"] { background: #202124; }

.serp-result { max-width: 600px; }
.serp-stage[data-device="mobile"] { align-items: center; background: #f1f3f4; }
.serp-stage[data-device="mobile"][data-theme="dark"] { background: #202124; }
.serp-stage[data-device="mobile"] .serp-result {
  width: 100%;
  max-width: 400px;
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.18);
}
.serp-stage[data-device="mobile"][data-theme="dark"] .serp-result {
  background: #303134;
  box-shadow: none;
}

.serp-dummy { display: none; }
.serp-stage.show-context .serp-dummy { display: block; opacity: 0.55; }

.serp-source { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.serp-source [hidden] { display: none !important; }
.serp-favicon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f1f3f4;
  border: 1px solid #ecedef;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
}
img.serp-favicon { padding: 4px; object-fit: contain; }
.serp-favicon-letter {
  font-size: 13px;
  font-weight: 700;
  color: #5f6368;
}
.serp-stage[data-theme="dark"] .serp-favicon { background: #303134; border-color: #3c4043; }
.serp-stage[data-theme="dark"] .serp-favicon-letter { color: #bdc1c6; }

.serp-source-text { display: flex; flex-direction: column; min-width: 0; }
.serp-sitename {
  font-size: 14px;
  line-height: 20px;
  color: #202124;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.serp-url {
  font-style: normal;
  font-size: 12px;
  line-height: 18px;
  color: #4d5156;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.serp-stage[data-theme="dark"] .serp-sitename { color: #dadce0; }
.serp-stage[data-theme="dark"] .serp-url { color: #bdc1c6; }

.serp-title {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 26px;
  font-weight: 400;
  color: #1a0dab;
  overflow-wrap: break-word;
}
.serp-stage[data-device="desktop"] .serp-title span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  max-width: 600px;
}
.serp-live .serp-title span { cursor: pointer; }
.serp-live .serp-title span:hover { text-decoration: underline; }
.serp-stage[data-theme="dark"] .serp-title { color: #99c3ff; }

.serp-desc {
  margin: 0;
  font-size: 14px;
  line-height: 22px;
  color: #474747;
  overflow-wrap: break-word;
}
.serp-stage[data-theme="dark"] .serp-desc { color: #bdc1c6; }
.serp-desc b { font-weight: 700; }
.serp-date { color: #70757a; }
.serp-stage[data-theme="dark"] .serp-date { color: #9aa0a6; }

.limits-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.71875rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: center;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 10px 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}
.site-footer a { color: var(--violet); font-weight: 500; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer p { margin: 0; }

/* ---------- Accessibility helpers ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .tool { grid-template-columns: minmax(0, 1fr); max-width: 680px; margin: 0 auto; row-gap: 24px; }
  .tool > *, .preview-shell, .limits-note, .checklist { min-width: 0; }
  /* Single column flows preview → inputs → checks */
  .preview-pane { display: contents; }
  .preview-shell { order: -2; }
  .limits-note { order: -1; margin-top: -14px; }
  .editor { order: 0; }
  .checklist { order: 1; }
}
@media (max-width: 1150px) {
  .header-title p { display: none; }
}
@media (max-width: 720px) {
  .site-header { flex-wrap: wrap; row-gap: 4px; }
  .header-title {
    order: 3;
    flex-basis: 100%;
    border-left: none;
    padding-left: 0;
  }
  .header-title h1 { white-space: normal; }
}
@media (max-width: 560px) {
  .field-row { flex-direction: column; gap: 24px; }
  .date-row { align-items: flex-start; gap: 12px; }
  .serp-stage { padding: 18px 14px; }
  .context-toggle { margin-left: 0; }
}

/* Comfortable touch targets on coarse pointers */
@media (pointer: coarse) {
  .seg button { padding: 9px 16px; }
  .btn-copy { padding: 7px 12px; }
  .check-label input { width: 18px; height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
