
/* Text size (settings): 1 = normal, 2 = +1, 3 = +2. rem/em text scales with the root; the px-sized controls use --fs directly. */
:root { --fs: 1; }
html[data-fs="1"] { --fs: 1.15; }
html[data-fs="2"] { --fs: 1.3; }
html { font-size: calc(100% * var(--fs)); }

body {
  font-family: Arial, sans-serif;
  background: #fff;
  color: #333;
  margin: 0;
  padding: 12px;
}

@media(max-width: 767px) {
  body {
    font-family: Arial, sans-serif;
    background: #fff;
    color: #333;
    margin: 0;
    padding: 6px;
  }
}

#app {
  max-width: 768px;
  margin: auto;
}

:root {
  /* --color-primary / --color-secondary come from theme-vars.php (theme.json) */
  --color-primary-light: #97df76;
  --color-primary-lighter: #c1e2b3;
  --color-secondary-lighter: #96CFF5;
  --color-tertiary: #5C3E7E;
  --color-tertiary-light: #8D67B8;
  --color-tertiary-lighter: #B89DDC;
  --color-quaternary: #F07822;
  --color-quaternary-light: #FEB389;
  --color-quaternary-lighter: #FEDAC7;

}

.controls {
  display: flex;
  margin-top: 1em;
  gap: 12px;
}


:root {
  --bottom-offset: 180px;
}

.home-category h3 {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}
.home-category h3 svg {
  margin-top: -3px;
  margin-right: 6px;
  height: 30px;
  width: 30px;
}
.home-category h3 svg path {
  fill:var(--color-secondary-light);
}

#record {
  width: 40%;
  max-width: 160px;
  flex-shrink: 0;
  padding: 0.8em 12px;
  font-size: calc(15px * var(--fs));
  background: var(--color-secondary-light);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
#record svg path {
  fill: #fff;
  margin-right: 9px;
}

#textInput {
  width: 60%;
  flex: 1;
  padding: 0.8em;
  font-size: calc(15px * var(--fs));
  border-radius: 6px;
  border: 1px solid #ccc;
}

/* Shrink the audio player and float it to the corner */
.tiny-audio {
  width: 28px;
  height: 28px;
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  margin-top: -6px;
  float: right;
  opacity: 0.7;
  background: transparent;
}

/* Hide timeline, just show the button */
.tiny-audio::-webkit-media-controls-panel {
  background: none;
}
.tiny-audio::-webkit-media-controls-timeline,
.tiny-audio::-webkit-media-controls-current-time-display,
.tiny-audio::-webkit-media-controls-time-remaining-display,
.tiny-audio::-webkit-media-controls-volume-slider {
  display: none !important;
}

.chat-container {
  border: 1px solid #ccc;
  padding: 1em;
  height: calc(100vh - var(--bottom-offset)); /* -200px */
  overflow-y: auto;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
}
@media(max-width: 700px) {
  .chat-container {
    padding: 0.7em;
  }
}

.chat-bubble {
  margin: 18px 0px;
  padding: 0px;
  border-radius: 10px;
  /* max-width: 85%; */
  width: 95%;
}
@media(max-width: 640px) {
  .chat-bubble {
    width: 98%;
  }
}

.chat-bubble.user {
  background: transparent; /* d0f0ff */
  align-self: flex-end;
}

.chat-bubble.assistant {
  background: transparent; /* e8e8e8 */
  align-self: flex-start;
}

/* .chat-bubble .timestamp {
  display: block;
  font-size: 0.75em;
  color: #888;
  margin-top: 4px;
  text-align: right;
} */


.chat-bubble {
  display: flex;
  flex-direction: column;
  margin-bottom: 0px;
}

.chat-bubble .message-text {
  color: #333;
  font-size: 0.84rem;
  line-height: 1.3rem;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 500;
}
.chat-bubble.user .message-text {
  background: #d0f0ff;
  font-style: italic;
  font-weight: 400;
}
.chat-bubble.assistant .message-text {
  background: #e8e8e8;
  font-weight: 400;
}

/* Image-generation "please wait" bubble: highlight border that fades out after 3s. */
.chat-bubble.img-patience .message-text {
  border: solid 2px #ffc863;
  animation: imgPatienceBorderFade 0.8s ease-out 3s forwards;
}
@keyframes imgPatienceBorderFade {
  to { border-color: transparent; }
}

.chat-bubble .timestamp {
  font-size: 0.73rem;
  color: #888;
  margin-top: 2px;
  text-align: right;
}

.play-button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.73em;
  margin-left: 6px;
  opacity: 0.7;
  transition: opacity 0.2s;
  text-align: right;
  padding: 0px;
}
.play-button:hover {
  opacity: 1;
}

/* "Yes - please continue" under a long reply: stands out from the small Replay / Full Audio links */
.play-button.continue-button {
  font-size: 0.85em;
  font-weight: 600;
  opacity: 1;
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: #3b82f6;
}
.play-button.continue-button:hover {
  background: rgba(59, 130, 246, 0.15);
}
.play-button.continue-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.stop-button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.73em;
  margin-left: 6px;
  opacity: 0.7;
  transition: opacity 0.2s;
  color: #d9534f;
  padding: 0px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.stop-button:hover {
  opacity: 1;
}
.stop-button-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(217, 83, 79, 0.25);
  border-top-color: #d9534f;
  border-radius: 50%;
  animation: stop-spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes stop-spin {
  to { transform: rotate(360deg); }
}

.graph-this-btn {
  background: none;
  border: 1px solid var(--color-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72em;
  margin-left: 8px;
  padding: 7px 7px;
  color: var(--color-secondary);
  opacity: 0.8;
  transition: opacity 0.2s, background 0.2s;
  white-space: nowrap;
  display: flex;
  justify-content: center;
  align-items: center;
}
.graph-this-btn:hover {
  opacity: 1;
  background: var(--color-secondary-light);
  color: #fff;
}

/* "Preview Post" button — shown on social post image responses (opens modal) */
.share-post-btn {
  background: none;
  border: 1px solid var(--color-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72em;
  margin-right: 8px;
  padding: 7px 7px;
  color: var(--color-secondary);
  opacity: 0.8;
  transition: opacity 0.2s, background 0.2s;
  white-space: nowrap;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.share-post-btn:hover {
  opacity: 1;
  background: var(--color-secondary-light);
  color: #fff;
}
.share-post-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* "Copy Message" button — shown on email/SMS draft responses */
.copy-message-btn {
  background: none;
  border: 1px solid var(--color-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72em;
  margin-right: 8px;
  padding: 7px 7px;
  color: var(--color-secondary);
  opacity: 0.8;
  transition: opacity 0.2s, background 0.2s;
  white-space: nowrap;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.copy-message-btn:hover {
  opacity: 1;
  background: var(--color-secondary-light);
  color: #fff;
}
.copy-message-btn.copied {
  opacity: 0.6;
  cursor: default;
}
/* Small screens: Copy / Share / Download show just their icon (the "Copied" confirmation still shows its word for a moment) */
@media (max-width: 600px) {
  .copy-message-btn .tool-label { display: none; }
  .copy-message-btn.copied .tool-label { display: inline; }
  .copy-message-btn { padding: 7px 9px; }
  /* the tools row wraps onto a second line instead of running off the screen; labels stay on one line */
  .bubble-tools-wrapper { flex-wrap: wrap; row-gap: 6px; }
  .play-button, .stop-button, .graph-this-btn { white-space: nowrap; }
}

.chart-download-btn {
  margin-left: 12px;
}

/* ── Share Preview Modal ─────────────────────────────── */
.share-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.share-preview-overlay.share-preview-visible {
  opacity: 1;
}
.share-preview-modal {
  position: relative;
  background: var(--color-bg, #fff);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  /* No overflow here — scrolling is handled by .share-preview-scroll */
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  transition: transform 0.18s ease;
}
.share-preview-overlay.share-preview-visible .share-preview-modal {
  transform: translateY(0);
}

/* Scrollable content area — image + caption; image fills the top of the modal */
.share-preview-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  /* no border-radius here — footer handles the bottom corners */
}

/* Close button — floats over the image, never scrolls */
.share-preview-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.45);
  background: var(--color-secondary-light);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  backdrop-filter: blur(2px);
}
.share-preview-close:hover {
  background: rgba(0, 0, 0, 0.65);
}

/* Generated image — goes all the way to the top of the modal */
.share-preview-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px 14px 0 0;
  display: block;
}

/* Pinned footer — buttons + tip; always visible, never scrolls */
.share-preview-footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--color-bg, #fff);
  border-radius: 0 0 14px 14px;
  padding: 12px 16px 14px;
}

/* Post body */
.share-preview-body {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.share-preview-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text, #111);
  line-height: 1.3;
}
.share-preview-platform {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-secondary, #4a90d9);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.share-preview-caption {
  font-size: 0.85rem;
  color: var(--color-text-muted, #444);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.share-preview-hashtag {
  color: var(--color-secondary, #4a90d9);
  font-weight: 500;
}

/* Action row — lives inside .share-preview-footer (no extra padding/border needed) */
.share-preview-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.share-preview-copy-btn {
  background: none;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--color-text-muted, #555);
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.share-preview-copy-btn:hover {
  border-color: var(--color-secondary, #4a90d9);
  color: var(--color-secondary, #4a90d9);
}
.share-preview-share-btn {
  background: var(--color-secondary, #4a90d9);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.share-preview-share-btn:hover {
  opacity: 0.88;
}
.share-preview-share-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Instagram tip — sits below the action buttons, inside the pinned footer */
.share-preview-instagram-tip {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  line-height: 1.4;
}

/* Hint message shown after download+copy fallback — lives inside .share-preview-footer */
.share-hint-msg {
  margin: 8px 0 0;
  padding: 10px 14px;
  background: #eaf4ff;
  border-left: 3px solid var(--color-secondary, #4a90d9);
  border-radius: 6px;
  font-size: 0.82rem;
  color: #1a4a6e;
  line-height: 1.45;
  animation: fadeInUp 0.2s ease;
}

.chat-bubble.user .play-button {
  text-align: right;
}

.chat-bubble.assistant .play-button {
  text-align: left;
}

.chat-bubble.assistant .stop-button {
  text-align: left;
}

.chat-bubble.user .timestamp {
  text-align: right;
}
.chat-bubble.assistant .timestamp {
  text-align: left;
}

.bubble-tools-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0px;
  margin-top: 6px;
  padding: 0px 6px;
}

.chat-bubble.user .bubble-tools-wrapper {
  justify-content: flex-end;
}

/* "What can you do?" cheat sheet modal */
.cheat-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}
.cheat-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  border-radius: 14px;
  background: #fff;
  color: #222;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.cheat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid #ddd;
}
.cheat-head h3 { margin: 0 0 4px; font-size: 1.2rem; }
.cheat-head p { margin: 0; font-size: 0.85rem; color: #666; }
.cheat-close {
  border: 0;
  background: transparent;
  color: #888;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
}
.cheat-close:hover { color: var(--color-primary, #2563eb); }
.cheat-body { padding: 8px 20px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cs-section { margin-top: 16px; }
.cs-section h4 { margin: 0 0 6px; font-size: 0.95rem; color: var(--color-primary, #2563eb); }
.cs-note { margin: 0 0 8px; font-size: 0.8rem; color: #777; line-height: 1.25rem; }
.cs-phrase {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 8px 12px;
  border: 1px solid #bfc9e2;
  border-radius: 8px;
  background: #e0f0f8;
  color: #222;
  font-size: 0.85rem;
  font-style: italic;
  text-align: left;
  cursor: pointer;
}
.cs-phrase:hover { background: #d0f0ff; }
.cs-list { margin: 0; padding-left: 18px; font-size: 0.85rem; line-height: 1.4rem; }
html[data-theme="dark"] .cheat-dialog { background: var(--d-raised); color: var(--d-text); }
html[data-theme="dark"] .cheat-head { border-color: var(--d-border); }
html[data-theme="dark"] .cheat-head p, html[data-theme="dark"] .cs-note { color: var(--d-muted); }
html[data-theme="dark"] .cs-phrase { background: var(--d-surface); border-color: var(--d-border); color: var(--d-text); }
html[data-theme="dark"] .cs-phrase:hover { background: var(--d-bg); }

/* "Undo to here" icon at the right of your own messages + its confirmation dialog */
.undo-here-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #888;
  cursor: pointer;
}
.undo-here-btn:hover, .undo-here-btn:focus-visible { color: var(--color-primary, #2563eb); background: rgba(127, 127, 127, 0.15); }
.undo-here-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}
.undo-here-dialog {
  width: 100%;
  max-width: 360px;
  padding: 22px 22px 18px;
  border-radius: 14px;
  background: #fff;
  color: #222;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.undo-here-dialog h3 { margin: 0 0 8px; font-size: 1.15rem; }
.undo-here-dialog p { margin: 0 0 18px; font-size: 0.9rem; line-height: 1.35rem; color: #555; }
.undo-here-actions { display: flex; justify-content: flex-end; gap: 10px; }
.undo-here-actions button {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.undo-here-confirm { border: 0; background: var(--color-primary, #2563eb); color: #fff; }
.undo-here-cancel { border: 1px solid #c9cfd8; background: transparent; color: #6b7280; font-weight: 500; }
.undo-here-actions button:disabled { opacity: 0.6; cursor: default; }
html[data-theme="dark"] .undo-here-dialog { background: var(--d-raised); color: var(--d-text); }
html[data-theme="dark"] .undo-here-dialog p { color: var(--d-muted); }
html[data-theme="dark"] .undo-here-cancel { border-color: var(--d-border); color: var(--d-muted); }
.chat-bubble.assistant .bubble-tools-wrapper {
  justify-content: flex-start;
}

.chat-bubble.user .message-text.thinking,
.chat-bubble.assistant .message-text.thinking {
  color: #666;
  font-style: italic;
  opacity: 0.8;
  transition: color 0.3s ease, opacity 0.3s ease;
}

.chat-bubble.user .message-text,
.chat-bubble.assistant .message-text {
  transition: color 0.3s ease, opacity 0.3s ease;
}


/* MD styling */
.chat-bubble.assistant .message-text p {
  margin: 4px 0;
}

.chat-bubble.assistant .message-text code {
  background: #f2f2f2;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}

.chat-bubble.assistant .message-text pre code {
  display: block;
  padding: 8px;
  overflow-x: auto;
}


.session-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  z-index: 1000;
}
.session-panel {
  position: fixed;
  right: -360px;
  top: 0;
  width: 280px;
  height: 100%;
  background: #fff;
  border-left: 1px solid #ccc;
  box-shadow: -2px 0 6px rgba(0,0,0,0.1);
  transition: right 0.3s ease;
  z-index: 999;
  overflow-y: auto;
  padding: 16px;
}
.session-panel.open {
  right: 0;
}
.session-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 8px;
  cursor: pointer;
}
.session-item:hover {
  background: #eee;
}

.chat-controls {
  position: relative;
  width: calc(100% - 12px);
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  margin: 6px 6px 12px 6px;
}

.session-btn {
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease;
}

.session-btn:hover {
  background: #333;
}

.session-btn.clear {
  background: #b33;
}

.session-btn.clear:hover {
  background: #c44;
}

.control-btn {
  background: #444;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
}

.control-btn.danger {
  background: #b33;
}
.control-btn.primary {
  background: var(--color-secondary-light);
}
.control-btn.secondary {
  background: #ddd;
  color: #333;
}

.control-btn.primary svg path {
  fill: #fff;
}

#app-home.control-btn {
  background: #ddd;
  color: #222;
  border: none;
  border-radius: 6px;
  border: solid 2px var(--color-secondary-light);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
#app-home svg path {
  fill: var(--color-secondary-light);
}


.session-panel {
  position: fixed;
  right: -360px;
  top: 0;
  height: 100%;
  width: 280px;
  background: #f4f4f4;
  border-left: 2px solid #ccc;
  box-shadow: -3px 0 10px rgba(0, 0, 0, 0.15);
  padding: 15px;
  transition: right 0.3s ease;
  overflow-y: auto;
  z-index: 1000;
}

.session-panel.open {
  right: 0;
}

.session-panel h3 {
  margin-top: 0;
}


.session-item {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: stretch;
}

.session-load-btn {
  flex: 1;
  text-align: left;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-load-btn:hover {
  background: #e9e9e9;
}

.session-delete-btn {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.session-delete-btn:hover {
  background: #fee;
  border-color: #b33;
}


.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.session-header h3 {
  margin: 0;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.close-btn:hover {
  background: #ddd;
  color: #333;
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.user-info-label {
  margin-left: auto;
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  align-self: center;
  padding: 0 4px;
}

/* Image generation loading spinner */
.image-loading {
  display: inline-block;
  margin-left: 8px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(100, 150, 255, 0.3);
  border-top-color: #6496ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Recording pulse overlay ─────────────────────────────────────────────── */
#recording-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;   /* clicks fall through to the button underneath */
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.15s ease;
}
#recording-overlay.active {
  opacity: 1;
}
.recording-pulse-dot {
  width: 72px;
  height: 72px;
  background: #e53935;
  border-radius: 50%;
  position: relative;
}
.recording-pulse-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(229, 57, 53, 0.4);
  border-radius: 50%;
  animation: recording-pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes recording-pulse-ring {
  0%   { transform: scale(0.33); opacity: 1; }
  80%, 100% { transform: scale(2.5); opacity: 0; }
}
.recording-overlay-label {
  margin-top: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e53935;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.9;
}

.generating-text {
  font-style: italic;
  color: #6496ff;
}


#quickActions {
    padding: 0px 0px 12px 0px;
    margin: 0px 0px 18px 0px;
    border-bottom: 1px solid #ddd;
}

#quickActions h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.5px;
}

/* .quick-action-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin-bottom: 9px;
    background: #445669;
    border: 1px solid #d0d9f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    transition: background 0.2s;
}

.quick-action-btn:hover {
    background: #4d5f74;
} */

.quick-action-btn {
    /* display: block; */
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin-bottom: 7px;
    background: #e0f0f8; /* d0f0ff */
    border: 1px solid #bfc9e2; /* d0d9f0 */
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #222;
    transition: background 0.2s;
    display: flex;
    flex-direction: row;
    gap: 9px;
    justify-content: flex-start;
    align-items: center;
}

.quick-action-btn:hover {
    background: #d0f0ff; /* daf1fc */
}


#home-panel {
    display: none;
    flex-direction: column;
    height: calc(100vh - var(--bottom-offset));
    overflow-y: auto;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 10px;
}

.home-grid h2 {
    margin: 0 0 24px 0;
    font-size: 1.3rem;
    color: #333;
}

.home-category {
    margin-bottom: 24px;
}

.home-category h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #555;
    border-bottom: 1px solid #ddd;
    padding-bottom: 6px;
}

.home-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.home-buttons button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 9px 14px;
    background: #e0f0f8;
    border: 1px solid #bfc9e2;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.home-buttons button:hover {
    background: #d0f0ff;
}

.home-buttons button strong {
    font-size: 0.9rem;
    color: #222;
    margin-bottom: 4px;
}

.home-buttons button span {
    font-size: 0.78rem;
    color: #666;
    line-height: 1.3;
}
/* ── Invite followup action card ─────────────────────────── */
.invite-followup-card {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.invite-followup-btn {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--color-secondary, #4a90d9);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.invite-followup-yes {
  background: var(--color-secondary, #4a90d9);
  color: #fff;
}
.invite-followup-yes:hover { opacity: 0.85; }
.invite-followup-no {
  background: transparent;
  color: var(--color-secondary, #4a90d9);
}
.invite-followup-no:hover { background: #f0f7ff; }

/* ── Template picker (inline in chat bubble) ─────────────── */
.template-picker-inline {
  margin-top: 12px;
  padding: 14px;
  background: #f8f9fb;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
}
.template-picker-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: #222;
}
.template-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.template-card {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: center;
}
.template-card:hover {
  border-color: var(--color-secondary, #4a90d9);
  box-shadow: 0 2px 8px rgba(74,144,217,0.2);
}
.template-card-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: contain;
  background: #f5f5f5;
  display: block;
}
.template-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f7ff;
  font-size: 2rem;
  color: #aac;
}
.template-card-name {
  font-size: 0.75rem;
  padding: 6px 8px;
  color: #333;
  line-height: 1.3;
}
.template-picker-cancel {
  display: block;
  margin: 0 auto;
  padding: 6px 20px;
  border: 1px solid #ccc;
  border-radius: 16px;
  background: transparent;
  font-size: 0.82rem;
  cursor: pointer;
  color: #666;
}
.template-picker-cancel:hover { background: #f5f5f5; }

/* ── Product offer picker (inline in chat bubble) ─────────── */
.product-picker-inline {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.product-option-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  border: 2px solid #d0e8ff;
  border-radius: 8px;
  background: #f0f7ff;
  color: #1a4a7a;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.product-option-btn:hover {
  background: #daeeff;
  border-color: #4a9cd6;
}

/* ===== v2 additions ===== */
/* Right side of the toolbar: username, then language */
.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar-right .user-info-label { margin-left: 0; }

/* Language dropdown: flag + 2-letter code in the toolbar, flag + native name in the list */
.lang-menu { position: relative; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--color-primary-border, #ccc);
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 13px; font-weight: 600; letter-spacing: .03em;
  cursor: pointer;
}
.lang-btn::after { content: ""; border: 4px solid transparent; border-top-color: #777; margin-top: 4px; }
.lang-btn:hover:not(:disabled) { background: var(--color-primary-faint, #f3f7fd); }
.lang-btn:disabled { opacity: .5; cursor: not-allowed; }
.lang-flag { width: 18px; height: 12px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); flex: none; display: block; }
.lang-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 1000;
  min-width: 160px; margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.lang-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; color: #222;
}
.lang-list li:hover, .lang-list li.active { background: var(--color-primary-faint, #f3f7fd); }
.lang-list li[aria-selected="true"] { font-weight: 600; }
.lang-list li[aria-selected="true"]::after { content: "✓"; margin-left: auto; color: var(--color-primary, #1274dd); }
/* Settings (cog) menu: username + logout */
.settings-menu { position: relative; }
.settings-btn { padding: 6px 8px; }
.settings-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 1000;
  min-width: 200px; padding: 6px;
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.settings-user {
  padding: 8px 10px 10px; font-size: 13px; color: #666;
  border-bottom: 1px solid #eee; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}
.settings-user strong { color: #222; }
.settings-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 6px; background: none;
  font-size: calc(14px * var(--fs)); color: #222; cursor: pointer; text-align: left;
}
.settings-item svg { width: 20px; height: 20px; fill: currentColor; }
.settings-item:hover:not(:disabled) { background: var(--color-primary-faint, #f3f7fd); }
.settings-item:disabled { opacity: .5; cursor: not-allowed; }

/* Narrow screens: icon-only toolbar buttons to save space */
@media (max-width: 600px) {
  .chat-controls .control-btn > span { display: none; }
  .chat-controls { gap: 6px; }
  .lang-btn { padding: 6px 8px; }
}

.cancel-row { margin-top: 4px; }

/* v2: inline charts */
.chart-container { position: relative; width: 100%; max-width: 560px; height: 300px; margin: 8px 0; background: #fff; border-radius: 8px; padding: 8px; box-sizing: border-box; }
@media (max-width:600px) { .chart-container { height: 240px; } }

/* v2: voice jobs (Aider / ComfyUI) */
.job-card { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; padding: 10px 12px; border: 1px dashed var(--color-primary, #1274dd); border-radius: 10px; font-size: 0.9rem; color: #444; background: rgba(18,116,221,0.05); max-width: 640px; }
.job-card .job-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.job-card.expanded { align-items: flex-start; }
.job-card.expanded .job-text { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.job-card .job-text:focus-visible { outline: 2px solid var(--color-primary, #1274dd); outline-offset: 2px; border-radius: 4px; }
.job-cancel-btn { border: 1px solid #ccc; background: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 0.85rem; }
.job-cancel-btn:hover { border-color: #c62828; color: #c62828; }
.reply-video { display: block; width: 100%; max-width: 560px; margin-top: 10px; border-radius: 8px; background: #000; }

/* v2: send button inside the text box */
.input-wrap { position: relative; flex: 1; display: flex; min-width: 0; }
.input-wrap #textInput { width: 100%; padding-right: 44px; box-sizing: border-box; }
#sendBtn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center; border: none; border-radius: 50%; background: transparent;
  color: #9aa3ad; cursor: pointer; transition: background .15s, color .15s; }
#sendBtn.ready { color: #fff; background: var(--color-secondary-light, #1274dd); }
#sendBtn:hover:not(:disabled) { color: #fff; background: var(--color-secondary, #0d5fb8); }
#sendBtn:disabled { opacity: .4; cursor: default; }

/* Talk button: full label on desktop, mic + short word on phones */
#record .label-short { display: none; }
#record svg { flex-shrink: 0; }
@media (max-width: 600px) {
  #record { width: auto; min-width: 88px; padding: 0.8em 14px; gap: 4px; }
  #record .label-full { display: none; }
  #record .label-short { display: inline; white-space: nowrap; }
}

/* Translate card: target language picker */
.translate-picker { position: fixed; z-index: 1000; display: flex; flex-direction: column; min-width: 180px; padding: 6px;
  background: #fff; border: 1px solid #ddd; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.translate-picker-title { font-size: 12px; color: #777; padding: 4px 8px 6px; }
.translate-picker button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: none; background: none;
  border-radius: 6px; cursor: pointer; font-size: 14px; text-align: left; color: #222; }
.translate-picker button:hover { background: rgba(18,116,221,.08); }

/* Tap on the talk button: "hold to talk" hint */
.controls { position: relative; }
#hold-hint { position: absolute; left: 0; bottom: calc(100% + 8px); max-width: min(360px, 100%); padding: 8px 12px; border-radius: 8px;
  background: #222; color: #fff; font-size: 13px; line-height: 1.35; box-shadow: 0 4px 14px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
#hold-hint.show { opacity: 1; transform: none; }

/* Local AI service not answering */
#health-banner { margin: 0 0 8px; padding: 8px 12px; border-radius: 8px; background: #fff4e5; color: #7a4300; border: 1px solid #f5c27a; font-size: 13px; line-height: 1.4; }

/* =====================================================================
   Dark mode (settings menu toggle). html[data-theme="dark"] is set by a tiny
   script in <head> before the page paints, so there is no white flash.
   ===================================================================== */
html[data-theme="dark"] {
  --d-bg: #111827;          /* page */
  --d-surface: #182132;     /* chat area, panels */
  --d-raised: #222d42;      /* bubbles, cards, menus */
  --d-hover: #2b3852;
  --d-border: #33415c;
  --d-text: #e6ebf3;
  --d-muted: #9aa7ba;
  --d-user: #1c3b63;        /* your own bubbles */
  --color-primary: #4f9bff;             /* brighter brand blue for dark backgrounds */
  --color-secondary: #3b8cf5;
  --color-secondary-light: #2f84f0;     /* main buttons: still dark enough for white text */
  --color-primary-faint: rgba(79, 155, 255, 0.14);
  --color-primary-border: rgba(79, 155, 255, 0.45);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--d-bg); color: var(--d-text); }
html[data-theme="dark"] .chat-container,
html[data-theme="dark"] #home-panel { background: var(--d-surface); border-color: var(--d-border); }
html[data-theme="dark"] .chat-bubble .message-text { color: var(--d-text); }
html[data-theme="dark"] .chat-bubble.user .message-text { background: var(--d-user); }
html[data-theme="dark"] .chat-bubble.assistant .message-text { background: var(--d-raised); }
html[data-theme="dark"] .chat-bubble .timestamp,
html[data-theme="dark"] .chat-bubble .message-text.thinking { color: var(--d-muted); }
html[data-theme="dark"] .chat-bubble.assistant .message-text code { background: #0f1522; }
html[data-theme="dark"] #textInput { background: var(--d-surface); color: var(--d-text); border-color: var(--d-border); }
html[data-theme="dark"] #textInput::placeholder { color: var(--d-muted); }
html[data-theme="dark"] .control-btn.secondary,
html[data-theme="dark"] #app-home.control-btn { background: var(--d-raised); color: var(--d-text); }
html[data-theme="dark"] .control-btn { background: var(--d-raised); }
html[data-theme="dark"] .control-btn.primary { background: var(--color-secondary-light); }
html[data-theme="dark"] .session-panel { background: var(--d-surface); border-color: var(--d-border); box-shadow: -3px 0 10px rgba(0,0,0,.4); }
html[data-theme="dark"] .session-panel h2, html[data-theme="dark"] .session-panel h3, html[data-theme="dark"] .session-panel h4 { color: var(--d-text); }
html[data-theme="dark"] .session-load-btn,
html[data-theme="dark"] .session-delete-btn,
html[data-theme="dark"] .session-item { background: var(--d-raised); border-color: var(--d-border); color: var(--d-text); }
html[data-theme="dark"] .session-load-btn:hover { background: var(--d-hover); }
html[data-theme="dark"] .session-delete-btn:hover { background: #3a1f24; border-color: #e5484d; }
html[data-theme="dark"] .close-btn { color: var(--d-muted); }
html[data-theme="dark"] .close-btn:hover { background: var(--d-hover); color: var(--d-text); }
html[data-theme="dark"] #quickActions { border-color: var(--d-border); }
html[data-theme="dark"] .quick-action-btn,
html[data-theme="dark"] .home-buttons button { background: var(--d-raised); border-color: var(--d-border); color: var(--d-text); }
html[data-theme="dark"] .quick-action-btn:hover,
html[data-theme="dark"] .home-buttons button:hover { background: var(--d-hover); }
html[data-theme="dark"] .home-grid h2, html[data-theme="dark"] .home-buttons button strong { color: var(--d-text); }
html[data-theme="dark"] .home-category h3 { color: var(--d-muted); border-color: var(--d-border); }
html[data-theme="dark"] .home-buttons button span { color: var(--d-muted); }
html[data-theme="dark"] .lang-btn { background: var(--d-raised); color: var(--d-text); }
html[data-theme="dark"] .lang-list,
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .translate-picker { background: var(--d-raised); border-color: var(--d-border); box-shadow: 0 8px 24px rgba(0,0,0,.45); }
html[data-theme="dark"] .lang-list li,
html[data-theme="dark"] .settings-item,
html[data-theme="dark"] .settings-user strong,
html[data-theme="dark"] .translate-picker button { color: var(--d-text); }
html[data-theme="dark"] .settings-user, html[data-theme="dark"] .translate-picker-title { color: var(--d-muted); border-color: var(--d-border); }
html[data-theme="dark"] .copy-message-btn,
html[data-theme="dark"] .graph-this-btn,
html[data-theme="dark"] .chart-download-btn { background: transparent; }
html[data-theme="dark"] .chart-container { background: #1f2a3d !important; }
html[data-theme="dark"] .job-card { color: var(--d-text); background: rgba(79,155,255,.08); }
html[data-theme="dark"] .job-cancel-btn { background: var(--d-raised); border-color: var(--d-border); color: var(--d-text); }
html[data-theme="dark"] #sendBtn { color: var(--d-muted); }
html[data-theme="dark"] #health-banner { background: #3a2a12; color: #ffd08a; border-color: #7a5320; }
html[data-theme="dark"] #hold-hint { background: #e6ebf3; color: #111827; }

/* ---------- Sun / moon switch in the settings menu ---------- */
.theme-row { justify-content: space-between; gap: 16px; box-sizing: border-box; cursor: default; }
.settings-panel { min-width: 220px; box-sizing: border-box; }
.settings-panel .settings-item { box-sizing: border-box; }
.theme-row:hover { background: none !important; }
.theme-switch {
  position: relative; width: 64px; height: 32px; flex-shrink: 0; padding: 0; border: 0; border-radius: 999px; cursor: pointer;
  background: #e4e8ef; box-shadow: inset 0 2px 5px rgba(0,0,0,.15), inset 0 -1px 2px rgba(255,255,255,.8);
  transition: background .3s;
}
.theme-switch .ts-bg { position: absolute; top: 7px; width: 18px; height: 18px; color: #9aa3b2; transition: opacity .3s; }
.theme-switch .ts-bg.sun { left: 9px; opacity: 0; }
.theme-switch .ts-bg.moon { right: 9px; opacity: 1; }
.theme-switch .ts-knob {
  position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ffb347, #f28a00); box-shadow: 0 2px 6px rgba(242,138,0,.45);
  transition: transform .3s cubic-bezier(.4,1.4,.6,1), background .3s, box-shadow .3s;
}
.theme-switch .ts-knob svg { position: absolute; width: 16px; height: 16px; transition: opacity .2s, transform .3s; }
.theme-switch .ts-knob .moon { opacity: 0; transform: rotate(-60deg); }
.theme-switch[aria-checked="true"] { background: #0f172a; box-shadow: inset 0 2px 5px rgba(0,0,0,.6), inset 0 -1px 1px rgba(255,255,255,.06); }
.theme-switch[aria-checked="true"] .ts-bg.sun { opacity: 1; color: #55627a; }
.theme-switch[aria-checked="true"] .ts-bg.moon { opacity: 0; }
.theme-switch[aria-checked="true"] .ts-knob {
  transform: translateX(32px);
  background: radial-gradient(circle at 35% 30%, #6fb0ff, #2f6fe0); box-shadow: 0 2px 8px rgba(47,111,224,.55);
}
.theme-switch[aria-checked="true"] .ts-knob .sun { opacity: 0; transform: rotate(60deg); }
.theme-switch[aria-checked="true"] .ts-knob .moon { opacity: 1; transform: none; }
.theme-switch:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .theme-switch, .theme-switch * { transition: none !important; } }

/* Local service status list (settings menu) */
.service-status { padding: 6px 10px 8px; border-top: 1px solid #eee; margin-top: 4px; font-size: 13px; }
.service-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: #222; }
.service-row .dot { width: 9px; height: 9px; border-radius: 50%; background: #16a34a; flex: none; }
.service-row.down .dot { background: #dc2626; }
.service-row .name { flex: 1; }
.service-row .ms { color: #888; font-size: 12px; }
.service-row.down .ms { color: #dc2626; }
html[data-theme="dark"] .service-status { border-color: var(--d-border); }
html[data-theme="dark"] .service-row { color: var(--d-text); }

/* Login / register pages in dark mode */
html[data-theme="dark"] .auth-container { background: var(--d-raised); border: 1px solid var(--d-border); box-shadow: 0 8px 24px rgba(0,0,0,.45); }
html[data-theme="dark"] .auth-container h2,
html[data-theme="dark"] .form-group label { color: var(--d-text); }
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select { background: var(--d-bg); color: var(--d-text); border-color: var(--d-border) !important; }
html[data-theme="dark"] .form-group input::placeholder { color: var(--d-muted); }
html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group select:focus { outline: 2px solid #4f9cf0; outline-offset: 0; border-color: #4f9cf0; }
html[data-theme="dark"] .auth-link { color: var(--d-muted); }
html[data-theme="dark"] .auth-link a { color: #6cb0ff; }
html[data-theme="dark"] .pw-toggle { color: var(--d-muted); }
html[data-theme="dark"] .pw-toggle:hover { color: var(--d-text); }
html[data-theme="dark"] .error-message { background: #4a1d24; color: #ffb4bc; }

/* Quick Actions icons: same blue as the home category icons */
.quick-action-btn svg { flex: none; }
.quick-action-btn svg path { fill: var(--color-secondary-light); }

/* Trash + "generating image" SVG icons (replace the emoji) */
.session-delete-btn { display: inline-flex; align-items: center; justify-content: center; color: #666; }
.session-delete-btn:hover { color: #b33; }
html[data-theme="dark"] .session-delete-btn { color: var(--d-muted); }
html[data-theme="dark"] .session-delete-btn:hover { color: #ff7b80; }
.ico-inline { vertical-align: -4px; margin-right: 4px; color: var(--color-secondary-light); }

/* Settings cog icon: same blue as the other icons */
.settings-btn svg path { fill: var(--color-secondary-light); }

/* Gap between the Replay/Stop buttons and the Copy/Share/Download set */
.play-button + .copy-message-btn,
.stop-button + .copy-message-btn { margin-left: 10px; }

/* Reference images: attach button, thumbnail tray, thumbnails in chat bubbles */
#attachBtn { position: absolute; right: 42px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: none;
  color: var(--color-secondary-light, #1274dd); cursor: pointer; }
#attachBtn:hover:not(:disabled) { background: var(--color-primary-faint, #eef4fc); }
#attachBtn:disabled { opacity: .4; cursor: default; }
.input-wrap #textInput { padding-right: 82px; }
.ref-tray { display: flex; gap: 8px; padding: 6px 0 2px; flex-wrap: wrap; }
.ref-tray[hidden] { display: none; }
.ref-thumb { position: relative; }
.ref-thumb img { height: 64px; width: auto; max-width: 110px; object-fit: cover; border-radius: 8px; border: 1px solid #ccc; display: block; }
.ref-thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: #333; color: #fff; font-size: 14px; line-height: 20px; cursor: pointer; }
.bubble-refs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.bubble-refs img { height: 72px; width: auto; max-width: 120px; object-fit: cover; border-radius: 8px; cursor: pointer; }
body.dragging-file::after { content: 'Drop image to attach'; position: fixed; inset: 12px; z-index: 2000; display: flex; align-items: center; justify-content: center;
  border: 3px dashed var(--color-secondary-light, #1274dd); border-radius: 14px; background: rgba(18,116,221,.12); color: var(--color-secondary-light, #1274dd);
  font-size: 1.4rem; font-weight: 600; pointer-events: none; }
html[data-theme="dark"] #attachBtn:hover:not(:disabled) { background: var(--d-hover); }
html[data-theme="dark"] .ref-thumb img { border-color: var(--d-border); }

/* Image shape select in the settings menu */
.aspect-row { justify-content: space-between; cursor: default; }
.aspect-row select { font: inherit; font-size: calc(13px * var(--fs)); padding: 3px 6px; border: 1px solid #ccc; border-radius: 6px; background: #fff; color: #222; }
html[data-theme="dark"] .aspect-row select { background: var(--d-bg); color: var(--d-text); border-color: var(--d-border); }

/* ComfyUI row: idle state + Auto/On/Off switch */
.service-row.idle .dot { background: #9aa3b2; }
.service-row.idle .ms { color: #888; }
.mode-seg { display: inline-flex; margin-left: 6px; border: 1px solid #ccc; border-radius: 6px; overflow: hidden; flex: none; }
.mode-seg button { border: 0; background: none; padding: 1px 7px; font: inherit; font-size: 12px; color: #555; cursor: pointer; }
.mode-seg button + button { border-left: 1px solid #ccc; }
.mode-seg button[aria-pressed="true"] { background: var(--color-secondary-light, #1274dd); color: #fff; }
html[data-theme="dark"] .mode-seg, html[data-theme="dark"] .mode-seg button + button { border-color: var(--d-border); }
html[data-theme="dark"] .mode-seg button { color: var(--d-muted); }
html[data-theme="dark"] .mode-seg button[aria-pressed="true"] { color: #fff; }

/* Settings menu: wider panel; ComfyUI toggle beside its name, time on the right like the other rows */
.settings-panel { min-width: 300px; }
.service-row .ms { margin-left: auto; }
.service-row.has-seg .name { flex: none; }

/* Toast at the top of the page */
#toast { position: fixed; top: 12px; left: 50%; transform: translate(-50%, -140%); z-index: 3000; max-width: min(92vw, 520px);
  padding: 10px 18px; border-radius: 10px; background: #1f2937; color: #fff; font-size: 14px; line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.12); opacity: 0; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
html[data-theme="dark"] #toast { background: var(--d-raised); border-color: var(--d-border); }
.graph-this-btn svg { width: 14px; height: 14px; margin-right: 4px; flex: none; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* Several charts in one reply sit side by side (stack on narrow screens) */
.chart-row { display: flex; flex-wrap: wrap; gap: 12px; }
.chart-row .chart-container { flex: 1 1 280px; min-width: 0; max-width: 560px; }

/* Remote mode box in the settings menu */
.remote-box .remote-line { margin-bottom: 6px; }
.remote-box button { font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid var(--color-secondary-light, #1274dd); border-radius: 6px; background: none; color: var(--color-secondary-light, #1274dd); cursor: pointer; }
.remote-box button:hover { background: var(--color-secondary-light, #1274dd); color: #fff; }

/* Phones: size the app to the VISIBLE screen (dynamic viewport, safe areas) and keep the input row pinned at the bottom.
   The old fixed "100vh - 180px" hid the input row behind the browser bars once the toolbar wrapped. */
@media (max-width: 767px) {
  html, body { height: 100%; }
  body { box-sizing: border-box; height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); overflow: hidden;
         padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
  #app { display: flex; flex-direction: column; height: 100%; max-width: none; }
  #app > .chat-container, #app > #home-panel { flex: 1 1 auto; min-height: 0; height: auto !important; }
  #app > .chat-controls, #app > .ref-tray, #app > .controls { flex: none; }
  #app > .controls { margin-top: 8px; }
}

/* Storyboard Pro cards */
.sb-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.sb-cards.single { grid-template-columns: minmax(0, 520px); }
.sb-card { background: #fff; border: 1px solid #d5dbe5; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sb-card img { width: 100%; border-radius: 6px; cursor: pointer; display: block; background: #eee; }
.sb-title { font-weight: 600; font-size: 14px; color: #222; }
.sb-badge { align-self: flex-start; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef2f8; color: #556; }
.sb-card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 13px; }
.sb-card dt { color: #777; } .sb-card dd { margin: 0; color: #222; }
.sb-body { margin: 0; font-size: 13px; line-height: 1.4; color: #333; white-space: pre-wrap; }
.sb-video { width: 100%; border-radius: 6px; background: #000; }
.sb-dl { font-size: 13px; color: var(--color-secondary, #1274dd); }
html[data-theme="dark"] .sb-card { background: var(--d-raised); border-color: var(--d-border); }
html[data-theme="dark"] .sb-title, html[data-theme="dark"] .sb-card dd, html[data-theme="dark"] .sb-body { color: var(--d-text); }
html[data-theme="dark"] .sb-card dt { color: var(--d-muted); }
html[data-theme="dark"] .sb-badge { background: var(--d-hover); color: var(--d-muted); }

/* Quick-reply choice buttons */
.choice-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.choice-btn { font: inherit; font-size: 13px; padding: 5px 11px; border: 1px solid var(--color-secondary-light, #1274dd); border-radius: 16px; background: none; color: var(--color-secondary-light, #1274dd); cursor: pointer; }
.choice-btn:hover:not(:disabled) { background: var(--color-secondary-light, #1274dd); color: #fff; }
.choice-btn:disabled { opacity: .5; cursor: default; }
.choice-btn.picked { opacity: 1; background: var(--color-secondary-light, #1274dd); color: #fff; }


/* Voice setting + samples window */
.voice-samples-link { margin-left: 4px; font-size: 12px; color: var(--color-secondary-light, #1274dd); text-decoration: none; }
.voice-samples-link:hover { text-decoration: underline; }
.voice-modal-overlay { position: fixed; inset: 0; z-index: 9500; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.55); }
.voice-modal-overlay[hidden] { display: none; }
.voice-modal { width: 100%; max-width: 440px; max-height: min(86dvh, 640px); display: flex; flex-direction: column; background: #fff; color: #222; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.voice-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 4px; }
.voice-modal-head h2 { margin: 0; font-size: 18px; }
.voice-modal-close { border: 0; background: none; font-size: 26px; line-height: 1; color: inherit; opacity: .6; cursor: pointer; padding: 0 4px; }
.voice-modal-close:hover { opacity: 1; }
.voice-modal-phrase { margin: 0; padding: 0 18px 10px; font-size: 13px; font-style: italic; color: #666; border-bottom: 1px solid #eee; }
.voice-list { list-style: none; margin: 0; padding: 4px 10px 10px; overflow-y: auto; }
.voice-list li { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; }
.voice-list li:hover { background: var(--color-primary-faint, #f3f7fd); }
.voice-play { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; background: var(--color-secondary-light, #1274dd); color: #fff; }
.voice-play svg { width: 18px; height: 18px; fill: currentColor; }
.voice-play.loading { opacity: .6; animation: voice-pulse 1s ease-in-out infinite; }
@keyframes voice-pulse { 50% { opacity: .3; } }
.voice-meta { flex: 1; min-width: 0; }
.voice-name { font-weight: 600; font-size: 14px; }
.voice-info { font-size: 12px; color: #777; }
.voice-bar { height: 3px; margin-top: 6px; border-radius: 2px; background: rgba(128,128,128,.25); overflow: hidden; }
.voice-bar i { display: block; height: 100%; width: 0; background: var(--color-secondary-light, #1274dd); }
html[data-theme="dark"] .voice-modal { background: var(--d-raised); color: var(--d-text); }
html[data-theme="dark"] .voice-modal-phrase { color: var(--d-muted); border-color: var(--d-border); }
html[data-theme="dark"] .voice-info { color: var(--d-muted); }
html[data-theme="dark"] .voice-list li:hover { background: rgba(79,155,255,.1); }

/* Settings divider + full-screen usage modal */
.settings-item[hidden] { display: none; }
.settings-sep { height: 0; margin: 4px 0; border-top: 1px solid #eee; }
html[data-theme="dark"] .settings-sep { border-color: var(--d-border); }
.usage-modal { position: fixed; inset: 0; z-index: 9600; display: flex; flex-direction: column; background: var(--color-bg, #fff); }
.usage-modal[hidden] { display: none; }
.usage-modal-bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; background: #fff; color: #222; border-bottom: 1px solid #ddd; }
.usage-modal-bar h2 { margin: 0; font-size: 17px; }
.usage-modal-close { border: 0; background: none; font-size: 28px; line-height: 1; color: inherit; opacity: .65; cursor: pointer; padding: 0 6px; }
.usage-modal-close:hover { opacity: 1; }
.usage-frame { flex: 1; width: 100%; border: 0; background: #fff; }
html[data-theme="dark"] .usage-modal { background: var(--d-bg); }
html[data-theme="dark"] .usage-modal-bar { background: var(--d-raised); color: var(--d-text); border-color: var(--d-border); }


.comfy-busy-alert { display: flex; align-items: center; gap: 6px; padding: 4px 12px; font-size: 12px; color: #f59e0b; }
.comfy-busy-alert[hidden] { display: none; }

/* Seek bar under a bubble's buttons, shown only while that bubble's audio plays */
.audio-scrub {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 0;
  font-size: 0.72em;
  opacity: 0.85;
  max-width: 420px;
}
.audio-scrub.active { display: flex; }
.audio-scrub .scrub-time { font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: center; white-space: nowrap; }
.audio-scrub .scrub-range { flex: 1; min-width: 0; height: 18px; accent-color: #3b82f6; cursor: pointer; }
.audio-scrub .scrub-range:disabled { cursor: default; opacity: 0.5; }
.chat-bubble.user .audio-scrub { margin-left: auto; }

.audio-scrub .scrub-toggle {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #3b82f6;
  border-radius: 50%;
  background: none;
  color: #3b82f6;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.audio-scrub .scrub-toggle:hover { background: rgba(59, 130, 246, 0.15); }

/* ===== Button icons: white SVG on a blue badge (replaces the emoji) =====
   Primary audio buttons (Replay, Stop, Yes - please continue) get the badge; secondary actions
   (Copy, Share, Download, Graph this) keep the thin blue outline on a transparent background. */
html .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-radius: 9px;
  margin-left: 6px;
  padding: 1px 5px 1px 1px;
  font-size: 0.8em;
  font-weight: 500;
  color: inherit;
  opacity: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s;
}
html .icon-btn:hover { background: none; color: inherit; filter: brightness(1.08); }
html .icon-btn:disabled { cursor: wait; }
html .icon-btn .ico {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 6px;
  box-sizing: border-box;
  border-radius: 8px;
  background: var(--color-secondary-light, #1274dd);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s;
}
html .icon-btn .ico svg { width: 100%; height: 100%; fill: currentColor; display: block; }
/* orange: Stop while audio plays, and Yes - please continue until it has been clicked once */
html .icon-btn.orange .ico,
html .stop-button.icon-btn .ico { background: var(--color-quaternary, #F07822); }
/* the icon becomes a spinner while the audio renders */
html .icon-btn.busy .ico svg { visibility: hidden; }
html .icon-btn.busy .ico::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: icoSpin 0.8s linear infinite;
}
@keyframes icoSpin { to { transform: rotate(360deg); } }
/* Cancel button: same orange, with its own little spinner */
html .stop-button-spinner { border-color: rgba(240, 120, 34, 0.25); border-top-color: var(--color-quaternary, #F07822); }
html .play-button.continue-button { border: none; border-radius: 9px; color: inherit; }

/* Secondary actions: thin blue outline, transparent background, plain blue icon */
html .bubble-tools-wrapper .copy-message-btn.icon-btn,
html .bubble-tools-wrapper .graph-this-btn.icon-btn {
  border: 1px solid var(--color-secondary);
  border-radius: 6px;
  background: transparent;
  color: var(--color-secondary);
  margin: 0 0 0 6px;
  padding: 5px 9px;
  font-size: 0.76em;
  font-weight: 400;
  gap: 6px;
  opacity: 0.9;
  filter: none;
}
html .bubble-tools-wrapper .copy-message-btn.icon-btn .ico,
html .bubble-tools-wrapper .graph-this-btn.icon-btn .ico {
  width: 14px;
  height: 14px;
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
}
html .bubble-tools-wrapper .copy-message-btn.icon-btn:hover,
html .bubble-tools-wrapper .graph-this-btn.icon-btn:hover {
  opacity: 1;
  background: var(--color-secondary-light);
  color: #fff;
  filter: none;
}
html .bubble-tools-wrapper .copy-message-btn.icon-btn.copied { opacity: 0.75; cursor: default; }

/* seek bar: pause/play toggle as a badge too */
html .audio-scrub { font-size: 0.78em; }
html .audio-scrub .scrub-toggle {
  width: 26px;
  height: 26px;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: var(--color-secondary-light, #1274dd);
  color: #fff;
  box-sizing: border-box;
}
html .audio-scrub .scrub-toggle:hover { background: var(--color-secondary-light, #1274dd); filter: brightness(1.1); }
html .audio-scrub .scrub-toggle svg { width: 100%; height: 100%; fill: currentColor; display: block; }
html .audio-scrub .scrub-range { accent-color: var(--color-secondary-light, #1274dd); }
@media (max-width: 600px) {
  html .icon-btn { margin-left: 5px; }
  html .bubble-tools-wrapper .copy-message-btn.icon-btn { margin-left: 5px; padding: 6px 8px; }
}
#health-banner.info { background: #e8f1fd; color: #1c4a80; border-color: #9cc2ef; }
html[data-theme="dark"] #health-banner.info { background: #17283f; color: #b8d6fb; border-color: #2f5a8f; }

/* Text size switch (settings menu): three A's of growing size */
.fs-seg { display: inline-flex; border: 1px solid #ccc; border-radius: 6px; overflow: hidden; flex: none; }
.fs-seg button { border: 0; background: none; padding: 2px 11px; font: inherit; line-height: 1.3; color: #555; cursor: pointer; }
.fs-seg button + button { border-left: 1px solid #ccc; }
.fs-seg button:nth-child(1) { font-size: 12px; }
.fs-seg button:nth-child(2) { font-size: 15px; }
.fs-seg button:nth-child(3) { font-size: 19px; }
.fs-seg button[aria-pressed="true"] { background: var(--color-secondary-light, #1274dd); color: #fff; }
html[data-theme="dark"] .fs-seg, html[data-theme="dark"] .fs-seg button + button { border-color: var(--d-border); }
html[data-theme="dark"] .fs-seg button { color: var(--d-muted); }
html[data-theme="dark"] .fs-seg button[aria-pressed="true"] { color: #fff; }

/* Quick actions in the history sidebar are hidden for now (markup kept in index.html) - delete this block to bring them back */
#quickActions { display: none; }
#sessionPanel .session-header:has(#closeSessionPanel) h3 { visibility: hidden; }
