/* AI Citability Checker (ac-*). Shared controls (sv-btn, sv-panel, tl-field…) come from tools.css. */
.ac-app { display: grid; grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); gap: 16px; align-items: start; font-size: 14px; line-height: 1.5; color: #343a40; }
.ac-app * { box-sizing: border-box; }
.ac-side { position: sticky; top: 5rem; } /* below the sticky frosted navbar */
.ac-app code { font-size: .92em; padding: 0 .3em; background: #f1f3f5; color: #2f4ac0; border-radius: 3px; }

/* Editor: textarea over a backdrop that carries the highlight */
.ac-editor {
    position: relative; height: 560px; height: min(560px, calc(100vh - 17rem)); min-height: 260px; resize: vertical; overflow: hidden; scroll-margin-top: 5.5rem;
    border: 1px solid #dee2e6; border-radius: 10px; background: #f8f9fb; transition: border-color .15s, box-shadow .15s;
}
.ac-editor:focus-within { border-color: #3b5bdb; background: #fff; box-shadow: 0 0 0 3px rgba(59, 91, 219, .12); }
.ac-app .ac-backdrop, .ac-app .ac-input {
    /* !important: article styles must not change metrics, or the highlight drifts from the text */
    position: absolute; inset: 0; width: 100%; height: 100%; margin: 0 !important; padding: 10px 12px !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "PingFang SC", "Microsoft YaHei", monospace !important;
    font-size: 12.5px !important; line-height: 20px !important; letter-spacing: 0 !important; tab-size: 4;
    white-space: pre-wrap !important; overflow-wrap: anywhere; word-break: normal; overflow-y: scroll; overflow-x: hidden;
    border: 0; border-radius: 0;
}
.ac-app .ac-backdrop { color: transparent; pointer-events: none; background: transparent; scrollbar-width: none; }
.ac-app .ac-backdrop::-webkit-scrollbar { display: none; }
.ac-app .ac-backdrop mark { color: transparent; background: rgba(250, 176, 5, .32); border-radius: 3px; box-shadow: 0 0 0 2px rgba(250, 176, 5, .32); padding: 0; }
.ac-input { resize: none; outline: none; background: transparent; color: #212529; caret-color: #1e3a8a; }
.ac-input::placeholder { color: #adb5bd; }

/* Results */
.ac-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.ac-toolbar .tl-summary { margin: 0; }
.ac-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ac-toggle { font-size: 12.5px; color: #495057; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ac-toggle input { accent-color: #3b5bdb; }
.ac-note { font-size: 12.5px; color: #495057; background: #f3f6ff; border-left: 3px solid #4c6ef5; border-radius: 6px; padding: 8px 10px; margin: 0 0 12px !important; line-height: 1.6; }
.ac-block { margin-bottom: 14px; }
.ac-block-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0 6px; }
.tool-page .content .ac-block-head h3 { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #495057; margin: 0 !important; }
.ac-cnts { display: inline-flex; gap: 4px; flex-wrap: wrap; flex: none; }
.ac-cnt { font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 99px; line-height: 18px; white-space: nowrap; }
.ac-cnt.st-suggest { background: #fff3bf; color: #a35f00; }
.ac-cnt.st-ok { background: #ebfbee; color: #2b8a3e; }

.ac-sec { border: 1px solid rgba(15, 23, 42, .08); border-radius: 12px; background: #fff; margin-bottom: 8px; }
.ac-sec.has-issues { border-color: rgba(245, 159, 0, .35); }
.ac-sec > summary {
    display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none; border-radius: 12px;
}
.ac-sec > summary::-webkit-details-marker { display: none; }
.ac-sec > summary::before { content: '\25B8'; color: #adb5bd; font-size: 11px; transition: transform .15s; flex: none; }
.ac-sec[open] > summary::before { transform: rotate(90deg); }
.ac-sec > summary:hover { background: #f8f9fa; }
.ac-sec > summary:focus-visible { outline: 2px solid #3b5bdb; outline-offset: 1px; }
.ac-sec-level { flex: none; font-size: 11px; font-weight: 700; color: #3b5bdb; background: rgba(59, 91, 219, .1); border-radius: 5px; padding: 0 6px; line-height: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ac-sec-title { flex: 1; min-width: 0; font-weight: 600; color: #212529; word-break: break-word; }
.ac-sec-body { padding: 0 12px 10px; }
.ac-sec-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: #868e96; margin-bottom: 6px; }
.tool-page .content blockquote.ac-first {
    margin: 0 0 8px !important; padding: 6px 10px !important; font-size: 13px; color: #495057; background: #f8f9fa;
    border-left: 3px solid #ced4da; border-radius: 0 6px 6px 0; word-break: break-word;
}

.ac-app ul.ac-checks { list-style: none; margin: 0 !important; padding: 0; }
.ac-app .ac-checks li.ac-check { margin: 0 !important; padding: 2px 0; border-bottom: 1px dashed #f1f3f5; }
.ac-app .ac-checks li.ac-check:last-child { border-bottom: 0; }
.ac-check-head { display: flex; align-items: baseline; gap: 8px; }
.ac-st { flex: none; font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 99px; line-height: 18px; min-width: 3.2em; text-align: center; }
.st-ok .ac-st { background: #ebfbee; color: #2b8a3e; }
.st-suggest .ac-st { background: #fff3bf; color: #a35f00; }
.st-info .ac-st { background: #f1f3f5; color: #495057; }
.ac-check-title {
    flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 5px 0; margin: 0; font: inherit; font-size: 13px;
    color: #343a40; cursor: pointer; word-break: break-word; line-height: 1.55;
}
.ac-check-title:hover { color: #1e3a8a; }
.ac-check-title:focus-visible { outline: 2px solid #3b5bdb; outline-offset: 1px; border-radius: 3px; }
.ac-check.is-active { background: #f3f6ff; border-radius: 6px; }
.ac-grade {
    flex: none; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 4px; line-height: 17px; white-space: nowrap; cursor: help;
    border: 1px solid transparent;
}
.ac-grade.g-A { background: #e6fcf5; color: #087f5b; border-color: #96f2d7; }
.ac-grade.g-B { background: #e7f5ff; color: #1864ab; }
.ac-grade.g-C { background: #f3f0ff; color: #5f3dc4; }
.ac-grade.g-D { background: #fff4e6; color: #a34700; border-color: #ffd8a8; }
.ac-grade.g-R { background: #f1f3f5; color: #495057; border-color: #dee2e6; }
.ac-check-body { padding: 2px 0 10px 4.1em; font-size: 12.5px; color: #495057; }
.ac-check-body[hidden] { display: none; }
.ac-app .ac-check-body p { margin: 0 0 6px !important; line-height: 1.65; }
.ac-check-body b { color: #212529; }
.ac-tpl { border: 1px solid #e9ecef; border-radius: 8px; margin: 4px 0 8px; overflow: hidden; }
.ac-tpl-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 10px; background: #f8f9fa; font-size: 12px; font-weight: 600; }
.ac-app .ac-tpl pre { margin: 0 !important; padding: 8px 10px !important; font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; background: #fff; color: #343a40; border-radius: 0; }

.ac-sources summary { cursor: pointer; font-weight: 700; font-size: 13px; color: #495057; }
.ac-sources[open] summary { margin-bottom: .5rem; }
.ac-app .ac-sources ul { list-style: none; margin: 0 !important; padding: 0; }
.ac-app .ac-sources li { margin: 0 0 6px !important; font-size: 12.5px; display: flex; gap: 8px; align-items: baseline; }

.ac-check { animation: ac-in .25s ease both; }
@keyframes ac-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ac-check { animation: none; } .ac-sec > summary::before { transition: none; } }

@media screen and (max-width: 960px) {
    .ac-app { grid-template-columns: minmax(0, 1fr); }
    .ac-side { position: static; }
    .ac-editor { height: 320px; }
}
@media screen and (max-width: 600px) {
    .ac-check-body { padding-left: 0; }
    .ac-check-head { flex-wrap: wrap; }
    .ac-check-title { flex-basis: calc(100% - 5em); }
}
