.inline-ai { border: 1px solid rgba(36,87,214,.24); border-radius: 7px; padding: 4px 8px; background: #fff; color: #2457d6; font-size: 9px; font-weight: 650; cursor: pointer; transition: .16s ease; }
.inline-ai:hover { background: #e9efff; border-color: #2457d6; }

.past-filter-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; padding: 11px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,248,.72); }
.past-search { position: relative; flex: 1 1 290px; min-width: 200px; }
.past-search input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--paper); color: var(--ink); font-size: 11.5px; outline: none; }
.past-search input:focus { border-color: rgba(36,87,214,.45); background: #fff; box-shadow: 0 0 0 3px rgba(36,87,214,.07); }
.past-filter-panel select { max-width: 230px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 28px 8px 10px; background: #fff; color: var(--ink-2); font-size: 10.5px; outline: none; cursor: pointer; }
.past-filter-panel select:focus { border-color: rgba(36,87,214,.45); }
.past-filter-panel .mini-action { align-self: center; }

.exam-subject-card > i span { display: block; height: 100%; border-radius: inherit; background: var(--subj); }

.past-card { display: grid; gap: 7px; width: 100%; padding: 11px 12px 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,253,248,.68); text-align: left; cursor: pointer; transition: .16s ease; }
.past-card:hover { border-color: var(--subj); background: var(--card); transform: translateX(2px); box-shadow: var(--shadow-soft); }
.past-card[aria-current="true"] { background: var(--subj-soft); border-color: var(--subj); box-shadow: inset 3px 0 0 var(--subj); }
.past-card-top { display: flex; align-items: center; gap: 6px; }
.past-year { color: var(--subj); font: 700 10px var(--mono); letter-spacing: .04em; }
.past-subject, .past-type { padding: 2px 5px; border-radius: 4px; background: var(--card); color: var(--muted); font-size: 8px; }
.past-card-top .exam-status { margin-left: auto; }
.past-card-stem { display: -webkit-box; overflow: hidden; color: var(--ink-2); font-size: 11px; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.past-card-foot { display: flex; flex-wrap: wrap; gap: 5px 9px; color: var(--muted); font-size: 8.5px; }
.past-card-foot .has-analysis { color: #08705d; }
.past-card-foot .no-analysis, .past-missing-tag { color: #9a5b00 !important; }
.past-more { display: block; width: calc(100% - 32px); margin: 0 16px 16px; padding: 9px; border: 1px dashed var(--line-strong); border-radius: 9px; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.past-more:hover { border-color: var(--ink); color: var(--ink); background: var(--paper); }
.past-detail-card .exam-detail-no { font-size: 31px; letter-spacing: -.04em; }
.question-images { display: grid; gap: 10px; margin: -3px 0 16px; }
.question-image { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.question-image img { display: block; width: auto; max-width: 100%; max-height: 480px; height: auto; margin: 0 auto; object-fit: contain; }
.point-past-card .question-images { margin: 8px 0 12px; }
.point-past-card .question-image { padding: 7px 9px; }
.point-past-card .question-image img { max-height: 320px; }
.past-answer-copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.past-source-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.past-dashboard .exam-metric strong { font-size: 33px; }

.ai-fab { position: fixed; right: 24px; bottom: 22px; z-index: 90; display: flex; align-items: center; gap: 9px; padding: 10px 15px 10px 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 99px; background: #172033; color: #fff; box-shadow: 0 16px 44px rgba(16,24,40,.28); font-size: 12px; font-weight: 650; cursor: pointer; transition: .2s ease; }
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 20px 52px rgba(16,24,40,.34); }
.ai-fab.hidden { display: none; }
.ai-spark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #ffb86b, #ff6b6b 58%, #7c9cff); color: #172033; font: 800 10px var(--mono); letter-spacing: -.03em; }

.ai-drawer { position: fixed; right: 22px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; width: min(430px, calc(100vw - 28px)); height: min(710px, calc(100vh - 40px)); overflow: hidden; border: 1px solid rgba(23,32,51,.16); border-radius: 22px; background: #fffdf8; box-shadow: 0 28px 90px rgba(16,24,40,.28); opacity: 0; pointer-events: none; transform: translateY(14px) scale(.985); transition: .2s ease; }
.ai-drawer.open { opacity: 1; pointer-events: auto; transform: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px 13px; background: linear-gradient(140deg, #172033, #202e45 72%); color: #fff; }
.ai-head-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ai-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 12px; background: linear-gradient(135deg, #ffb86b, #ff6b6b 58%, #7c9cff); color: #172033; font: 800 11px var(--mono); }
.ai-head b { display: block; font-size: 13px; }
.ai-head small { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: #9fb0c8; font-size: 9px; }
.ai-live-dot { width: 6px; height: 6px; border-radius: 50%; background: #76d6b6; box-shadow: 0 0 0 3px rgba(118,214,182,.14); }
.ai-head-actions { display: flex; gap: 4px; }
.ai-head-actions button { border: 0; border-radius: 7px; padding: 6px 8px; background: rgba(255,255,255,.08); color: #cdd8e8; font-size: 9px; cursor: pointer; }
.ai-head-actions button:hover { background: rgba(255,255,255,.16); color: #fff; }
.ai-head-actions #aiCloseBtn { padding: 6px 9px; font-size: 16px; line-height: 1; }

.ai-settings { display: grid; gap: 9px; max-height: 47%; overflow-y: auto; padding: 13px 16px; border-bottom: 1px solid var(--line); background: #f7f3e9; }
.ai-settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-settings label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; }
.ai-settings input, .ai-settings select { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; background: #fff; color: var(--ink); font-size: 10px; outline: none; }
.ai-settings input:focus, .ai-settings select:focus { border-color: #2457d6; box-shadow: 0 0 0 3px rgba(36,87,214,.08); }
.ai-privacy { margin: 0; color: #8a6a2f; font-size: 9px; line-height: 1.55; }
.ai-settings-actions { display: flex; gap: 7px; }

.ai-context { display: flex; align-items: center; gap: 7px; margin: 10px 14px 0; padding: 7px 9px; border: 1px solid rgba(36,87,214,.16); border-radius: 9px; background: #eef3ff; }
.ai-context span { flex: 0 0 auto; color: #2457d6; font: 700 8px var(--mono); }
.ai-context b { min-width: 0; overflow: hidden; color: var(--ink-2); font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.ai-context button { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }
.ai-messages { flex: 1; overflow-y: auto; padding: 13px 14px 8px; scrollbar-width: thin; }
.ai-welcome { display: grid; justify-items: start; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.ai-welcome-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #172033; color: #ffb86b; font: 800 11px var(--mono); }
.ai-welcome b { color: var(--ink); font-size: 12px; }
.ai-welcome p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.75; }
.ai-message { max-width: 94%; margin-bottom: 11px; }
.ai-message.user { margin-left: auto; }
.ai-message-head { display: flex; gap: 6px; margin: 0 0 4px 3px; color: var(--muted); font: 600 8px var(--mono); }
.ai-message.user .ai-message-head { justify-content: flex-end; margin: 0 3px 4px 0; }
.ai-message-head span { color: #8a93a1; font: 400 8px var(--sans); }
.ai-message-body { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink-2); font-size: 10.5px; line-height: 1.8; overflow-wrap: anywhere; }
.ai-message.user .ai-message-body { border-color: #172033; border-bottom-right-radius: 4px; background: #172033; color: #f4f1e9; }
.ai-message.assistant .ai-message-body { border-bottom-left-radius: 4px; background: #fffdf8; }
.ai-message-body strong { color: var(--ink); font-weight: 700; }
.ai-message.user .ai-message-body strong { color: #fff; }
.ai-message-body code { padding: 1px 4px; border-radius: 4px; background: var(--paper-2); color: #b42318; font: 9.5px var(--mono); }
.ai-message-body pre { margin: 7px 0; overflow-x: auto; padding: 9px; border-radius: 8px; background: #172033; color: #dce5f1; }
.ai-message-body pre code { padding: 0; background: transparent; color: inherit; font-size: 9px; line-height: 1.65; }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 14px 9px; }
.ai-suggestions button { border: 1px solid var(--line); border-radius: 99px; padding: 5px 8px; background: transparent; color: var(--muted); font-size: 8.5px; cursor: pointer; }
.ai-suggestions button:hover { border-color: #2457d6; background: #eef3ff; color: #2457d6; }
.ai-compose { display: flex; align-items: end; gap: 7px; margin: 0 13px; padding: 7px; border: 1px solid var(--line-strong); border-radius: 13px; background: #fff; }
.ai-compose:focus-within { border-color: rgba(36,87,214,.52); box-shadow: 0 0 0 3px rgba(36,87,214,.07); }
.ai-compose textarea { flex: 1; min-height: 28px; max-height: 120px; resize: none; border: 0; padding: 5px 4px; background: transparent; color: var(--ink); font-size: 11px; line-height: 1.55; outline: none; }
.ai-compose button { display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 auto; border: 0; border-radius: 9px; background: #172033; color: #fff; font-size: 17px; cursor: pointer; }
.ai-compose button.loading { opacity: .55; }
.ai-footnote { padding: 6px 14px 10px; color: #8a93a1; font-size: 8px; text-align: center; }

@media (max-width: 760px) {
  .past-filter-panel select { flex: 1 1 130px; max-width: none; }
  .ai-fab { right: 14px; bottom: 14px; }
  .ai-drawer { right: 0; bottom: 0; width: 100%; height: 88vh; border-radius: 20px 20px 0 0; }
  .ai-settings-row { grid-template-columns: 1fr; }
}

.question-image img { cursor: zoom-in; }
