/* AI Mode chat widget — matches site theme via CSS variables */
#ai-mode-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-ink);
  color: var(--color-ink-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#ai-mode-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3); }
#ai-mode-fab .ai-spark {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  align-items: center;
  justify-content: center;
}
#ai-mode-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5rem;
  z-index: 9999;
  width: min(24rem, calc(100vw - 2.5rem));
  height: min(32rem, calc(100vh - 8rem));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  font-family: var(--font-body);
}
#ai-mode-panel.open { display: flex; }
#ai-mode-panel .ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--color-ink);
  color: var(--color-ink-text);
}
#ai-mode-panel .ai-head strong { font-size: 0.95rem; letter-spacing: 0.02em; }
#ai-mode-panel .ai-head small { display: block; font-weight: 400; opacity: 0.75; font-size: 0.72rem; }
#ai-mode-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
#ai-mode-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  font-size: 0.88rem;
  line-height: 1.55;
}
.ai-msg { max-width: 88%; padding: 0.6rem 0.85rem; border-radius: 0.9rem; }
.ai-msg.bot {
  align-self: flex-start;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 0.25rem;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--color-ink);
  color: var(--color-ink-text);
  border-bottom-right-radius: 0.25rem;
}
.ai-msg a { color: var(--color-accent); text-decoration: underline; }
#ai-mode-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.6rem;
}
#ai-mode-chips button {
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}
#ai-mode-chips button:hover { background: var(--color-surface-2); }
#ai-mode-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 1rem 1rem;
  border-top: 1px solid var(--color-border);
}
#ai-mode-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
}
#ai-mode-input:focus { border-color: var(--color-accent); }
#ai-mode-send {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-full);
  border: 0;
  background: var(--color-ink);
  color: var(--color-ink-text);
  cursor: pointer;
}
@media (max-width: 480px) {
  #ai-mode-fab { right: 1rem; bottom: 1rem; left: 1rem; justify-content: center; }
  #ai-mode-panel {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 4.75rem;
    width: auto;
    height: 70vh;
    height: 70dvh;
  }
  #ai-mode-input { font-size: 16px; }
}
