/* 全局 AI 助手与「大模型设置」弹窗。各页面共用，只依赖页面主题变量（--panel、--line、--text、--accent、--ai 等）。
   层级：按钮与面板 19，在页面自己的弹层（20 起）、pad 工作台浮层与锁屏之下；设置弹窗 35，在锁屏（40）之下。 */
.aa-root { font: 13px/1.5 var(--ui); color: var(--text); }
.aa-root, .aa-root * { box-sizing: border-box; }
:where(.aa-root) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(.aa-root) button:disabled { opacity: .4; cursor: default; }
:where(.aa-root) :is(input, textarea) { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; -webkit-user-select: text; user-select: text; }
:where(.aa-root) :is(input, textarea):focus { outline: none; border-color: var(--accent); }
:where(.aa-root) svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.aa-fab { position: fixed; right: 18px; bottom: 18px; z-index: 19; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai) 75%, #fff), color-mix(in srgb, var(--ai) 70%, #2a0a8a)); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--ai) 40%, transparent), 0 3px 0 color-mix(in srgb, var(--ai) 50%, #000); }
.aa-fab svg { width: 26px; height: 26px; stroke-width: 1.7; }
.aa-fab:active { transform: translateY(2px); }
.aa-fab.on { outline: 2px solid color-mix(in srgb, var(--ai) 60%, transparent); outline-offset: 3px; }

.aa-panel { position: fixed; right: 18px; bottom: 82px; z-index: 19; width: min(420px, calc(100vw - 36px)); height: min(580px, calc(100vh - 110px)); display: flex; flex-direction: column;
  border: 1px solid color-mix(in srgb, var(--ai) 50%, var(--line-2)); border-radius: 14px; background: var(--panel); box-shadow: 0 14px 44px rgba(0, 0, 0, .45); overflow: hidden; }
.aa-nofab .aa-panel { bottom: 96px; }
.aa-panel > header { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.aa-panel > header b { font-size: 15px; color: var(--ai); }
.aa-st { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.aa-st::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--muted); vertical-align: 1px; }
.aa-st--ok::before { background: var(--ok); }
.aa-st--warn::before { background: var(--yellow); }
.aa-ic { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.aa-ic:not(:disabled):hover { background: var(--panel-2); color: var(--text); }

.aa-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.aa-m { max-width: 88%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.6; -webkit-user-select: text; user-select: text; }
.aa-m--user { align-self: flex-end; background: color-mix(in srgb, var(--ai) 22%, var(--panel-2)); border-bottom-right-radius: 4px; }
.aa-m--assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.aa-m--md { white-space: normal; }
.aa-m--note { color: var(--muted); border-style: dashed; }
.aa-md > :first-child { margin-top: 0; }
.aa-md > :last-child { margin-bottom: 0; }
.aa-md p, .aa-md ul, .aa-md ol { margin: 0.45em 0; }
.aa-md h1, .aa-md h2, .aa-md h3 { margin: 0.6em 0 0.3em; font-size: 1em; font-weight: 700; line-height: 1.35; }
.aa-md h1 { font-size: 1.08em; }
.aa-md ul, .aa-md ol { padding-left: 1.25em; }
.aa-md li { margin: 0.15em 0; }
.aa-md li + li { margin-top: 0.2em; }
.aa-md code { font-family: var(--num, ui-monospace, monospace); font-size: 0.92em; padding: 0.05em 0.35em; border-radius: 4px; background: var(--panel-3, rgba(0,0,0,.06)); }
.aa-md pre { margin: 0.5em 0; padding: 8px 10px; overflow-x: auto; border-radius: 8px; background: var(--panel-3, rgba(0,0,0,.06)); border: 1px solid var(--line); }
.aa-md pre code { padding: 0; background: none; font-size: 12px; white-space: pre; }
.aa-md a { color: var(--ai); text-decoration: underline; }
.aa-md hr { border: 0; border-top: 1px solid var(--line); margin: 0.7em 0; }
.aa-md strong { font-weight: 700; }
.aa-empty { margin: auto 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; color: var(--muted); }
.aa-empty p { margin: 0; }
.aa-empty button { padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 10px; text-align: left; color: var(--text); }
.aa-empty button:hover { border-color: var(--ai); }
.aa-empty small { margin-top: 4px; font-size: 11px; }
.aa-err { flex: none; margin: 0; padding: 6px 14px; font-size: 12px; color: var(--red); border-top: 1px solid var(--line); }

.aa-input { flex: none; display: flex; align-items: flex-end; gap: 4px; padding: 10px; border-top: 1px solid var(--line); }
.aa-input textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; line-height: 1.5; }
.aa-mic.on { color: #fff; background: var(--red); animation: aaPulse 1.2s ease-in-out infinite; }
.aa-go:not(:disabled) { color: var(--ai); }
@keyframes aaPulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--red) 25%, transparent); } }

.aa-modal { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .55); }
.aa-dlg { position: relative; width: min(880px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); box-shadow: 0 18px 56px rgba(0, 0, 0, .5); }
.aa-x { position: absolute; top: 12px; right: 12px; z-index: 1; }

/* 大模型设置 */
.aa-set { padding: 20px 28px 28px; }
.aa-head { padding-right: 36px; margin-bottom: 4px; }
.aa-head h3 { margin: 0 0 4px; font-size: 17px; }
.aa-head p { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.aa-set section { padding: 14px 0; border-top: 1px solid var(--line); }
.aa-set h4 { margin: 0 0 10px; font-size: 14px; }
.aa-set h4 small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
.aa-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.aa-row > span { flex: 0 0 96px; color: var(--muted); font-size: 12px; padding-top: 5px; }
.aa-row > div { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.aa-row input:not([type="checkbox"]) { min-width: 260px; }
.aa-row input.grow { flex: 1; }
.aa-row input.ai-num { min-width: 0; width: 72px; }
.aa-hint { width: 100%; margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.aa-warn { color: var(--warn); }
.aa-muted { color: var(--muted); }
.aa-btn { height: 30px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-2); }
.aa-btn:not(:disabled):hover { border-color: var(--accent); }
.aa-btn--primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.aa-btn--ghost { background: transparent; }
.aa-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.aa-seg button { padding: 4px 12px; font-size: 12px; }
.aa-seg button + button { border-left: 1px solid var(--line-2); }
.aa-seg button.is-on { background: var(--accent); color: var(--on-accent); }
.aa-sw { position: relative; display: inline-block; width: 38px; height: 22px; }
.aa-sw input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; min-width: 0; }
.aa-sw i { position: absolute; inset: 0; border-radius: 11px; background: var(--line-2); transition: background .15s; }
.aa-sw i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.aa-sw input:checked + i { background: var(--ok); }
.aa-sw input:checked + i::after { transform: translateX(16px); }
.aa-gate { padding-top: 10px; }
.aa-gate input { min-width: 220px; }
.ai-act, .ai-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.ai-foot { padding: 14px 0; border-top: 1px solid var(--line); }
.ai-msg { margin: 0; font-size: 12px; }
.ai-msg--ok { color: var(--ok); }
.ai-msg--err { color: var(--red); }
.ai-msg--info { color: var(--muted); }
.ai-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--panel-3); font-size: 12px; }
.ai-off { margin-bottom: 12px; padding: 10px 14px; border-radius: 8px; background: color-mix(in srgb, var(--yellow) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--yellow) 35%, var(--line)); }
.ai-off p { margin: 0 0 8px; }
.aa-set code { font-family: var(--num); padding: 0 4px; border-radius: 4px; background: var(--panel-3); }
