/* ── hfs-ai bubble + fullscreen styles ──────────────────────────────────────── */
/* Adapts to the HFS theme by reading --bg, --text, and --button-bg from the    */
/* host page and deriving the full palette from them. Navy dark is the fallback. */

/* ── Theme palette ────────────────────────────────────────────────────────── */
/*
  We define our own variables scoped to #hfs-ai-root, built from the three
  variables HFS exposes:

    --bg           page background color
    --text         primary text color
    --button-bg    button/accent color

  From those we derive:
    --ai-bg        deepest background (panel body)
    --ai-surface   slightly raised surface (header, input area, popovers)
    --ai-surface2  hovered/selected surface
    --ai-border    border color
    --ai-text      primary text
    --ai-muted     muted / secondary text
    --ai-accent    accent / link / active blue (= --button-bg with fallback)
    --ai-accent-fg foreground on accent backgrounds (always white)
    --ai-dot-bdr   online-dot border (matches deep bg)

  The color-mix() trick lets us lighten/darken --bg relative to itself so
  everything tracks the host theme automatically (light pages stay light,
  dark pages stay dark).
*/

#hfs-ai-root {
  /* Pull HFS tokens in; fall back to the original navy palette. */
  --ai-bg:       var(--bg,       #1a1a2e);
  --ai-text:     var(--text,     #e0e0ff);
  --ai-accent:   var(--button-bg,#5b7fa6);
  --ai-accent-fg: #fff;

  /* Derive surface layers using color-mix so they're always relative to --bg. */
  --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);
}

/* ── Navy theme override ──────────────────────────────────────────────────── */
/* Forces the original navy palette regardless of the host HFS theme. */
#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;
}

/* color-mix() is well-supported (Chrome 111+, Firefox 113+, Safari 16.2+) but
   if a very old browser is encountered the fallbacks above kick in. */

#hfs-ai-root * { box-sizing: border-box; margin: 0; padding: 0; }
#hfs-ai-root { font-family: 'DM Mono', 'Fira Mono', monospace; }

/* ── Launcher ─────────────────────────────────────────────────────────────── */
#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; }

/* ── Panel (compact + fullscreen states) ─────────────────────────────────── */
#hfs-ai-panel {
  position: fixed; z-index: 9001;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; pointer-events: none;
  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);
  bottom: 84px; right: 24px;
  width: 360px; height: 520px;
  border-radius: 18px;
  transform: scale(0.9) translateY(12px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
#hfs-ai-panel.open {
  opacity: 1; pointer-events: all;
  transform: scale(1) translateY(0);
}
#hfs-ai-panel.fullscreen {
  inset: 12px; width: auto; height: auto;
  bottom: 12px; right: 12px;
  border-radius: 18px;
  transform: none !important;
}
@media (max-width: 520px) {
  #hfs-ai-panel { right: 8px; left: 8px; width: auto; bottom: 80px; height: 65vh; }
  #hfs-ai-panel.fullscreen { inset: 0; border-radius: 0; }
  #hfs-ai-btn { right: 16px; bottom: 16px; }
}

/* ── Header ───────────────────────────────────────────────────────────────── */
#hfs-ai-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; background: var(--ai-surface);
  border-bottom: 1px solid var(--ai-border); flex-shrink: 0;
}
.ai-header-logo { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; cursor: default; }
.ai-header-logo svg { width: 20px; height: 20px; fill: none; stroke: var(--ai-accent); stroke-width: 1.8; stroke-linecap: round; flex-shrink: 0; }
#hfs-ai-model-name {
  font-size: 13px; font-weight: 700; color: var(--ai-text); letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-model-caret { width: 10px; height: 10px; opacity: 0.5; flex-shrink: 0; stroke: var(--ai-text); fill: none; stroke-width: 2.5; }
.ai-status-pill {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--ai-muted); background: var(--ai-surface2);
  border: 1px solid var(--ai-border); border-radius: 100px; padding: 3px 8px;
  transition: border-color 0.2s; white-space: nowrap; flex-shrink: 0;
}
.ai-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ai-muted); flex-shrink: 0; transition: background 0.3s; }
.ai-status-dot.online { background: #4caf50; box-shadow: 0 0 5px #4caf50; animation: ai-pulse 2s infinite; }
.ai-status-dot.error { background: #ff6b6b; }
@keyframes ai-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Header buttons */
.ai-hdr-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--ai-border);
  background: none; color: var(--ai-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ai-hdr-btn:hover { background: var(--ai-surface2); color: var(--ai-text); }
.ai-hdr-btn.active:not(#ai-settings-btn) { border-color: var(--ai-accent); color: var(--ai-accent); }
.ai-hdr-btn.danger:hover { background: color-mix(in srgb, #ff6b6b 15%, var(--ai-bg)); color: #ff6b6b; border-color: #ff6b6b; }
.ai-hdr-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.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); }

/* Model popover */
#hfs-ai-model-pop {
  position: absolute; top: 52px; left: 12px; z-index: 100;
  background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 10px;
  min-width: 220px; 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); color: var(--ai-text); }

/* ── Messages area ────────────────────────────────────────────────────────── */
#hfs-ai-msgs {
  flex: 1; overflow-y: auto; padding: 14px 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; }

.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.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); }

/* typing bubble */
.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; }

/* ── 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;
  border-radius: 10px 10px 0 0; 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: 8px 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); }
#hfs-ai-textarea::-webkit-scrollbar { width: 3px; }
#hfs-ai-textarea::-webkit-scrollbar-thumb { background: var(--ai-border); border-radius: 2px; }
.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.danger:hover { background: color-mix(in srgb, #ff6b6b 15%, var(--ai-bg)); color: #ff6b6b; border-color: #ff6b6b; }
.ai-input-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#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-input-hint kbd { background: var(--ai-surface2); border: 1px solid var(--ai-border); border-radius: 3px; padding: 1px 4px; font-family: inherit; font-size: 9px; }
.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; }

/* ── 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; }

/* ── Persona / Speak / Settings dropdowns (fullscreen) ───────────────────── */
.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: 200px; box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  display: none; overflow: hidden;
  max-height: calc(100% - 52px); overflow-y: auto;
}
.ai-settings-dd { min-width: 0; width: calc(100% - 16px); max-width: 280px; }
.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; }
.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-dd-opt[data-persona] { position: relative; }
.ai-prompt-edit-btn { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--ai-muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 3px; }
.ai-prompt-edit-btn:hover { color: var(--ai-text); background: var(--ai-surface2); }
.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-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-settings-lbl span { color: var(--ai-text); font-size: 11px; letter-spacing: 0; text-transform: none; }

/* Number inputs pick up the accent color on focus */
input[type=number]#ai-np-input:focus,
input[type=number]#ai-tmp-input:focus {
  outline: 1px solid var(--ai-accent);
  border-color: var(--ai-accent);
}

/* ── 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);
  border-radius: 16px 0 0 16px;
}
#hfs-ai-history-sidebar.open { width: 240px; }
.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-list::-webkit-scrollbar { width: 3px; }
#ai-history-list::-webkit-scrollbar-track { background: transparent; }
#ai-history-list::-webkit-scrollbar-thumb { background: var(--ai-border); border-radius: 2px; }
.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; }
