@font-face {
    font-family: 'JetBrains Mono';
    src: url('jbm.woff2') format('woff2');
    font-weight: 100 800;
    font-display: swap;
}

/* Catppuccin Mocha */
:root {
    --base: #1e1e2e;
    --mantle: #181825;
    --crust: #11111b;
    --text: #cdd6f4;
    --subtext1: #bac2de;
    --subtext0: #a6adc8;
    --overlay1: #7f849c;
    --overlay0: #6c7086;
    --surface2: #585b70;
    --surface1: #45475a;
    --surface0: #313244;
    --blue: #89b4fa;
    --lavender: #b4befe;
    --sapphire: #74c7ec;
    --sky: #89dceb;
    --teal: #94e2d5;
    --green: #a6e3a1;
    --yellow: #f9e2af;
    --peach: #fab387;
    --maroon: #eba0ac;
    --red: #f38ba8;
    --mauve: #cba6f7;
    --pink: #f5c2e7;
    --accent: var(--teal);
    color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    background: var(--crust);
    background-image:
        radial-gradient(ellipse 70% 50% at 85% -10%, color-mix(in srgb, var(--teal) 9%, transparent), transparent 70%),
        radial-gradient(ellipse 60% 40% at 0% 0%, color-mix(in srgb, var(--mauve) 6%, transparent), transparent 70%);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--accent); }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.slash { color: var(--accent); }

/* ribbon */
.ribbon {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--subtext0);
    background: color-mix(in srgb, var(--mantle) 92%, transparent);
    border: 1px solid var(--surface0);
    border-radius: 999px;
    padding: 5px 11px;
    text-decoration: none;
}
.ribbon:hover { color: var(--text); border-color: var(--surface1); }

/* top bar */
.top {
    max-width: 1320px;
    margin: 0 auto;
    padding: 18px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; color: var(--text); }
.crumb { font-size: 13px; color: var(--subtext0); }
.live {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--subtext0); text-decoration: none;
    border: 1px solid var(--surface0); border-radius: 999px; padding: 5px 12px;
}
.live:hover { color: var(--text); border-color: var(--surface1); }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 20%, transparent); }

main { max-width: 1320px; margin: 0 auto; padding: 0 24px 72px; }

/* hero */
.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 26px 0 18px;
}
.hero h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; }
.hero p { margin-top: 6px; font-size: 13.5px; color: var(--subtext0); max-width: 640px; }

.controls { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.ctl {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12.5px; font-weight: 600; color: var(--text);
    background: var(--base); border: 1px solid var(--surface1); border-radius: 8px;
    padding: 7px 12px; cursor: pointer;
}
.ctl:hover { background: var(--surface0); }
.ctl svg { width: 15px; height: 15px; fill: currentColor; }
.ctl .i-play { display: none; }
.ctl[aria-pressed="true"] .i-play { display: block; }
.ctl[aria-pressed="true"] .i-pause { display: none; }
.ctl.ghost { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.ctl.ghost svg { fill: none; }

/* stage */
.stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
    gap: 18px;
    align-items: start;
}
.pane-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.pane-head h2 { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--overlay1); }
.pane-sub { font-size: 11px; color: var(--overlay0); }

/* visitor card (mirrors the live card) */
.card {
    background: var(--base);
    border: 1px solid var(--surface0);
    border-radius: 14px;
    overflow: hidden;
    min-height: 600px;
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}
.progress { display: none; align-items: center; gap: 14px; padding: 15px 22px 0; font-size: 11px; color: var(--overlay1); letter-spacing: 0.04em; }
.card[data-stage="ask"] .progress, .card[data-stage="contact"] .progress { display: flex; }
.bar { flex: 1; height: 4px; border-radius: 4px; background: var(--surface0); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; }
.card-body { padding: 22px; }

.enter { animation: enter 0.35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.intro-title { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 0.08em; }
.intro-lead { margin-top: 8px; font-size: 13.5px; color: var(--subtext1); line-height: 1.7; }
.points { list-style: none; margin: 18px 0; display: grid; gap: 8px; }
.points li { font-size: 13.5px; padding-left: 18px; position: relative; color: var(--text); }
.points li::before { content: '>'; position: absolute; left: 0; color: var(--accent); }
.warn { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.6; color: var(--peach); background: color-mix(in srgb, var(--peach) 8%, transparent); border: 1px solid color-mix(in srgb, var(--peach) 25%, transparent); border-radius: 10px; padding: 10px 12px; }
.warn svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: inherit; font-weight: 700; font-size: 13px;
    border-radius: 9px; padding: 10px 16px; border: 1px solid transparent; cursor: default;
}
.btn-primary { background: var(--accent); color: var(--crust); }
.btn-primary.busy { opacity: 0.75; }
.btn-outline { background: transparent; border-color: var(--surface1); color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.note { font-size: 11.5px; color: var(--overlay1); line-height: 1.6; }
.ts { display: inline-flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 11.5px; color: var(--subtext0); border: 1px solid var(--surface1); border-radius: 6px; padding: 9px 12px; background: var(--mantle); }
.ts .box { width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--surface2); display: grid; place-items: center; }
.ts.ok .box { border-color: var(--green); background: var(--green); }
.ts.ok .box::after { content: ''; width: 5px; height: 9px; border: solid var(--crust); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.ts.spin .box { border-color: var(--surface2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.q { font-size: 18px; font-weight: 700; line-height: 1.45; margin-bottom: 16px; }
.hint { font-size: 11.5px; color: var(--overlay1); margin: -8px 0 14px; }
.options { display: grid; gap: 7px; }
.options.cols { grid-template-columns: 1fr 1fr; }
.opt {
    display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
    font-size: 13px; color: var(--text); background: transparent;
    border: 1px solid var(--surface1); border-radius: 9px; padding: 9px 12px; line-height: 1.4;
    transition: border-color 0.2s, background 0.2s;
}
.opt .key { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; font-size: 10.5px; border: 1px solid var(--surface1); border-radius: 5px; color: var(--overlay1); }
.opt.hover { border-color: var(--overlay0); background: var(--surface0); }
.opt.chosen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.opt.chosen .key { background: var(--accent); color: var(--crust); border-color: var(--accent); }
.ta {
    width: 100%; min-height: 128px; font-family: inherit; font-size: 13.5px; line-height: 1.65; color: var(--text);
    background: var(--mantle); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap;
}
.ta .caret { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: -2px; margin-left: 1px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ta-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 11px; color: var(--overlay1); }
.secret-hint { color: var(--peach); }

.trail { margin-top: 22px; border-top: 1px dashed var(--surface0); padding-top: 12px; display: grid; gap: 4px; }
.trail div { display: flex; gap: 10px; font-size: 11.5px; color: var(--overlay1); min-width: 0; }
.trail div span:first-child { flex: none; color: var(--surface2); }
.trail div span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trail b { color: var(--subtext0); font-weight: 600; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 11.5px; color: var(--subtext0); }
.field label em { font-style: normal; color: var(--overlay0); }
.field .in { font-size: 13.5px; background: var(--mantle); border: 1px solid var(--surface1); border-radius: 8px; padding: 9px 12px; min-height: 40px; }
.field .in.focus { border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 12px; line-height: 1.55; color: var(--subtext1); margin-bottom: 10px; }
.check .cb { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 4px; border: 1.5px solid var(--surface2); display: grid; place-items: center; }
.check .cb.on { background: var(--accent); border-color: var(--accent); }
.check .cb.on::after { content: ''; width: 4px; height: 8px; border: solid var(--crust); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }

.think { display: flex; align-items: center; gap: 12px; padding: 40px 0 16px; font-size: 13px; color: var(--subtext0); }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: dot 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* result */
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.res-head h3 { font-size: 18px; font-weight: 800; }
.tabs { display: inline-flex; background: var(--mantle); border: 1px solid var(--surface0); border-radius: 9px; padding: 3px; gap: 2px; }
.tab { font-size: 11.5px; font-weight: 600; color: var(--subtext0); background: transparent; border: 0; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface0); color: var(--text); }
.tab-note { font-size: 11.5px; color: var(--overlay1); margin: -4px 0 12px; line-height: 1.55; }
.blocks { display: grid; gap: 9px; }
.block { padding: 11px 14px; border: 1px solid var(--surface0); border-left: 3px solid var(--c); border-radius: 10px; background: var(--mantle); }
.block h4 { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; color: var(--c); margin-bottom: 5px; }
.block p, .block li { font-size: 13px; line-height: 1.6; }
.block ul { list-style: none; display: grid; gap: 5px; }
.block li { padding-left: 16px; position: relative; }
.block li::before { content: '-'; position: absolute; left: 0; color: var(--overlay1); }
.services { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.svc { padding: 10px 12px; border: 1px solid var(--surface1); border-radius: 10px; }
.svc.primary { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.svc strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.svc em { font-style: normal; font-size: 10px; letter-spacing: 0.08em; color: var(--accent); margin-left: 6px; font-weight: 600; }
.svc span { font-size: 11.5px; line-height: 1.55; color: var(--subtext1); }
.sent { margin-top: 12px; font-size: 11.5px; line-height: 1.6; color: var(--subtext0); }

.report { font-size: 11.5px; line-height: 1.65; color: var(--subtext1); background: var(--mantle); border: 1px solid var(--surface0); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto; }
.report .h { color: var(--accent); font-weight: 700; }
.report .k { color: var(--overlay1); }
.report .v { color: var(--text); }
.report .tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 4px; background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }

/* server side */
.arch { background: var(--base); border: 1px solid var(--surface0); border-radius: 14px; padding: 14px 14px 10px; }
#arch { display: block; width: 100%; height: auto; font-family: inherit; }
.edge { fill: none; stroke: var(--surface1); stroke-width: 1.6; transition: stroke 0.3s; }
.arrhead { fill: var(--surface2); }
.edge.on { stroke: var(--accent); stroke-dasharray: 5 5; animation: flow 0.7s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -10; } }
.node { cursor: pointer; outline: none; }
.node rect { fill: var(--mantle); stroke: var(--surface1); stroke-width: 1.4; transition: fill 0.3s, stroke 0.3s; }
.node .nt { fill: var(--text); font-size: 13px; font-weight: 700; text-anchor: middle; }
.node .ns { fill: var(--overlay1); font-size: 10.5px; text-anchor: middle; }
.node.core rect { stroke: var(--surface2); }
.node.on rect { fill: color-mix(in srgb, var(--accent) 14%, var(--mantle)); stroke: var(--accent); }
.node.ai.on rect { fill: color-mix(in srgb, var(--mauve) 16%, var(--mantle)); stroke: var(--mauve); }
.node.sel rect { stroke-width: 2.4; }
.node:hover rect, .node:focus-visible rect { stroke: var(--subtext0); }
.node.off rect { stroke: var(--red); stroke-dasharray: 4 3; fill: color-mix(in srgb, var(--red) 8%, var(--mantle)); }
.swipe { display: none; font-size: 11px; color: var(--overlay0); padding: 0 12px 4px; }
.arch-cap { font-size: 12px; line-height: 1.6; color: var(--subtext0); min-height: 40px; margin-top: 4px; padding: 0 4px; }
.arch-cap b { color: var(--text); }

.log {
    margin-top: 12px;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 14px;
    padding: 12px 14px;
    height: 262px;
    overflow-y: auto;
    font-size: 11.5px;
    line-height: 1.7;
    scroll-behavior: smooth;
}
.ln { display: grid; grid-template-columns: 46px 74px minmax(0, 1fr); gap: 8px; animation: enter 0.25s ease both; }
.ln .t { color: var(--surface2); }
.ln .tag { font-weight: 700; }
.ln .m { color: var(--subtext1); word-break: break-word; }
.ln .m code { font-family: inherit; color: var(--text); }
.ln .m .dim { color: var(--overlay0); }
.ln .m .hl { color: var(--yellow); }
.ln.sep { display: block; color: var(--surface2); margin-top: 6px; }
.ln .tag.lt-fn { color: var(--sapphire); }
.ln .tag.lt-ts { color: var(--peach); }
.ln .tag.lt-d1 { color: var(--blue); }
.ln .tag.lt-rules { color: var(--teal); }
.ln .tag.lt-ai { color: var(--mauve); }
.ln .tag.lt-chk { color: var(--green); }
.ln .tag.lt-crm { color: var(--pink); }
.ln .tag.lt-warn { color: var(--red); }

/* guardrails section */
.rules-sec { margin-top: 56px; }
.rules-sec h2 { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; color: var(--subtext0); margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid article { background: var(--base); border: 1px solid var(--surface0); border-radius: 12px; padding: 16px 18px; }
.grid h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.grid p { font-size: 12.5px; line-height: 1.7; color: var(--subtext0); }
.foot { margin-top: 22px; font-size: 12px; color: var(--overlay1); }

@media (max-width: 1080px) {
    .stage { grid-template-columns: minmax(0, 1fr); }
    .pane { min-width: 0; }
    .grid { grid-template-columns: 1fr 1fr; }
    .hero { flex-direction: column; align-items: flex-start; }
    .card { min-height: 0; }
}

@media (max-width: 640px) {
    body { font-size: 14px; }
    .top { padding: 14px 16px 0; }
    .live { font-size: 0; gap: 0; padding: 7px; }
    .live .dot { margin: 0; }
    main { padding: 0 16px 64px; }
    .hero { padding: 18px 0 14px; gap: 14px; }
    .hero h1 { font-size: 21px; }
    .controls { width: 100%; }
    .ctl { padding: 7px 10px; }
    .ctl.ghost { flex-basis: 100%; justify-content: center; }
    .card-body { padding: 18px 16px; }
    .progress { padding: 13px 16px 0; }
    .q { font-size: 16px; }
    .options.cols { grid-template-columns: 1fr; }
    .services { grid-template-columns: 1fr; }
    .grid { grid-template-columns: 1fr; }
    .ln { grid-template-columns: 74px minmax(0, 1fr); }
    .ln .t { display: none; }
    .log { height: 240px; }
    .arch { padding: 10px 0 8px; }
    .arch-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 10px; }
    #arch { width: 540px; max-width: none; }
    .arch-cap { padding: 0 12px; }
    .swipe { display: block; }
    .res-head { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
    .edge.on { stroke-dasharray: none; }
}
