/* ai-assistant.css — the design assistant's launcher and panel (Stop 75; js/ai-assistant.js). Admin-only: the script
   builds them only while /api/me says so. Both stand above the price bar (--ai-bottom, set by the script from where
   the bar is), only on the two design screens, and never over an open dialog or a view-only link. */

#ai-launch, #ai-panel { position: fixed; right: 16px; bottom: var(--ai-bottom, 96px); z-index: 800; box-sizing: border-box; font-family: var(--f-ui, Arial, sans-serif); }
body:not(:has(#s-room.active, #s-config.active)) :is(#ai-launch, #ai-panel, #ai-chats-page),
body:has(dialog[open]) :is(#ai-launch, #ai-panel, #ai-chats-page),
html.view-only :is(#ai-launch, #ai-panel, #ai-chats-page),
#ai-launch[hidden], #ai-panel[hidden], #ai-chats-page[hidden] { display: none; }

/* Stop 78 item 2: the admin's "Chats (n)" on the page itself, by the design's name — a small pill above the launcher. */
#ai-chats-page {
  position: fixed; right: 16px; bottom: calc(var(--ai-bottom, 96px) + 52px); z-index: 800; box-sizing: border-box;
  display: inline-flex; align-items: center; gap: 8px; max-width: min(320px, calc(100vw - 32px)); min-height: 36px; padding: 0 14px;
  border: 1px solid var(--b-light, #D8CFBF); border-radius: 999px; background: var(--paper, #FCFBF8); color: var(--t-dark, #14110B);
  font: 500 13px/1.2 var(--f-ui, Arial, sans-serif); text-decoration: none; box-shadow: 0 4px 14px rgba(20, 17, 11, 0.14);
}
#ai-chats-page .ai-chats-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--t-mid, #4A3C28); }
#ai-chats-page .ai-chats-n { white-space: nowrap; text-decoration: underline; text-underline-offset: 2px; }
#ai-chats-page:focus-visible { outline: 2px solid var(--gold, #B08D3C); outline-offset: 2px; }

/* The launcher: the plan's dark pill (styles.css #rp-placing). */
#ai-launch {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px 0 14px;
  border: 1px solid var(--ink, #14110B); border-radius: 999px; background: var(--ink, #14110B); color: #fff;
  font: 500 13px/1.2 var(--f-ui, Arial, sans-serif); cursor: pointer; box-shadow: 0 6px 20px rgba(20, 17, 11, 0.22);
}
#ai-launch:hover { background: var(--ink-4, #3A2E1E); }
#ai-launch .ai-launch-mark { color: var(--gold-3, #D9B968); font-size: 14px; }

#ai-panel {
  display: flex; flex-direction: column; width: 380px; max-width: calc(100vw - 32px);
  height: min(560px, calc(100dvh - var(--ai-bottom, 96px) - var(--hdr-h, 64px) - 24px)); min-height: 280px;
  background: var(--paper, #FCFBF8); color: var(--t-dark, #14110B);
  border: 1px solid var(--b-light, #D8CFBF); border-radius: var(--r3, 3px); box-shadow: 0 10px 30px rgba(20, 17, 11, 0.18);
}
.ai-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 8px 12px 16px; border-bottom: 1px solid var(--b-faint, #E7E0D2); }
.ai-title { margin: 0; font: 500 19px/1.2 var(--f-head, Georgia, serif); }
.ai-sub { margin: 3px 0 0; font-size: 12px; line-height: 1.4; color: var(--t-sub, #746753); }
.ai-sub a { color: var(--t-mid, #4A3C28); text-underline-offset: 2px; white-space: nowrap; }   /* Stop 77: the privacy notice; the admin's "Chats (n)" */
.ai-sub a + a { margin-left: 8px; }
.ai-close { flex: none; width: 44px; height: 44px; margin-top: -8px; border: 0; background: transparent; color: var(--t-mid, #4A3C28); font-size: 24px; line-height: 1; cursor: pointer; }
.ai-close:hover { color: var(--t-dark, #14110B); }

.ai-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px 4px; overscroll-behavior: contain; }
.ai-hint { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: var(--t-mid, #4A3C28); }
.ai-msg { margin: 0 0 14px; }
.ai-who { display: block; margin-bottom: 3px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t-sub, #746753); }
.ai-words { margin: 0; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-you .ai-words { padding: 9px 12px; background: var(--cream, #F4EFE6); border-radius: var(--r3, 3px); }
.ai-note .ai-words { padding: 9px 12px; border-left: 3px solid var(--warning, #884800); background: var(--cream, #F4EFE6); color: var(--t-dark, #14110B); }
.ai-undo {
  margin-top: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--gold-line, rgba(176, 141, 60, 0.3)); border-radius: var(--r, 2px);
  background: transparent; color: var(--t-dark, #14110B); font: 500 13px/1.2 var(--f-ui, Arial, sans-serif); cursor: pointer;
}
.ai-undo:hover:not(:disabled) { background: var(--gold-pale, rgba(176, 141, 60, 0.14)); border-color: var(--gold-2, #C9A14A); }
.ai-undo:disabled { color: var(--t-sub, #746753); border-color: var(--b-faint, #E7E0D2); cursor: default; }

.ai-status { min-height: 20px; margin: 0; padding: 2px 16px 6px; font-size: 13px; line-height: 1.4; color: var(--t-sub, #746753); }
.ai-status.on { color: var(--t-mid, #4A3C28); }
.ai-status.on::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--gold, #B08D3C); animation: ai-pulse 1.1s ease-in-out infinite; }
@keyframes ai-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-status.on::before { animation: none; } }

.ai-steve-row { padding: 0 16px 6px; }
.ai-steve {
  width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--gold-line, rgba(176, 141, 60, 0.3)); border-radius: var(--r, 2px);
  background: transparent; color: var(--t-dark, #14110B); font: 500 13px/1.2 var(--f-ui, Arial, sans-serif); cursor: pointer;
}
.ai-steve:hover:not(:disabled) { background: var(--gold-pale, rgba(176, 141, 60, 0.14)); border-color: var(--gold-2, #C9A14A); }
.ai-steve:disabled { color: var(--t-sub, #746753); border-color: var(--b-faint, #E7E0D2); cursor: default; }
.ai-steve:focus-visible { outline: 2px solid var(--gold, #B08D3C); outline-offset: 2px; }
/* Voice (Stop 76 item 5): the speaker toggle in the header, and the microphone's one setting above the box. */
.ai-head > div { margin-right: auto; }
.ai-speak { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-top: -8px; border: 1px solid transparent; border-radius: var(--r, 2px); background: transparent; color: var(--t-sub, #746753); cursor: pointer; }
.ai-speak[hidden] { display: none; }
.ai-speak:hover { color: var(--t-dark, #14110B); }
.ai-speak[aria-pressed="true"] { color: var(--t-dark, #14110B); border-color: var(--gold, #B08D3C); background: var(--gold-pale, rgba(176, 141, 60, 0.14)); }
.ai-speak[aria-pressed="true"] .ai-mute, .ai-speak[aria-pressed="false"] .ai-waves { display: none; }
.ai-opts { display: flex; flex-wrap: wrap; gap: 0 16px; padding: 0 16px 2px; }
.ai-opts[hidden], .ai-opt[hidden] { display: none; }
.ai-opt { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13px; line-height: 1.3; color: var(--t-mid, #4A3C28); cursor: pointer; }
.ai-opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink, #14110B); }
.ai-form { padding: 10px 16px 14px; border-top: 1px solid var(--b-faint, #E7E0D2); }
.ai-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#ai-text {
  display: block; width: 100%; box-sizing: border-box; min-height: 56px; max-height: 140px; padding: 10px 12px; resize: none;
  border: 1px solid var(--b-light, #D8CFBF); border-radius: var(--r, 2px); background: #fff; color: var(--t-dark, #14110B);
  font: 400 16px/1.45 var(--f-ui, Arial, sans-serif);   /* (16 px: a phone does not zoom the page to type) */
}
.ai-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ai-cost { margin-right: auto; font-size: 12px; line-height: 1.4; color: var(--t-sub, #746753); }
.ai-mic {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--b-light, #D8CFBF); border-radius: var(--r, 2px);
  background: transparent; color: var(--t-dark, #14110B); font: 500 13px/1.2 var(--f-ui, Arial, sans-serif); cursor: pointer;
}
.ai-mic[hidden] { display: none; }
/* The microphone's level while it listens (Stop 80 item 1): a still bar is a microphone hearing nothing. */
.ai-meter { width: 48px; height: 6px; border-radius: 3px; background: var(--b-light, #D8CFBF); overflow: hidden; }
.ai-meter[hidden] { display: none; }
.ai-meter i { display: block; width: 0; height: 100%; background: var(--gold, #B08D3C); }
.ai-mic.on { border-color: var(--gold, #B08D3C); background: var(--gold-pale, rgba(176, 141, 60, 0.14)); }
.ai-send { min-height: 44px; padding: 0 22px; }
.ai-send:disabled, .ai-mic:disabled { opacity: 0.5; cursor: default; }

:is(#ai-launch, .ai-close, .ai-speak, .ai-undo, .ai-mic, .ai-log):focus-visible, .ai-opt input:focus-visible { outline: 2px solid var(--gold, #B08D3C); outline-offset: 2px; }
#ai-text:focus-visible { outline: 2px solid var(--ink, #14110B); outline-offset: 1px; }

/* A phone: the panel takes the width, above the price bar. */
@media (max-width: 600px) {
  #ai-launch, #ai-panel { right: 8px; }
  #ai-panel { left: 8px; width: auto; max-width: none; height: min(560px, calc(100dvh - var(--ai-bottom, 96px) - 64px)); }
}
