/* Assistant uses the knowledge library's existing light/dark design tokens. */
.kba-layer[hidden], .kba-layer [hidden] { display: none !important; }
.kba-layer { position: fixed; inset: 0; z-index: 80; color: var(--ink); font-family: var(--sans); }
.kba-scrim { position: absolute; inset: 0; background: rgba(10,16,15,.32); }
.kba-panel { position: absolute; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; width: min(550px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lift); overscroll-behavior: contain; }
.kba-panel button, .kba-panel select, .kba-panel textarea, .kba-panel input { font: inherit; color: inherit; }
.kba-panel button { cursor: pointer; touch-action: manipulation; }
.kba-panel button:disabled { opacity: .44; cursor: default; }
.kba-panel button:focus-visible, .kba-panel select:focus-visible, .kba-panel textarea:focus-visible, .kba-panel input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kba-head { display: flex; align-items: flex-start; gap: 16px; padding: max(22px, env(safe-area-inset-top)) 24px 18px; border-bottom: 1px solid var(--line); }
.kba-character { flex: none; width: 76px; height: 88px; position: relative; display: grid; place-items: center; border-radius: 24px 24px 10px 10px; background: var(--accent-soft); overflow: hidden; }
.kba-character img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.kba-character-fallback { color: var(--accent); font-size: 31px; font-weight: 600; }
.kba-character::after { content: ''; position: absolute; bottom: 5px; left: 28px; right: 28px; height: 3px; border-radius: 5px; background: var(--accent); opacity: .5; }
.kba-character[data-state="listening"]::after { animation: kba-listen 1s ease-in-out infinite; }
.kba-character[data-state="thinking"]::after { animation: kba-think 1.4s ease-in-out infinite; }
.kba-character[data-state="speaking"] img { animation: kba-speak 1.2s ease-in-out infinite; }
.kba-character[data-state="speaking"]::after { animation: kba-listen .45s ease-in-out infinite alternate; }
.kba-heading { min-width: 0; flex: 1; padding-top: 4px; }
.kba-heading h2 { margin: 0; font-size: 19px; letter-spacing: .04em; line-height: 1.4; font-weight: 650; }
.kba-heading p { margin: 6px 0 0; font-size: 12px; line-height: 1.7; color: var(--ink-soft); }
.kba-status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--accent); margin-top: 8px; }
.kba-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.kba-close { background: none; border: 0; flex: none; padding: 3px 6px; font-size: 24px !important; line-height: 1.2; color: var(--ink-soft) !important; }
.kba-controls { padding: 14px 24px 12px; display: grid; gap: 9px; border-bottom: 1px solid var(--line); }
.kba-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kba-select { min-width: 0; flex: 1; width: 100%; padding: 7px 28px 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 12px !important; text-overflow: ellipsis; }
.kba-button { border: 1px solid var(--line-strong); padding: 6px 10px; min-height: 33px; border-radius: 6px; background: var(--surface); font-size: 12px !important; white-space: nowrap; }
.kba-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.kba-button--primary { background: var(--accent); color: var(--accent-ink) !important; border-color: var(--accent); }
.kba-button--primary:hover:not(:disabled) { filter: brightness(.94); }
.kba-label { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); flex: none; }
.kba-scope-lock { font-size: 11px; color: var(--ink-soft); line-height: 1.4; }
.kba-notice { display: flex; align-items: flex-start; gap: 8px; margin: 12px 24px 0; padding: 9px 11px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 12px; line-height: 1.7; flex: none; }
.kba-notice > span { flex: 1; min-width: 0; max-height: 90px; overflow: auto; overflow-wrap: anywhere; }
.kba-notice-close { flex: none; border: 0; background: transparent; padding: 0; width: 28px; min-height: 28px; border-radius: 4px; font-size: 20px !important; line-height: 1; }
.kba-notice-close:hover { background: var(--surface-2); }
.kba-speech-progress { flex: none; margin: 12px 24px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 12px; }
.kba-speech-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--accent); }
.kba-speech-percent { flex: none; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.kba-speech-bar { height: 6px; margin: 10px 0 8px; background: var(--line); border-radius: 3px; overflow: hidden; }
.kba-speech-bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .25s ease; }
.kba-speech-bar[data-indeterminate="true"] > span { animation: kba-progress 1.6s ease-in-out infinite alternate; }
.kba-speech-detail { color: var(--ink-soft); font-variant-numeric: tabular-nums; line-height: 1.6; }
.kba-speech-hint { margin: 4px 0 0; color: var(--ink-faint); font-size: 11px; line-height: 1.6; }
@keyframes kba-progress { from { transform: translateX(0); } to { transform: translateX(185%); } }
.kba-messages { flex: 1; min-height: 0; overflow: auto; padding: 22px 24px; scroll-behavior: smooth; overscroll-behavior: contain; }
.kba-empty { padding: 36px 0 20px; }
.kba-empty h3 { margin: 0 0 9px; font-size: 18px; font-weight: 550; }
.kba-empty p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.8; }
.kba-prompts { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; margin-top: 22px; }
.kba-prompts button { text-align: left; white-space: normal; background: var(--ground); border-color: var(--line); padding: 10px 13px; line-height: 1.7; }
.kba-message { margin: 0 0 25px; padding: 0; }
.kba-message--user { padding: 12px 15px; background: var(--surface-2); border-radius: 10px 10px 2px 10px; margin-left: 28px; }
.kba-message-label { display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 10px; color: var(--ink-soft); margin-bottom: 7px; }
.kba-message-label time { color: var(--ink-faint); }
.kba-message-content { font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
.kba-message-content > :first-child { margin-top: 0; }
.kba-message-content > :last-child { margin-bottom: 0; }
.kba-message-content p { margin: 0 0 .8em; }
.kba-message-content h1, .kba-message-content h2, .kba-message-content h3, .kba-message-content h4, .kba-message-content h5, .kba-message-content h6 { font-size: 15px; line-height: 1.65; margin: 1em 0 .45em; }
.kba-message-content ul, .kba-message-content ol { padding-left: 1.5em; margin: .6em 0; }
.kba-message-content pre { overflow: auto; max-width: 100%; font-family: var(--mono); font-size: 12px; }
.kba-message-content img { max-width: 100%; height: auto; }
.kba-message-content a { color: var(--accent); }
.kba-message-content blockquote { border-left: 2px solid var(--line-strong); margin: 1em 0; padding-left: 12px; color: var(--ink-soft); }
.kba-message-content table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kba-message-content td, .kba-message-content th { border: 1px solid var(--line); padding: 5px; }
.kba-message-content--plain { white-space: pre-wrap; }
.kba-message-state { color: var(--ink-soft); font-size: 12px; line-height: 1.7; }
.kba-message-state--error { color: var(--warn); }
.kba-message-tools { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.kba-message-tools .kba-button { font-size: 11px !important; min-height: 29px; padding: 3px 9px; }
.kba-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; border-top: 1px solid var(--line); padding-top: 10px; }
.kba-sources-label { width: 100%; font-size: 10px; color: var(--ink-soft); font-family: var(--mono); }
.kba-source { background: var(--accent-soft); color: var(--accent) !important; border: 0; border-radius: 4px; padding: 4px 7px; text-align: left; font-size: 11px !important; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kba-compose { flex: none; border-top: 1px solid var(--line); padding: 12px 24px max(16px, env(safe-area-inset-bottom)); background: var(--surface); }
.kba-compose-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; gap: 8px; }
.kba-auto { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 11px; cursor: pointer; }
.kba-auto input { accent-color: var(--accent); }
.kba-input { display: block; resize: vertical; width: 100%; min-height: 75px; max-height: 180px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--ground); padding: 10px 12px; font-size: 13px !important; line-height: 1.7; }
.kba-compose-actions { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.kba-compose-actions .kba-send { margin-left: auto; min-width: 72px; }
.kba-record[data-recording="true"] { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.kba-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 10px; color: var(--ink-faint); font-size: 10px; line-height: 1.5; margin-top: 9px; }
.kba-draft { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--surface); z-index: 1; }
.kba-draft-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: max(20px, env(safe-area-inset-top)) 24px 17px; border-bottom: 1px solid var(--line); }
.kba-draft-head h3 { margin: 0; font-size: 17px; }
.kba-draft-fields { padding: 20px 24px; overflow: auto; flex: 1; min-height: 0; }
.kba-draft-fields label { display: block; font-size: 12px; margin: 17px 0 6px; color: var(--ink-soft); }
.kba-draft-fields label:first-child { margin-top: 0; }
.kba-draft-fields input, .kba-draft-fields textarea, .kba-draft-fields select { width: 100%; border: 1px solid var(--line-strong); background: var(--ground); border-radius: 6px; padding: 9px 11px; font-size: 13px; }
.kba-draft-fields textarea { min-height: 250px; line-height: 1.85; resize: vertical; }
.kba-draft-hint { color: var(--ink-soft); font-size: 12px; line-height: 1.8; margin: 0 0 14px; }
.kba-draft-actions { padding: 14px 24px max(20px, env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.kba-player { margin: 10px 24px 0; flex: none; }
.kba-player audio { display: block; width: 100%; height: 40px; }
.kba-compose-top .kba-auto { margin-left: auto; }
.kba-voice-fields { padding: 20px 24px; overflow: auto; flex: 1; min-height: 0; }
.kba-voice-provider { color: var(--ink-faint); font-family: var(--mono); font-size: 11px; margin: 0 0 9px; }
.kba-voice-current { color: var(--accent); font-size: 13px; line-height: 1.7; margin: 0 0 20px; }
.kba-voice-fields label { display: block; margin: 14px 0 7px; font-size: 12px; color: var(--ink-soft); }
.kba-voice-fields select, .kba-voice-fields input:not([type="checkbox"]) { width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: 6px; padding: 10px; background: var(--ground); font-size: 13px; }
.kba-voice-fields input[type="file"] { font-size: 12px; overflow: hidden; }
.kba-voice-description { color: var(--ink-soft); font-size: 12px; margin: 9px 0 15px; }
.kba-voice-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 16px; }
.kba-voice-preview > p { margin: 0 0 14px; font-size: 14px; line-height: 1.85; }
.kba-voice-help { color: var(--ink-soft); font-size: 12px; line-height: 1.8; margin: 12px 0; }
.kba-voice-hint { color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.kba-voice-custom { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 24px; }
.kba-voice-custom h4 { margin: 0; font-size: 16px; font-weight: 600; }
.kba-voice-recorder { margin: 18px 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.kba-voice-reading-label { color: var(--accent); font-size: 11px; font-weight: 550; }
.kba-voice-reading { margin: 10px 0 16px; font-size: 15px; line-height: 1.95; }
.kba-voice-record-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kba-voice-record-time { font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.kba-voice-record-progress { display: block; width: 100%; height: 6px; margin-top: 12px; border: 0; border-radius: 3px; accent-color: var(--accent); background: var(--line); overflow: hidden; }
.kba-voice-record-progress::-webkit-progress-bar { background: var(--line); }
.kba-voice-record-progress::-webkit-progress-value { background: var(--accent); }
.kba-voice-record-progress::-moz-progress-bar { background: var(--accent); }
.kba-voice-recorder .kba-voice-help { margin-bottom: 0; }
.kba-voice-recorded { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.kba-voice-recorded > p { color: var(--accent); font-size: 12px; line-height: 1.7; margin: 0 0 10px; }
.kba-voice-recorded audio { display: block; width: 100%; height: 40px; margin-bottom: 10px; }
.kba-voice-fields .kba-voice-consent { display: flex; align-items: flex-start; gap: 8px; line-height: 1.8; cursor: pointer; }
.kba-voice-consent input { accent-color: var(--accent); margin-top: 4px; flex: none; }
.kba-voice-item { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.kba-voice-item-detail { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kba-voice-item strong { display: block; font-size: 13px; font-weight: 550; }
.kba-voice-item span { display: block; font-size: 11px; color: var(--ink-soft); line-height: 1.7; margin-top: 4px; }
.kba-voice-fields .kba-notice, .kba-voice-fields .kba-speech-progress, .kba-voice-fields .kba-player { margin: 12px 0 0; }
@keyframes kba-listen { 0%, 100% { transform: scaleX(.6); opacity: .5; } 50% { transform: scaleX(1.65); opacity: 1; } }
@keyframes kba-think { 0%, 100% { transform: translateX(-12px); opacity: .4; } 50% { transform: translateX(12px); opacity: 1; } }
@keyframes kba-speak { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@media (max-width: 600px) {
  .kba-panel { width: 100%; border-left: 0; }
  .kba-head { padding-left: 18px; padding-right: 18px; gap: 13px; }
  .kba-character { width: 62px; height: 74px; }
  .kba-heading h2 { font-size: 18px; }
  .kba-heading p { margin-top: 4px; }
  .kba-controls { padding: 11px 18px; }
  .kba-messages { padding: 20px 18px; }
  .kba-compose { padding-left: 18px; padding-right: 18px; }
  .kba-notice, .kba-speech-progress { margin-left: 18px; margin-right: 18px; }
  .kba-empty { padding-top: 24px; }
  .kba-button { min-height: 38px; }
  .kba-input { font-size: 16px !important; min-height: 78px; }
  .kba-draft-fields input, .kba-draft-fields textarea, .kba-draft-fields select { font-size: 16px; }
  .kba-voice-fields { padding-left: 18px; padding-right: 18px; }
  .kba-voice-fields select, .kba-voice-fields input:not([type="checkbox"]) { font-size: 16px; }
  .kba-player { margin-left: 18px; margin-right: 18px; }
}
@media (max-height: 680px) { .kba-head { padding-top: 12px; padding-bottom: 12px; } .kba-character { height: 61px; width: 55px; } .kba-heading p { display: none; } .kba-empty { padding-top: 12px; } }
@media (prefers-reduced-motion: reduce) { .kba-character::after, .kba-character img, .kba-speech-bar > span { animation: none !important; transition: none !important; } .kba-messages { scroll-behavior: auto; } }

/* The reading directory shares the conversation scope; navigation is free. */
.kba-reading { flex-shrink:0; padding:10px 22px; border-bottom:1px solid var(--line); }
.kba-reading-heading,.kba-reading-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.kba-reading-heading { justify-content:space-between; margin-bottom:7px; font-size:13px; }
.kba-reading .kba-select { width:100%; }
.kba-reading-status,.kba-reading-hint { font-size:11px; line-height:1.5; color:var(--ink-soft); margin:6px 0; }
.kba-reading-progress { width:100%; height:5px; accent-color:var(--accent); display:block; margin:7px 0; }
.kba-reading-actions .kba-button { padding:6px 9px; }
.kba-reading-badge { margin:0 0 8px; font-size:11px; color:var(--ink-soft); }
@media (max-width:600px) { .kba-reading { padding:8px 16px; } }
