/* RS UX v0.1 — tokens mirrored from public/styles.css + try-shared.css */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #fafaf7;
  --bg-secondary: #f3efe6;
  --bg-tertiary: #ede8dd;
  --bg-surface: #ffffff;

  --text-primary: #0a0a0a;
  --text-secondary: #444;
  --text-tertiary: #777;
  --text-quaternary: #999;

  --navy: #0A1628;
  --navy-soft: #2a4568;

  --accent: #c07a00;
  --accent-hover: #8a5800;
  --accent-soft: #fff4e0;

  --border-light: #e5e1d8;
  --border-medium: #c8c4ba;
  --border-dark: #999488;

  --status-ready-fg: #3a5a28;
  --status-ready-bg: #f0f5e8;
  --status-ready-border: #c8d4b8;

  --status-needs-fg: #2a4568;
  --status-needs-bg: #eef2f7;
  --status-needs-border: #c5d0dd;

  --status-not-fg: #7a4a00;
  --status-not-bg: #fdf3e2;
  --status-not-border: #e9d2a7;

  --mono: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 28px 96px;
}

header.head {
  margin-bottom: 32px;
}
header.head .eyebrow {
  color: var(--text-tertiary);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
header.head h1 {
  color: var(--navy);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
header.head .lede {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 10px;
  max-width: 62ch;
}

section.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 24px 28px;
  margin-bottom: 20px;
}

/* ── "Try this first" quick-start chips ─────────────────────────────────── */
.try-first {
  margin-bottom: 20px;
}
.try-first-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 10px;
}
.try-first-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}
.try-first-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.try-btn {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--navy-soft);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.try-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

label.field-label {
  display: block;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field-hint {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-bottom: 14px;
}
.warning {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  font-size: 12.5px;
  padding: 9px 12px;
  margin-bottom: 14px;
}

textarea#policy-text {
  display: block;
  width: 100%;
  min-height: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  padding: 12px 14px;
  resize: vertical;
}
textarea#policy-text:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.row .left { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 8px; }
.row .right { flex: 0 0 auto; }

button {
  font-family: var(--sans);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.08s ease, border-color 0.08s ease, color 0.08s ease;
}
.example-select-label {
  color: var(--text-tertiary);
  font-size: 12.5px;
  align-self: center;
  margin-right: 4px;
}
.example-select {
  font-family: var(--sans);
  font-size: 13px;
  padding: 9px 30px 9px 12px;
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-secondary);
  color: var(--navy);
  border: 1px solid var(--border-light);
  transition: border-color 0.08s ease, background 0.08s ease;
  /* Custom caret — the row uses an amber accent elsewhere. */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23777' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.example-select:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-medium);
}
.example-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
button.primary {
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy);
  font-weight: 500;
  padding: 10px 22px;
}
button.primary:hover {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
}
button.primary:disabled {
  background: var(--border-medium);
  border-color: var(--border-medium);
  cursor: not-allowed;
}

.char-counter {
  color: var(--text-quaternary);
  font-family: var(--mono);
  font-size: 12px;
}
.char-counter.over { color: #b3401d; }

/* Result area */
#result { display: none; }
#result.shown { display: block; }

.result-status {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
}
.result-status .label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.result-status .verdict {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.result-status.is-ready { background: var(--status-ready-bg); border-color: var(--status-ready-border); }
.result-status.is-ready .verdict { color: var(--status-ready-fg); }
.result-status.is-needs { background: var(--status-needs-bg); border-color: var(--status-needs-border); }
.result-status.is-needs .verdict { color: var(--status-needs-fg); }
.result-status.is-not { background: var(--status-not-bg); border-color: var(--status-not-border); }
.result-status.is-not .verdict { color: var(--status-not-fg); }

.result-sub {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-bottom: 16px;
}
.result-sub .impact-blocking { color: var(--status-not-fg); }
.result-sub .impact-advisory { color: var(--text-secondary); }

h3.section {
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 8px;
  margin-bottom: 8px;
}
h3.section .qualifier {
  color: var(--text-tertiary);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-left: 8px;
}

ul.findings { list-style: none; padding: 0; }
ul.findings li {
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-left-width: 3px;
  border-radius: 3px;
  margin-bottom: 6px;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--bg-surface);
}
ul.findings.blocking li { border-left-color: var(--accent); }
ul.findings.advisory li { border-left-color: var(--border-medium); color: var(--text-secondary); }

.empty-state {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 16px 18px;
  border-radius: 4px;
  font-size: 13.5px;
}

.why {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 14px 18px;
  border-radius: 4px;
  font-size: 13.5px;
  margin-top: 18px;
  white-space: pre-line;
  font-family: var(--sans);
}

.tech-details {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}
.tech-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
  list-style: none;
}
.tech-details summary::before {
  content: '▸ ';
}
.tech-details[open] summary::before {
  content: '▾ ';
}

/* ── Field-by-field confirmation cards ──────────────────────────────────── */
.fields-lede {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px;
  max-width: 64ch;
}
.fields-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 6px;
}
.auth-card {
  border: 1px solid var(--border-light);
  border-left-width: 3px;
  border-left-color: var(--border-medium);
  border-radius: 4px;
  background: var(--bg-surface);
  padding: 14px 16px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.auth-card.is-confirmed {
  border-left-color: var(--status-ready-border);
  background: var(--status-ready-bg);
}
.auth-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.auth-card-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--navy);
}
.auth-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
}
.auth-card.is-confirmed .auth-badge { color: var(--status-ready-fg); }

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 14px;
  margin-bottom: 12px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.auth-field-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
/* Small, muted helper text shown under an auth-card field input. */
.auth-field-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 2px;
}
.auth-input {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text-primary);
  padding: 7px 10px;
  border: 1px solid var(--border-medium);
  border-radius: 3px;
  background: var(--bg-surface);
}
.auth-input:focus {
  outline: none;
  border-color: var(--navy-soft);
}
.auth-input:disabled {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-color: var(--border-light);
  cursor: default;
}
/* Read-only field value (prohibition cards — confirmed as-extracted, not edited). */
.auth-readonly {
  font-size: 13.5px;
  color: var(--text-primary);
  padding: 7px 0;
}

.auth-source {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 9px 11px;
  background: var(--bg-secondary);
  border-radius: 3px;
  margin-bottom: 12px;
}
.auth-source-label {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.auth-source-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
}
button.confirm-field {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 16px;
  border-radius: 4px;
  border: 1px solid var(--status-ready-border);
  background: var(--status-ready-bg);
  color: var(--status-ready-fg);
}
button.confirm-field:hover {
  border-color: var(--status-ready-fg);
}
button.confirm-field.is-edit {
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-secondary);
}
button.confirm-field.is-edit:hover {
  border-color: var(--navy-soft);
  color: var(--navy);
}

/* ── Confirm-and-emit affordance ────────────────────────────────────────── */
#emit-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}
.emit-lede {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  max-width: 56ch;
}

/* ── Emitted package summary ────────────────────────────────────────────── */
.emit-result {
  margin-top: 18px;
  border: 1px solid var(--border-light);
  border-left-width: 3px;
  border-radius: 4px;
  padding: 16px 18px;
  background: var(--bg-surface);
}
.emit-result.is-emitted {
  border-left-color: var(--status-ready-border);
  background: var(--status-ready-bg);
}
.emit-result.is-rejected {
  border-left-color: var(--accent);
  background: var(--status-not-bg);
}
.emit-head {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.emit-result.is-emitted .emit-head { color: var(--status-ready-fg); }
.emit-result.is-rejected .emit-head { color: var(--status-not-fg); }
.emit-line {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 5px 0;
  font-size: 13.5px;
}
.emit-key {
  flex: 0 0 140px;
  color: var(--text-tertiary);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
/* Bug 4: long values (Package ID, 64-char Hash, Registered gaps) must wrap,
   not clip, on narrow screens. */
.emit-val {
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.emit-val.muted { color: var(--text-quaternary); }
ul.emit-sublist {
  margin: 0;
  padding-left: 0;
  list-style: none;
  flex: 1;
  min-width: 0;
}
ul.emit-sublist li {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-primary);
  padding: 2px 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.emit-closing {
  margin: 12px 0 0;
  font-size: 13px;
  font-style: italic;
  color: var(--text-secondary);
}

/* Frozen package identity + ClearState handoff (post-emit) */
.pkg-identity {
  margin: 14px 0 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 5px;
}
.emit-cta-note {
  margin: 14px 0 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy, #2a4568);
}
a.cs-test-link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--green, #0a5c3a);
  border: 1px solid var(--green, #0a5c3a);
  border-radius: 6px;
  padding: 11px 22px;
  text-decoration: none;
  margin-top: 4px;
}
a.cs-test-link:hover { background: #094e31; border-color: #094e31; }
.emit-reason {
  font-size: 13.5px;
  color: var(--status-not-fg);
  font-family: var(--mono);
}

footer.foot {
  margin-top: 40px;
  color: var(--text-tertiary);
  font-size: 12.5px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}
footer.foot p + p { margin-top: 6px; }

/* ══ RS-UX v10.2 ══════════════════════════════════════════════════════════ */
/* Alias tokens — map the v10.2 component vocabulary onto the existing palette
   (mockup: --navy #2a4568 == existing --navy-soft, --amber #c07a00 == --accent). */
:root{
  --amber: var(--accent);
  --amber-lt: rgba(192,122,0,0.10);
  --muted: #6b6055;
  --text: var(--text-primary);
  --bg-doc: var(--bg-tertiary);
  --secondary-bg: var(--bg-secondary);
  --light-border: var(--border-light);
  --border-input: var(--border-medium);
  --doc-bg: var(--bg-surface);
  --rs-red: #8c1f15;
  --green: #0a5c3a;
}

/* Step 1 */
.step-badge{display:inline-flex;align-items:center;gap:6px;
  font-family:var(--mono);font-size:10px;color:var(--amber);
  letter-spacing:.1em;text-transform:uppercase;margin-bottom:10px;}
.step-num{background:var(--amber);color:#fff;border-radius:50%;
  width:18px;height:18px;display:inline-flex;align-items:center;
  justify-content:center;font-size:10px;font-weight:600;flex-shrink:0;}
.step-question{font-size:15px;font-weight:600;color:var(--navy-soft);
  margin-bottom:6px;}
.step-helper{font-size:13px;color:var(--muted);margin-bottom:14px;
  line-height:1.55;}
.type-select{width:100%;font-family:var(--sans);font-size:14px;
  border:1px solid var(--border-input);border-radius:6px;padding:10px 14px;
  background:var(--bg-doc);color:var(--text);appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%236b6055'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 14px center;
  cursor:pointer;}
.type-select.selected{border-color:var(--amber);
  background-color:rgba(192,122,0,0.10);}
.more-toggle{font-size:12.5px;color:var(--navy-soft);cursor:pointer;
  margin-top:8px;display:inline-block;text-decoration:underline;}
.other-input-wrap{margin-top:12px;}
.other-input-lbl{font-size:12.5px;color:var(--muted);display:block;
  margin-bottom:6px;}
.other-input{width:100%;font-family:var(--sans);font-size:14px;
  border:1px solid var(--border-input);border-radius:5px;
  min-height:48px;padding:12px 14px;
  background:#fff;color:var(--text);}
.other-examples{font-size:11.5px;color:var(--muted);margin-top:5px;
  line-height:1.6;font-style:italic;}
.lede-problem {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.65;
  max-width: 580px;
  margin-top: 8px;
}
.lede-cs{font-size:13.5px;color:var(--muted);line-height:1.65;
  max-width:580px;margin-top:7px;}

/* Checked-for context block */
.checked-for{padding:12px 14px;background:var(--secondary-bg);
  border:1px solid var(--light-border);border-radius:5px;
  margin-bottom:20px;}
.checked-for-line{font-size:13px;color:var(--navy-soft);margin-bottom:6px;}
.looked-for{font-size:12.5px;color:var(--muted);}

/* Human conclusion */
.human-conclusion{font-size:15.5px;font-weight:500;line-height:1.65;
  padding:14px 18px;border-left:3px solid var(--amber);
  border-radius:0 5px 5px 0;background:rgba(192,122,0,0.10);
  margin-bottom:20px;}
.human-conclusion.is-blocking{border-left-color:var(--rs-red);
  background:rgba(140,31,21,0.07);}
.next-step-box {
  padding: 12px 16px;
  background: rgba(42,69,104,0.05);
  border-left: 3px solid var(--navy, #2a4568);
  border-radius: 0 5px 5px 0;
  font-size: 13.5px;
  color: var(--navy, #2a4568);
  line-height: 1.65;
  margin-bottom: 20px;
}

/* Source text */
.source-highlighted{font-size:14px;line-height:1.9;
  background:var(--bg-doc);border:1px solid var(--border-input);
  border-radius:5px;padding:14px 16px;word-break:break-word;}
mark.src-found{background:rgba(192,122,0,0.13);
  border-bottom:2px solid var(--amber);border-radius:2px;
  padding:1px 2px;font-family:var(--mono);font-size:.91em;
  color:inherit;}
.source-legend{display:flex;gap:14px;margin-top:8px;flex-wrap:wrap;}
.src-leg-item{display:flex;align-items:center;gap:5px;font-size:12px;
  color:var(--muted);}
.src-leg-dot{width:14px;height:3px;border-radius:2px;}

/* Confirm disclaimer — highlighted box, sits directly before the save action */
.confirm-disclaimer{font-size:13.5px;color:var(--navy);
  background:var(--accent-soft);border:1px solid var(--amber);
  border-left:4px solid var(--amber);
  border-radius:6px;padding:12px 15px;margin:6px 0 16px;line-height:1.6;}
.confirm-disclaimer strong{color:var(--accent-hover);}

/* Recheck bar */
.recheck-bar{margin:16px 0;padding:12px 16px;
  background:rgba(42,69,104,0.06);border:1px solid rgba(42,69,104,0.2);
  border-radius:5px;display:flex;align-items:center;gap:14px;
  flex-wrap:wrap;}
.recheck-msg{font-size:13px;color:var(--navy-soft);flex:1;}
.btn-recheck{background:transparent;border:1px solid var(--navy-soft);
  color:var(--navy-soft);border-radius:4px;padding:6px 14px;
  font-family:var(--sans);font-size:12.5px;font-weight:500;
  cursor:pointer;white-space:nowrap;}

/* Soft char warning */
.soft-warn-msg{font-size:12px;color:var(--amber);margin-top:6px;
  display:none;line-height:1.5;}
.char-counter.soft{color:var(--amber);}

/* Gap cards with patch */
.gap-patch-form{margin-top:12px;}
.gap-patch-lbl{font-size:13px;color:var(--text);margin-bottom:6px;
  display:block;font-weight:500;}
.gap-patch-input{width:100%;font-family:var(--sans);font-size:13px;
  border:1px solid var(--border-input);border-radius:4px;padding:8px 12px;
  background:#fff;min-height:60px;resize:vertical;line-height:1.55;}
.gap-patch-note{font-size:11.5px;color:var(--muted);margin-top:5px;}
.btn-add-patch{margin-top:8px;background:transparent;
  border:1px solid var(--rs-red);
  color:var(--rs-red);border-radius:4px;padding:6px 14px;
  font-family:var(--sans);font-size:13px;font-weight:500;
  cursor:pointer;}
.gap-why,.gap-define{display:block;font-size:.875em;margin-top:3px;
  color:var(--muted);line-height:1.5;}
.gap-define{color:var(--navy-soft);font-weight:500;}

/* Confirm package */
.confirm-pkg{padding:20px;border:1px solid var(--border-input);
  border-radius:6px;background:var(--secondary-bg);}
.confirm-pkg h3{font-size:14px;font-weight:600;color:var(--navy-soft);
  margin-bottom:6px;}
.confirm-intro{font-size:13px;color:var(--muted);margin-bottom:16px;
  line-height:1.6;}
.pkg-scope{margin-bottom:18px;border:1px solid var(--light-border);
  border-radius:5px;overflow:hidden;}
.pkg-scope-row{padding:11px 14px;font-size:13px;line-height:1.55;}
.pkg-scope-row:first-child{
  border-bottom:1px solid var(--light-border);}
.pkg-scope-row strong{font-weight:600;color:var(--navy-soft);
  display:block;margin-bottom:3px;}
.pkg-scope-row p{color:var(--muted);}
.final-policy{margin-bottom:18px;}
.final-policy-lbl{font-family:var(--mono);font-size:10.5px;
  color:var(--muted);text-transform:uppercase;letter-spacing:.08em;
  margin-bottom:6px;display:block;}
.final-policy textarea{background:#fff;font-size:13px;min-height:120px;
  border-color:var(--border-input);border-radius:4px;cursor:default;
  width:100%;font-family:var(--mono);padding:10px 12px;
  color:var(--text);resize:vertical;}
.form-row{display:flex;gap:12px;margin-bottom:10px;flex-wrap:wrap;}
.form-field{flex:1;min-width:160px;}
.form-lbl{font-size:12px;color:var(--muted);display:block;
  margin-bottom:4px;}
.form-input{width:100%;font-family:var(--sans);font-size:13.5px;
  border:1px solid var(--border-input);border-radius:4px;
  padding:7px 10px;background:#fff;color:var(--text);}
.auth-opts{margin:14px 0;}
.auth-opts-lbl{font-size:13px;font-weight:500;color:var(--navy-soft);
  margin-bottom:10px;display:block;}
.auth-opt{display:flex;gap:10px;align-items:flex-start;
  padding:10px 12px;border:1px solid var(--light-border);
  border-radius:5px;margin-bottom:8px;cursor:pointer;font-size:13px;
  line-height:1.5;background:#fff;}
.auth-opt.selected{border-color:var(--navy-soft);
  background:rgba(42,69,104,0.04);}
.auth-actions-row{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px;}
button.primary.green{background:var(--green);border-color:var(--green);}
button.primary.green:hover{background:#094e31;border-color:#094e31;}
.export-panel{margin-top:16px;padding:14px 16px;
  background:var(--secondary-bg);border:1px solid var(--border-input);
  border-radius:5px;}
.export-panel h4{font-size:13px;font-weight:600;color:var(--navy-soft);
  margin-bottom:10px;}
.export-row{display:flex;gap:10px;padding:5px 0;
  border-bottom:1px solid var(--light-border);font-size:12.5px;}
.export-row:last-child{border-bottom:none;}
.export-key{font-family:var(--mono);font-size:10.5px;
  color:var(--muted);text-transform:uppercase;letter-spacing:.06em;
  width:140px;flex-shrink:0;padding-top:2px;}
.export-val{color:var(--text);line-height:1.5;}

/* Gate card */
.gate-card{margin-top:14px;padding:16px 18px;
  background:rgba(42,69,104,0.05);
  border:1px solid rgba(42,69,104,0.18);
  border-radius:6px;animation:fadeIn .2s ease;}
.gate-intro{font-size:13px;font-weight:600;color:var(--navy);
  margin-bottom:8px;}
.gate-list{margin:0 0 14px 18px;padding:0;}
.gate-list li{font-size:13px;color:var(--text);line-height:1.7;}
.gate-question{font-size:13.5px;color:var(--navy);font-weight:500;
  margin-bottom:14px;}
.gate-actions{display:flex;gap:10px;flex-wrap:wrap;}
.btn-gate-confirm{background:var(--navy);color:#fff;border:none;
  border-radius:5px;padding:9px 20px;font-family:var(--sans);
  font-size:13.5px;font-weight:600;cursor:pointer;}
.btn-gate-confirm:hover{opacity:.88;}
.btn-gate-change{background:transparent;
  border:1px solid var(--navy);color:var(--navy);
  border-radius:5px;padding:9px 16px;font-family:var(--sans);
  font-size:13px;cursor:pointer;}
.gate-confirmed-label{font-size:13px;color:var(--navy);
  font-weight:500;margin-right:12px;}

/* Step 2 locked */
.step-locked{opacity:.45;pointer-events:none;
  transition:opacity .25s ease;}
.step-locked-msg{font-size:12.5px;color:var(--muted);
  margin-top:8px;font-style:italic;}

/* Gate invalidation notice */
.gate-invalidation{padding:10px 14px;background:rgba(192,122,0,0.08);
  border:1px solid rgba(192,122,0,0.25);border-radius:5px;
  font-size:13px;color:var(--navy);margin-bottom:16px;
  line-height:1.55;}

@keyframes fadeIn{from{opacity:0;transform:translateY(-4px)}
  to{opacity:1;transform:none}}

/* ══ Result blocks — four visually distinct sections ══════════════════════════
   Each named group (found / missing / needs confirmation / action) is a framed
   block with a colour-coded banner, so a first-time tester can tell the four
   apart at a glance. Inner section IDs and show/hide logic are unchanged; a thin
   JS helper (syncResultGroups) shows a block only when it has visible content. */
.result-block{
  border:1px solid var(--light-border);
  border-radius:8px;
  background:var(--bg-surface);
  margin:0 0 18px;
  overflow:hidden;
}
.block-banner{
  display:flex;flex-direction:column;gap:2px;
  padding:12px 16px;
  background:var(--bg-secondary);
  border-bottom:1px solid var(--light-border);
  border-left:4px solid var(--border-medium);
}
.block-kind{font-family:var(--mono);font-size:10px;letter-spacing:.1em;
  text-transform:uppercase;color:var(--muted);}
.block-title{font-size:16px;font-weight:600;color:var(--navy);
  letter-spacing:-.005em;}
.block-sub{font-size:12.5px;color:var(--muted);line-height:1.5;}

/* Inner sections get their padding from the block, not their own borders. */
.result-block > div[id$="-section"]{padding:14px 16px;}
.result-block > div[id$="-section"] + div[id$="-section"]{
  border-top:1px solid var(--light-border);}

/* Per-kind accent — reuse existing palette tokens. */
.block-found  .block-banner{border-left-color:var(--amber);}
.block-missing .block-banner{border-left-color:var(--rs-red);
  background:rgba(140,31,21,0.05);}
.block-missing{border-color:rgba(140,31,21,0.25);}
.block-confirm .block-banner{border-left-color:var(--navy-soft);
  background:rgba(42,69,104,0.05);}
.block-action{border-color:rgba(10,92,58,0.30);}
.block-action .block-banner{border-left-color:var(--green);
  background:rgba(10,92,58,0.06);}
.block-action .block-title{color:var(--green);}

/* The emit section sits inside the action banner; drop its own divider. */
.block-action #emit-section{margin-top:0;padding-top:14px;border-top:none;}
.block-action #emit-result{margin:0 16px 16px;}

/* Sub-heading inside a block (prohibitions / advisory / needs). */
h3.section.sub{margin-top:0;}

/* Instruction text — clearly marked as guidance, distinct from the generated
   output cards (which carry "From the text" provenance) and the action buttons. */
.instruction{
  position:relative;
  font-size:12.5px;color:var(--muted);line-height:1.6;
  margin:0 0 12px;padding:8px 12px 8px 32px;
  background:var(--bg-secondary);border-radius:5px;max-width:66ch;
}
.instruction::before{
  content:'i';position:absolute;left:10px;top:8px;
  width:15px;height:15px;display:inline-flex;align-items:center;
  justify-content:center;font-family:var(--mono);font-size:10px;
  font-weight:600;font-style:normal;color:#fff;background:var(--navy-soft);
  border-radius:50%;}

/* Developer details — in-result collapsed toggle, matches .tech-details. */
.dev-details{margin-top:12px;border-top:1px dashed var(--light-border);
  padding-top:10px;}
.dev-details summary{cursor:pointer;color:var(--muted);font-size:12px;
  user-select:none;list-style:none;}
.dev-details summary::before{content:'▸ ';}
.dev-details[open] summary::before{content:'▾ ';}
.dev-details .emit-line{padding:4px 0;}

/* ══ Mobile ════════════════════════════════════════════════════════════════
   Single source of truth for small screens. The cards carry no horizontal
   margin of their own — their visible gutter comes from .page padding. */

/* Never allow a horizontal scrollbar, and wrap long unbreakable tokens
   (underscored rule keys, URLs) inside findings and the source view. */
html, body { max-width: 100%; overflow-x: hidden; }
ul.findings li,
.source-highlighted,
.auth-card,
footer.foot p { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 640px) {
  /* 1. Visible gutter from the screen edges (16px each side, > 12px minimum). */
  .page { padding: 32px 16px 64px; }
  section.card { padding: 18px 16px; }

  /* 2. iOS zooms a field on focus unless its font-size is ≥16px. !important is
        needed to beat the id/class rules above (textarea#policy-text,
        .type-select, .auth-input, .form-input, …). */
  input, select, textarea { font-size: 16px !important; }

  /* 3. Stack rows and collapse the auth grid so nothing forces overflow. */
  .try-first-buttons { flex-direction: column; }
  .try-btn { width: 100%; text-align: left; }
  .form-row, .auth-actions-row { flex-direction: column; }
  .form-field { min-width: 0; }
  .auth-grid { grid-template-columns: 1fr; }

  /* Bug 4: stack the post-emit key/value rows so Package ID + Hash get the full
     width and wrap cleanly instead of being clipped by the fixed-width key. */
  .emit-line { flex-direction: column; gap: 2px; }
  .emit-key { flex: none; }
}

/* Bug 2: edit-policy affordance in the "What is missing" block. */
.missing-edit { margin-top: 12px; }
.btn-edit-policy {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--rs-red, #8c1f15);
  background: transparent;
  border: 1px solid var(--rs-red, #8c1f15);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
}
.btn-edit-policy:hover { background: rgba(140, 31, 21, 0.06); }

/* Bug 3: inline field validation. */
.field-error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--rs-red, #8c1f15);
  overflow-wrap: anywhere;
}
.form-input.input-error { border-color: var(--rs-red, #8c1f15); }

/* ── Decision-readiness checklist (display-only, derived from RS output) ── */
.rs-checklist {
  margin: 4px 0 18px;
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
}
.rs-checklist-h {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.rs-checklist-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}
.rs-checklist-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: baseline;
  margin-bottom: 12px;
}
.rs-ready-line { font-size: 14.5px; font-weight: 700; }
.rs-ready-line.is-yes { color: var(--status-ready-fg); }
.rs-ready-line.is-no { color: var(--rs-red, #8c1f15); }
.rs-gaps-line { font-size: 12.5px; color: var(--muted); }

.rs-checklist-rows { display: flex; flex-direction: column; gap: 6px; }
.rs-row {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-primary);
}
.rs-row.is-found { border-left: 3px solid var(--status-ready-border); }
.rs-row.is-missing { border-left: 3px solid var(--rs-red, #8c1f15); }
.rs-row-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  list-style: none;
}
.rs-row-summary::-webkit-details-marker { display: none; }
.rs-row-summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--text-quaternary);
  font-size: 12px;
}
.rs-row[open] .rs-row-summary::after { content: '▴'; }
.rs-row-icon { font-size: 13px; }
.rs-row-name { font-weight: 600; color: var(--text-primary); }
.rs-row-dash { color: var(--text-quaternary); }
.rs-row-status { color: var(--muted); }
.rs-row.is-missing .rs-row-status { color: var(--rs-red, #8c1f15); }
.rs-row-detail {
  padding: 0 12px 11px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.rs-row-found { color: var(--text-secondary); overflow-wrap: anywhere; }
/* Locked gap-card section labels: "Missing" and "Why this is needed". */
.rs-row-section-label {
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--navy, #0A1628); margin: 8px 0 2px;
}
.rs-row-section-label:first-child { margin-top: 0; }
.rs-row-missing-line { color: var(--text-secondary); margin: 0; }
.rs-row-needed { color: var(--muted); margin: 0; }

.rs-checklist-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 12.5px;
  color: var(--rs-red, #8c1f15);
  line-height: 1.5;
}
.rs-checklist-editbar { margin-top: 10px; }

/* UI export gate message (display-only). */
.rs-export-gate-msg {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--rs-red, #8c1f15);
  line-height: 1.5;
}

/* "Suggest wording" — LLM-backed draft (display-only) on each missing row. */
.rs-suggest-wording { margin-top: 10px; }
.btn-suggest-wording {
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--navy, #0A1628); background: transparent;
  border: 1px solid var(--border-medium, #c8c4ba); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
.btn-suggest-wording:hover { background: rgba(10,22,40,.05); }
.btn-suggest-wording:disabled { opacity: .6; cursor: default; }
.rs-wording-out {
  margin-top: 8px; padding: 10px 12px;
  border: 1px solid var(--border-light, #e5e1d8); border-left: 3px solid var(--accent, #c07a00);
  border-radius: 6px; background: #fff;
}
.rs-wording-explain { font-size: 13px; line-height: 1.55; color: var(--text-secondary, #444); margin: 0 0 8px; }
.rs-wording-label { font-size: 11.5px; letter-spacing: .02em; color: var(--muted); margin: 0 0 2px; }
/* Editable draft — the user edits the example wording before inserting it. */
.rs-wording-draft {
  display: block; width: 100%; min-height: 56px; resize: vertical;
  font: inherit; font-size: 13px; line-height: 1.55; color: var(--navy, #0A1628);
  background: #fff; border: 1px solid var(--border-medium, #c8c4ba);
  border-radius: 6px; padding: 8px 10px; margin: 0 0 6px;
}
/* Placeholder warning — shown while the editable draft still contains [brackets]. */
.rs-wording-warn { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: #8c1f15; }
.rs-wording-note { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
/* The only control that inserts the edited draft into the policy text. */
.btn-add-draft {
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: #fff; background: var(--accent, #c07a00); border: none;
  border-radius: 6px; padding: 7px 14px; cursor: pointer;
}
.btn-add-draft:hover { background: var(--accent-hover, #8a5800); }
.rs-wording-status { margin-top: 6px; font-size: 12px; color: var(--accent, #c07a00); }
.rs-wording-err { margin-top: 6px; font-size: 12px; color: #8c1f15; }

/* ── Policy structure guide (above the policy textarea, informational) ──────── */
.policy-guide {
  margin: 10px 0 12px; padding: 12px 14px;
  background: var(--bg-secondary, #f3efe6); border: 1px solid var(--border-light, #e5e1d8);
  border-radius: 8px; font-size: 13px; line-height: 1.55; color: var(--text-secondary, #444);
}
.policy-guide-intro { font-weight: 600; margin-bottom: 6px; color: var(--text-primary, #0a0a0a); }
.policy-guide-list { margin: 0 0 8px 18px; padding: 0; }
.policy-guide-list li { margin: 2px 0; }
.policy-guide-note { font-size: 12.5px; color: var(--muted, #6b6055); }

/* OTP modal (Auth Phase 1 — Server Väg A). Inert in this bit: hidden by default,
   shown later by toggling .otp-open on #otp-overlay from JS. */
#otp-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.55); /* navy at 55% — no token for this overlay tint */
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#otp-overlay.otp-open { display: flex; }
#otp-modal {
  background: var(--bg-surface);
  width: 100%;
  max-width: 420px;
  padding: 28px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(10, 22, 40, 0.25);
  font-family: var(--sans);
  color: var(--text-primary);
}
#otp-modal h3 {
  color: var(--navy);
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 8px;
}
#otp-modal .otp-intro {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin-bottom: 16px;
}
#otp-modal .form-field { margin-bottom: 12px; }
.otp-terms-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 8px;
}
.otp-verify-section { display: none; }
.otp-verify-sep {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-light);
  margin: 18px 0 12px;
  padding-top: 16px;
}
#otp-send-btn,
#otp-verify-btn { width: 100%; margin-top: 6px; }
.otp-cancel {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}
.otp-cancel:hover { color: var(--text-secondary); }
#otp-status {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 12px;
}
#otp-modal.otp-code-sent .otp-verify-section {
  display: block;
}

@media(max-width:600px){
  .final-policy textarea{min-height:160px;}
}
