/*
 * DocVera Assist admin. Shares SignForge's neutrals and Figtree so the
 * DocVera family feels like one product line; Assist's own accent is a
 * deep teal ("answers"), with amber reserved for handoffs and gaps.
 * Mobile first: base rules are the phone layout, min-width adds room.
 */
@font-face {
    font-family: 'Figtree';
    font-style: normal;
    font-weight: 300 900;
    font-display: swap;
    src: url('fonts/figtree-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Figtree';
    font-style: normal;
    font-weight: 300 900;
    font-display: swap;
    src: url('fonts/figtree-latin-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --accent: #0e7c86;
    --accent-deep: #0a5c63;
    --accent-soft: #e3f2f2;
    --accent-tint: #c7e6e7;

    --mist: #eef2f1;
    --surface: #ffffff;
    --ink: #1d2330;
    --graphite: #5b6475;
    --faint: #8a93a3;
    --hairline: #dce2e0;
    --hairline-strong: #c5ceca;

    --ok: #1b7f5a;
    --ok-soft: #e2f3ea;
    --warn: #9a4a07;
    --warn-soft: #fcefd8;
    --bad: #b42318;
    --bad-soft: #fdebe9;

    --r-control: 10px;
    --r-panel: 16px;
    --r-sheet: 22px;

    --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, monospace;
    --shadow-pop: 0 12px 32px -12px rgba(29, 35, 48, .28);

    /* SignForge's type steps */
    --step--1: 0.8125rem;  /* 13 */
    --step-0: 0.9375rem;   /* 15 */
    --step-1: 1.0625rem;   /* 17 */
    --step-2: 1.25rem;     /* 20 */
    --step-3: 1.625rem;    /* 26 */
    --step-4: 2.125rem;    /* 34 */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--mist);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: var(--step-3); letter-spacing: -.02em; }
h2 { font-size: var(--step-1); }
h3 { font-size: var(--step-0); }
p { margin: 0 0 .75rem; }
a { color: var(--accent-deep); }
code, .mono { font-family: var(--mono); font-size: .88em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--graphite); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1rem; background: var(--surface); border-bottom: 1px solid var(--hairline);
    position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; text-decoration: none; color: var(--ink); }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand small { font-weight: 500; color: var(--graphite); }
.topbar .spacer { flex: 1; }
.nav-toggle { display: inline-flex; }

.sidebar {
    display: none; background: var(--surface); border-right: 1px solid var(--hairline);
    padding: 1rem .75rem; overflow-y: auto;
}
.sidebar.open { display: block; position: fixed; inset: 53px 0 0 0; z-index: 19; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: var(--r-control);
    color: var(--graphite); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--mist); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-deep); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-group { margin: 1.1rem .7rem .35rem; font-size: .8rem; color: var(--faint); font-weight: 600; }
.nav .bot-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

.main { flex: 1; padding: 1.25rem 1rem 3rem; min-width: 0; }
.content { max-width: 1100px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head p { margin: 0; color: var(--graphite); }

.banner {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    padding: .6rem 1rem; background: var(--warn-soft); color: var(--warn); font-weight: 600; border-bottom: 1px solid #f1d6a8;
}

@media (min-width: 900px) {
    .shell { display: grid; grid-template-columns: 248px 1fr; grid-template-rows: auto 1fr; }
    .topbar { grid-column: 1 / -1; }
    .sidebar, .sidebar.open { display: block; inset: auto; position: sticky; top: 53px; height: calc(100vh - 53px); } /* inset first: it resets top */
    .topbar .nav-toggle { display: none; }
    .main { padding: 2rem 2.25rem 4rem; }
}

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-panel); padding: 1.25rem; }
.panel + .panel { margin-top: 1rem; }
.grid-2 > .panel + .panel, .stack > .panel + .panel, .stats + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }
.stack { display: grid; gap: 1rem; }
.grid-2 { display: grid; gap: 1rem; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--hairline); border: 1px solid var(--hairline); border-radius: var(--r-panel); overflow: hidden; }
.stat { background: var(--surface); padding: 1rem 1.1rem; }
.stat b { display: block; font-size: var(--step-3); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.stat b small { font-size: var(--step-0); font-weight: 600; color: var(--graphite); }
.stat span { color: var(--graphite); font-size: var(--step--1); }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Dashboard: visitors' questions first, numbers beside them ---------- */
.dash { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; }
@media (min-width: 1000px) { .dash { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.asked { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sheet); padding: 1.25rem 1.25rem .5rem; }
.asked .panel-head { margin-bottom: .25rem; }
.asked-empty { padding: 1rem 0 1.25rem; }
.asked-list { list-style: none; margin: 0; padding: 0; }
.asked-item { padding: .9rem 0; border-top: 1px solid var(--hairline); }
.asked-item:first-child { border-top: 0; }
.asked-q { display: block; max-width: 62ch; font-size: var(--step-1); font-weight: 600; line-height: 1.35; color: var(--ink); text-decoration: none; }
.asked-q::before { content: '\201C'; color: var(--faint); margin-right: .05em; }
.asked-q::after { content: '\201D'; color: var(--faint); margin-left: .05em; }
.asked-q:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
.asked-meta { margin: .3rem 0 0; font-size: var(--step--1); display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.outcome { display: inline-flex; align-items: center; gap: .4rem; font-weight: 650; color: var(--graphite); }
.outcome::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--hairline-strong); flex: none; }
[data-outcome=answered] .outcome { color: var(--graphite); font-weight: 600; } /* the usual case stays quiet; exceptions carry colour */
[data-outcome=answered] .outcome::before { background: var(--ok); }
[data-outcome=unsure] .outcome { color: var(--warn); }
[data-outcome=unsure] .outcome::before { background: #d98a1f; }
[data-outcome=handoff] .outcome { color: var(--accent-deep); }
[data-outcome=handoff] .outcome::before { background: var(--accent); border-radius: 50%; }

.glance { display: grid; gap: 1.25rem; }
.glance .stats { grid-template-columns: 1fr 1fr; background: none; border: 0; border-radius: 0; gap: 1rem 1.25rem; }
.glance .stat { background: none; padding: 0; }
.glance h2 { font-size: var(--step-0); display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.gap-call, .cost { border-top: 1px solid var(--hairline-strong); padding-top: 1rem; }
.gap-call p, .cost p { margin-bottom: .6rem; color: var(--graphite); }
.gap-call.open { border-top: 3px solid #d98a1f; }
.gap-call.open p { color: var(--ink); }
.cost-value { font-size: var(--step-2); font-weight: 700; color: var(--ink) !important; margin: 0 0 .25rem !important; }

.chart svg { display: block; }
.chart rect { fill: var(--hairline); }
.chart rect.on { fill: var(--accent); }
.chart-axis { justify-content: space-between; }

/* ---------- Forms ---------- */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; align-content: start; }
.field > label, .label { font-weight: 600; font-size: .92rem; }
.hint { color: var(--graphite); font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], input[type=color], input[type=date], select, textarea {
    width: 100%; font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--hairline-strong); border-radius: var(--r-control); padding: .6rem .75rem; min-height: 42px;
}
input[type=color] { padding: .2rem; width: 56px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; }
.check input { margin-top: .25rem; accent-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.row > .grow { flex: 1; min-width: 180px; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; }
.error-text { color: var(--bad); font-size: .88rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    font: inherit; font-weight: 650; border-radius: var(--r-control); border: 1px solid transparent;
    min-height: 40px; padding: .5rem 1rem; cursor: pointer; text-decoration: none; white-space: nowrap;
    background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-deep); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--hairline-strong); }
.btn.secondary:hover { background: var(--mist); }
.btn.ghost { background: transparent; color: var(--graphite); }
.btn.ghost:hover { background: var(--mist); color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #f0c2bd; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 32px; padding: .3rem .7rem; font-size: .88rem; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Tables & lists ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--hairline); vertical-align: top; }
th { font-size: .85rem; color: var(--graphite); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 650; background: var(--mist); color: var(--graphite); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent-deep); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--graphite); }
.empty h3 { color: var(--ink); }

.notice { padding: .75rem 1rem; border-radius: var(--r-control); background: var(--accent-soft); color: var(--accent-deep); margin-bottom: 1rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

.codebox { position: relative; background: #17202b; color: #e7eef5; border-radius: var(--r-control); padding: .85rem 1rem; font-family: var(--mono); font-size: .85rem; overflow-x: auto; white-space: pre; }
.codebox .copy { position: absolute; top: .45rem; right: .45rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--hairline); margin-bottom: 1.25rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: .6rem .85rem; text-decoration: none; color: var(--graphite); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--accent-deep); border-bottom-color: var(--accent); }

/* ---------- Knowledge ---------- */
.qa-item { border: 1px solid var(--hairline); border-radius: var(--r-control); padding: .7rem .9rem; }
.qa-item summary { cursor: pointer; list-style: none; }
.qa-item summary::-webkit-details-marker { display: none; }
.qa-item[open] { border-color: var(--accent-tint); background: #fbfdfd; }

/* ---------- Playground ---------- */
.playground { display: grid; gap: 1rem; }
@media (min-width: 1000px) { .playground { grid-template-columns: minmax(340px, 420px) 1fr; align-items: start; } }
.pg-chat { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sheet); overflow: hidden; display: flex; flex-direction: column; height: 620px; box-shadow: var(--shadow-pop); }
.pg-chat-head { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--hairline); box-shadow: inset 4px 0 0 var(--bot); }
.pg-chat-head .btn.ghost { color: var(--graphite); }
.pg-chat-head .btn.ghost:hover { background: var(--mist); color: var(--ink); }
.pg-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: #f7f9f9; }
.pg-msg { max-width: 86%; padding: .6rem .85rem; border-radius: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.pg-msg.bot { background: var(--surface); border: 1px solid var(--hairline); border-bottom-left-radius: 6px; align-self: flex-start; }
.pg-msg.user { background: var(--bot); color: var(--bot-text); border-bottom-right-radius: 6px; align-self: flex-end; }
.pg-msg.error { border-color: #f0c2bd; color: var(--bad); }
.pg-msg ul { margin: .3rem 0; padding-left: 1.2rem; }
.pg-msg .cite { font-size: .7em; color: var(--accent-deep); font-weight: 700; margin-left: 1px; }
.pg-sources { margin-top: .6rem; padding: .1rem 0 .1rem .65rem; border-left: 3px solid var(--bot, var(--accent)); font-size: var(--step--1); line-height: 1.4; color: var(--graphite); }
.pg-msg.typing { display: inline-flex; gap: 4px; padding: .8rem .9rem; }
.pg-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: pg-blink 1s infinite ease-in-out; }
.pg-msg.typing span:nth-child(2) { animation-delay: .15s; } .pg-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pg-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.pg-input { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--hairline); background: var(--surface); }
.pg-input input { flex: 1; }
.meter { position: relative; height: 10px; border-radius: 99px; background: var(--mist); overflow: visible; margin: .35rem 0; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--ok); transition: width .3s; }
.meter span.low { background: var(--warn); }
.meter i { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--ink); }
.chunk-list { margin: .4rem 0 0; padding-left: 1.2rem; display: grid; gap: .8rem; }
.scorebar { height: 4px; border-radius: 99px; background: var(--mist); margin: .3rem 0; }
.scorebar span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.chunk-text { margin: .3rem 0 0; color: var(--graphite); max-height: 7.5em; overflow: hidden; white-space: pre-line; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 100; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--r-control); box-shadow: var(--shadow-pop); font-weight: 600; }
.toast.bad { background: var(--bad); }

/* ---------- Auth / installer ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: min(100%, 440px); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sheet); padding: 1.75rem; }
.auth-card.wide { width: min(100%, 640px); }
.auth-card .brand { margin-bottom: 1.25rem; }
.steps { list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.steps li { font-size: .82rem; font-weight: 650; padding: .2rem .6rem; border-radius: 999px; background: var(--mist); color: var(--graphite); }
.steps li[aria-current="step"] { background: var(--accent); color: #fff; }
.steps li.done { background: var(--accent-soft); color: var(--accent-deep); }
.req { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; }
.req li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .7rem; border-radius: var(--r-control); background: var(--mist); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------- Uploads & crawling ---------- */
.dropzone { border: 2px dashed var(--hairline-strong); border-radius: var(--r-panel); background: #fafcfc; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-label { display: grid; gap: .25rem; place-items: center; text-align: center; padding: 2rem 1rem; cursor: pointer; }
.dropzone:focus-within { outline: 3px solid var(--accent-tint); }
.upload-list { list-style: none; padding: 0; margin: .5rem 0 .75rem; display: grid; gap: .5rem; }
.upload-batch { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-top: 1rem; font-size: var(--step--1); color: var(--graphite); }
.upload-batch strong { color: var(--ink); font-size: var(--step-0); }
.upload-batch.ok strong { color: var(--ok); }
.upload-batch.bad strong { color: var(--bad); }
.upload-batch .num, .upload-batch span { font-variant-numeric: tabular-nums; }
/* One card per file; the left rule carries its state (working / ready / failed). */
.upload-item { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .9rem; padding: .9rem 1rem; border: 1px solid var(--hairline); border-radius: var(--r-control); background: var(--surface); box-shadow: inset 3px 0 0 var(--hairline-strong); }
.upload-item.working { border-color: var(--accent-tint); box-shadow: inset 3px 0 0 var(--accent); }
.upload-item.ok { box-shadow: inset 3px 0 0 var(--ok); }
.upload-item.bad { border-color: #f0c7c2; box-shadow: inset 3px 0 0 var(--bad); }
.upload-item .ext { width: 2.5rem; height: 3rem; display: grid; place-items: end center; padding-bottom: .4rem; background: var(--mist); color: var(--graphite); font-size: .6875rem; font-weight: 700; letter-spacing: .02em; clip-path: polygon(0 0, 68% 0, 100% 24%, 100% 100%, 0 100%); border-radius: 4px; }
.upload-item.working .ext { background: var(--accent-soft); color: var(--accent-deep); }
.upload-item.ok .ext { background: var(--ok-soft); color: var(--ok); }
.upload-item.bad .ext { background: var(--bad-soft); color: var(--bad); }
.upload-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.upload-name { font-weight: 600; overflow-wrap: anywhere; }
.upload-size { color: var(--faint); font-size: var(--step--1); white-space: nowrap; font-variant-numeric: tabular-nums; }
.upload-steps { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .45rem 0 .6rem; padding: 0; font-size: var(--step--1); color: var(--faint); }
.upload-steps li { display: inline-flex; align-items: center; gap: .35rem; }
.upload-steps li + li::before { content: ''; width: 1.25rem; height: 1px; background: var(--hairline-strong); margin-right: .1rem; }
.upload-steps i { width: .75rem; height: .75rem; border-radius: 50%; border: 1.5px solid var(--hairline-strong); background: var(--surface); flex: none; }
.upload-steps li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.upload-steps li[aria-current="step"] i { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 45%, transparent 50%); }
.upload-steps li.done { color: var(--graphite); }
.upload-steps li.done i { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2 4-4.4' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat; }
.upload-item.bad .upload-steps li[aria-current="step"] i { border-color: var(--bad); background: var(--bad-soft); }
.upload-bar { height: 6px; border-radius: 99px; background: var(--mist); overflow: hidden; }
.upload-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }
/* Server-side indexing has no measurable progress: a moving stripe says "working". */
.upload-bar.indeterminate span { width: 100% !important; background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, var(--accent-tint) 8px 16px); background-size: 22.6px 22.6px; animation: upload-stripe .8s linear infinite; }
@keyframes upload-stripe { to { background-position: 22.6px 0; } }
.upload-item.ok .upload-bar span { background: var(--ok); }
.upload-item.bad .upload-bar span { width: 100% !important; background: var(--bad-soft); }
.upload-state { margin: .45rem 0 0; font-size: var(--step--1); color: var(--graphite); }
.upload-item.ok .upload-state { color: var(--ok); font-weight: 600; }
.upload-item.bad .upload-state { color: var(--bad); }
.upload-item [data-retry] { margin-top: .6rem; }
.ok-text { color: var(--ok); }
.crawl-progress { border-color: var(--accent-tint); }
.crawl-progress [data-last] { overflow-wrap: anywhere; }

/* Appearance tab: keep the form clear of the live widget preview on wide screens */
@media (min-width: 1280px) {
    .branding-layout { padding-right: 400px; }
    /* preview on the left covers the sidebar and ~130px of content */
    .branding-layout.preview-left { padding-right: 0; padding-left: 130px; }
}

/* =====================================================================
 * Phone first. Everything a person does daily fits one hand: a thumb bar
 * at the bottom, lists that read as rows, filters folded until needed,
 * and a numbered path through setting up a bot.
 * ===================================================================== */

/* ---------- Thumb bar (phones) ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--surface); border-top: 1px solid var(--hairline);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; padding: 6px 2px; border-radius: var(--r-control);
    color: var(--graphite); text-decoration: none; font-size: .72rem; font-weight: 650; line-height: 1.1; text-align: center;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--accent-deep); }
.tabbar a[aria-current="page"]::before { content: ''; position: absolute; top: -5px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.tabbar .count {
    position: absolute; top: 2px; left: calc(50% + 5px); min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: #d98a1f; color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px;
}
.main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
.sidebar.open { z-index: 31; }
@media (max-width: 599px) { .top-name { display: none; } }
@media (min-width: 900px) {
    .tabbar { display: none; }
    .main { padding-bottom: 4rem; }
    .toasts { bottom: 1rem; }
}

/* ---------- Touch sizes ---------- */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn.small { min-height: 38px; }
}
@media (max-width: 599px) {
    .panel { padding: 1rem; }
    .page-head { margin-bottom: 1rem; }
    .page-head > .btn, .page-head > .row { width: 100%; }
    .page-head > .btn { justify-content: center; }
}

/* ---------- Lists: tables become rows on phones ---------- */
@media (max-width: 759px) {
    .table-wrap:not(.keep) { overflow: visible; }
    .table-wrap:not(.keep) table, .table-wrap:not(.keep) tbody { display: block; }
    .table-wrap:not(.keep) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-wrap:not(.keep) tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .9rem; padding: .9rem 0; border-bottom: 1px solid var(--hairline); }
    .table-wrap:not(.keep) tbody tr:last-child { border-bottom: 0; }
    .table-wrap:not(.keep) td { display: block; padding: 0; border: 0; max-width: 100% !important; overflow-wrap: anywhere; }
    /* The row's main line: first cell, or the one the table names */
    .table-wrap:not(.keep) table:not([data-primary]) td:first-child,
    .table-wrap:not(.keep) table[data-primary="2"] td:nth-child(2),
    .table-wrap:not(.keep) table[data-primary="3"] td:nth-child(3),
    .table-wrap:not(.keep) td[colspan] { flex-basis: 100%; order: -1; }
    .table-wrap:not(.keep) td.num[data-label]::before { content: attr(data-label) ' '; color: var(--graphite); font-weight: 500; font-size: var(--step--1); }
    .table-wrap:not(.keep) td.actions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .5rem; text-align: left; white-space: normal !important; margin-top: .3rem; }
    .table-wrap:not(.keep) td.actions > .btn, .table-wrap:not(.keep) td.actions > form { flex: 1 1 auto; }
    .table-wrap:not(.keep) td.actions > form .btn { width: 100%; }
    .table-wrap:not(.keep) td.actions:empty { display: none; }
}

/* ---------- Filters: search always there, the rest folded on phones ---------- */
.filters { display: grid; gap: .6rem; margin-bottom: 1rem; }
.search-row { display: flex; gap: .5rem; }
.search-row input { flex: 1; min-width: 0; }
.more-filters > summary, details.provider > summary { list-style: none; cursor: pointer; }
.more-filters > summary::-webkit-details-marker, details.provider > summary::-webkit-details-marker { display: none; }
.more-filters > summary { display: inline-flex; align-items: center; gap: .45rem; font-weight: 650; color: var(--graphite); font-size: var(--step--1); padding: .25rem 0; }
.more-filters > summary::after, details.provider > summary::after {
    content: ''; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg); transition: transform .15s; flex: none;
}
.more-filters[open] > summary::after, details.provider[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.more-filters .row { margin-top: .6rem; }
.more-filters .row > select, .more-filters .row > input { flex: 1 1 150px; }
.more-filters .row.dates { display: grid; grid-template-columns: auto 1fr; gap: .5rem .6rem; align-items: center; }
@media (min-width: 760px) {
    .more-filters > summary { display: none; }
    .more-filters .row > select { flex: 0 1 auto; width: auto; }
    .more-filters .row.dates { display: flex; }
    .more-filters .row.dates > input { flex: 0 1 auto; width: auto; }
}

/* ---------- Tab bars that scroll sideways on phones ---------- */
.tabs { scroll-behavior: smooth; }
.tabs.more-right { -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); mask-image: linear-gradient(to right, #000 82%, transparent); }

/* ---------- Bot setup path ---------- */
.step-no {
    display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: .4rem; flex: none;
    border-radius: 50%; background: var(--hairline); color: var(--graphite); font-size: .72rem; font-weight: 700;
}
.tabs a[aria-current="page"] .step-no { background: var(--accent); color: #fff; }
.bot-tabs a { display: inline-flex; align-items: center; }
.bot-tabs a.after-steps { margin-left: .9rem; position: relative; }
.bot-tabs a.after-steps::before { content: ''; position: absolute; left: -.55rem; top: 30%; bottom: 30%; width: 1px; background: var(--hairline-strong); }
.next-step {
    margin-top: 1.5rem; padding: 1rem 1.15rem; border-radius: var(--r-panel); background: var(--accent-soft);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
}
.next-step p { margin: 0; color: var(--accent-deep); max-width: 56ch; font-weight: 500; }
.next-step .btn .step-no { background: rgba(255, 255, 255, .25); color: #fff; margin-right: .1rem; }
@media (max-width: 599px) { .next-step .btn { width: 100%; } }

/* ---------- Settings: one provider open at a time ---------- */
details.provider > summary { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
details.provider > summary h2 { margin: 0; flex: 1 1 auto; font-size: var(--step-0); }
details.provider[open] > summary { margin-bottom: 1rem; }

/* ---------- Dashboard on phones: what needs you first ---------- */
@media (max-width: 999px) {
    .glance { display: contents; }
    .dash > .asked { order: 1; }
    .glance .gap-call.open { order: 0; border-top: 0; padding: 1rem; border-radius: var(--r-panel); background: var(--warn-soft); }
    .glance .gap-call { order: 3; }
    .glance .stats { order: 2; }
    .glance .cost { order: 4; }
}
/* ---------- Modals: create / edit a bot. A sheet from the bottom on phones ---------- */
dialog.modal {
    border: 0; padding: 0; margin: auto; color: var(--ink); background: var(--surface);
    width: min(560px, calc(100vw - 2rem)); max-height: min(88vh, 760px);
    border-radius: var(--r-sheet); box-shadow: 0 24px 60px -20px rgba(29, 35, 48, .45), 0 2px 8px rgba(29, 35, 48, .08);
    overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .18s ease-out; }
dialog.modal::backdrop { background: rgba(29, 35, 48, .46); }
dialog.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.1rem 1.25rem .35rem; }
.modal-head h2 { margin: 0; font-size: var(--step-2); }
.modal-x { min-width: 40px; padding: .3rem; }
.modal-x svg { width: 18px; height: 18px; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; overscroll-behavior: contain; }
.modal-lede { margin-bottom: 1rem; max-width: 52ch; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .85rem 1.25rem; border-top: 1px solid var(--hairline); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@media (max-width: 599px) {
    dialog.modal {
        width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92vh;
        border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    }
    dialog.modal[open] { animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1); }
    .modal-foot { padding-bottom: calc(.85rem + env(safe-area-inset-bottom)); }
    .modal-foot .btn { flex: 1; }
    .modal-foot .btn[type=submit] { order: 2; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
dialog.modal .toasts { position: absolute; bottom: 5rem; }

/* ---------- Bot settings summary ---------- */
.facts { margin: 0; display: grid; gap: .8rem; }
.facts > div { display: grid; gap: .15rem; }
.facts dt { font-size: var(--step--1); color: var(--graphite); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 760px) {
    .facts > div { grid-template-columns: 200px 1fr; gap: 1rem; align-items: baseline; }
}

/* ---------- Create bot: the chat button, previewed as you choose ---------- */
.identity { display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem; margin-bottom: 1.1rem; border-radius: var(--r-panel); background: var(--mist); }
.identity-mark {
    width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center;
    background: var(--accent); color: #fff; box-shadow: 0 8px 20px -8px rgba(29, 35, 48, .45);
    transition: background-color .15s;
}
.identity-mark svg { width: 24px; height: 24px; }
.identity-text { display: grid; gap: .1rem; min-width: 0; }
.identity-text strong { font-size: var(--step-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

fieldset.pick { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.pick legend { padding: 0; margin-bottom: .45rem; }
.icon-pick, .swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.icon-pick label, .swatches label { position: relative; cursor: pointer; }
.icon-pick input, .swatches input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.icon-pick .tile {
    width: 52px; height: 52px; border-radius: var(--r-control); display: grid; place-items: center;
    border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--graphite);
}
.icon-pick input:checked + .tile { background: var(--sw, var(--accent)); color: var(--on, #fff); border-color: transparent; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw, var(--accent)); }
.icon-pick input:focus-visible + .tile, .swatches input:focus-visible + .sw { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 3px; }
.swatches .sw { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatches input:checked + .sw { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.sw-custom { display: grid; place-items: center; }
.sw-custom input[type=color] {
    width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%; border: 1px dashed var(--hairline-strong); cursor: pointer;
    background: conic-gradient(#e03131, #f59f00, #37b24d, #1c7ed6, #7048e8, #e03131);
}
.sw-custom input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.sw-custom input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; opacity: 0; }
.sw-custom input[type=radio]:checked ~ input[type=color] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); border-style: solid; }
@media (pointer: coarse) { .swatches .sw, .sw-custom input[type=color] { width: 40px; height: 40px; } }

.bot-desc { display: block; margin: .1rem 0 0; max-width: 60ch; }
.page-head .bot-desc { margin: .15rem 0 .1rem; }
#nb-description, #g-description { min-height: 0; }

/* ---------- A bot, as its owner recognises it: chat button, name, what it's for ---------- */
.bot-id { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: .75rem; align-items: center; text-decoration: none; color: inherit; min-width: 200px; }
.bot-mark { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.bot-mark svg { width: 18px; height: 18px; }
.bot-id-text { display: grid; gap: .1rem; min-width: 0; }
.bot-id-text strong { color: var(--accent-deep); line-height: 1.25; }
.bot-id:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.bot-id .bot-desc {
    margin: 0; font-size: var(--step--1); line-height: 1.35; color: var(--graphite); max-width: 46ch;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
@media (min-width: 760px) { .bots-table td { vertical-align: middle; } }

/* ---------- Two clear options instead of a dropdown (e.g. invite vs create) ---------- */
.choice { display: grid; gap: .5rem; }
@media (min-width: 600px) { .choice { grid-template-columns: 1fr 1fr; } }
.choice label { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span { display: grid; gap: .2rem; height: 100%; padding: .75rem .9rem; border: 1px solid var(--hairline-strong); border-radius: var(--r-control); background: var(--surface); }
.choice small { color: var(--graphite); font-size: var(--step--1); line-height: 1.35; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:checked + span strong { color: var(--accent-deep); }
.choice input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }
.modal-sub { margin: .15rem 0 0; overflow-wrap: anywhere; }
.more-limits { margin-top: 1rem; border-top: 1px solid var(--hairline); padding-top: .85rem; }
.more-limits > summary { cursor: pointer; font-weight: 650; }
.more-limits[open] > summary { margin-bottom: .5rem; }

/* ---------- Conversations inbox ---------- */
.status-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.status-tabs a {
    display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; text-decoration: none;
    padding: .45rem .85rem; min-height: 38px; border-radius: 999px; border: 1px solid var(--hairline-strong);
    background: var(--surface); color: var(--graphite); font-weight: 650; font-size: var(--step--1);
}
.status-tabs a .n { font-variant-numeric: tabular-nums; color: var(--faint); font-weight: 600; }
.status-tabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.status-tabs a[aria-current="page"] .n { color: rgba(255, 255, 255, .7); }
.status-tabs a.waiting.has { border-color: #e9b46a; background: var(--warn-soft); color: var(--warn); }
.status-tabs a.waiting.has[aria-current="page"] { background: #b8620c; border-color: #b8620c; color: #fff; }

.inbox { padding-top: .75rem; }
.inbox-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.inbox-top p { margin: 0; }
.inbox-day { font-size: var(--step--1); color: var(--graphite); font-weight: 650; margin: 1rem 0 .25rem; }
.inbox-list { list-style: none; margin: 0; padding: 0; }
.conv { border-top: 1px solid var(--hairline); }
.inbox-list .conv:first-child { border-top: 0; }
.conv > a {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: .8rem; align-items: start;
    padding: .8rem .6rem; margin: 0 -.6rem; border-radius: var(--r-control); color: inherit; text-decoration: none;
}
.conv > a:hover { background: var(--mist); }
.conv-main { display: grid; gap: .15rem; min-width: 0; }
.conv-q { font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-a { color: var(--graphite); font-size: var(--step--1); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-a em { font-style: normal; color: var(--faint); }
.conv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .7rem; margin-top: .2rem; font-size: var(--step--1); color: var(--faint); }
.conv-meta .unsure { color: var(--warn); font-weight: 600; }
.conv-side { display: grid; justify-items: end; gap: .15rem; font-size: var(--step--1); color: var(--graphite); white-space: nowrap; }
.conv.status-handoff > a { box-shadow: inset 3px 0 0 #d98a1f; background: color-mix(in srgb, var(--warn-soft) 55%, transparent); }
.conv.status-closed .conv-q { color: var(--graphite); font-weight: 600; }
.inbox-empty { text-align: center; padding: 2rem 1rem; color: var(--graphite); display: grid; gap: .75rem; justify-items: center; }
.inbox-empty p { margin: 0; max-width: 48ch; }
@media (max-width: 599px) {
    .conv > a { grid-template-columns: 32px minmax(0, 1fr); }
    .conv > a .bot-mark { width: 32px; height: 32px; }
    .conv-side { grid-column: 2; justify-items: start; grid-auto-flow: column; gap: .7rem; }
}

/* ---------- Leads: one card per person, their words first ---------- */
.search-row .bot-filter { width: auto; flex: 0 1 200px; }
@media (max-width: 599px) { .search-row { flex-wrap: wrap; } .search-row .bot-filter { flex: 1 1 100%; order: 3; } }
.people { padding-top: .75rem; }
.people-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.person { border: 1px solid var(--hairline); border-radius: var(--r-panel); padding: .9rem 1rem; background: var(--surface); }
.person.kind-handoff { box-shadow: inset 3px 0 0 #d98a1f; }
.person.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.person-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: .75rem; align-items: center; }
.initials {
    width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
    background: var(--mist); color: var(--graphite); font-weight: 700; font-size: var(--step--1); letter-spacing: .02em;
}
.kind-handoff .initials { background: var(--warn-soft); color: var(--warn); }
.person-id { display: grid; gap: .1rem; min-width: 0; }
.person-id strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact { display: flex; flex-wrap: wrap; gap: .1rem .9rem; font-size: var(--step--1); }
.contact a { color: var(--accent-deep); overflow-wrap: anywhere; }
.person-said {
    margin: .75rem 0 0 52px; padding: .1rem 0 .1rem .8rem; border-left: 3px solid var(--hairline-strong);
    color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; line-height: 1.5;
}
.kind-handoff .person-said { border-left-color: #e9b46a; }
.person-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin: .8rem 0 0 52px; }
.person-meta { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--step--1); color: var(--graphite); }
.bot-mark.sm { width: 22px; height: 22px; }
.bot-mark.sm svg { width: 12px; height: 12px; }
.person-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.person-actions .del { color: var(--bad); }
.person-actions .del:hover { background: var(--bad-soft); color: var(--bad); }
.thread { margin: .8rem 0 0 52px; padding: .75rem; border-radius: var(--r-control); background: var(--mist); display: grid; gap: .45rem; }
.thread [data-transcript-body] { display: grid; gap: .45rem; }
.thread .line { margin: 0; max-width: 85%; padding: .45rem .7rem; border-radius: 12px; font-size: var(--step--1); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.thread .line.assistant { background: var(--surface); border: 1px solid var(--hairline); justify-self: start; }
.thread .line.visitor { background: var(--accent-soft); justify-self: end; }
.thread .line strong { font-weight: 650; }
@media (max-width: 599px) {
    .person-head { grid-template-columns: 36px minmax(0, 1fr); }
    .person-head .badge { grid-column: 2; justify-self: start; }
    .initials { width: 36px; height: 36px; }
    .person-said, .person-foot, .thread { margin-left: 0; }
    .person-actions { width: 100%; }
    .person-actions .btn { flex: 1; }
}

/* ---------- Reply chooser (Leads) ---------- */
dialog.modal > .modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.reply-said { margin: 0 0 1rem; }
.reply-ways { display: grid; gap: .5rem; margin: .5rem 0 .75rem; }
@media (min-width: 600px) { .reply-ways { grid-template-columns: 1fr 1fr; } }
.reply-ways .btn { width: 100%; }
.reply-note { margin: 0; }

/* ---------- Confirmation modal (delete and other point-of-no-return actions) ---------- */
dialog.confirm-modal { width: min(440px, calc(100vw - 2rem)); }
.confirm-box { padding: 1.4rem 1.4rem .6rem; display: grid; gap: .5rem; }
.confirm-box h2 { margin: 0; font-size: var(--step-2); line-height: 1.25; overflow-wrap: anywhere; }
.confirm-text { margin: 0; color: var(--graphite); line-height: 1.5; }
.confirm-icon {
    width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: .25rem;
    background: var(--accent-soft); color: var(--accent-deep);
}
.confirm-icon::before {
    content: ''; width: 22px; height: 22px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.confirm-modal.danger .confirm-icon { background: var(--bad-soft); color: var(--bad); }
.confirm-modal.danger .confirm-icon::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E");
}
.confirm-expect { margin: .5rem 0 0; }
.confirm-expect .label, .confirm-expect label { font-weight: 600; font-size: var(--step--1); }
.confirm-modal .modal-foot { border-top: 0; padding-top: .9rem; }
.btn.danger-solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger-solid:hover { background: #8f1c13; }
.btn.danger-solid:disabled { background: var(--bad); opacity: .45; }

/* Settings tab: the one irreversible action, kept apart */
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--hairline); }
.danger-zone p { margin: .2rem 0 0; max-width: 60ch; }

/* ---------- Knowledge gaps: questions waiting for an answer, most-asked first ---------- */
.gaps-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
.gaps-bar .status-tabs { margin-bottom: 0; }
.gaps-bot select { width: auto; min-width: 180px; }
@media (max-width: 599px) { .gaps-bot, .gaps-bot select { width: 100%; } }
.gaps { padding-top: .9rem; }
.gaps-lede { margin: 0 0 .4rem; }
.gap-list { list-style: none; margin: 0; padding: 0; }
.gap { border-top: 1px solid var(--hairline); padding: .9rem 0; }
.gap-list .gap:first-child { border-top: 0; }
.gap-main { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: .9rem; align-items: start; }
.gap-count {
    display: grid; justify-items: center; gap: 0; padding: .35rem 0; border-radius: var(--r-control);
    background: var(--mist); color: var(--graphite); line-height: 1.1; min-height: 48px; align-content: center;
}
.gap-count.hot { background: var(--warn-soft); color: var(--warn); }
.gap-count.hot b { color: var(--warn); }
.gap-count b { font-size: var(--step-1); color: var(--ink); }
.gap-count span { font-size: .68rem; }
.gap-body { min-width: 0; }
.gap-q { margin: 0; font-weight: 650; font-size: var(--step-0); line-height: 1.4; overflow-wrap: anywhere; max-width: 70ch; }
.gap-q::before { content: '\201C'; color: var(--faint); }
.gap-q::after { content: '\201D'; color: var(--faint); }
.gap-meta { margin: .3rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; font-size: var(--step--1); color: var(--graphite); }
.gap-bot { display: inline-flex; align-items: center; gap: .35rem; }
.why { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.why::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--hairline-strong); }
.why-content { color: var(--warn); } .why-content::before { background: #d98a1f; }
.why-down { color: var(--bad); } .why-down::before { background: var(--bad); }
.why-person { color: var(--accent-deep); } .why-person::before { background: var(--accent); border-radius: 50%; }
.gap-answer { margin: .55rem 0 0; padding: .1rem 0 .1rem .7rem; border-left: 3px solid var(--ok); color: var(--ink); font-size: var(--step--1); max-width: 70ch; overflow-wrap: anywhere; }
.gap-answer span { color: var(--ok); font-weight: 650; }
.gap-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.gap-reply { margin: .8rem 0 0 calc(52px + .9rem); padding: .9rem 1rem; border-radius: var(--r-panel); background: var(--accent-soft); }
.gap-reply .field { margin-bottom: .75rem; }
.gap-reply textarea { min-height: 90px; background: var(--surface); }
.gap-wording { margin-bottom: .75rem; }
.gap-wording > summary { cursor: pointer; font-size: var(--step--1); font-weight: 600; color: var(--accent-deep); margin-bottom: .4rem; }
.gap.replying .gap-q { color: var(--accent-deep); }
@media (max-width: 599px) {
    .gap-main { grid-template-columns: 44px minmax(0, 1fr); }
    .gap-actions { grid-column: 1 / -1; justify-content: stretch; }
    .gap-actions .btn { flex: 1; }
    .gap-reply { margin-left: 0; }
}

/* ---------- Bots list: where each bot stands, and the next thing to do ---------- */
.bot-state { margin: .45rem 0 0 calc(36px + .75rem); display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .45rem; font-size: var(--step--1); color: var(--graphite); }
.bot-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hairline-strong); flex: none; }
.bot-state a { font-weight: 650; color: var(--accent-deep); }
.state-live { color: var(--ok); } .state-live .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.state-needs { color: var(--warn); } .state-needs .dot { background: #d98a1f; }
.state-setup .dot { background: var(--accent); }
.state-paused .dot { background: var(--faint); }
.bot-activity { display: grid; gap: .1rem; font-size: var(--step--1); color: var(--graphite); white-space: nowrap; }
.bot-activity b { color: var(--ink); font-size: var(--step-0); }
.bot-activity .to-answer { color: var(--warn); text-decoration: none; font-weight: 600; }
.bot-activity .to-answer b { color: var(--warn); }
.bot-activity .to-answer:hover { text-decoration: underline; }
.bot-code { display: inline-flex; align-items: center; gap: .1rem; }
.bot-code code { font-size: .82rem; color: var(--graphite); }
.copy-id { min-height: 30px; padding: .2rem .35rem; }
.copy-id svg { width: 15px; height: 15px; }
@media (max-width: 759px) {
    .bots-table .bot-activity { margin-left: calc(36px + .75rem); }
    .bots-table .col-id { margin-left: calc(36px + .75rem); }
}

/* ---------- Dashboard: summary, what needs you, what visitors asked ---------- */
.dash-summary { margin: .25rem 0 0; font-size: var(--step-1); color: var(--graphite); max-width: 60ch; }
.dash-summary strong { color: var(--ink); font-weight: 700; }
.range-tabs { margin-bottom: 0; }
.dash-main { display: grid; gap: 1.25rem; min-width: 0; }
.todo { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sheet); padding: 1.1rem 1.25rem; }
.todo h2 { margin: 0 0 .6rem; font-size: var(--step-1); }
.todo p { margin: 0; }
.todo.clear { border-color: var(--ok-soft); background: color-mix(in srgb, var(--ok-soft) 45%, var(--surface)); }
.todo.clear h2 { color: var(--ok); margin-bottom: .2rem; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding: .65rem 0 .65rem .9rem; border-top: 1px solid var(--hairline); position: relative; }
.todo-list li:first-child { border-top: 0; }
.todo-list li::before { content: ''; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--hairline-strong); }
.todo-person::before { background: #d98a1f !important; }
.todo-gap::before { background: #d98a1f !important; border-radius: 2px !important; }
.todo-setup::before { background: var(--accent) !important; }
.todo-text { font-weight: 600; }
.todo-more { padding-left: .9rem; }
.todo-more::before { display: none; }
.todo-more a { font-size: var(--step--1); font-weight: 600; }
.asked-q + .times { font-size: var(--step--1); font-weight: 700; color: var(--graphite); background: var(--mist); border-radius: 999px; padding: .05rem .45rem; vertical-align: 2px; }
.cost h2 { display: block; }
@media (max-width: 599px) {
    .todo-list li { flex-wrap: wrap; }
    .todo-list li .btn { width: 100%; }
    .range-tabs { width: 100%; }
}
.asked-item .asked-q { display: inline; }
@media (max-width: 599px) { .todo-list li::before { top: 1.15rem; margin-top: 0; } }

/* ---------- Settings: named groups, the emergency stop up top, Save always in reach ---------- */
.settings-form { padding-top: .25rem; padding-bottom: 0; }
.set-group { display: grid; gap: .75rem 2rem; padding: 1.25rem 0; border-top: 1px solid var(--hairline); }
.set-group:first-of-type { border-top: 0; }
@media (min-width: 900px) { .set-group { grid-template-columns: 240px minmax(0, 1fr); } }
.set-intro h2 { font-size: var(--step-0); margin: 0 0 .25rem; }
.set-intro p { margin: 0; color: var(--graphite); font-size: var(--step--1); line-height: 1.45; max-width: 36ch; }
.set-fields { min-width: 0; }
.set-fields > .field:last-child, .set-fields .grid-2 > .field { margin-bottom: .75rem; }
.set-fields .check + .check { margin-top: .5rem; }
.field.narrow { max-width: 240px; }

/* Emergency stop: an on/off switch that turns red while every bot is paused */
.set-group.stop .set-intro h2 { color: var(--bad); }
.switch { display: flex; gap: .8rem; align-items: flex-start; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--hairline-strong); position: relative; transition: background .15s; margin-top: .05rem; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(29, 35, 48, .3); transition: transform .15s; }
.switch input:checked + .track { background: var(--bad); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }
.switch strong { display: block; }
.switch .hint { display: block; margin-top: .15rem; }
.set-group.stop:has(input:checked), .set-group.stop.on { background: var(--bad-soft); margin: 0 -1.25rem; padding-left: 1.25rem; padding-right: 1.25rem; }

/* Cron: a status line first, the setup command folded away */
.cron-status { padding: .75rem .9rem; border-radius: var(--r-control); background: var(--mist); }
.cron-status p { margin: 0; }
.cron-status p + p { margin-top: .2rem; }
.cron-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: .5rem; vertical-align: 1px; }
.cron-status.ran .dot { background: var(--ok); }
.cron-status details { margin-top: .5rem; }
.cron-status summary { cursor: pointer; font-size: var(--step--1); font-weight: 600; color: var(--accent-deep); }
.cron-status .codebox { white-space: normal; word-break: break-all; margin-top: .4rem; }

/* Save stays on screen on long forms */
.save-bar {
    position: sticky; bottom: 0; z-index: 5; margin: 0 -1.25rem; padding: .85rem 1.25rem;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
    border-top: 1px solid var(--hairline); border-radius: 0 0 var(--r-panel) var(--r-panel);
}
@media (max-width: 899px) { .save-bar { bottom: calc(60px + env(safe-area-inset-bottom)); } }
@media (max-width: 599px) { .save-bar { margin: 0 -1rem; padding: .75rem 1rem; } .set-group.stop:has(input:checked) { margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; } }

/* ---------- Empty states: a faint sketch of what will be here, why it's empty, the next step ---------- */
.empty-state { text-align: center; padding: 1.5rem 1rem 1.75rem; display: grid; justify-items: center; gap: .5rem; }
.empty-state h2 { margin: .5rem 0 0; font-size: var(--step-1); }
.empty-state p { margin: 0; color: var(--graphite); max-width: 46ch; line-height: 1.5; }
.es-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .6rem; }
.empty-state.good h2 { color: var(--ok); }
.empty-state.good::before {
    content: ''; width: 44px; height: 44px; border-radius: 50%; background: var(--ok-soft);
    -webkit-mask: none; box-shadow: inset 0 0 0 2px var(--ok);
}

/* the sketch: rows in the page's own shape, fading out */
.es-ghost { width: min(100%, 420px); display: grid; gap: .5rem; margin-bottom: .25rem;
    -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent); mask-image: linear-gradient(to bottom, #000 30%, transparent); }
.g-row { display: grid; grid-template-columns: 34px 1fr 48px; gap: .75rem; align-items: center; padding: .7rem .8rem; border: 1px solid var(--hairline); border-radius: var(--r-control); background: var(--surface); text-align: left; }
.g-mark { width: 34px; height: 34px; border-radius: 50%; background: var(--mist); }
.g-lines { display: grid; gap: .4rem; }
.g-lines i { display: block; height: 8px; border-radius: 4px; background: var(--mist); }
.g-lines i:first-child { width: 78%; background: var(--hairline-strong); }
.g-lines i:last-child { width: 52%; }
.g-side { height: 8px; border-radius: 4px; background: var(--mist); }
.g-row:first-child .g-mark { background: var(--accent-tint); }
/* per page: an inbox row, a person card, a bot, a question with its count, a teammate */
.es-people .g-mark { border-radius: 50%; background: var(--warn-soft) !important; }
.es-people .g-row { grid-template-columns: 34px 1fr; padding-bottom: 1.1rem; }
.es-people .g-side { display: none; }
.es-bots .g-side { width: 48px; height: 22px; border-radius: 999px; background: var(--ok-soft); }
.es-gaps .g-mark { border-radius: var(--r-control); }
.es-gaps .g-side { height: 26px; border-radius: var(--r-control); background: var(--accent-soft); }
.es-team .g-side { width: 44px; height: 18px; border-radius: 999px; }

/* the dashboard's first run: three real steps, the first one ready to go */
.welcome { padding: 1.5rem 1.4rem; }
.welcome > h2 { margin: 0; font-size: var(--step-2); }
.welcome > p { margin: .3rem 0 1.2rem; max-width: 56ch; }
.welcome-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
@media (min-width: 900px) { .welcome-steps { grid-template-columns: repeat(3, 1fr); } }
.welcome-steps li { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem; border-radius: var(--r-panel); border: 1px solid var(--hairline); background: var(--surface); color: var(--graphite); }
.welcome-steps li.now { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.welcome-steps .step-no { width: 26px; height: 26px; font-size: var(--step--1); margin: 0; }
.welcome-steps li.now .step-no { background: var(--accent); color: #fff; }
.welcome-steps strong { display: block; color: var(--ink); }
.welcome-steps p { margin: .2rem 0 .7rem; font-size: var(--step--1); line-height: 1.45; }
.welcome-steps li:not(.now) p { margin-bottom: 0; }
.asked-empty { display: grid; justify-items: start; gap: .6rem; padding: .75rem 0 1.25rem; }
.asked-empty p { margin: 0; }

/* ---------- Profile: who you are, your details, your password, your plan ---------- */
.me { display: flex; align-items: center; gap: .9rem; }
.me-initials { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent); color: #fff; font-weight: 700; font-size: var(--step-1); letter-spacing: .02em; }
.me h1 { margin: 0; }
.me p { margin: .2rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; color: var(--graphite); overflow-wrap: anywhere; }
.profile-forms { align-items: start; }
.profile-forms h2 { margin-bottom: 1rem; }
.pw { position: relative; }
.pw input { padding-right: 3rem; }
.pw-eye { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); min-height: 34px; padding: .25rem .5rem; color: var(--graphite); }
.pw-eye svg { width: 18px; height: 18px; }
.pw-eye[aria-pressed="true"] { color: var(--accent-deep); }
.pw-rule { display: inline-flex; align-items: center; gap: .4rem; }
.pw-rule .tick { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--hairline-strong); flex: none; }
.pw-rule.met { color: var(--ok); }
.pw-rule.met .tick { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 2px var(--surface); }
.usage { margin-top: 1rem; }
.meters { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem 2rem; }
@media (min-width: 760px) { .meters { grid-template-columns: 1fr 1fr; } }
.meter-head { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--step--1); margin-bottom: .35rem; }
.meter-head span:first-child { font-weight: 600; color: var(--ink); }
.meter-head .num { color: var(--graphite); }
.bar { height: 8px; border-radius: 99px; background: var(--mist); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.meter-row.high .bar span { background: #d98a1f; }
.meter-row.high .meter-head .num { color: var(--warn); font-weight: 600; }
.meter-row.full .bar span { background: var(--bad); }
.meter-row.full .meter-head .num { color: var(--bad); font-weight: 600; }
.profile-out { margin-top: 1rem; display: flex; justify-content: flex-end; }
.profile-out .btn { color: var(--graphite); }
.profile-out svg { width: 16px; height: 16px; }
@media (max-width: 599px) { .profile-out .btn { width: 100%; } }

/* ---------- Bot page: setup that ticks itself off, knowledge you can choose how to add ---------- */
.setup-line { display: flex; align-items: center; gap: .6rem; margin: .35rem 0 .15rem; font-size: var(--step--1); font-weight: 600; color: var(--accent-deep); }
.setup-bar { width: 120px; height: 6px; border-radius: 99px; background: var(--hairline); overflow: hidden; flex: none; }
.setup-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.step-no.done { background: var(--ok) !important; color: #fff !important; font-size: .7rem; }

.kb-first { margin: -.25rem 0 1rem; max-width: 60ch; }
.kb-ways { display: grid; gap: .5rem; margin-bottom: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kb-way {
    display: grid; gap: .2rem; text-align: left; padding: .75rem .85rem; border-radius: var(--r-control);
    border: 1px solid var(--hairline-strong); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit;
}
.kb-way strong { font-size: var(--step-0); }
.kb-way span { font-size: var(--step--1); color: var(--graphite); line-height: 1.35; }
.kb-way:hover { border-color: var(--accent); }
.kb-way.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.kb-way.on strong { color: var(--accent-deep); }
.kb-way:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 2px; }
@media (max-width: 599px) { .kb-ways { grid-template-columns: 1fr 1fr; } }

.pg-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; }

/* ---------- Answers & handoff: five topics, each folded to one line that says where things stand ---------- */
.topics { padding: 0; overflow: hidden; }
.topic { border-top: 1px solid var(--hairline); }
.topic:first-of-type { border-top: 0; }
.topic > summary {
    list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; row-gap: .15rem;
    align-items: center; padding: 1rem 1.25rem;
}
.topic > summary::-webkit-details-marker { display: none; }
.topic > summary::after {
    content: ''; grid-column: 2; grid-row: 1 / span 2; width: 9px; height: 9px; border-right: 2px solid var(--graphite); border-bottom: 2px solid var(--graphite);
    transform: rotate(45deg); transition: transform .15s; margin-right: .25rem;
}
.topic[open] > summary::after { transform: rotate(-135deg); }
.topic > summary:hover { background: var(--mist); }
.topic-title { font-weight: 700; font-size: var(--step-0); grid-column: 1; }
.topic-sum { grid-column: 1; font-size: var(--step--1); color: var(--graphite); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic[open] > summary .topic-sum { display: none; }
.topic-body { padding: 0 1.25rem 1.1rem; max-width: 760px; }
.topic-body > .notice { margin-top: 0; }
.topics .save-bar { margin: 0; border-radius: 0; }
.switch input:checked + .track.on-ok { background: var(--ok); }
.handoff-more { margin-top: 1rem; transition: opacity .15s; }
.handoff-more.off { opacity: .45; }
.handoff-test { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; }
.handoff-test h2 { margin: 0 0 .2rem; font-size: var(--step-0); }
.handoff-test p { margin: 0; }
@media (max-width: 599px) { .topic > summary { padding: .9rem 1rem; } .topic-body { padding: 0 1rem 1rem; } .handoff-test form, .handoff-test .btn { width: 100%; } }

/* ---------- API tab: what it's for, then three numbered steps, then the extras ---------- */
.api-intro { margin-bottom: 1rem; padding: 1.1rem 1.25rem; border-radius: var(--r-panel); background: var(--surface); border: 1px dashed var(--hairline-strong); }
.api-intro h2 { margin: 0 0 .3rem; font-size: var(--step-1); }
.api-intro p { margin: 0; max-width: 68ch; color: var(--graphite); }
.api-intro .api-skip { margin-top: .5rem; color: var(--accent-deep); font-weight: 600; font-size: var(--step--1); }
.api-step { display: flex; align-items: center; gap: .55rem; }
.api-step .step-no { width: 24px; height: 24px; margin: 0; background: var(--accent); color: #fff; }
.api-more { font-size: var(--step-0); color: var(--graphite); margin: 1.75rem 0 .75rem; }
.api-none { margin: 0 0 .5rem; padding: .9rem 1rem; border-radius: var(--r-control); background: var(--mist); color: var(--graphite); }

/* ---------- API secret keys: one clean row per key ---------- */
.keys { list-style: none; margin: .75rem 0 1rem; padding: 0; }
.key { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; padding: .85rem 0; border-top: 1px solid var(--hairline); }
.keys .key:first-child { border-top: 0; }
.key-main { min-width: 0; flex: 1 1 280px; }
.key-name { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.key-mask { display: inline-block; margin-top: .15rem; font-size: .82rem; color: var(--graphite); background: none; padding: 0; }
.key-meta { margin: .3rem 0 0; display: flex; flex-wrap: wrap; gap: .2rem 1rem; font-size: var(--step--1); color: var(--graphite); }
.warn-text { color: var(--warn); font-weight: 600; }
.key.state-revoked, .key.state-expired { opacity: .55; }
.key-actions { display: flex; align-items: center; gap: .35rem; position: relative; }
.btn.ghost.key-revoke { color: var(--bad); }
.btn.ghost.key-revoke:hover { background: var(--bad-soft); color: var(--bad); }
.rotate-menu > summary { list-style: none; }
.rotate-menu > summary::-webkit-details-marker { display: none; }
.rotate-pop {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 10; width: min(300px, 80vw); display: grid; gap: .45rem;
    padding: .9rem; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--shadow-pop);
}
.rotate-pop p { margin: 0 0 .2rem; color: var(--graphite); }
.key-create { margin-top: .5rem; }
.key-create > summary { list-style: none; display: inline-flex; }
.key-create > summary::-webkit-details-marker { display: none; }
.key-create > summary.hidden-summary { display: none; }
.key-create[open] > summary { margin-bottom: 1rem; }
.key-create > form { padding: 1rem; border-radius: var(--r-panel); background: var(--mist); }
.key-create > summary.hidden-summary + form { padding: 0; background: none; }
.choice.scopes { grid-template-columns: 1fr; }
@media (min-width: 760px) { .choice.scopes { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 599px) { .key-actions { width: 100%; } .rotate-menu { flex: 1; } .rotate-menu > summary { width: 100%; justify-content: center; } .rotate-pop { left: 0; right: auto; } }

/* ---------- Knowledge > Sources: readable rows + "what the bot reads" viewer ---------- */
.src-list { list-style: none; margin: 0; padding: 0; }
.src { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: .35rem .85rem; padding: .95rem 0; border-top: 1px solid var(--hairline); }
.src:first-child { border-top: 0; padding-top: .25rem; }
.src-ico { width: 2.25rem; height: 2.25rem; border-radius: var(--r-control); background: var(--mist); color: var(--graphite); display: grid; place-items: center; }
.src-ico svg { width: 18px; height: 18px; }
.src-main { min-width: 0; }
.src-name { margin: 0; font-weight: 600; font-size: var(--step-0); line-height: 1.35; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.src-name a { color: var(--ink); text-decoration: none; }
.src-name a:hover .src-path, .src-name a:focus-visible .src-path { text-decoration: underline; text-underline-offset: 3px; }
.src-host { color: var(--faint); font-weight: 500; }
.src-meta { margin: .3rem 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; font-size: var(--step--1); color: var(--graphite); }
.src-type { color: var(--faint); }
.src-status { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; color: var(--graphite); }
.src-status::before { content: ''; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.src-status.ok { color: var(--ok); }
.src-status.bad { color: var(--bad); }
.src-status.warn { color: var(--warn); }
.src-status.accent { color: var(--accent); }
.src-note { margin: .45rem 0 0; font-size: var(--step--1); padding: .45rem .7rem; border-radius: var(--r-control); max-width: 70ch; }
.src-note.warn { background: var(--warn-soft); color: var(--warn); }
.src-note.bad { background: var(--bad-soft); color: var(--bad); }
.src-note .linklike { margin-left: .35rem; }
.src-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .35rem; }
.src-actions .src-delete { margin-left: auto; }
.src-edit { grid-column: 1 / -1; margin-top: .5rem; padding: 1rem; border-radius: var(--r-control); background: var(--mist); }
@media (min-width: 900px) {
    .src { grid-template-columns: 2.25rem minmax(0, 1fr) auto; align-items: start; }
    .src-actions { grid-column: 3; margin-top: 0; justify-content: flex-end; }
    .src-actions .src-delete { margin-left: 0; }
}
.linklike { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linklike:hover { color: var(--accent); }

dialog.modal.wide { width: min(760px, calc(100vw - 2rem)); height: min(86vh, 820px); }
@media (max-width: 599px) { dialog.modal.wide { width: 100%; height: 92vh; } }
.modal-sub { margin: .15rem 0 0; }
.sv-tabs { display: flex; gap: .25rem; padding: .5rem 1.25rem 0; border-bottom: 1px solid var(--hairline); }
.sv-tabs[hidden] { display: none; }
.sv-tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--graphite); padding: .5rem .75rem .6rem; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.sv-tabs button[aria-selected="true"] { color: var(--accent-deep); border-bottom-color: var(--accent); }
dialog.modal.wide .modal-body { flex: 1; }
.sv-tools { position: sticky; top: -.5rem; z-index: 1; background: var(--surface); padding: .5rem 0 .4rem; }
.sv-tools input { width: 100%; }
.sv-count { margin: .25rem 0 .75rem; }
.sv-page { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .6rem; margin: 1.25rem 0 .5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--hairline); font-size: var(--step--1); color: var(--graphite); }
.sv-page:first-child { margin-top: 0; }
.sv-page a { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
/* Each passage as the bot reads it: its place in the page, the heading it sits under, the text. */
.sv-passage { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: .75rem; padding: .7rem 0; }
.sv-passage + .sv-passage { border-top: 1px dashed var(--hairline); }
.sv-n { font-weight: 700; font-size: var(--step--1); color: var(--accent-deep); background: var(--accent-soft); border-radius: 6px; height: 1.6rem; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.sv-trail { margin: 0 0 .25rem; font-size: var(--step--1); font-weight: 600; color: var(--graphite); }
.sv-text { margin: 0; white-space: pre-line; line-height: 1.6; max-width: 72ch; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.sv-passage.open .sv-text { display: block; -webkit-line-clamp: unset; }
.sv-text mark { background: #fde9a8; color: inherit; border-radius: 2px; padding: 0 .1em; }
.sv-expand { margin-top: .35rem; font-size: var(--step--1); }
.sv-empty { color: var(--graphite); padding: 1.5rem 0; }
.sv-more { margin-top: .75rem; }
.sv-pages { list-style: none; margin: 0; padding: 0; }
.sv-pages li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem 1rem; padding: .55rem 0; border-top: 1px solid var(--hairline); font-size: var(--step--1); }
.sv-pages li:first-child { border-top: 0; }
.sv-pages a { color: var(--ink); overflow-wrap: anywhere; }
.pg-status { font-weight: 600; text-align: right; }
.pg-reason { display: block; font-weight: 400; color: var(--graphite); }
.pg-done .pg-status { color: var(--ok); }
.pg-failed .pg-status { color: var(--bad); }
.pg-skipped .pg-status, .pg-queued .pg-status { color: var(--graphite); }
.pg-blocked .pg-status { color: var(--warn); }
@media (max-width: 599px) { .sv-pages li { grid-template-columns: 1fr; } .pg-status { text-align: left; } }
/* Playground: the handoff button and form visitors get (a preview here) */
.pg-offer { display: flex; width: fit-content; align-items: center; gap: .4rem; margin-top: .65rem; padding: .35rem .8rem; border: 1.5px solid var(--bot, var(--accent)); border-radius: 99px; background: var(--surface); color: var(--bot, var(--accent)); font: inherit; font-size: var(--step--1); font-weight: 600; cursor: pointer; }
.pg-offer svg { width: 15px; height: 15px; }
.pg-offer:hover { background: var(--accent-soft); }
.pg-msg.pg-form { display: grid; gap: .55rem; width: min(100%, 340px); max-width: 100%; }
.pg-form-title { font-size: var(--step-0); }
.pg-form label { display: grid; gap: .2rem; font-size: var(--step--1); font-weight: 600; color: var(--ink); }
.pg-form input, .pg-form textarea { width: 100%; font: inherit; font-size: var(--step--1); padding: .45rem .6rem; border: 1px solid var(--hairline); border-radius: 8px; background: var(--mist); color: var(--ink); resize: none; }
.pg-form .btn { justify-self: end; background: var(--bot, var(--accent)); color: var(--bot-text, #fff); border-color: transparent; opacity: .6; }
.pg-form-note { margin: .1rem 0 0; font-size: var(--step--1); color: var(--graphite); line-height: 1.45; }
.pg-form-note a { font-weight: 600; }
.pg-handoff-note { margin: 0 0 .5rem; }
/* Knowledge gaps > Answered, while nothing is answered yet: the before/after of answering one */
.answered-empty { display: grid; gap: 1.5rem 2.5rem; padding: .75rem .25rem; align-items: center; }
@media (min-width: 760px) { .answered-empty { grid-template-columns: minmax(0, 1fr) minmax(0, 20rem); padding: 1.25rem 1rem; } }
.ae-copy h2 { margin: 0 0 .5rem; font-size: var(--step-2); letter-spacing: -.01em; }
.ae-copy p { margin: 0; color: var(--graphite); max-width: 44ch; line-height: 1.55; }
.ae-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.ae-demo { margin: 0; padding: 1rem 1.1rem 1.1rem; border-radius: var(--r-panel); background: var(--mist); display: grid; gap: .3rem; }
.ae-demo figcaption { font-size: var(--step--1); color: var(--graphite); margin-top: .4rem; }
.ae-demo figcaption:first-child { margin-top: 0; }
.ae-bubble { margin: 0; padding: .55rem .8rem; border-radius: 14px; font-size: var(--step--1); line-height: 1.45; overflow-wrap: anywhere; max-width: 92%; }
.ae-visitor { justify-self: end; background: var(--bot, var(--accent)); color: var(--bot-text, #fff); border-bottom-right-radius: 5px; font-weight: 600; }
.ae-unsure { justify-self: start; background: var(--warn-soft); color: var(--warn); border-bottom-left-radius: 5px; }
.ae-yours { justify-self: start; background: var(--surface); color: var(--accent-deep); border: 1.5px dashed var(--accent); border-bottom-left-radius: 5px; font-weight: 600; }
/* Bot header: which AI answers (links to the details on Settings) */
.bot-idline { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; }
.ai-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem .12rem .45rem; border-radius: 99px; font-size: var(--step--1); font-weight: 600; text-decoration: none; background: var(--accent-soft); color: var(--accent-deep); }
.ai-chip svg { width: 13px; height: 13px; flex: none; }
.ai-chip:hover { text-decoration: underline; text-underline-offset: 2px; }
.ai-chip.test { background: var(--warn-soft); color: var(--warn); }
.ai-chip.off { background: var(--bad-soft); color: var(--bad); }
/* Settings > AI: what answers, who chose it, which key, search by meaning */
.ai-facts { display: grid; gap: .2rem; }
.ai-facts > span { color: var(--graphite); font-size: var(--step--1); }
.ai-facts .ai-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; color: var(--ink); font-size: var(--step-0); }
.ai-note { margin-top: .35rem; padding: .45rem .7rem; border-radius: var(--r-control); max-width: 62ch; line-height: 1.45; }
.ai-facts .ai-note.warn { background: var(--warn-soft); color: var(--warn); }
.ai-facts .ai-note.bad { background: var(--bad-soft); color: var(--bad); }