@import url("./vendor/katex/katex.min.css");

.learning-assistant { border-top: 1px solid var(--line); margin-top: 56px; padding: 40px 0 12px; }
.assistant-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.assistant-heading h2 { font-size: clamp(28px, 3.5vw, 40px); max-width: 720px; margin-bottom: 12px; line-height: 1.2; }
.assistant-badge { flex-shrink: 0; border: 1px solid var(--line); padding: 6px 12px; font-size: 12px; color: var(--muted); }
.assistant-intro { color: var(--muted); max-width: 730px; }
.assistant-layout { display: grid; grid-template-columns: minmax(240px, .85fr) minmax(0, 1.65fr); border: 1px solid var(--line); margin-top: 28px; }
.assistant-faq { background: var(--surface); padding: 24px; min-width: 0; }
.assistant-faq h3 { font-size: 21px; margin-bottom: 18px; }
.learning-assistant label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.learning-assistant input, .learning-assistant textarea { width: 100%; background: var(--paper); color: var(--ink); border: 1px solid #8ca89d; padding: 10px 12px; font: inherit; font-size: 15px; border-radius: 0; }
.learning-assistant input:focus-visible, .learning-assistant textarea:focus-visible { outline: 3px solid #ac7841; outline-offset: 2px; }
.learning-assistant textarea { resize: vertical; min-height: 92px; max-height: 300px; }
.faq-count { font-size: 12px; color: var(--muted); margin: 8px 0 12px; }
.faq-list { max-height: 430px; overflow-y: auto; padding: 4px 6px 6px; margin: 0 -6px; }
.faq-list button { display: block; width: 100%; border: 0; border-bottom: 1px solid #c9d5cd; background: transparent; color: var(--ink); text-align: left; padding: 12px 2px; font-size: 14px; line-height: 1.5; }
.faq-list button:hover { color: var(--accent); text-decoration: underline; }
.assistant-chat { background: #fff; padding: 24px; min-width: 0; }
.chat-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.chat-toolbar button { background: transparent; border: 0; padding: 4px 0; color: var(--accent); font-size: 12px; text-decoration: underline; }
.chat-log { height: 290px; overflow-y: auto; padding: 18px 6px 0 0; }
.chat-message { margin-bottom: 16px; padding: 14px 16px; background: var(--surface); overflow-wrap: anywhere; }
.chat-message.user { background: #f4f1e9; margin-left: 28px; }
.chat-message > strong, .chat-reading > strong { display: block; color: var(--muted); font-size: 11px; letter-spacing: .03em; margin-bottom: 5px; }
.chat-message p { font-size: 14px; line-height: 1.65; margin: 0; white-space: pre-wrap; }
.chat-body { font-size: 14px; line-height: 1.65; }
.chat-message.user .chat-body { white-space: pre-wrap; }
.chat-body > :first-child { margin-top: 0; }
.chat-body > :last-child { margin-bottom: 0; }
.chat-body p { margin: 0 0 12px; white-space: normal; }
.chat-body h1, .chat-body h2, .chat-body h3, .chat-body h4, .chat-body h5, .chat-body h6 { font-family: inherit; color: var(--ink); font-size: 16px; line-height: 1.35; margin: 20px 0 8px; }
.chat-body h1 { font-size: 20px; }
.chat-body h2 { font-size: 18px; }
.chat-body strong { font-weight: 700; }
.chat-body ul, .chat-body ol { padding-left: 22px; margin: 8px 0 14px; }
.chat-body li { margin: 4px 0; }
.chat-body li > p { margin-bottom: 6px; }
.chat-body li > ul, .chat-body li > ol { margin: 4px 0; }
.chat-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.chat-body blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.chat-body blockquote > :last-child { margin-bottom: 0; }
.chat-body code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; background: #e1e9e3; padding: 2px 5px; border-radius: 3px; }
.chat-body pre { max-width: 100%; overflow-x: auto; margin: 12px 0; padding: 14px; background: #e1e9e3; border: 1px solid #bdcfc2; white-space: pre; overflow-wrap: normal; }
.chat-body pre code { padding: 0; background: transparent; border-radius: 0; }
.chat-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.chat-body th, .chat-body td { padding: 8px 10px; border: 1px solid #bdcfc2; text-align: left; min-width: 90px; }
.chat-body th { background: #e1e9e3; font-weight: 650; }
.chat-body hr { border: 0; border-top: 1px solid #bdcfc2; margin: 16px 0; }
.chat-status { margin: 12px 0; font-size: 13px; color: var(--muted); min-height: 2em; }
.chat-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.chat-actions small, .chat-privacy { font-size: 11px; color: var(--muted); }
.chat-privacy { margin: 16px 0 0; line-height: 1.6; }
.assistant-jump { display: inline-block; margin-top: 4px; font-size: 14px; text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 760px) {
    .assistant-layout { grid-template-columns: 1fr; }
    .assistant-heading { flex-direction: column; gap: 8px; }
    .faq-list { max-height: 220px; }
    .assistant-faq, .assistant-chat { padding: 20px; }
    .chat-log { height: 320px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.chat-reading { margin-top: 16px; padding-top: 12px; border-top: 1px solid #bdcfc2; }
.reading-list a { display: inline-block; font-size: 14px; font-weight: 600; line-height: 1.5; text-decoration: underline; text-underline-offset: 3px; }
.chat-reading .reading-citation { font-size: 11px; color: var(--muted); margin: 5px 0 8px; }
.chat-reading .reading-focus { font-size: 12px; }

.reading-list { list-style: none; padding: 0; margin: 0; }
.reading-list li + li { border-top: 1px solid #bdcfc2; margin-top: 12px; padding-top: 12px; }
.reading-kind { display: block; color: var(--muted); font-size: 11px; margin: 7px 0 4px; }
.chat-math { overflow-wrap: normal; }
.chat-math-display { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 4px 2px; margin: 12px 0; }
.chat-math-display .katex-display { margin: 0; text-align: left; }
.chat-math-display .katex-display > .katex { text-align: left; }
.chat-body .math-fallback { white-space: pre-wrap; overflow-wrap: anywhere; }

.chat-quiz { margin-top: 16px; border-top: 1px solid #bdcfc2; padding-top: 12px; }
.chat-log:has(.chat-quiz[open]) { height: min(65vh, 640px); min-height: 320px; }
.chat-quiz summary { color: var(--accent); font-size: 14px; font-weight: 650; cursor: pointer; }
.chat-quiz summary:focus-visible, .chat-quiz button:focus-visible { outline: 3px solid #ac7841; outline-offset: 3px; }
.chat-quiz > p { font-size: 12px; color: var(--muted); margin: 8px 0 12px; }
.chat-quiz fieldset { min-width: 0; border: 1px solid #bdcfc2; padding: 10px 12px; margin: 12px 0; }
.chat-quiz legend { font-size: 13px; line-height: 1.5; padding: 0 4px; }
.chat-quiz label { display: inline-flex; align-items: center; gap: 7px; margin: 4px 16px 4px 0; min-height: 32px; cursor: pointer; }
.chat-quiz input[type="radio"] { width: 17px; height: 17px; margin: 0; padding: 0; accent-color: var(--accent); }
.chat-quiz .quiz-feedback { border-top: 1px solid #bdcfc2; padding-top: 8px; margin-top: 8px; font-size: 12px; }
.chat-quiz .quiz-result { font-size: 13px; font-weight: 650; margin: 10px 0; }
.chat-quiz button { border: 1px solid var(--accent); background: var(--accent); color: white; padding: 9px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chat-quiz [hidden] { display: none; }
