/* Build Familiar — mobile-first */
:root {
  --navy: #091b46;
  --navy-2: #0d2563;
  --ink: #f4f6ff;
  --muted: #aab4d8;
  --gold: #e8b33c;
  --gold-soft: #f5d67b;
  --card: #101f52;
  --line: #233470;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, var(--navy-2), var(--navy)) fixed, var(--navy);
  color: var(--ink);
  line-height: 1.6;
}
a { color: var(--gold-soft); }
a:active { opacity: .7; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(9, 27, 70, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: .6rem 1rem;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.brand-mark { font-size: 1.4rem; }
.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; font-size: 1.3rem;
  background: transparent; border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
}
.menu-toggle:active { background: var(--card); }
.site-nav { display: none; width: 100%; flex-direction: column; }
.site-nav.open { display: flex; }
.site-nav a {
  color: var(--ink); text-decoration: none; padding: .8rem .25rem;
  border-top: 1px solid var(--line); font-weight: 600;
}
.site-nav a:active { background: var(--card); }

/* search */
.search-wrap { position: relative; width: 100%; }
.search-form { display: flex; gap: .4rem; }
.search-form input {
  flex: 1; min-height: 44px; padding: .55rem .8rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: #0a1740; color: var(--ink);
}
.search-form input::placeholder { color: var(--muted); }
.search-form button {
  min-width: 44px; min-height: 44px; font-size: 1.1rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
}
.search-form button:active { background: var(--navy-2); }
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  margin: 0; padding: .35rem; list-style: none;
  background: #0c1c50; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.suggest li a {
  display: block; padding: .7rem .8rem; border-radius: 8px;
  color: var(--ink); text-decoration: none;
}
.suggest li a .s-title { display: block; font-weight: 600; }
.suggest li a .s-ex { display: block; font-size: .85rem; color: var(--muted); }
.suggest li a.active, .suggest li a:active { background: var(--card); }

/* layout */
main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.breadcrumbs { font-size: .9rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--gold-soft); }

/* hero */
.hero { text-align: center; padding: 2.5rem 0 2rem; }
.hero h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 .75rem; }
.hero h1 .gold { color: var(--gold); }
.hero p.lede { font-size: 1.1rem; color: var(--muted); max-width: 34rem; margin: 0 auto 1.5rem; }
.cta-row { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block; min-height: 48px; padding: .8rem 1.6rem;
  border-radius: 999px; font-weight: 700; text-decoration: none;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gold); color: #1a1206; }
.btn-ghost { border-color: var(--line); color: var(--ink); }

/* cards */
.loop { display: grid; gap: 1rem; margin: 2.5rem 0; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem;
}
.card h2, .card h3 { margin-top: 0; }
.card .step { font-size: .8rem; font-weight: 700; letter-spacing: .08em; color: var(--gold); text-transform: uppercase; }
.guard { border-color: var(--gold); }

/* prose pages */
.prose { max-width: 44rem; }
.prose h1 { font-size: 1.7rem; }
.prose li { margin-bottom: .4rem; }

/* search results */
.results { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: .9rem; }
.results a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; text-decoration: none; color: var(--ink); }
.results a:active { background: var(--navy-2); }
.results .r-title { font-weight: 700; color: var(--gold-soft); }
.results .r-ex { color: var(--muted); font-size: .95rem; }
.no-results { color: var(--muted); }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: rgba(6, 17, 46, .85); }
.footer-inner {
  max-width: 1080px; margin: 0 auto; padding: 2rem 1rem 1rem;
  display: grid; gap: 1.5rem;
}
.footer-brand { font-weight: 700; font-size: 1.05rem; margin: 0 0 .25rem; }
.footer-tag { color: var(--muted); margin: 0; font-size: .95rem; }
.footer-head { font-weight: 700; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.footer-col nav, .footer-col { display: flex; flex-direction: column; }
.footer-col a { color: var(--ink); text-decoration: none; padding: .45rem 0; }
.footer-col a:active { color: var(--gold-soft); }
.footer-fine { text-align: center; color: var(--muted); font-size: .85rem; padding: 0 1rem 1.5rem; margin: 0; }

/* wider screens */
@media (min-width: 760px) {
  .menu-toggle { display: none; }
  .site-nav { display: flex; width: auto; flex-direction: row; gap: 1.25rem; }
  .site-nav a { border: 0; padding: .4rem 0; }
  .search-wrap { width: 260px; margin-left: auto; }
  .header-inner { flex-wrap: nowrap; }
  .brand { margin-right: 0; }
  .hero h1 { font-size: 2.75rem; }
  .loop { grid-template-columns: repeat(3, 1fr); }
  .footer-inner { grid-template-columns: 1.2fr 1fr 1fr; }
}

/* templates index */
.tpl-grid { display: grid; gap: 1rem; margin: 2rem 0; }
.tpl-card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem; text-decoration: none; color: var(--ink);
}
.tpl-card:active { background: var(--navy-2); }
.tpl-card h2 { margin: 0 0 .4rem; color: var(--gold-soft); }
.tpl-card p { margin: 0 0 .8rem; color: var(--muted); }
.tpl-card .go { font-weight: 700; }

/* builder wizard */
.builder { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin: 1.5rem 0; }
.builder-progress { height: 8px; background: #0a1740; border-radius: 99px; overflow: hidden; }
.builder-progress-bar { height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .3s ease; }
.builder-progress-text { font-size: .9rem; color: var(--muted); font-weight: 600; }
.builder-intro { color: var(--muted); }
.builder-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }
.builder-nav .btn { min-width: 120px; }
.field { margin-bottom: 1.1rem; }
.field-label { display: block; font-weight: 600; margin-bottom: .4rem; }
.field-input {
  width: 100%; min-height: 48px; padding: .65rem .8rem; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px; background: #0a1740; color: var(--ink);
  font-family: inherit;
}
textarea.field-input { min-height: 140px; resize: vertical; }
.field-input::placeholder { color: var(--muted); }
.field.invalid .field-input { border-color: #e05c5c; }
.field-error { color: #f0a0a0; font-size: .9rem; margin: .3rem 0 0; }
.checks { display: grid; gap: .5rem; }
.check {
  display: flex; align-items: center; gap: .7rem; min-height: 48px;
  padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: #0a1740;
}
.check input { width: 22px; height: 22px; accent-color: var(--gold); flex-shrink: 0; }
.tabs { display: flex; gap: .5rem; margin: 1rem 0 .5rem; }
.tab {
  min-height: 44px; padding: .55rem 1.1rem; border: 1px solid var(--line);
  border-radius: 999px; background: transparent; color: var(--ink); font-weight: 600;
}
.tab.active { background: var(--gold); color: #1a1206; border-color: var(--gold); }
.code-block {
  background: #060f2e; border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  font-size: .88rem; line-height: 1.55; max-height: 420px; overflow-y: auto;
}
.next-box { margin-top: 1.25rem; padding: 1rem 1.1rem; border: 1px dashed var(--gold); border-radius: 10px; color: var(--muted); font-size: .95rem; }
.next-box strong { color: var(--ink); }

@media (min-width: 760px) {
  .tpl-grid { grid-template-columns: repeat(3, 1fr); }
  .checks { grid-template-columns: 1fr 1fr; }
}

/* key pill + key page */
.key-pill {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: .4rem .9rem; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600;
  white-space: nowrap;
}
.key-pill:active { background: var(--card); }
.key-pill.has-key { color: var(--gold-soft); border-color: var(--gold); }
.key-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; margin: 1.5rem 0;
}
.key-card .btn { margin-top: .25rem; }
.key-ok { color: #9fe6a0; font-weight: 600; }
.field-hint { color: var(--muted); font-size: .88rem; margin: .3rem 0 0; }
#forget-wrap { margin-top: 1rem; }
.check small { color: var(--muted); }

/* guardrail gate */
.gate-demo {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; margin: 2rem 0;
}
.gate-demo h2 { margin-top: 0; }
.config-details { margin-bottom: 1.1rem; }
.config-details summary { min-height: 44px; font-weight: 600; color: var(--gold-soft); cursor: pointer; }
.config-details textarea { font-family: ui-monospace, monospace; font-size: .82rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 1rem; }
.chip {
  min-height: 44px; padding: .5rem 1rem; border: 1px solid var(--line);
  border-radius: 999px; background: #0a1740; color: var(--ink); font-size: .9rem;
}
.chip:active { background: var(--navy-2); border-color: var(--gold); }
.phases { display: grid; gap: .5rem; margin: 1.25rem 0; }
.phase {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px;
  background: #0a1740; font-weight: 600;
}
.phase .p-dot { width: 10px; height: 10px; border-radius: 99px; background: var(--muted); flex-shrink: 0; }
.phase.active .p-dot { background: var(--gold); animation: pulse 1s infinite; }
.phase.done .p-dot { background: #7ddf8a; }
.phase.blocked { border-color: #e05c5c; }
.phase.blocked .p-dot { background: #e05c5c; }
.phase .badge { margin-left: auto; }
@keyframes pulse { 50% { opacity: .4; } }
.badge {
  display: inline-block; padding: .2rem .7rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; letter-spacing: .04em;
}
.badge.pass { background: rgba(125,223,138,.15); color: #7ddf8a; border: 1px solid #7ddf8a; }
.badge.warn { background: rgba(232,179,60,.15); color: var(--gold-soft); border: 1px solid var(--gold); }
.badge.block { background: rgba(224,92,92,.15); color: #f0a0a0; border: 1px solid #e05c5c; }
.violations { list-style: none; margin: .4rem 0 .8rem; padding: 0; font-size: .92rem; }
.violations li { padding: .5rem .8rem; border-radius: 8px; margin-bottom: .35rem; background: #0a1740; }
.violations li.block { border-left: 3px solid #e05c5c; }
.violations li.warn { border-left: 3px solid var(--gold); }
.report { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.report h3 { margin-top: 0; }
.r-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: .45rem 0; }
.r-row span:first-child { color: var(--muted); }
.r-note { color: var(--muted); font-size: .9rem; margin: -.2rem 0 .6rem; padding-left: .2rem; }
.verdict { font-weight: 700; font-size: 1.05rem; padding: .8rem 1rem; border-radius: 10px; margin: 1rem 0; }
.verdict.pass { background: rgba(125,223,138,.12); border: 1px solid #7ddf8a; }
.verdict.block { background: rgba(224,92,92,.12); border: 1px solid #e05c5c; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 10, 30, .75);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card); border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 1.5rem; max-width: 26rem; width: 100%;
}
.modal-card h2 { margin: .2rem 0 .5rem; }
.approval-desc { background: #0a1740; border: 1px solid var(--line); border-radius: 10px; padding: .9rem; }

/* sandbox */
.scenario-desc { color: var(--muted); font-size: .95rem; margin: .25rem 0 1rem; min-height: 1.4em; }
.chip.active-chip { border-color: var(--gold); color: var(--gold-soft); }
.trace { display: grid; gap: .5rem; margin: 1.25rem 0; }
.trace-entry {
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px;
  background: #0a1740; font-size: .95rem;
}
.trace-entry .t-label { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: .2rem; }
.trace-entry.act { border-left: 3px solid var(--gold); }
.trace-entry.observe { border-left: 3px solid #7ddf8a; }
.trace-entry .badge { margin-left: .4rem; }
.sim-note { color: var(--muted); font-size: .88rem; }

/* deploy */
.checks-list { display: grid; gap: .6rem; margin: 1rem 0; }
.check-row {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: #0a1740;
}
.check-row .c-dot { width: 10px; height: 10px; border-radius: 99px; background: var(--muted); flex-shrink: 0; }
.check-row.ok .c-dot { background: #7ddf8a; }
.check-row.missing .c-dot { background: var(--gold); }
.check-row .c-label { flex: 1; min-width: 200px; font-size: .95rem; }
.check-row .c-link { font-size: .9rem; font-weight: 600; }
.live-log { display: grid; gap: .6rem; margin: 1rem 0; max-height: 480px; overflow-y: auto; }
.live-msg {
  padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px;
  background: #0a1740; font-size: .95rem;
}
.live-msg .live-who { display: block; font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: .2rem; }
.live-msg.agent { border-left: 3px solid var(--gold); }
.live-msg.user { border-left: 3px solid #7d9bdf; }
.live-msg.gate { border-left: 3px solid #7ddf8a; }
.live-msg .live-text { white-space: pre-wrap; word-break: break-word; }
