.bk-autofill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    margin-bottom: 14px;
}

.bk-autofill-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.bk-autofill-row {
    display: flex;
    gap: 8px;
}

.bk-autofill-row .bk-input { flex: 1; min-width: 0; min-height: 44px; }

.bk-autofill-btn {
    min-height: 44px;
    padding: 0 16px;
    font-size: 13px;
    white-space: nowrap;
}

.bk-autofill-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.bk-autofill-error {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--danger);
}

.bk-autofill-error:empty { display: none; }

.bk-autofill-steps {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    color: var(--text-2);
}

.bk-autofill-step { padding: 2px 0; }
.bk-autofill-mark { display: inline-block; width: 1.2em; }
.bk-autofill-step.is-done .bk-autofill-mark { color: var(--success); }
.bk-autofill-step.is-failed .bk-autofill-mark { color: var(--danger); }
.bk-autofill-step.is-running { color: var(--text); font-weight: 600; }
.bk-autofill-step.is-pending { color: var(--text-3); }

.bk-autofill-step.is-running .bk-autofill-mark { animation: bk-autofill-pulse 1.4s ease-in-out infinite; }

@keyframes bk-autofill-pulse { 50% { opacity: .35; } }

.bk-autofill-note {
    margin: 10px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
}

@media (max-width: 520px) {
    .bk-autofill-row { flex-direction: column; }
    .bk-autofill-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .bk-autofill-step.is-running .bk-autofill-mark { animation: none; }
}

.bk-autofill-step-note { color: var(--text-3); font-weight: 400; }

.bk-autofill-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bk-autofill-result .bk-autofill-note { margin: 10px 4px 0 0; flex: 0 1 auto; min-width: 0; }
.bk-autofill-result .bk-autofill-btn { margin-top: 10px; }
.bk-autofill-result [hidden] { display: none; }
.bk-autofill-result:has(#bkAutofillReviewBtn:not([hidden])) { justify-content: flex-end; }

.bk-autofill-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 199; }

.bk-autofill-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 200;
    width: min(480px, 100vw);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px rgba(13, 27, 42, .10);
    animation: bk-autofill-in .22s cubic-bezier(.16, 1, .3, 1);
}

.bk-autofill-panel[hidden], .bk-autofill-backdrop[hidden] { display: none; }
.bk-autofill-panel:focus { outline: none; }

@keyframes bk-autofill-in { from { transform: translateX(24px); opacity: 0; } }

.bk-autofill-panel-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}

.bk-autofill-panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.bk-autofill-panel-head p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.bk-autofill-close { min-width: 44px; min-height: 44px; font-size: 20px; line-height: 1; padding: 0; }

.bk-autofill-panel-body { flex: 1; overflow-y: auto; padding: 4px 18px 12px; overscroll-behavior: contain; }

.bk-autofill-group { margin: 0; padding: 14px 0 4px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.bk-autofill-finds, .bk-autofill-skipped { list-style: none; margin: 0; padding: 0; }

.bk-autofill-find {
    display: grid; grid-template-columns: 44px 1fr; gap: 0 4px;
    padding: 8px 0; border-top: 1px solid var(--border);
    font-size: 13px; line-height: 1.45;
}

.bk-autofill-find:first-child { border-top: 0; }
.bk-autofill-find input { width: 20px; height: 20px; margin: 12px auto 0; accent-color: var(--primary); cursor: pointer; }
.bk-autofill-find input:focus-visible, .bk-autofill-close:focus-visible, .bk-autofill-panel .bk-autofill-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bk-autofill-find-main { min-width: 0; padding: 10px 0 2px; overflow-wrap: anywhere; }
.bk-autofill-find-label { font-weight: 600; color: var(--text); cursor: pointer; }

.bk-autofill-kind { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--surface-soft); color: var(--text-2); }
.bk-autofill-kind.is-stated { background: var(--success-soft); color: var(--success); }
.bk-autofill-kind.is-inferred { background: var(--warning-soft); color: var(--warning); }

.bk-autofill-new { margin-top: 2px; color: var(--text); }
.bk-autofill-old, .bk-autofill-src { margin-top: 2px; font-size: 12px; color: var(--text-3); }
.bk-autofill-evidence::before, .bk-autofill-host::before { content: " · "; }
.bk-autofill-src > :first-child::before { content: ""; }
.bk-autofill-src q::before { content: "\201C"; }
.bk-autofill-src q::after { content: "\201D"; }
.bk-autofill-old .bk-autofill-colors { display: inline-flex; vertical-align: middle; }
.bk-autofill-warn { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--warning); }

.bk-autofill-list { margin: 0; padding-left: 18px; }
.bk-autofill-colors { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.bk-autofill-color { display: inline-flex; align-items: center; gap: 6px; }
.bk-autofill-sw { display: inline-block; width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .12); }
.bk-autofill-old .bk-autofill-sw { width: 12px; height: 12px; border-radius: 4px; }
.bk-autofill-logo { display: block; max-width: 160px; max-height: 56px; object-fit: contain; margin-bottom: 4px; padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); }
.bk-autofill-logo[hidden] { display: none; }

.bk-autofill-partial { margin: 12px 0 0; padding: 8px 12px; border-radius: var(--radius-md); background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 600; }
.bk-autofill-empty { margin: 24px 0; color: var(--text-2); font-size: 14px; }
.bk-autofill-skipped { padding-bottom: 8px; font-size: 12px; color: var(--text-3); }
.bk-autofill-skipped li { padding: 2px 0; }

.bk-autofill-panel-msg { margin: 0; padding: 0 18px; font-size: 12px; font-weight: 600; color: var(--danger); }
.bk-autofill-panel-msg:empty { display: none; }
.bk-autofill-panel-msg:not(:empty) { padding-top: 8px; }

.bk-autofill-panel-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 12px 18px; border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-3);
}

.bk-autofill-foot-actions { display: flex; gap: 8px; }
.bk-autofill-foot-actions [hidden] { display: none; }

@media (max-width: 520px) {
    .bk-autofill-panel { width: 100vw; border-left: 0; }
    .bk-autofill-panel-foot { flex-direction: column; align-items: stretch; }
    .bk-autofill-foot-actions .bk-autofill-btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .bk-autofill-panel { animation: none; }
}

/* =========================================================
   Reading the site: the page dims behind a calm loader
   ========================================================= */
.bk-autofill-loader {
    position: fixed; inset: 0; z-index: 198;
    display: grid; place-items: center; padding: 16px;
    background: rgba(13, 27, 42, .42);
    backdrop-filter: blur(3px);
    animation: bk-autofill-fade .2s ease-out;
}
.bk-autofill-loader[hidden] { display: none; }
@keyframes bk-autofill-fade { from { opacity: 0; } }
.bk-autofill-loader-card {
    width: min(440px, 100%);
    display: grid; justify-items: center; gap: 10px; text-align: center;
    padding: 28px 26px 22px; border-radius: 22px;
    background: var(--surface); box-shadow: 0 30px 70px -20px rgba(13, 27, 42, .45);
}
.bk-autofill-loader-card h3 { margin: 6px 0 0; font-size: 17px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.bk-autofill-loader-hint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); max-width: 340px; }
/* two rings orbiting a dot: busy, never alarming */
.bk-autofill-orbit { position: relative; width: 64px; height: 64px; }
.bk-autofill-orbit span { position: absolute; inset: 0; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--primary); animation: bk-autofill-spin 1.1s linear infinite; }
.bk-autofill-orbit span + span { inset: 9px; border-top-color: transparent; border-bottom-color: #6d5ce7; animation-duration: 1.6s; animation-direction: reverse; }
.bk-autofill-orbit i { position: absolute; inset: 25px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 6px var(--primary-soft); }
@keyframes bk-autofill-spin { to { transform: rotate(360deg); } }
.bk-autofill-loader-bar { width: 100%; height: 6px; border-radius: 999px; overflow: hidden; background: var(--surface-soft); margin-top: 4px; }
.bk-autofill-loader-bar i { display: block; height: 100%; width: 12%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #6d5ce7); transition: width .6s ease; }
.bk-autofill-loader .bk-autofill-steps { width: 100%; margin: 4px 0 0; text-align: left; font-size: 13px; }
.bk-autofill-loader .bk-autofill-step { display: flex; gap: 6px; padding: 4px 0; }
.bk-autofill-loader .bk-autofill-btn { margin-top: 6px; }

/* =========================================================
   The review panel: what was found, before → after
   ========================================================= */
.bk-autofill-panel { width: min(560px, 100vw); background: var(--surface-soft); }
.bk-autofill-panel-head { background: var(--surface); padding: 18px 20px 12px; border-bottom: 0; }
.bk-autofill-eyebrow { display: inline-block; margin-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.bk-autofill-panel-head h3 { font-size: 18px; }
.bk-autofill-panel-head p { font-size: 13px; color: var(--text-2); }
.bk-autofill-tools { padding: 0 20px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.bk-autofill-tools:empty { display: none; }
.bk-autofill-summary { margin: 0 0 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.bk-autofill-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.bk-autofill-quick button { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.bk-autofill-quick button:hover { border-color: var(--primary); color: var(--primary); }
.bk-autofill-quick button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* block flow, not grid: a grid would squeeze the rounded (overflow-hidden) cards to fit instead of scrolling */
.bk-autofill-panel-body { padding: 14px 16px 16px; display: block; }
.bk-autofill-panel-body > * + * { margin-top: 12px; }
.bk-autofill-section { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.bk-autofill-section .bk-autofill-group { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.bk-autofill-section .bk-autofill-group span { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center; background: var(--surface-soft); font-size: 11.5px; letter-spacing: 0; color: var(--text-2); }
.bk-autofill-section .bk-autofill-finds { padding: 0 6px; }
.bk-autofill-find { grid-template-columns: 40px 1fr; padding: 4px 6px; border-radius: 12px; border-top: 1px solid var(--border); transition: background .15s; }
.bk-autofill-find:hover { background: var(--surface-soft); }
.bk-autofill-find:has(input:not(:checked)) .bk-autofill-find-main { opacity: .55; }
.bk-autofill-find input { width: 18px; height: 18px; margin-top: 14px; }
.bk-autofill-find-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.bk-autofill-find-top .bk-autofill-kind { margin-left: 0; }
.bk-autofill-same { font-size: 11px; font-weight: 600; color: var(--text-3); }
.bk-autofill-new { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--primary-soft); color: var(--text); font-size: 13.5px; line-height: 1.5; }
.bk-autofill-find.is-same .bk-autofill-new { background: var(--surface-soft); color: var(--text-2); }
.bk-autofill-old { margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--border); font-size: 12px; }
.bk-autofill-why { margin-top: 6px; }
.bk-autofill-why summary { cursor: pointer; width: fit-content; font-size: 12px; font-weight: 600; color: var(--primary); list-style: none; }
.bk-autofill-why summary::-webkit-details-marker { display: none; }
.bk-autofill-why summary::before { content: "▸ "; }
.bk-autofill-why[open] summary::before { content: "▾ "; }
.bk-autofill-why .bk-autofill-src { margin-top: 4px; padding: 8px 10px; border-radius: 10px; background: var(--surface-soft); line-height: 1.5; }
.bk-autofill-skipped { padding: 4px 16px 12px; }
.bk-autofill-panel-body > .bk-autofill-group { padding: 6px 4px 0; }

.bk-autofill-panel-foot { background: var(--surface); padding: 14px 20px; box-shadow: 0 -10px 24px -18px rgba(13, 27, 42, .35); font-size: 12.5px; font-weight: 600; color: var(--text-2); }

@media (prefers-reduced-motion: reduce) {
    .bk-autofill-loader, .bk-autofill-orbit span { animation: none; }
}

/* =========================================================
   The review, centred: it continues from the loader card
   ========================================================= */
.bk-autofill-backdrop { background: rgba(13, 27, 42, .42); backdrop-filter: blur(3px); }
.bk-autofill-panel {
    top: 50%; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    width: min(680px, calc(100vw - 32px));
    height: min(820px, calc(100vh - 48px));
    border: 0; border-radius: 22px; overflow: hidden;
    box-shadow: 0 40px 90px -24px rgba(13, 27, 42, .5);
    animation: bk-autofill-pop .24s cubic-bezier(.16, 1, .3, 1);
}
@keyframes bk-autofill-pop { from { opacity: 0; transform: translate(-50%, calc(-50% + 14px)) scale(.98); } }
.bk-autofill-panel-head { padding: 22px 24px 12px; }
.bk-autofill-tools { padding: 0 24px 16px; }
.bk-autofill-panel-body { padding: 16px 20px 18px; }
.bk-autofill-panel-foot { padding: 14px 24px; }

/* applying: the list dims and holds still, the button explains the wait */
.bk-autofill-panel.is-applying .bk-autofill-panel-body,
.bk-autofill-panel.is-applying .bk-autofill-tools { opacity: .55; pointer-events: none; transition: opacity .2s; }
.bk-autofill-btn.is-busy { display: inline-flex; align-items: center; gap: 8px; opacity: 1 !important; }
.bk-autofill-btn.is-busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: bk-autofill-spin .8s linear infinite; }

/* the result */
.bk-autofill-done { z-index: 201; }
.bk-autofill-done-mark { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 700; color: #fff; background: var(--success); box-shadow: 0 0 0 8px var(--success-soft); }
.bk-autofill-done-actions { display: flex; gap: 8px; margin-top: 6px; }

@media (max-width: 520px) {
    .bk-autofill-panel { width: 100vw; height: 100vh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .bk-autofill-panel { animation: none; }
    .bk-autofill-btn.is-busy::before { animation: none; }
}
