/* public/bubble.css */
/* ── hfs-ai window styles ──────────────────────────────────────────────────── */

#hfs-ai-root {
  --ai-bg:       var(--bg,       #1a1a2e);
  --ai-text:     var(--text,     #e0e0ff);
  --ai-accent:   var(--button-bg,#5b7fa6);
  --ai-accent-fg: #fff;
  --ai-surface:  color-mix(in srgb, var(--ai-bg) 70%, var(--ai-text) 30%);
  --ai-surface2: color-mix(in srgb, var(--ai-bg) 55%, var(--ai-text) 45%);
  --ai-border:   color-mix(in srgb, var(--ai-bg) 50%, var(--ai-text) 50%);
  --ai-muted:    color-mix(in srgb, var(--ai-bg) 30%, var(--ai-text) 70%);
  --ai-dot-bdr:  var(--ai-bg);
}

#hfs-ai-root[data-ai-theme="navy"] {
  --ai-bg:        #1a1a2e;
  --ai-text:      #e0e0ff;
  --ai-accent:    #5b8af5;
  --ai-accent-fg: #fff;
  --ai-surface:   #22224a;
  --ai-surface2:  #2a2a55;
  --ai-border:    #333355;
  --ai-muted:     #9090bb;
  --ai-dot-bdr:   #1a1a2e;
}

/* Fixed deep forest-green palette ("Emerald Theme"). Chosen so a bright
   emerald accent can sit on near-black green without a white-text contrast
   problem — hence --ai-accent-fg is a dark green rather than white. */
#hfs-ai-root[data-ai-theme="emerald"] {
  --ai-bg:        #0a1a12;
  --ai-text:      #dcf5e7;
  --ai-accent:    #33d69a;
  --ai-accent-fg: #052b1c;
  --ai-surface:   #0f261a;
  --ai-surface2:  #163324;
  --ai-border:    #1f4a33;
  --ai-muted:     #86b89e;
  --ai-dot-bdr:   #0a1a12;
}

/* The inline SVGs hard-code their logo "eye" fills, so pin them to the theme
   variables: the launcher eyes follow the icon stroke (accent-fg) and the
   title-bar logo eyes follow the accent, keeping every theme consistent. */
#hfs-ai-btn svg circle      { fill: var(--ai-accent-fg); }
.ai-window-title svg circle { fill: var(--ai-accent); }

#hfs-ai-root * { box-sizing: border-box; margin: 0; padding: 0; }
#hfs-ai-root { font-family: 'DM Mono', 'Fira Mono', monospace; }

/* ── Launcher button ─────────────────────────────────────────────────────── */
#hfs-ai-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--ai-accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
#hfs-ai-btn:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
#hfs-ai-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ai-accent-fg); stroke-width: 1.8; stroke-linecap: round; }
#hfs-ai-btn .ai-online-dot {
  position: absolute; top: 4px; right: 4px; width: 11px; height: 11px;
  border-radius: 50%; background: #4caf50; border: 2px solid var(--ai-dot-bdr); display: none;
}
#hfs-ai-btn .ai-online-dot.on { display: block; }

/* ── Main window ──────────────────────────────────────────────────────────── */
#hfs-ai-window {
  position: fixed; z-index: 9001;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: scale(0.9) translateY(12px);
  transition: opacity 0.22s cubic-bezier(0.34,1.2,0.64,1),
              transform 0.22s cubic-bezier(0.34,1.2,0.64,1),
              width 0.1s, height 0.1s;
  bottom: 100px; right: 24px;
  width: 320px; height: 380px;
  min-width: 320px; min-height: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
#hfs-ai-window.open {
  opacity: 1; pointer-events: all;
  transform: scale(1) translateY(0);
}
#hfs-ai-window.maximized {
  inset: 12px !important;
  width: auto !important;
  height: auto !important;
  border-radius: 12px;
}

@media (max-width: 480px) {
  #hfs-ai-window {
    right: 8px; left: 8px;
    width: auto !important;
    bottom: 80px;
    height: 65vh;
  }
  #hfs-ai-window.maximized { inset: 0 !important; border-radius: 0; }
  #hfs-ai-btn { right: 16px; bottom: 16px; }
}
/* ── Titlebar ─────────────────────────────────────────────────────────────── */
#hfs-ai-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--ai-surface);
  border-bottom: 1px solid var(--ai-border);
  flex-shrink: 0;
  cursor: default;
  user-select: none;
  min-height: 40px;
}

/* Left side: model name + status */
.ai-window-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ai-window-title svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ai-accent);
  stroke-width: 1.8;
  flex-shrink: 0;
}
#hfs-ai-model-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ai-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes ai-pulse {
  0%,100%{opacity:1}
  50%{opacity:.4}
}

/* Middle: settings/history/new chat buttons */
.ai-titlebar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Right side: window controls (min/max/close) */
.ai-window-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 4px;
}

.ai-hdr-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: none;
  color: var(--ai-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.ai-hdr-btn:hover {
  background: var(--ai-surface2);
  color: var(--ai-text);
}
.ai-hdr-btn.active { color: var(--ai-accent); }
.ai-hdr-btn.danger:hover {
  background: color-mix(in srgb, #ff6b6b 15%, var(--ai-bg));
  color: #ff6b6b;
}
.ai-hdr-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.ai-model-caret {
  width: 10px;
  height: 10px;
  opacity: 0.5;
}

/* "Stop Playing" — shown in the title bar while HFS is showing/playing a file.
   The chat window sits above HFS's full-screen .dialog-backdrop (z-index 1000),
   so this stays clickable even when the file-show overlay is open. */
.ai-hdr-btn#ai-stopplay-btn {
  color: #ff6b6b;
}
.ai-hdr-btn#ai-stopplay-btn:hover {
  background: color-mix(in srgb, #ff6b6b 18%, var(--ai-bg));
  color: #ff6b6b;
}
.ai-hdr-btn#ai-stopplay-btn svg {
  fill: currentColor;
  stroke: none;
}

.ai-win-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: none;
  color: var(--ai-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.ai-win-btn:hover {
  background: var(--ai-surface2);
  color: var(--ai-text);
}
.ai-win-btn#ai-close-btn:hover {
  background: #e74c3c;
  color: #fff;
}
.ai-win-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Resize handle ────────────────────────────────────────────────────────── */
.ai-resize-handle {
  position: absolute; bottom: 0; right: 0;
  width: 20px; height: 20px;
  cursor: nwse-resize;
  color: var(--ai-muted);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  user-select: none;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.ai-resize-handle:hover { opacity: 1; }
/* Top-left grip mirrors the bottom-right one */
.ai-resize-handle.tl { top: 0; left: 0; bottom: auto; right: auto; }

/* ── Popovers ─────────────────────────────────────────────────────────────── */
#hfs-ai-model-pop {
  position: absolute; top: 44px; left: 50px; z-index: 100;
  background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 10px;
  min-width: 200px; max-height: 260px; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4); display: none;
}
#hfs-ai-model-pop.open { display: block; }
.ai-model-pop-hdr { font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ai-muted); padding: 8px 12px 5px; border-bottom: 1px solid var(--ai-border); }
.ai-model-opt { padding: 8px 12px; font-size: 12px; color: var(--ai-text); cursor: pointer; border-bottom: 1px solid var(--ai-border); transition: background 0.1s; display: flex; align-items: center; justify-content: space-between; }
.ai-model-opt:last-child { border-bottom: none; }
.ai-model-opt:hover { background: var(--ai-surface2); }
.ai-model-opt.active { background: color-mix(in srgb, var(--ai-accent) 15%, transparent); border-left: 2px solid var(--ai-accent); }

.ai-dd {
  position: absolute; top: 44px; right: 8px; z-index: 100;
  background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 10px;
  min-width: 220px; max-width: 280px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  display: none; overflow: hidden;
  max-height: calc(100% - 52px); overflow-y: auto;
}
.ai-dd.open { display: block; }
.ai-dd-hdr { font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ai-muted); padding: 8px 12px 5px; border-bottom: 1px solid var(--ai-border); }
.ai-dd-opt { display: flex; flex-direction: column; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--ai-border); transition: background 0.1s; position: relative; }
.ai-dd-opt:last-child { border-bottom: none; }
.ai-dd-opt:hover { background: var(--ai-surface2); }
.ai-dd-opt.sel { background: color-mix(in srgb, var(--ai-accent) 15%, transparent); border-left: 2px solid var(--ai-accent); }
.ai-prompt-edit-btn { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--ai-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 3px; }
.ai-prompt-edit-btn:hover { color: var(--ai-text); background: var(--ai-surface2); }
.ai-dd-label { font-size: 12px; color: var(--ai-text); font-weight: 500; }
.ai-dd-desc { font-size: 10px; color: var(--ai-muted); margin-top: 2px; line-height: 1.4; }
.ai-settings-section { padding: 10px 12px; border-bottom: 1px solid var(--ai-border); display: flex; flex-direction: column; gap: 5px; }
.ai-settings-section:last-child { border-bottom: none; }
.ai-settings-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ai-muted); display: flex; align-items: center; justify-content: space-between; }
.ai-btn { font-size: 11px; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--ai-border); background: var(--ai-surface2); color: var(--ai-text); cursor: pointer; }
.ai-btn:hover { background: color-mix(in srgb, var(--ai-accent) 20%, transparent); }
.ai-proj-btn {
  background: none; border: 1px solid var(--ai-border); border-radius: 6px;
  color: var(--ai-muted); cursor: pointer; padding: 4px 7px; font-size: 10px; font-family: inherit;
  display: flex; align-items: center; gap: 3px; white-space: nowrap;
  transition: all 0.1s;
}
.ai-proj-btn:hover { background: var(--ai-surface2); color: var(--ai-text); }
.ai-proj-btn.danger:hover { background: color-mix(in srgb, #ff6b6b 15%, var(--ai-bg)); color: #ff6b6b; border-color: #ff6b6b; }

/* ── Messages area ────────────────────────────────────────────────────────── */
#hfs-ai-msgs {
  flex: 1; overflow-y: auto; padding: 12px 12px 8px;
  display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth;
}
#hfs-ai-msgs::-webkit-scrollbar { width: 4px; }
#hfs-ai-msgs::-webkit-scrollbar-thumb { background: var(--ai-border); border-radius: 2px; }

#hfs-ai-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; color: var(--ai-muted); text-align: center; padding: 24px;
}
#hfs-ai-empty svg { width: 40px; height: 40px; stroke: var(--ai-muted); fill: none; stroke-width: 1.5; opacity: 0.4; }
#hfs-ai-empty-title { font-size: 14px; font-weight: 700; color: var(--ai-text); }
#hfs-ai-empty-sub { font-size: 11px; line-height: 1.7; max-width: 260px; }
/* Highlighted auto-search link shown one line under the empty-state text */
#hfs-ai-empty .ai-empty-srch {
  margin-top: 2px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  color: var(--ai-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
#hfs-ai-empty .ai-empty-srch:hover { color: var(--ai-text); }

.ai-msg-group { display: flex; flex-direction: column; gap: 2px; animation: ai-fadein 0.2s ease; }
@keyframes ai-fadein { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.ai-msg-label { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ai-muted); padding: 0 3px; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; }
.ai-msg-group.user .ai-msg-label { justify-content: flex-end; }
.ai-msg-group.user { align-items: flex-end; }
.ai-msg-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.65; word-break: break-word; white-space: pre-wrap;
}
.ai-msg-group.user .ai-msg-bubble {
  background: var(--ai-accent); border: 1px solid color-mix(in srgb, var(--ai-accent) 80%, #000);
  border-bottom-right-radius: 3px; color: var(--ai-accent-fg);
}
.ai-msg-group.user.ai-resend-on .ai-msg-bubble { outline: 2px solid var(--ai-accent-fg); }
.ai-msg-group.ai .ai-msg-bubble {
  background: var(--ai-surface); border: 1px solid var(--ai-border);
  border-bottom-left-radius: 3px; color: var(--ai-text);
}
.ai-msg-bubble pre { background: var(--ai-bg); border-radius: 7px; padding: 10px 12px; overflow-x: auto; font-size: 12px; margin: 6px 0; }
.ai-msg-bubble code { font-family: 'DM Mono','Fira Mono',monospace; font-size: 12px; background: var(--ai-bg); padding: 1px 4px; border-radius: 3px; }
.ai-msg-bubble pre code { background: none; padding: 0; }
.ai-msg-bubble li { list-style-position: inside; }
.ai-code-block { position: relative; margin: 6px 0; }
.ai-code-block pre { margin: 0; padding-bottom: 32px !important; }
.ai-code-hdr { position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 4px 10px; background: var(--ai-surface2); border-radius: 0 0 7px 7px; font-size: 9px; color: var(--ai-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.ai-copy-btn { background: none; border: 1px solid var(--ai-border); border-radius: 4px; color: var(--ai-muted); font-family: inherit; font-size: 9px; padding: 2px 7px; cursor: pointer; letter-spacing: 0.05em; text-transform: uppercase; transition: all 0.15s; }
.ai-copy-btn:hover { border-color: var(--ai-accent); color: var(--ai-text); }

.ai-typing-bub {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--ai-surface); border: 1px solid var(--ai-border);
  border-radius: 12px; border-bottom-left-radius: 3px; width: fit-content;
}
.ai-typing-dot { width: 5px; height: 5px; background: var(--ai-muted); border-radius: 50%; animation: ai-blink 1.2s infinite; }
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-blink { 0%,80%,100%{opacity:.2;transform:scale(.9)} 40%{opacity:1;transform:scale(1)} }
.ai-typing-phase { font-size: 10px; color: var(--ai-muted); letter-spacing: 0.07em; text-transform: uppercase; white-space: nowrap; }
.ai-stream-cursor { display: inline-block; width: 7px; height: 13px; background: var(--ai-text); border-radius: 1px; vertical-align: text-bottom; animation: ai-cur 0.7s step-end infinite; margin-left: 2px; opacity: 0.7; }
@keyframes ai-cur { 0%,100%{opacity:.7} 50%{opacity:0} }
.ai-token-stats { font-size: 9px; color: var(--ai-muted); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; letter-spacing: 0.04em; }
.ai-token-stats b { color: color-mix(in srgb, var(--ai-muted) 60%, var(--ai-text) 40%); }
.ai-speak-btn { background: none; border: none; color: var(--ai-muted); cursor: pointer; padding: 0 2px; display: inline-flex; align-items: center; transition: color 0.15s; }
.ai-speak-btn:hover { color: var(--ai-text); }
.ai-speak-btn.on { color: var(--ai-accent); }
.ai-speak-btn svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.ai-file-badge { display: inline-flex; align-items: center; gap: 5px; background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 5px; padding: 3px 7px; font-size: 10px; color: var(--ai-muted); margin-bottom: 4px; }
.ai-file-badge svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 2; opacity: 0.7; }

/* ── Cue (play queue) ────────────────────────────────────────────────────── */
/* The cue panel opens while hovering the Stop button in the title bar. */
.ai-cue-panel { min-width: 230px; max-width: 300px; }

/* Cue button (shown only once items are queued) and its count pill. */
.ai-hdr-btn#ai-cue-btn { position: relative; }
.ai-cue-count {
  position: absolute; top: -1px; right: -1px;
  min-width: 14px; height: 14px; padding: 0 3px; box-sizing: border-box;
  border-radius: 9px; background: var(--ai-accent); color: var(--ai-accent-fg);
  border: 1px solid var(--ai-bg);
  font-size: 9px; line-height: 12px; text-align: center; font-weight: 700;
  display: none; pointer-events: none;
}
.ai-cue-count.on { display: block; }
.ai-cue-now {
  padding: 7px 12px; font-size: 11px; color: var(--ai-muted);
  border-bottom: 1px solid var(--ai-border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-cue-now b { color: var(--ai-accent); font-weight: 600; }
.ai-cue-list { max-height: 180px; overflow-y: auto; }
.ai-cue-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-bottom: 1px solid var(--ai-border);
  font-size: 12px; color: var(--ai-text);
}
.ai-cue-item:last-child { border-bottom: none; }
.ai-cue-item-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: pointer;
}
.ai-cue-item-name:hover { color: var(--ai-accent); }
.ai-cue-item-rm {
  flex-shrink: 0; background: none; border: none; color: var(--ai-muted);
  cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1;
}
.ai-cue-item-rm:hover { color: #ff6b6b; }
.ai-cue-empty { padding: 12px; font-size: 11px; color: var(--ai-muted); text-align: center; }
.ai-cue-actions { padding: 8px 12px; border-top: 1px solid var(--ai-border); }
.ai-cue-btn-clear {
  width: 100%; background: none; border: 1px solid var(--ai-border);
  color: var(--ai-muted); font-size: 10px; text-transform: uppercase;
  letter-spacing: .05em; padding: 5px; border-radius: 6px; cursor: pointer;
  font-family: inherit;
}
.ai-cue-btn-clear:hover { color: #ff6b6b; border-color: #ff6b6b; }

/* ── File results ─────────────────────────────────────────────────────────── */
.ai-file-results { display: flex; flex-direction: column; gap: 4px; margin: 0 0 8px; max-height: 200px; overflow-y: auto; }
.ai-file-result {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 6px;
  padding: 5px 9px; cursor: pointer; transition: border-color .15s;
}
.ai-file-result-name {
  font-size: 12px; font-weight: 600; color: var(--ai-text);
  white-space: normal; overflow-wrap: anywhere;
}
.ai-file-result-meta {
  font-size: 10px; color: var(--ai-muted);
  white-space: normal; overflow-wrap: anywhere;
}
.ai-file-result-path {
  font-size: 10px; color: var(--ai-muted); opacity: 0.85;
  white-space: normal; overflow-wrap: anywhere;
}
.ai-file-result:hover { border-color: var(--ai-accent); }
/* Active (currently opened/playing) row: keep the row's normal background —
   only the accent border marks it, so it isn't darkened. */
.ai-file-result.active { border-color: var(--ai-accent); }
/* Prevent the OS text-selection / long-press (copy/paste) menu from hijacking
   the long-press-to-cue gesture on these rows. Web-search rows are untouched. */
.ai-file-result, .ai-file-result * {
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
}
.ai-file-header { font-size: 13px; }
/* Flash shown on a media row after it is added to the cue by long-press. */
.ai-file-result.cue-flash { border-color: var(--ai-accent); background: var(--ai-surface2); }

/* ── Web search results ───────────────────────────────────────────────────── */
.ai-web-results { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 10px; max-height: 260px; overflow-y: auto; }
.ai-web-hdr { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ai-muted); padding-bottom: 2px; }
.ai-web-row {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 6px;
  padding: 6px 9px; cursor: pointer; transition: border-color .15s;
}
.ai-web-row:hover { border-color: var(--ai-accent); }
.ai-web-title { color: var(--ai-accent); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-web-source { font-size: 10px; color: var(--ai-accent); opacity: 0.85; margin-top: 1px; }
.ai-web-snippet { font-size: 10px; color: var(--ai-muted); line-height: 1.5; }
.ai-web-url { font-size: 9px; color: var(--ai-muted); opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.ai-web-note { font-size: 11px; color: var(--ai-muted); font-style: italic; margin-top: 4px; }
.ai-web-more { display: block; text-align: center; font-size: 10px; color: var(--ai-accent); text-decoration: none; margin: 2px 0 6px; padding: 5px; border: 1px solid var(--ai-border); border-radius: 7px; background: var(--ai-bg); }
.ai-web-more:hover { border-color: var(--ai-accent); color: var(--ai-accent); }
/* ── Attachment bar ───────────────────────────────────────────────────────── */
#hfs-ai-attbar {
  display: none; align-items: center; gap: 5px; padding: 5px 8px;
  background: var(--ai-surface2); border: 1px solid var(--ai-border); border-bottom: none;
  font-size: 11px; color: var(--ai-muted); flex-wrap: wrap;
  flex-shrink: 0;
}
#hfs-ai-attbar.on { display: flex; }
.ai-att-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 5px;
  padding: 2px 5px 2px 6px; font-size: 10px; color: var(--ai-text); max-width: 180px; flex-shrink: 0;
}
.ai-att-chip img { width: 20px; height: 20px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.ai-att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.ai-att-size { color: var(--ai-muted); font-size: 9px; white-space: nowrap; flex-shrink: 0; }
.ai-att-rm { background: none; border: none; color: var(--ai-muted); cursor: pointer; font-size: 12px; line-height: 1; padding: 0 1px; flex-shrink: 0; transition: color 0.15s; }
.ai-att-rm:hover { color: #ff6b6b; }
.ai-att-clearall { background: none; border: none; color: var(--ai-muted); cursor: pointer; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; margin-left: auto; flex-shrink: 0; transition: color 0.15s; }
.ai-att-clearall:hover { color: #ff6b6b; }

/* ── Input area ───────────────────────────────────────────────────────────── */
#hfs-ai-inputarea { flex-shrink: 0; padding: 8px 10px 10px; background: var(--ai-surface); border-top: 1px solid var(--ai-border); }
.ai-input-row {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 12px; padding: 6px 8px;
  transition: border-color 0.2s;
}
.ai-input-row:focus-within { border-color: var(--ai-accent); }
#hfs-ai-textarea {
  flex: 1; background: transparent; border: none; color: var(--ai-text);
  font-family: inherit; font-size: 13px; resize: none; outline: none;
  min-height: 20px; max-height: 150px; line-height: 1.55; overflow-y: auto;
  padding: 3px 4px;
}
#hfs-ai-textarea::placeholder { color: var(--ai-muted); }
.ai-input-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--ai-border);
  background: none; color: var(--ai-muted); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.ai-input-btn:hover { background: var(--ai-surface); color: var(--ai-text); border-color: var(--ai-surface2); }
.ai-input-btn.active, .ai-input-btn.on { border-color: var(--ai-accent); color: var(--ai-accent); }
.ai-input-btn.recording { border-color: #ff6b6b; color: #ff6b6b; animation: ai-pulse 1.2s infinite; }
.ai-input-btn.transcribing { opacity: 0.5; cursor: not-allowed; }
.ai-input-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#ai-search-btn.off { opacity: 0.5; filter: grayscale(0.8); }
#ai-search-btn.off:hover { background: none; border-color: var(--ai-border); color: var(--ai-muted); }
#hfs-ai-send {
  width: 32px; height: 32px; border-radius: 8px; background: var(--ai-accent);
  border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: opacity 0.15s;
}
#hfs-ai-send:disabled { opacity: 0.4; cursor: default; }
#hfs-ai-send.recording { background: #ff4444; animation: ai-pulse 1s infinite; }
#hfs-ai-send.transcribing { background: #f5a623; }
#hfs-ai-send svg { width: 14px; height: 14px; fill: none; stroke: var(--ai-accent-fg); stroke-width: 2.2; stroke-linecap: round; }

.ai-input-hint { margin-top: 5px; font-size: 9px; color: var(--ai-muted); text-align: center; letter-spacing: 0.04em; }
.ai-search-info-wrap { position: relative; display: inline-block; }
.ai-search-trigger { cursor: pointer; color: var(--ai-accent); font-size: 9px; letter-spacing: 0.04em; user-select: none; }
.ai-search-trigger:hover { color: var(--ai-text); }
.ai-search-balloon {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 10px;
  padding: 10px 12px; width: 300px; font-size: 10px; color: var(--ai-muted);
  line-height: 1.7; z-index: 999; text-align: left;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.ai-search-balloon::after { content:''; position:absolute; top:100%; left:50%; transform:translateX(-50%); border:5px solid transparent; border-top-color: var(--ai-border); }
.ai-search-balloon.on { display: block; }
.ai-search-balloon b { color: var(--ai-text); display: block; margin-top: 6px; margin-bottom: 1px; }
.ai-search-balloon b:first-child { margin-top: 0; }
.ai-kw { background: var(--ai-bg); border: 1px solid var(--ai-border); border-radius: 4px; padding: 1px 5px; font-size: 9px; margin: 1px; display: inline-block; }
.ai-balloon-row { display: flex; align-items: flex-start; gap: 6px; margin-top: 3px; }
.ai-balloon-row .ai-kw { flex: 0 0 auto; margin: 0; }
.ai-cmd-desc { color: var(--ai-muted); line-height: 1.5; }
/* File-command help rows: each command is its own chip box, with the meaning
   running after the chips and wrapping naturally. */
.ai-cmd-group { margin-top: 3px; line-height: 1.9; }
.ai-cmd-group .ai-kw { margin: 1px 1px 1px 0; vertical-align: middle; }
.ai-cmd-group .ai-cmd-desc { margin-left: 6px; }
.ai-balloon-tip { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--ai-border); font-size: 9px; color: var(--ai-muted); line-height: 1.5; }

/* ── Error banner ─────────────────────────────────────────────────────────── */
#hfs-ai-error {
  display: none; margin: 0 10px 4px; padding: 8px 12px;
  background: var(--ai-surface); border: 1px solid #ff6b6b; border-radius: 8px;
  font-size: 11px; color: #ff6b6b; align-items: center; gap: 8px; flex-shrink: 0;
}
#hfs-ai-error.on { display: flex; }
#hfs-ai-error svg { width: 13px; height: 13px; stroke: #ff6b6b; fill: none; stroke-width: 2; flex-shrink: 0; }

/* ── Confirm dialog ───────────────────────────────────────────────────────── */
#hfs-ai-confirm {
  display: none; position: absolute; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
  border-radius: inherit;
}
#hfs-ai-confirm.on { display: flex; }
.ai-confirm-box {
  background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 12px;
  padding: 20px; max-width: 300px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.ai-confirm-title { font-size: 14px; font-weight: 700; color: var(--ai-text); margin-bottom: 6px; }
.ai-confirm-msg { font-size: 11px; color: var(--ai-muted); line-height: 1.6; margin-bottom: 16px; }
.ai-confirm-btns { display: flex; gap: 8px; justify-content: flex-end; }
.ai-confirm-cancel { background: none; border: 1px solid var(--ai-border); border-radius: 7px; color: var(--ai-muted); font-family: inherit; font-size: 11px; padding: 6px 14px; cursor: pointer; }
.ai-confirm-cancel:hover { border-color: var(--ai-surface2); color: var(--ai-text); }
.ai-confirm-ok { background: #ff6b6b; border: none; border-radius: 7px; color: #fff; font-family: inherit; font-size: 11px; font-weight: 700; padding: 6px 14px; cursor: pointer; letter-spacing: 0.04em; }
.ai-confirm-ok:hover { opacity: 0.85; }

/* ── Drag & drop overlay ──────────────────────────────────────────────────── */
#hfs-ai-window.dragover {
  border-color: var(--ai-accent);
  box-shadow: 0 0 0 2px var(--ai-accent), 0 8px 40px rgba(0,0,0,0.5);
}
#hfs-ai-dropoverlay {
  position: absolute; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--ai-bg) 82%, transparent);
  backdrop-filter: blur(3px);
  border-radius: inherit;
  pointer-events: none;
}
#hfs-ai-dropoverlay.on { display: flex; }
.ai-dropoverlay-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 28px 36px; border-radius: 14px;
  background: var(--ai-surface); border: 2px dashed var(--ai-accent);
  color: var(--ai-text); font-size: 13px; font-weight: 600;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.ai-dropoverlay-box svg {
  width: 34px; height: 34px; fill: none; stroke: var(--ai-accent);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Chat history sidebar ─────────────────────────────────────────────────── */
#hfs-ai-history-sidebar {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0;
  background: var(--ai-bg); border-right: 1px solid var(--ai-border);
  z-index: 40; overflow: hidden; display: flex; flex-direction: column;
  transition: width 0.22s cubic-bezier(0.4,0,0.2,1);
}
#hfs-ai-history-sidebar.open { width: 220px; }
.ai-history-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 8px 14px; border-bottom: 1px solid var(--ai-border);
  font-size: 11px; font-weight: 700; color: var(--ai-muted);
  text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0;
}
#ai-history-list {
  flex: 1; overflow-y: auto; padding: 6px 0;
}
.ai-history-empty { font-size: 11px; color: var(--ai-muted); padding: 16px 14px; text-align: center; opacity: 0.6; }
.ai-history-item {
  display: flex; align-items: center; padding: 0 6px 0 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ai-border) 50%, transparent); cursor: pointer; min-width: 0;
}
.ai-history-item:hover { background: var(--ai-surface); }
.ai-history-item.active { background: color-mix(in srgb, var(--ai-accent) 10%, transparent); border-left: 2px solid var(--ai-accent); }
.ai-history-item-body {
  flex: 1; padding: 9px 8px 9px 14px; min-width: 0;
}
.ai-history-title {
  font-size: 12px; color: var(--ai-text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-weight: 500; opacity: 0.9;
}
.ai-history-meta { font-size: 10px; color: var(--ai-muted); margin-top: 2px; white-space: nowrap; opacity: 0.7; }
.ai-history-del {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--ai-muted); padding: 4px; border-radius: 5px; display: flex; align-items: center;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.ai-history-item:hover .ai-history-del { opacity: 1; }
.ai-history-del:hover { color: #ff6b6b; }

/* ── Save indicator ───────────────────────────────────────────────────────── */
#hfs-ai-saveindicator {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: color-mix(in srgb, var(--ai-surface2) 90%, transparent);
  color: var(--ai-muted); font-size: 10px; padding: 3px 10px;
  border-radius: 20px; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  letter-spacing: 0.05em;
}
#hfs-ai-saveindicator.on { opacity: 1; }

/* ── Auto-search link inside a message bubble ───────────────────────────── */
.ai-msg-bubble .ai-search-trigger { font-size: 12px; white-space: nowrap; }