/* ==========================================================================
   第九道场 — 古籍智能问答界面
   设计：书斋夜话 · 宣纸为底 · 朱砂点醒 · 墨分五色
   ========================================================================== */

/* ---------- 道场容器 ---------- */
.abook-school-wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 16px 48px;
    font-family: var(--sans);
    color: var(--ink);
    min-height: 70vh;
    position: relative;
}

/* 容器顶部朱砂晕染氛围 */
.abook-school-wrap::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 220px;
    background: radial-gradient(ellipse 60% 100% at 50% 0%, rgba(168,56,46,.05), transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- 登录提示 ---------- */
.abook-school-login-tip {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 90px 24px 100px;
    color: var(--ink-light);
    background: var(--paper-light);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.abook-school-login-icon { font-size: 44px; margin-bottom: 16px; filter: grayscale(.2); }
.abook-school-login-tip p { font-size: 15px; font-family: var(--serif); letter-spacing: 1px; }
.abook-school-login-tip a {
    color: var(--cinnabar);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(168,56,46,.35);
    padding-bottom: 1px;
    transition: border-color .25s, color .25s;
}
.abook-school-login-tip a:hover { color: var(--cinnabar-soft); border-color: var(--cinnabar-soft); }

/* ---------- 顶栏 ---------- */
.abook-chat-topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 4px 16px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

/* 顶栏下方的朱砂短印线 */
.abook-chat-topbar::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 4px;
    width: 52px;
    height: 2px;
    background: var(--cinnabar);
    border-radius: 2px;
}

.abook-chat-topbar-left,
.abook-chat-topbar-right { display: flex; align-items: center; gap: 12px; }

.abook-chat-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 21px;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.abook-chat-brand {
    font-family: var(--serif);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--ink);
}

/* 配额胶囊 */
.abook-quota-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 15px;
    font-size: 13px;
    color: var(--ink-soft);
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: border-color .25s;
}
.abook-quota-pill strong {
    color: var(--cinnabar);
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.abook-quota-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--jade);
    animation: abookQuotaPulse 2.4s infinite ease-in-out;
}
@keyframes abookQuotaPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(63,122,77,.35); }
    50%       { box-shadow: 0 0 0 5px rgba(63,122,77,0); }
}

/* 新对话按钮 */
.abook-chat-new-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--ink-soft);
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .25s;
}
.abook-chat-new-btn:hover {
    color: var(--paper);
    background: var(--ink);
    border-color: var(--ink);
    transform: rotate(90deg);
}

/* ---------- 消息滚动区 ---------- */
.abook-chat-scroll {
    position: relative;
    z-index: 1;
    height: 480px;
    overflow-y: auto;
    padding: 26px 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.abook-chat-scroll::-webkit-scrollbar { width: 6px; }
.abook-chat-scroll::-webkit-scrollbar-track { background: transparent; }
.abook-chat-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.abook-chat-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-light); }

/* ---------- 欢迎态 ---------- */
.abook-chat-welcome {
    margin: auto;
    text-align: center;
    max-width: 560px;
    padding: 20px 12px;
    animation: abookWelcomeIn .6s cubic-bezier(.22,.9,.36,1) both;
}

@keyframes abookWelcomeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.abook-welcome-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    margin-bottom: 20px;
    color: var(--ink);
    animation: abookGlyphFloat 5s infinite ease-in-out;
}
@keyframes abookGlyphFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-7px); }
}
.abook-welcome-title {
    font-family: var(--serif);
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 10px;
    text-indent: 10px; /* 抵消末字间距 */
    color: var(--ink);
    margin: 0 0 10px;
}
.abook-welcome-subtitle {
    position: relative;
    display: inline-block;
    padding: 0 8px;
    font-size: 14px;
    letter-spacing: 3px;
    color: var(--ink-light);
    margin: 0 0 34px;
}

/* 副标题两侧墨点 */
.abook-welcome-subtitle::before,
.abook-welcome-subtitle::after {
    content: "·";
    position: absolute;
    top: 0;
    color: var(--cinnabar);
    font-weight: 700;
}
.abook-welcome-subtitle::before { left: -8px; }
.abook-welcome-subtitle::after  { right: -8px; }

/* 预置问题区 */
.abook-welcome-presets-label {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    letter-spacing: 3px;
    color: var(--ink-light);
    margin-bottom: 16px;
}
.abook-welcome-presets-label::before,
.abook-welcome-presets-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.abook-welcome-presets-label::before { background: linear-gradient(90deg, transparent, var(--line)); }
.abook-welcome-presets-label::after  { background: linear-gradient(90deg, var(--line), transparent); }

.abook-welcome-preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    text-align: left;
}

.abook-preset-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    background: var(--paper-light);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .28s cubic-bezier(.22,.9,.36,1);
    position: relative;
    overflow: hidden;
}

/* 卡片左侧朱砂书签条 */
.abook-preset-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--cinnabar);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform .28s cubic-bezier(.22,.9,.36,1);
}

.abook-preset-card:hover {
    transform: translateY(-3px);
    border-color: var(--line);
    box-shadow: var(--shadow-md);
    background: var(--paper);
}

.abook-preset-card:hover::before { transform: scaleY(1); }

.abook-preset-card-icon {
    flex: 0 0 auto;
    font-size: 17px;
    line-height: 1.5;
    filter: grayscale(.15);
}

.abook-preset-card-text {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--ink-soft);
    font-family: var(--serif);
    letter-spacing: .3px;
    transition: color .25s;
}

.abook-preset-card:hover .abook-preset-card-text { color: var(--ink); }

/* ---------- 消息行 ---------- */
.abook-chat-msg {
    display: flex;
    gap: 12px;
    max-width: 86%;
    animation: abookMsgIn .35s cubic-bezier(.22,.9,.36,1) both;
}
@keyframes abookMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.abook-chat-msg-user { align-self: flex-end; flex-direction: row-reverse; }
.abook-chat-msg-ai { align-self: flex-start; }

/* 头像 */
.abook-msg-avatar-wrap { flex: 0 0 auto; }
.abook-msg-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    user-select: none;
}
/* 道场头像：朱砂印章风 */
.abook-msg-avatar-ai {
    background: linear-gradient(145deg, var(--cinnabar), var(--cinnabar-soft));
    color: #fdf6ee;
    font-size: 17px;
    box-shadow: 0 2px 8px rgba(168,56,46,.28);
}
/* 用户头像：墨色 */
.abook-msg-avatar-user { background: var(--ink); color: var(--paper); font-family: var(--serif); }
.abook-msg-body { min-width: 0; flex: 1; }

/* 气泡 */
.abook-msg-bubble {
    padding: 13px 17px;
    font-size: 14.5px;
    line-height: 1.85;
    word-break: break-word;
    border-radius: var(--radius);
}

/* 用户气泡：墨色，右上小切角 */
.abook-chat-msg-user .abook-msg-bubble {
    background: var(--ink);
    color: var(--paper);
    border-top-right-radius: 3px;
    box-shadow: var(--shadow-sm);
}

/* 道场气泡：宣纸底 + 朱砂左界栏（古籍批注感） */
.abook-chat-msg-ai .abook-msg-bubble {
    background: var(--paper-light);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--cinnabar);
    color: var(--ink);
    border-top-left-radius: 3px;
    box-shadow: var(--shadow-sm);
}

/* 道场回答内的排版 */
.abook-chat-msg-ai .abook-msg-bubble p { margin: 0 0 9px; }
.abook-chat-msg-ai .abook-msg-bubble p:last-child { margin-bottom: 0; }
.abook-chat-msg-ai .abook-msg-bubble ul,
.abook-chat-msg-ai .abook-msg-bubble ol { padding-left: 20px; margin: 7px 0; }
.abook-chat-msg-ai .abook-msg-bubble li { margin-bottom: 5px; }
.abook-chat-msg-ai .abook-msg-bubble li::marker { color: var(--cinnabar); }
.abook-chat-msg-ai .abook-msg-bubble strong { color: var(--cinnabar); font-weight: 700; }
.abook-chat-msg-ai .abook-msg-bubble em { color: var(--ink-soft); }
.abook-chat-msg-ai .abook-msg-bubble code {
    background: var(--paper-warm);
    border: 1px solid var(--line-soft);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 13px;
    color: var(--indigo);
}

/* ---------- 打字指示 ---------- */
.abook-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 15px 18px;
    background: var(--paper-light);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--cinnabar);
    border-radius: var(--radius);
    border-top-left-radius: 3px;
}

.abook-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cinnabar);
    animation: abookTyping 1.2s infinite ease-in-out;
}

.abook-typing-dot:nth-child(2) { animation-delay: .18s; }
.abook-typing-dot:nth-child(3) { animation-delay: .36s; }

@keyframes abookTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40%           { transform: translateY(-6px); opacity: 1; }
}

/* ---------- 输入栏 ---------- */
.abook-chat-inputbar {
    position: relative;
    z-index: 2;
    margin-top: 8px;
}

.abook-quota-exhausted {
    text-align: center;
    font-size: 13px;
    color: var(--cinnabar);
    background: rgba(168,56,46,.06);
    border: 1px solid rgba(168,56,46,.18);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.abook-chat-input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 10px 10px 16px;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color .25s, box-shadow .25s;
}

.abook-chat-input-box:focus-within {
    border-color: var(--cinnabar);
    box-shadow: 0 0 0 3px rgba(168,56,46,.08), var(--shadow-sm);
}
#abook-chat-textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-size: 14.5px;
    line-height: 1.6;
    font-family: var(--sans);
    color: var(--ink);
    max-height: 140px;
    min-height: 26px;
    padding: 6px 0;
}
#abook-chat-textarea::placeholder { color: var(--ink-light); }
#abook-chat-textarea:disabled { color: var(--ink-light); cursor: not-allowed; }

/* 发送按钮：圆形朱砂印 */
.abook-send-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--line);
    color: var(--paper);
    cursor: pointer;
    transition: all .28s cubic-bezier(.22,.9,.36,1);
}
.abook-send-btn svg { transition: transform .28s; }
.abook-send-btn.active {
    background: linear-gradient(145deg, var(--cinnabar), var(--cinnabar-soft));
    box-shadow: 0 3px 12px rgba(168,56,46,.35);
}
.abook-send-btn.active:hover { transform: scale(1.06); }
.abook-send-btn.active:hover svg { transform: translateX(2px); }
.abook-send-btn:disabled { cursor: not-allowed; opacity: .7; }

.abook-chat-input-hint {
    text-align: center;
    font-size: 12px;
    letter-spacing: 1.5px;
    color: var(--ink-light);
    margin-top: 12px;
}
