.ai-qna-page {
    background:
        radial-gradient(circle at 8% 8%, rgba(183, 47, 42, .055), transparent 28rem),
        linear-gradient(180deg, #f4efe5 0, var(--paper) 520px);
}

.ai-qna-main { padding-top: 38px; }
.ai-qna-hero {
    position: relative;
    display: flex;
    min-height: 225px;
    align-items: center;
    justify-content: space-between;
    gap: 48px;
    overflow: hidden;
    padding: 42px 54px;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        radial-gradient(circle at 82% 26%, rgba(216,174,100,.25), transparent 30%),
        var(--pine);
    background-size: 52px 52px, 52px 52px, auto, auto;
    box-shadow: 0 22px 52px rgba(34, 53, 47, .14);
}
.ai-qna-hero::after {
    position: absolute;
    right: 11%;
    bottom: -96px;
    width: 250px;
    height: 250px;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 50%;
    content: "";
}
.ai-qna-hero .page-kicker { color: #e8c88b; }
.ai-qna-hero .page-lead { max-width: 700px; color: rgba(255,255,255,.72); }
.ai-qna-hero__mark {
    position: relative;
    z-index: 1;
    display: grid;
    width: 112px;
    height: 112px;
    flex: 0 0 112px;
    place-items: center;
    color: var(--pine);
    background: #f3dbac;
    border: 8px solid rgba(255,255,255,.17);
    outline: 1px solid rgba(243,219,172,.62);
    outline-offset: 5px;
    transform: rotate(2deg);
}
.ai-qna-hero__mark span { font: 700 46px/1 var(--serif); }
.ai-qna-hero__mark small { margin-top: -22px; font-size: 10px; letter-spacing: .14em; }

.main-content {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(310px, .7fr);
    gap: 28px;
    align-items: start;
    margin-top: 28px;
}
.qa-section { display: grid; gap: 20px; min-width: 0; }
.question-input-area,
.answer-area,
.citations-section {
    background: var(--paper-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.question-input-area { padding: 28px 30px; }
.question-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.question-heading h2,
.citations-header h2,
.answer-placeholder h2 { margin: 0; font: 700 25px/1.25 var(--serif); }
.book-id-field { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.book-id-field input { width: 108px; height: 36px; padding: 0 10px; color: var(--ink); border: 1px solid var(--line); background: #fff; }
.input-group { margin-top: 24px; }
.input-group > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.input-group textarea {
    width: 100%;
    min-height: 126px;
    padding: 16px 18px;
    resize: vertical;
    color: var(--ink);
    background: #fbfaf7;
    border: 1px solid var(--line);
    outline: none;
    font: 15px/1.75 var(--sans);
}
.input-group textarea:focus,
.book-id-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
.button-group { display: flex; gap: 10px; margin-top: 16px; }
.btn,
.btn-link {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line);
    cursor: pointer;
    font-weight: 700;
    transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}
.btn:hover,
.btn-link:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { color: #fff; background: var(--brand-dark); border-color: var(--brand-dark); }
.btn:disabled { opacity: .58; cursor: wait; transform: none; }
.btn-icon { font: 700 18px/1 Georgia, serif; }

.answer-area { position: relative; min-height: 390px; padding: 30px; }
.answer-placeholder { padding: 22px 8px 6px; }
.placeholder-index { display: block; margin-bottom: 28px; color: #c6bcae; font: 700 40px/1 Georgia, serif; }
.answer-placeholder > p { margin: 10px 0 0; color: var(--muted); line-height: 1.7; }
.example-questions { display: grid; gap: 1px; margin-top: 28px; background: var(--line); border: 1px solid var(--line); }
.example-title { margin: 0; padding: 10px 14px; color: var(--muted); background: #f5f0e7; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.example-item { min-height: 48px; padding: 0 14px; color: #514b43; text-align: left; background: var(--paper-strong); border: 0; cursor: pointer; font: 14px/1.5 var(--sans); }
.example-item::after { float: right; color: var(--brand); content: "→"; }
.example-item:hover,
.example-item:focus-visible { color: var(--brand); background: #fbf6ee; outline: none; }
.loading-animation { min-height: 300px; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.spinner { width: 42px; height: 42px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .85s linear infinite; }
.loading-animation p { margin-top: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.answer-content { animation: answer-in .3s ease both; }
@keyframes answer-in { from { opacity: 0; transform: translateY(8px); } }
.answer-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.answer-header h3 { margin: 0; font: 700 24px/1.3 var(--serif); }
.answer-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.confidence-badge,
.time-badge { padding: 5px 9px; font-size: 11px; font-weight: 700; border: 1px solid var(--line); }
.confidence-badge { color: #27604d; background: #edf5f0; border-color: #c3ddd2; }
.confidence-medium { color: #876420; background: #fff7df; border-color: #ebd79f; }
.confidence-low { color: #9a3831; background: #fff0ed; border-color: #e9c2bc; }
.time-badge { color: var(--muted); background: #f7f3eb; }
.answer-text { padding-top: 20px; color: #474139; font-size: 15px; line-height: 1.9; }
.answer-text p { margin: 0 0 14px; }
.answer-text strong { color: var(--brand-dark); }
.error-message { min-height: 300px; padding: 62px 20px; color: #99423c; text-align: center; }
.error-icon { display: grid; width: 42px; height: 42px; place-items: center; margin: 0 auto 16px; border: 1px solid #ddb1ab; border-radius: 50%; font: 700 22px/1 Georgia, serif; }

.citations-section { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 26px; }
.citations-header { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.citations-header h2 { font-size: 22px; }
.citations-count { color: var(--brand); font-size: 12px; font-weight: 800; white-space: nowrap; }
.citations-list { display: grid; gap: 12px; margin-top: 18px; }
.citations-placeholder { padding: 48px 14px; color: var(--muted); text-align: center; }
.citations-placeholder span { display: grid; width: 58px; height: 58px; place-items: center; margin: 0 auto 16px; color: #9d8c73; border: 1px solid #d8cdbd; font: 700 26px/1 var(--serif); }
.citations-placeholder p { margin: 0; line-height: 1.8; }
.citation-item { padding: 17px; background: #fbfaf7; border: 1px solid var(--line); transition: border-color .2s ease, box-shadow .2s ease; }
.citation-item:hover { border-color: #b9ad9d; box-shadow: 0 10px 26px rgba(60,48,37,.07); }
.citation-header { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 12px; }
.citation-number { color: var(--brand); font: 700 15px/1 Georgia, serif; }
.citation-chapter,
.citation-score { padding: 4px 7px; color: var(--muted); background: #f0ebe2; font-size: 11px; }
.citation-score { margin-left: auto; color: #27604d; background: #edf5f0; }
.citation-text { color: #5c554c; font-size: 13px; line-height: 1.75; }
.citation-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.btn-link { min-height: 32px; padding: 0 10px; font-size: 11px; }
.citation-highlight { border-color: #d4aa57; background: #fff9e9; box-shadow: 0 0 0 3px rgba(212,170,87,.13); }

.ai-qna-note { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 22px; padding: 18px 22px; color: var(--muted); background: rgba(255,253,248,.62); border: 1px solid var(--line); font-size: 12px; }
.ai-qna-note p { margin: 0; }
.ai-qna-note nav { display: flex; gap: 18px; }
.ai-qna-note a:hover { color: var(--brand); }

@media (max-width: 980px) {
    .main-content { grid-template-columns: 1fr; }
    .citations-section { position: static; max-height: 560px; }
}

@media (max-width: 760px) {
    .ai-qna-main { padding-top: 20px; }
    .ai-qna-hero { min-height: 0; padding: 30px 24px; }
    .ai-qna-hero__mark { width: 78px; height: 78px; flex-basis: 78px; border-width: 5px; }
    .ai-qna-hero__mark span { font-size: 34px; }
    .ai-qna-hero__mark small { display: none; }
    .question-input-area,
    .answer-area,
    .citations-section { padding: 22px 18px; }
    .question-heading { align-items: flex-start; flex-direction: column; }
    .book-id-field { width: 100%; justify-content: space-between; }
    .book-id-field input { flex: 1; }
    .ai-qna-note { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
    .ai-qna-hero__mark { display: none; }
    .button-group { flex-direction: column; }
    .answer-header { align-items: flex-start; flex-direction: column; }
    .answer-meta { justify-content: flex-start; }
    .ai-qna-note nav { flex-direction: column; gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; }
    .answer-content { animation: none; }
}
