/* ai add-on (see ADDONS.md) */
.spinner.sm { width: 13px; height: 13px; border-width: 2px; display: inline-block; vertical-align: -2px; }
.ai-notice { display: flex; gap: 10px; align-items: flex-start; background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12; border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; text-align: left; }
.ai-notice a { font-weight: 700; }
.ai-err { color: var(--bad); }
.ai-check { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--ink); font-size: 14px; margin: 6px 0; cursor: pointer; }
.ai-check input { width: auto; }
.ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-row input { flex: 1 1 200px; width: auto; }
.ai-help { margin-top: 6px; line-height: 1.45; }
.modal:has(.ai-modal-wide) { width: min(780px, 100%); }

/* Ask AI page */
.ai-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.ai-history { max-height: calc(100vh - 170px); overflow-y: auto; }
.ai-hrow { display: flex; align-items: center; gap: 4px; border-radius: 8px; padding: 4px 6px; }
.ai-hrow.on { background: var(--brand-soft); }
.ai-hrow .ai-open { flex: 1; min-width: 0; text-align: left; text-decoration: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.ai-hrow .ai-del { border: none; background: none; color: var(--muted); padding: 2px 6px; visibility: hidden; }
.ai-hrow:hover .ai-del { visibility: visible; }
.ai-main { padding: 0; overflow: hidden; }
.ai-chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; }
.ai-chat.compact { height: 100%; min-height: 0; }
.ai-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble { max-width: 85%; padding: 10px 14px; border-radius: 14px; line-height: 1.5; font-size: 14px; overflow-wrap: anywhere; }
.ai-msg.user .ai-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ai-msg.assistant .ai-bubble { background: #f3f4f6; color: var(--ink); border-bottom-left-radius: 4px; }
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child, .ai-bubble ul:last-child, .ai-bubble ol:last-child { margin-bottom: 0; }
.ai-bubble ul, .ai-bubble ol { margin: 0 0 8px; padding-left: 20px; }
.ai-bubble a { color: var(--brand); font-weight: 600; }
.ai-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.ai-composer textarea { resize: none; flex: 1; }
.ai-empty { margin: auto; text-align: center; max-width: 560px; padding: 20px; }
.ai-hero { font-size: 34px; color: var(--brand); }
.ai-examples { display: grid; gap: 8px; margin-top: 16px; }
.ai-ex { justify-content: flex-start; text-align: left; border-radius: 10px; background: #fff; }
.ai-ex:hover { border-color: var(--brand); color: var(--brand); }

/* floating button + drawer */
#ai-fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; border-radius: 999px; padding: 11px 18px; font-weight: 800; background: var(--brand); color: #fff; border: none; box-shadow: 0 8px 24px rgba(79,70,229,.35); }
#ai-fab:hover { filter: brightness(1.08); }
#ai-fab[hidden], #ai-drawer[hidden] { display: none; }
#ai-drawer { position: fixed; right: 16px; bottom: 76px; z-index: 45; width: min(440px, calc(100vw - 32px)); height: min(640px, calc(100vh - 110px)); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.22); display: flex; flex-direction: column; overflow: hidden; }
.ai-dhead { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ai-dhead .spacer { flex: 1; }
.ai-dbody { flex: 1; min-height: 0; }

/* notetaker */
.ai-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 8px; }
.ai-tabs button { border-radius: 999px; font-size: 13px; }
.ai-tabs button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }
.ai-tabbody { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fafafa; }
.ai-rec-bar { display: flex; gap: 12px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.ai-live { max-height: 160px; overflow-y: auto; background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; white-space: pre-wrap; min-height: 44px; }
.ai-live .interim { color: var(--muted); font-style: italic; }
.ai-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); animation: ai-pulse 1s infinite; vertical-align: 0; }
@keyframes ai-pulse { 50% { opacity: .25; } }
.ai-results { border-top: 2px solid var(--brand-soft); margin-top: 18px; padding-top: 12px; }
.ai-results ul { margin: 0 0 10px; padding-left: 20px; }
.ai-kv { grid-template-columns: 150px 1fr; margin-bottom: 10px; }
.ai-details { margin: 8px 0; }
.ai-details summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 13px; }
.ai-transcript { white-space: pre-wrap; font-size: 13px; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 6px; max-height: 320px; overflow-y: auto; }
.ai-task { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.ai-task input[type=checkbox] { width: auto; }
.ai-task .ai-ttitle { flex: 1; }
.ai-task input[type=date] { width: 150px; }

/* best matches */
.ai-match-card .card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-match-card .card-head h3 { margin: 0; }
.ai-match-card .spacer { flex: 1; }
.ai-match { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ai-match:last-child { border-bottom: none; }
.ai-score { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: #f3f4f6; color: #374151; }
.ai-score.mid { background: #fef3c7; color: #92400e; }
.ai-score.hi { background: #d1fae5; color: #065f46; }

/* settings */
.ai-set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ai-meter { height: 10px; background: #f3f4f6; border-radius: 999px; overflow: hidden; margin: 6px 0; }
.ai-meter div { height: 100%; background: var(--brand); }
.ai-usage { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }

@media (max-width: 800px) {
  .ai-layout, .ai-set-grid, .ai-usage { grid-template-columns: 1fr; }
  .ai-history { max-height: 180px; }
  .ai-chat { height: calc(100vh - 330px); }
  #ai-fab { right: 14px; bottom: 14px; }
}

@media (max-width: 860px) {
  #ai-fab { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); right: 14px; padding: 9px 14px; }
  #ai-drawer { bottom: calc(136px + env(safe-area-inset-bottom, 0px)); height: min(560px, calc(100vh - 170px)); }
}
