:root {
  --bg: #f5f4ef;
  --grid: rgba(20, 30, 25, 0.055);
  --ink: #111512;
  --muted: #5d625e;
  --faint: #8b908c;
  --card: #ffffff;
  --card-line: #e6e6e0;
  --green-deep: #1f4d33;
  --green: #169a55;
  --green-soft: #e3f5ea;
  --amber: #c26a12;
  --amber-soft: #fdf0de;
  --slate-soft: #eef0f2;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 8px 24px rgba(16, 24, 20, .08);
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --card-w: 196px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: center top;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.topbar {
  max-width: 1240px; margin: 0 auto; padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand-mark { display: grid; grid-template-columns: 8px 8px; gap: 3px; }
.brand-mark i { width: 8px; height: 8px; border-radius: 2px; background: var(--green); }
.brand-mark i:nth-child(4) { background: var(--green-deep); }
.topnav { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.link-login { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.link-login:hover { color: var(--green); }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border: 1px solid #c9cbc6; border-radius: 999px; background: rgba(255,255,255,.5);
  transition: background .15s, border-color .15s;
}
.btn-outline:hover { background: #fff; border-color: var(--ink); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 28px 16px 8px; }
.hero h1 {
  margin: 0; font-size: clamp(30px, 4.6vw, 48px); line-height: 1.15; letter-spacing: -.03em; font-weight: 700;
}
.hl {
  display: inline-block; background: var(--green-deep); color: #fff;
  padding: 2px 16px 6px; border-radius: 8px; margin-right: 6px;
}
.sub { max-width: 620px; margin: 16px auto 24px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.btn-dark {
  display: inline-block; background: #15201a; color: #fff; font-weight: 600; font-size: 15px;
  padding: 12px 24px; border-radius: 6px; box-shadow: 0 6px 16px rgba(21,32,26,.25);
  transition: transform .15s, background .15s;
}
.btn-dark:hover { background: #000; transform: translateY(-1px); }

/* ---------- stage ---------- */
.stage { position: relative; height: 400px; margin-top: 16px; overflow: hidden; }
.track {
  position: absolute; left: 0; right: 0; top: 50%; height: 0;
  border-top: 1px dashed #cfd3cd;
}
.lane { position: absolute; inset: 0; }

.core {
  position: absolute; left: 50%; top: 50%; z-index: 5;
  width: 240px; height: 240px; transform: translate(-50%, -50%);
}
.core-inner {
  position: relative; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background-color: #fbfbf8;
  background-image: radial-gradient(#d3d6d0 1px, transparent 1.2px);
  background-size: 12px 12px;
  border: 1px solid var(--card-line); border-radius: 18px;
  box-shadow: 0 0 0 6px rgba(255,255,255,.6), var(--shadow);
  transition: box-shadow .3s;
}
.core.pulse .core-inner { box-shadow: 0 0 0 6px rgba(22,154,85,.15), 0 0 32px rgba(22,154,85,.25), var(--shadow); }
.pill-engine {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--green);
  background: var(--green-soft); padding: 3px 9px; border-radius: 999px;
}
.pill-engine b { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: blink 1.6s infinite; }
.core-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; background: rgba(251,251,248,.9); padding: 0 6px; }
.core-sub { font-size: 14px; font-weight: 600; color: var(--green); text-align: center; line-height: 1.35; background: rgba(251,251,248,.9); padding: 0 6px; }
.chip-core {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  background: #fff; border: 1px solid var(--card-line); border-radius: 8px; padding: 7px 12px;
}
.chip-core svg { color: var(--green); }
.core.pulse .chip-core svg { animation: spin 1s linear; }
.chip-login {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--green);
  background: var(--green-soft); padding: 4px 10px; border-radius: 999px;
}
.chip-login:hover { background: #cdeedb; }

/* wires above and below the core */
.wire { position: absolute; left: 50%; transform: translateX(-50%); width: 84px; height: 52px; display: flex; justify-content: space-between; }
.wire-top { bottom: 100%; }
.wire-bottom { top: 100%; }
.wire i { position: relative; width: 1px; background: #b9dcc7; }
.wire i::after {
  content: ""; position: absolute; left: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--green);
}
.wire-top i::after { top: 0; }
.wire-bottom i::after { bottom: 0; }
.wire-top i:nth-child(2) { height: 100%; }
.wire i { height: 100%; }
.wire i::before {
  content: ""; position: absolute; left: -1px; width: 3px; height: 10px; border-radius: 2px; background: var(--green); opacity: 0;
  animation: flow 2.4s infinite;
}
.wire-bottom i::before { animation-direction: reverse; }
.wire i:nth-child(2)::before { animation-delay: .8s; }
.wire i:nth-child(3)::before { animation-delay: 1.6s; }

/* ---------- cards ---------- */
.card {
  position: absolute; left: 0; top: 50%; width: var(--card-w);
  background: var(--card); border: 1px solid var(--card-line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px 14px 10px; font-size: 11px; color: var(--muted);
  will-change: transform, opacity;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.card-title { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; color: var(--ink); text-transform: uppercase; }
.card-title svg { width: 12px; height: 12px; color: var(--faint); }
.tag { font-family: var(--mono); font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--slate-soft); color: #6a7178; }
.card-strong { font-size: 13px; font-weight: 700; color: var(--ink); margin: -2px 0 6px; }
.rows { display: grid; gap: 3px; }
.row { display: flex; justify-content: space-between; gap: 8px; }
.row span:last-child { font-family: var(--mono); color: var(--ink); font-weight: 600; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; padding-top: 7px; border-top: 1px solid #efefea; font-size: 10px; color: var(--faint); }
.status { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.status.warn { background: var(--amber-soft); color: var(--amber); }
.status.ok { background: var(--green-soft); color: var(--green); display: inline-flex; align-items: center; gap: 3px; }
.status.ok svg { width: 10px; height: 10px; }
.foot-ok { font-weight: 800; color: var(--green); letter-spacing: .05em; font-size: 9.5px; }
.card.out .card-title { color: var(--green-deep); }
.card.out .card-title svg { color: var(--green); }
.card.out { border-color: #dbe9df; }

/* clickable core */
.core { cursor: pointer; border-radius: 18px; }
.core:hover .core-inner { border-color: #b9dcc7; box-shadow: 0 0 0 6px rgba(22,154,85,.12), var(--shadow); }
.core:hover .chip-login { background: #cdeedb; }
.core:focus-visible { outline: none; }
.core:focus-visible .core-inner { outline: 2px solid var(--green); outline-offset: 4px; }

/* ---------- login modal ---------- */
.modal {
  width: min(400px, calc(100vw - 32px)); padding: 28px 28px 22px;
  border: 1px solid var(--card-line); border-radius: 20px; background: #fff; color: var(--ink);
  box-shadow: 0 24px 64px rgba(16, 24, 20, .22);
}
.modal::backdrop { background: rgba(21, 32, 26, .35); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .18s ease-out; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: #f1f2ef; color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.modal-close:hover { background: #e4e6e1; color: var(--ink); }
.modal-brand { display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.modal h2 { margin: 14px 0 6px; text-align: center; font-size: 21px; letter-spacing: -.02em; }
.modal-sub { margin: 0 0 20px; text-align: center; font-size: 13px; line-height: 1.5; color: var(--muted); }
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.field {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; margin-bottom: 14px;
  border: 1px solid #d9dcd6; border-radius: 8px; background: #fafbf9; transition: border-color .15s, box-shadow .15s;
}
.field:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,154,85,.15); background: #fff; }
.field.invalid { border-color: #c2410c; }
.field > svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 11px 0; font: inherit; font-size: 14px; color: var(--ink); }
.eye { border: 0; background: none; padding: 4px; cursor: pointer; color: var(--faint); display: grid; }
.eye:hover, .eye[aria-pressed="true"] { color: var(--ink); }
.eye svg { width: 16px; height: 16px; }
.row-between { display: flex; justify-content: space-between; margin: -6px 0 12px; }
.small-link { font-size: 12px; color: var(--green); font-weight: 600; }
.small-link:hover { text-decoration: underline; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.45; color: var(--muted); margin-bottom: 14px; cursor: pointer; }
.consent input { margin: 2px 0 0; accent-color: var(--green); width: 15px; height: 15px; flex: none; }
.consent a { color: var(--green); font-weight: 600; text-decoration: underline; }
.form-error { margin: -4px 0 12px; font-size: 12.5px; color: #b42318; background: #fef3f2; border-radius: 6px; padding: 8px 10px; }
.form-error.info { color: var(--green-deep); background: var(--green-soft); }
.btn-submit {
  width: 100%; display: flex; justify-content: center; align-items: center; gap: 8px;
  border: 0; border-radius: 8px; padding: 13px; background: #1b211d; color: #fff; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
}
.btn-submit:hover { background: #000; }
.btn-submit:focus-visible, .modal-close:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn-submit:disabled { opacity: .6; cursor: progress; }
.dev-note {
  margin: 8px 0 0; padding: 7px 10px; border: 1px dashed #c9a13b; border-radius: 8px;
  background: #fffaeb; color: #7a5a00; font-size: 12px; font-weight: 600; text-align: center;
}
.dev-note[hidden] { display: none; }
.modal-foot { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 16px 0 0; font-size: 11.5px; font-weight: 600; color: var(--green); text-align: center; }
.modal-foot svg { width: 13px; height: 13px; flex: none; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* legal document viewer (opens above the login popup) */
.viewer {
  width: min(860px, calc(100vw - 24px)); height: min(88vh, 900px); padding: 0;
  border: 1px solid var(--card-line); border-radius: 16px; background: #fff; color: var(--ink);
  box-shadow: 0 24px 64px rgba(16, 24, 20, .28); overflow: hidden;
}
.viewer[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.viewer::backdrop { background: rgba(21, 32, 26, .45); }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 12px 22px; border-bottom: 1px solid var(--card-line); }
.viewer-head h2 { margin: 0; font-size: 16px; }
.viewer-actions { display: flex; align-items: center; gap: 12px; }
.viewer-actions a { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--green); font-weight: 600; }
.viewer-actions a:hover { text-decoration: underline; }
.viewer .modal-close { position: static; }
.viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.viewer-foot { padding: 12px 16px; border-top: 1px solid var(--card-line); }
.site-foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 22px; padding: 20px 16px 32px; font-size: 13px; color: var(--faint); border-top: 1px solid rgba(20,30,25,.08); }
.site-foot a:hover { color: var(--green); text-decoration: underline; }

/* success screen (same modal, same size) */
.modal { display: none; flex-direction: column; }
.modal[open] { display: flex; }
.success { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; animation: fade .3s ease-out; }
@keyframes fade { from { opacity: 0; } }
.success[hidden] { display: none; }
.success { padding-bottom: 24px; }
.success-tick { width: 40px; height: 40px; fill: none; stroke: var(--green); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; animation: badge .45s cubic-bezier(.34,1.56,.64,1); }
.success-tick circle { stroke-dasharray: 132; stroke-dashoffset: 132; animation: draw .5s .05s ease-out forwards; }
.success-tick path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .3s .45s ease-out forwards; }
.success h3 { margin: 18px 0 8px; font-size: 19px; letter-spacing: -.01em; }
.success-auth { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.session-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700;
}
.session-pill b { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: blink 1.6s infinite; }
@keyframes badge { from { transform: scale(.4); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .success, .success-tick, .session-pill b { animation: none; }
  .success-tick circle, .success-tick path { animation: none; stroke-dashoffset: 0; }
}

/* ---------- trust strip ---------- */
.trust {
  list-style: none; margin: 8px auto 48px; padding: 0 16px; max-width: 900px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 28px; font-size: 13px; color: var(--muted);
}
.trust li { display: flex; align-items: center; gap: 6px; }
.trust li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.trust b { color: var(--ink); font-weight: 600; }

@keyframes blink { 50% { opacity: .3; } }
@keyframes spin { to { transform: rotate(180deg); } }
@keyframes flow {
  0% { top: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: calc(100% - 10px); opacity: 0; }
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  :root { --card-w: 150px; }
  .topbar { padding: 14px 16px; }
  .topnav { gap: 12px; }
  .btn-outline { padding: 7px 12px; font-size: 13px; }
  .link-login svg { display: none; }
  .hl { padding: 2px 10px 5px; }
  .stage { height: 340px; }
  .core { width: 190px; height: 190px; }
  .core-title { font-size: 18px; }
  .core-sub { font-size: 12px; }
  .card { font-size: 10px; padding: 10px 10px 8px; }
  .card-strong { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .pill-engine b, .wire i::before { animation: none; }
}
