.assistant-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 4.5rem;
  z-index: 1200;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--text-on-primary);
  font-size: 1.35rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.assistant-fab.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.home-entry-card.is-assistant-disabled {
  opacity: 0.72;
}

.assistant-panel {
  position: fixed;
  right: 1rem;
  bottom: 8rem;
  z-index: 1201;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(70vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.assistant-panel.hidden {
  display: none;
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.assistant-header h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-title);
}

.assistant-messages {
  flex: 1;
  overflow: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.assistant-msg-user .assistant-bubble {
  margin-left: auto;
  background: var(--primary-soft);
  color: var(--text-title);
}

.assistant-msg-assistant .assistant-bubble {
  margin-right: auto;
  background: var(--surface-muted);
  color: var(--text-body);
}

.assistant-bubble {
  max-width: 92%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-body);
}

.assistant-bubble.assistant-md {
  white-space: normal;
}

.assistant-bubble.assistant-md p {
  margin: 0 0 0.5rem;
}

.assistant-bubble.assistant-md p:last-child {
  margin-bottom: 0;
}

.assistant-bubble.assistant-md ul,
.assistant-bubble.assistant-md ol {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.25rem;
}

.assistant-bubble.assistant-md li {
  margin: 0.2rem 0;
}

.assistant-bubble.assistant-md li > ul,
.assistant-bubble.assistant-md li > ol {
  margin-top: 0.2rem;
  margin-bottom: 0;
}

.assistant-bubble.assistant-md h1,
.assistant-bubble.assistant-md h2,
.assistant-bubble.assistant-md h3,
.assistant-bubble.assistant-md h4 {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-title);
  line-height: 1.35;
}

.assistant-bubble.assistant-md h1:first-child,
.assistant-bubble.assistant-md h2:first-child,
.assistant-bubble.assistant-md h3:first-child,
.assistant-bubble.assistant-md h4:first-child {
  margin-top: 0;
}

.assistant-bubble.assistant-md strong,
.assistant-bubble.assistant-md b {
  font-weight: 600;
  color: var(--text-title);
}

.assistant-bubble.assistant-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface-muted);
}

.assistant-bubble.assistant-md pre {
  margin: 0.35rem 0;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: var(--surface-muted);
  overflow-x: auto;
  max-width: 100%;
}

.assistant-bubble.assistant-md pre code {
  padding: 0;
  background: transparent;
}

.assistant-bubble.assistant-md blockquote {
  margin: 0.35rem 0;
  padding-left: 0.65rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.assistant-bubble.assistant-md a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.assistant-bubble.assistant-md a:hover {
  opacity: 0.85;
}

.assistant-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.assistant-cite-btn {
  border: 1px solid var(--border-strong);
  background: var(--hover-fill);
  color: var(--text-body);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.assistant-cite-btn:hover {
  background: var(--hover-fill);
  border-color: var(--hover-border);
}

.assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 1rem 0.5rem;
}

.assistant-suggestions button {
  font-size: 0.75rem;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: var(--hover-fill);
  color: var(--text-body);
  padding: 0.2rem 0.55rem;
  cursor: pointer;
}

.assistant-suggestions button:hover {
  border-color: var(--hover-border);
  color: var(--text-title);
}

.assistant-compose {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.35rem;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}

.assistant-compose textarea {
  flex: 1;
  min-height: 2.5rem;
  max-height: 6rem;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-body);
  padding: 0.45rem 0.55rem;
  font: inherit;
}

.assistant-compose textarea::placeholder {
  color: var(--text-muted);
}

.assistant-mic {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

.assistant-mic:hover:not(:disabled) {
  border-color: var(--hover-border);
}

.assistant-mic.is-listening {
  background: var(--error, #c44);
  color: #fff;
  border-color: transparent;
  animation: assistant-mic-pulse 1.2s ease-in-out infinite;
}

.assistant-mic:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes assistant-mic-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.assistant-voice-opt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1rem 0.65rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  user-select: none;
}

.assistant-voice-opt input {
  margin: 0;
}

.assistant-status {
  padding: 0 1rem 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1rem;
}

.assistant-status.is-listening {
  color: var(--primary);
}

@media (max-width: 640px) {
  .assistant-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: 5.5rem;
  }
}
