:root{--accent:#e4002b;--accent-hover:#ff3357;--danger:#e4002b;--success:#10b981;--panel:#0d1728;--panel-border:#34445e;--text:#fff;--text-muted:#93a5bf;--warning:#f5b94b}
.maggie-chat-input-row button[type='submit'] {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.maggie-chat-input-row button[type='submit']:disabled {
  background: hsl(var(--muted));
  color: var(--text-muted);
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .maggie-chat-input-row button[type='submit']:hover {
    background: var(--accent-hover);
  }
}

.maggie-chat-input-row button[type='submit']:active {
  background: var(--accent-hover);
}
.maggie-root {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 150;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.maggie-character {
  position: relative;
  width: 110px;
}

.maggie-character img {
  width: 100%;
  display: block;
}

.maggie-entering {
  animation: maggie-walk-in 0.45s ease forwards;
}

.maggie-leaving {
  animation: maggie-walk-out 0.45s ease forwards;
}

@keyframes maggie-walk-in {
  from {
    transform: translateX(160px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes maggie-walk-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(160px);
    opacity: 0;
  }
}

.maggie-flip {
  transform: scaleX(-1);
}

/* Cloud-style speech bubble: a pill-shaped body with a trailing pair of
   dots (like a thought bubble) instead of a sharp triangle pointer - reads
   as "Maggie's speech" rather than another piece of the app's dark UI. */
.maggie-bubble {
  position: absolute;
  right: 100%;
  bottom: 85%;
  margin-right: 0.9rem;
  background: #fff;
  color: #12151f;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.maggie-bubble::before,
.maggie-bubble::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.maggie-bubble::before {
  width: 16px;
  height: 16px;
  bottom: -9px;
  right: 1.5rem;
}

.maggie-bubble::after {
  width: 9px;
  height: 9px;
  bottom: -20px;
  right: 1.1rem;
}

.maggie-fab {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--accent);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.maggie-fab img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.maggie-chat-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.maggie-chat-avatar {
  width: 70px;
  flex-shrink: 0;
}

.maggie-chat-avatar img {
  width: 100%;
  display: block;
}

/* Transparent by design - only the floating white message bubbles (and
   Maggie herself) should read as visible "chat," not a boxed panel behind
   them. Header text gets a drop shadow so it stays legible over whatever
   page content happens to sit underneath it. */
.maggie-chat-panel {
  width: min(320px, 78vw);
  max-height: 60vh;
  background: transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.maggie-chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.6rem 0.75rem;
}

.maggie-chat-header .modal-close {
  background: rgba(10, 14, 23, 0.6);
  border-radius: 50%;
  text-shadow: none;
}

.maggie-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Every message - Maggie's and the person's - is the same white cloud
   bubble; only the name label at the top and which side it sits on tell
   them apart. No accent-blue fill/border on either one. */
.maggie-msg {
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
  border-radius: 1.1rem;
  max-width: 85%;
  line-height: 1.35;
  background: #fff;
  color: #12151f;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.maggie-msg-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #667;
  margin-bottom: 0.15rem;
}

.maggie-msg-user {
  align-self: flex-end;
}

.maggie-msg-assistant {
  align-self: flex-start;
}

.maggie-typing {
  font-style: italic;
}

.maggie-msg-p {
  margin: 0 0 0.4rem 0;
}

.maggie-msg-p:last-child {
  margin-bottom: 0;
}

.maggie-msg-list {
  margin: 0.2rem 0 0.4rem 0;
  padding-left: 1.1rem;
}

.maggie-msg-list:last-child {
  margin-bottom: 0;
}

.maggie-msg-list li {
  margin-bottom: 0.2rem;
}

.maggie-msg-list li:last-child {
  margin-bottom: 0;
}

.maggie-voice-error {
  margin: 0 0.75rem;
  color: var(--warning);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.maggie-chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
}

/* Explicit background/color/border - a bare, unstyled <input> falls back
   to the browser's native widget rendering, which follows the OS/browser
   color-scheme (dark-mode Chrome/Firefox render it with a dark background
   and near-white text) regardless of this panel's own light, white-bubble
   look. Pin it to match the panel instead of leaving it to that guess. */
.maggie-chat-input-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.375rem;
  background: #fff;
  color: #12151f;
  font-size: 0.85rem;
}

.maggie-chat-input-row input::placeholder {
  color: var(--text-muted);
}

/* Mic, cancel, and accept are plain icon buttons sitting to the right of
   the textbox as their own row items - not overlaid inside the input -
   with Send always the rightmost element regardless of state. */
.maggie-icon-btn {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.maggie-voice-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
}

.maggie-voice-btn svg {
  fill: currentColor;
}

/* The global button hover/active rules are specific enough to otherwise
   override these plain icon buttons' colors - pin them explicitly. */
.maggie-voice-btn:hover,
.maggie-voice-btn:active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.maggie-voice-cancel,
.maggie-voice-cancel:hover,
.maggie-voice-cancel:active {
  background: var(--danger);
}

.maggie-voice-accept,
.maggie-voice-accept:hover,
.maggie-voice-accept:active {
  background: var(--success);
}

/* Live transcript popup shown in place of the messages/input while
   recording - large, readable, wrapping text instead of the single-line
   textbox that could only ever show the trailing few words. */
.maggie-voice-overlay {
  margin: 0.6rem 0.75rem;
  padding: 1rem;
  min-height: 140px;
  max-height: 50vh;
  background: rgba(18, 21, 31, 0.5);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.maggie-voice-transcript {
  flex: 1;
  overflow-y: auto;
  color: #fff;
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.maggie-voice-placeholder {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}

.maggie-voice-actions {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
}

.maggie-voice-actions .maggie-icon-btn {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.3rem;
}

@media (max-width: 480px) {
  .maggie-chat-avatar {
    display: none;
  }

  .maggie-chat-panel {
    width: 82vw;
  }
}

/* The walk-on character, docked button, and chat panel are all fixed
   pixel sizes, so on a phone (a narrow screen) they read as prominent,
   but the exact same pixel sizes shrink to a much smaller fraction of a
   wide desktop monitor. Scale them up on larger viewports so the widget
   feels proportioned the same way it already does on a phone, instead of
   looking small by comparison. */
@media (min-width: 768px) {
  .maggie-character {
    width: 170px;
  }

  .maggie-fab {
    width: 86px;
    height: 86px;
  }

  .maggie-chat-avatar {
    width: 100px;
  }

  .maggie-chat-panel {
    width: min(420px, 30vw);
  }

  .maggie-bubble {
    font-size: 0.9rem;
    padding: 0.7rem 1.25rem;
  }

  .maggie-msg {
    font-size: 0.95rem;
    padding: 0.55rem 0.8rem;
  }

  .maggie-chat-input-row input {
    font-size: 0.95rem;
  }
}

/* Conversation History - right-click the docked button, or the clock icon
   in the chat header, to reactivate or rename a past conversation. A
   full-viewport transparent backdrop closes it on an outside click,
   same convention as .maggie-history-backdrop's stopPropagation on the
   bubble itself below. */
.maggie-history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.maggie-history-bubble {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: min(340px, 86vw);
  max-height: 60vh;
  background: #fff;
  color: #12151f;
  border-radius: 1rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.maggie-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(18, 21, 31, 0.1);
}

.maggie-history-header .modal-close {
  color: #667;
}

.maggie-history-list {
  overflow-y: auto;
  padding: 0.4rem;
}

.maggie-history-empty {
  padding: 0.75rem;
  margin: 0;
}

.maggie-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.6rem;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .maggie-history-item:hover {
    background: rgba(59, 130, 246, 0.08);
  }
}

.maggie-history-item-active {
  background: rgba(59, 130, 246, 0.12);
}

.maggie-history-title {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maggie-history-title-input {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  background: #fff;
  color: #12151f;
}

.maggie-history-date {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: #889;
}

.maggie-history-edit-btn {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  background: transparent;
  color: #889;
}

@media (hover: hover) and (pointer: fine) {
  .maggie-history-edit-btn:hover {
    background: rgba(18, 21, 31, 0.08);
    color: #12151f;
  }
}

.maggie-history-save-btn {
  color: var(--success);
}

.maggie-history-cancel-btn {
  color: var(--danger);
}

.maggie-history-btn {
  background: transparent;
  color: var(--text-muted);
  margin-right: auto;
}

@media (hover: hover) and (pointer: fine) {
  .maggie-history-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
  }
}
.maggie-root .modal-close{border-radius:50%;width:32px;height:32px;padding:0;font-size:20px}
.maggie-root .hint{font-size:.85rem;font-style:italic}
