/*
 * MIA Console — command-palette-style nav overlay.
 * Replaces the chat bubble with a Spotlight/⌘K experience: type, see ranked
 * results, hit Enter, things happen. No avatars, no "online" status, no chat
 * vibe. Themed via theme.css variables so light/dark mode auto-follows.
 */

#mia-console {
  --console-z: 1100;
  --console-trigger-h: 38px;
  --console-input-h: 56px;
  --console-radius: 14px;
  --console-mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--console-z);
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

/* ============================================================
   Trigger pill (collapsed state) — small, tool-feeling, with a
   blinking caret and subtle tech-accent edge.
   ============================================================ */
.mia-console-trigger {
  pointer-events: auto;
  position: absolute;
  right: 24px;
  bottom: 24px;
  height: var(--console-trigger-h);
  padding: 0 12px 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card, #fff);
  color: var(--text-primary, #1c1c1e);
  border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.16));
  border-radius: 10px;     /* subtly squared, terminal-flavoured */
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10),
              0 1px 3px rgba(0, 0, 0, 0.06),
              inset 0 0 0 1px rgba(var(--color-tech-rgb, 0, 194, 255), 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease,
              border-color 0.15s ease, background 0.15s ease;
}
.mia-console-trigger:hover,
.mia-console-trigger:focus-visible {
  transform: translateY(-1px);
  border-color: var(--color-tech, #00c2ff);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.08),
              inset 0 0 0 1px rgba(var(--color-tech-rgb, 0, 194, 255), 0.20);
  outline: none;
}
.mia-console-trigger-prompt {
  font-family: var(--console-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-tech, #00c2ff);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  position: relative;
}
.mia-console-trigger-prompt::after {
  content: '_';
  position: absolute;
  left: 8px;
  color: currentColor;
  animation: mia-console-caret-blink 1.05s steps(2, end) infinite;
}
@keyframes mia-console-caret-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-trigger-prompt::after { animation: none; opacity: 0.6; }
}
.mia-console-trigger-label {
  flex: 1;
  font-weight: 500;
}
.mia-console-trigger-kbd {
  font-family: var(--console-mono);
  font-size: 10px;
  padding: 2px 6px 2px 6px;
  border-radius: 4px;
  background: var(--bg-section, rgba(0, 0, 0, 0.06));
  color: var(--text-secondary, #666);
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ============================================================
   Corner popover panel (open state)
   ----------------------------------------------------------------
   Anchored to bottom-right above the trigger pill — small, tucked
   in the corner. No full-screen modal vibe; visitors can still see
   the page behind and click through it. A transparent backdrop
   element catches outside clicks for dismissal but doesn't dim or
   blur the page.
   ============================================================ */
.mia-console-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}
.mia-console-panel {
  position: absolute;
  right: 24px;
  /* sit just above the trigger pill (38px + 12px gap) */
  bottom: calc(var(--console-trigger-h) + 36px);
  transform-origin: bottom right;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(520px, calc(100vh - 120px));
  background: var(--bg-card, #fff);
  color: var(--text-primary, #1c1c1e);
  border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.18));
  border-radius: var(--console-radius);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22), 0 3px 10px rgba(0, 0, 0, 0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.96);
  /* Snappier open/close — ~100ms instead of 160ms feels noticeably more responsive */
  transition: opacity 0.10s ease, transform 0.10s ease;
}

#mia-console.mia-console-open .mia-console-backdrop {
  opacity: 1;
  pointer-events: auto;
}
#mia-console.mia-console-open .mia-console-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Tiny brand strip at the top of the panel — "MIA Console" + a live
   breadcrumb showing the page (and ideally section) the visitor is on. */
.mia-console-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-family: var(--console-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary, #888);
  background: linear-gradient(180deg,
    var(--bg-section, rgba(0, 0, 0, 0.03)) 0%,
    var(--bg-card, #fff) 100%);
  border-bottom: 1px solid var(--border-light, rgba(0, 0, 0, 0.06));
  flex-shrink: 0;
}
.mia-console-titlebar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-tech, #00c2ff);
  box-shadow: 0 0 8px rgba(var(--color-tech-rgb, 0, 194, 255), 0.6);
  flex-shrink: 0;
  animation: mia-console-pulse 2s ease-in-out infinite;
}
@keyframes mia-console-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-titlebar-dot { animation: none; }
}
.mia-console-titlebar-name {
  font-weight: 700;
  color: var(--text-primary, #333);
  letter-spacing: 0.16em;
  flex-shrink: 0;
}
.mia-console-titlebar-crumb {
  flex: 1;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  color: var(--text-secondary, #888);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.mia-console-titlebar-progress {
  font-family: var(--console-mono);
  font-size: 10px;
  color: var(--text-secondary, #888);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mia-console-titlebar-progress-bar {
  width: 30px;
  height: 3px;
  border-radius: 2px;
  background: var(--border-light, rgba(0, 0, 0, 0.10));
  overflow: hidden;
  position: relative;
}
.mia-console-titlebar-progress-fill {
  position: absolute;
  inset: 0;
  background: var(--color-tech, #00c2ff);
  width: 0%;
  transition: width 0.18s ease-out;
}
.mia-console-titlebar-crumb-sep {
  margin: 0 6px;
  color: var(--border-medium, rgba(0, 0, 0, 0.18));
}
.mia-console-titlebar-crumb-here {
  color: var(--text-primary, #333);
  font-weight: 600;
}

/* Input row */
.mia-console-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: var(--console-input-h);
  border-bottom: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  flex-shrink: 0;
  background: var(--bg-card, #fff);
}
.mia-console-prompt {
  font-family: var(--console-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-tech, #00c2ff);
  flex-shrink: 0;
  user-select: none;
}
.mia-console-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--console-mono);
  font-size: 16px;
  color: var(--text-primary, #1c1c1e);
  padding: 0;
  caret-color: var(--color-tech, #00c2ff);
}
.mia-console-input::placeholder {
  color: var(--text-secondary, #888);
  font-style: normal;
}
.mia-console-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-medium, rgba(0, 0, 0, 0.12));
  border-top-color: var(--color-tech, #00c2ff);
  border-radius: 50%;
  animation: mia-console-spin 0.8s linear infinite;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.mia-console-spinner.is-active { opacity: 1; }
@keyframes mia-console-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-spinner { animation: none; }
}
.mia-console-mode-badge {
  font-family: var(--console-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.12);
  color: var(--color-primary, #1976d2);
  border: 1px solid rgba(var(--color-tech-rgb, 0, 194, 255), 0.3);
  flex-shrink: 0;
}
.mia-console-mode-badge[data-mode="ai"] {
  background: rgba(var(--color-accent-rgb, 255, 193, 7), 0.16);
  color: var(--color-primary-dark, #0d47a1);
  border-color: rgba(var(--color-accent-rgb, 255, 193, 7), 0.4);
}

/* Results list */
.mia-console-results {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 8px 0;
  background: var(--bg-card, #fff);
}
.mia-console-section {
  font-family: var(--console-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary, #888);
  padding: 12px 18px 6px;
  font-weight: 600;
}
.mia-console-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px 8px 14px;
  cursor: pointer;
  transition: background 0.10s ease, padding-left 0.12s ease;
  user-select: none;
  border-left: 3px solid transparent;
  /* Subtle stagger fade-in for newly-rendered rows. The :nth-child rules
     below give each row a few ms more delay so the list reveals top-down. */
  animation: mia-console-row-in 0.18s ease-out backwards;
}
.mia-console-result:nth-child(1) { animation-delay: 0ms; }
.mia-console-result:nth-child(2) { animation-delay: 22ms; }
.mia-console-result:nth-child(3) { animation-delay: 44ms; }
.mia-console-result:nth-child(4) { animation-delay: 66ms; }
.mia-console-result:nth-child(5) { animation-delay: 88ms; }
.mia-console-result:nth-child(6) { animation-delay: 110ms; }
.mia-console-result:nth-child(7) { animation-delay: 130ms; }
.mia-console-result:nth-child(8) { animation-delay: 150ms; }
.mia-console-result:nth-child(n+9) { animation-delay: 165ms; }
@keyframes mia-console-row-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-result { animation: none; }
}
.mia-console-result:hover {
  background: var(--bg-section, rgba(0, 0, 0, 0.035));
}
.mia-console-result.is-active {
  background: var(--bg-section, rgba(0, 0, 0, 0.05));
  border-left-color: var(--color-tech, #00c2ff);
  padding-left: 14px;
}
.mia-console-result-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary, #888);
  flex-shrink: 0;
  opacity: 0.65;
}
.mia-console-result.is-active .mia-console-result-icon {
  fill: var(--color-tech, #00c2ff);
  opacity: 1;
}
.mia-console-result-body {
  flex: 1;
  min-width: 0;
}
.mia-console-result-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #1c1c1e);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mia-console-result-meta {
  font-family: var(--console-mono);
  font-size: 11px;
  color: var(--text-secondary, #888);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mia-console-result-meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  flex-shrink: 0;
}
.mia-console-result-meta-type {
  text-transform: lowercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
/* Snippet only shows on the active row to cut visual noise */
.mia-console-result-snippet {
  display: none;
  font-size: 12px;
  color: var(--text-secondary, #666);
  margin-top: 4px;
  line-height: 1.45;
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 400;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mia-console-result.is-active .mia-console-result-snippet {
  display: -webkit-box;
}
/* "↵ Go" affordance on the active row — makes the next action unmissable */
.mia-console-result-action {
  display: none;
  flex-shrink: 0;
  font-family: var(--console-mono);
  font-size: 11px;
  color: var(--color-primary-dark, #0d47a1);
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.14);
  border: 1px solid rgba(var(--color-tech-rgb, 0, 194, 255), 0.30);
  padding: 3px 8px;
  border-radius: 5px;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
}
.mia-console-result.is-active .mia-console-result-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
[data-theme="dark"] .mia-console-result-action {
  color: var(--color-tech, #00c2ff);
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.18);
}
/* Type chip kept for legacy rendering paths; visually muted */
.mia-console-result-type {
  display: none;
}

/* Did-you-mean suggestions on zero results */
.mia-console-suggestions {
  padding: 4px 14px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mia-console-suggestion {
  font-family: var(--console-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 5px;
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.10);
  color: var(--color-primary-dark, #0d47a1);
  border: 1px solid rgba(var(--color-tech-rgb, 0, 194, 255), 0.28);
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.mia-console-suggestion:hover,
.mia-console-suggestion:focus-visible {
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.20);
  border-color: var(--color-tech, #00c2ff);
  outline: none;
}
[data-theme="dark"] .mia-console-suggestion {
  color: var(--color-tech, #00c2ff);
}

/* Skeleton placeholders — shimmer rows shown while a /search is in flight.
   Removes the "is it doing anything?" gap between keystroke and results. */
.mia-console-skeleton {
  height: 48px;
  margin: 4px 18px;
  border-radius: 8px;
  background: linear-gradient(90deg,
    var(--bg-section, rgba(0, 0, 0, 0.05)) 0%,
    var(--bg-elevated, rgba(0, 0, 0, 0.10)) 50%,
    var(--bg-section, rgba(0, 0, 0, 0.05)) 100%);
  background-size: 200% 100%;
  animation: mia-console-shimmer 1.1s linear infinite;
}
@keyframes mia-console-shimmer {
  0%   { background-position:  200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-skeleton { animation: none; }
}

/* Empty / hint states */
.mia-console-empty {
  padding: 18px 18px;
  font-size: 13px;
  color: var(--text-secondary, #888);
  line-height: 1.6;
}
.mia-console-empty kbd {
  font-family: var(--console-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-section, rgba(0, 0, 0, 0.06));
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  color: var(--text-primary, #333);
}

/* Welcome state — quick-action chip grid for first-open. Friendlier than
   "type something" and clearly demos what the tool does. */
.mia-console-welcome {
  padding: 14px 18px 8px;
}
.mia-console-welcome-eyebrow {
  font-family: var(--console-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary, #888);
  margin-bottom: 10px;
}
.mia-console-welcome-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}
.mia-console-welcome-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  background: var(--bg-section, rgba(0, 0, 0, 0.03));
  color: var(--text-primary, #1c1c1e);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.mia-console-welcome-chip:hover,
.mia-console-welcome-chip:focus-visible {
  background: var(--bg-card, #fff);
  border-color: var(--color-tech, #00c2ff);
  outline: none;
  transform: translateY(-1px);
}
.mia-console-welcome-chip-icon {
  width: 14px; height: 14px;
  fill: var(--color-tech, #00c2ff);
  flex-shrink: 0;
}
.mia-console-welcome-cmds {
  font-family: var(--console-mono);
  font-size: 11px;
  color: var(--text-secondary, #888);
  line-height: 1.7;
}
.mia-console-welcome-cmds code {
  background: var(--bg-section, rgba(0, 0, 0, 0.05));
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.06));
  color: var(--text-primary, #333);
  margin-right: 4px;
  cursor: pointer;
}
.mia-console-welcome-cmds code:hover {
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.10);
  border-color: var(--color-tech, #00c2ff);
}

/* AI response panel */
.mia-console-ai {
  padding: 16px 18px;
  background: var(--bg-section, rgba(0, 0, 0, 0.03));
  border-top: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary, #1c1c1e);
  flex-shrink: 0;
}
.mia-console-ai a {
  color: var(--color-primary-dark, #0d47a1);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Footer — keyboard hints + a live "next action" preview that tells you
   exactly what Enter will do. Updates whenever the active row changes. */
.mia-console-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  background: linear-gradient(0deg,
    var(--bg-section, rgba(0, 0, 0, 0.03)) 0%,
    var(--bg-card, #fff) 100%);
  font-size: 11px;
  color: var(--text-secondary, #888);
  flex-shrink: 0;
  min-height: 32px;
}
.mia-console-status {
  flex: 1;
  font-family: var(--console-mono);
  font-size: 11px;
  color: var(--text-primary, #333);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mia-console-status-arrow {
  color: var(--color-tech, #00c2ff);
  font-weight: 700;
  margin-right: 6px;
}
.mia-console-status-target {
  color: var(--text-primary, #1c1c1e);
  font-weight: 500;
}
.mia-console-status-empty {
  color: var(--text-secondary, #aaa);
  font-style: italic;
}
/* Live retrieval-latency chip — credibility detail next to the status text.
   Real number from performance.now(), not a hardcoded marketing claim. */
.mia-console-status-lat {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.10);
  color: var(--color-primary-dark, #0d47a1);
  border: 1px solid rgba(var(--color-tech-rgb, 0, 194, 255), 0.22);
  font-family: var(--console-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
[data-theme="dark"] .mia-console-status-lat {
  color: var(--color-tech, #00c2ff);
  background: rgba(var(--color-tech-rgb, 0, 194, 255), 0.16);
}
.mia-console-footer-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mia-console-footer-key kbd {
  font-family: var(--console-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-section, rgba(0, 0, 0, 0.06));
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  color: var(--text-primary, #333);
}
.mia-console-footer-spacer { flex: 1; }
.mia-console-footer-action {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--color-primary, #1976d2);
  cursor: pointer;
  font-family: inherit;
}
.mia-console-footer-action:hover {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb, 25, 118, 210), 0.06);
}

/* Section flash on arrival (re-using the chat-widget's style if present, but
   self-contained to allow chat-widget to be removed entirely later). */
.mia-console-target-flash {
  animation: mia-console-target-flash 1.4s ease-out;
}
@keyframes mia-console-target-flash {
  0%   { box-shadow: 0 0 0 0 rgba(var(--color-tech-rgb, 0, 194, 255), 0.55); }
  60%  { box-shadow: 0 0 0 14px rgba(var(--color-tech-rgb, 0, 194, 255), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--color-tech-rgb, 0, 194, 255), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-target-flash { animation: none; }
}

/* Mobile — keep the corner-popover behaviour but use full width since the
   screen is narrow. Sits above the site's bottom nav (~64px). */
@media (max-width: 768px) {
  .mia-console-trigger {
    right: 12px;
    bottom: calc(64px + 12px);
  }
  .mia-console-panel {
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    bottom: calc(64px + var(--console-trigger-h) + 24px);
    max-height: calc(100vh - 220px);
  }
}

/* Voice input mic button — only visible if SpeechRecognition is supported */
.mia-console-mic {
  display: none;            /* JS shows it when supported */
  background: transparent;
  border: 1px solid transparent;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary, #888);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mia-console-mic.is-supported { display: inline-flex; }
.mia-console-mic:hover {
  background: var(--bg-section, rgba(0, 0, 0, 0.05));
  border-color: var(--border-medium, rgba(0, 0, 0, 0.16));
  color: var(--text-primary, #333);
}
.mia-console-mic.is-listening {
  color: var(--color-accent, #ffc107);
  border-color: var(--color-accent, #ffc107);
  background: rgba(var(--color-accent-rgb, 255, 193, 7), 0.10);
  animation: mia-console-mic-pulse 1.1s ease-in-out infinite;
}
.mia-console-mic svg { width: 16px; height: 16px; fill: currentColor; }
@keyframes mia-console-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--color-accent-rgb, 255, 193, 7), 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(var(--color-accent-rgb, 255, 193, 7), 0); }
}
@media (prefers-reduced-motion: reduce) {
  .mia-console-mic.is-listening { animation: none; }
}

/* ============================================================
   Tour highlight — a vertical glowing rail spanning the current
   section + a "TOUR" pin near the heading. Drawn as absolutely-
   positioned overlays so they don't disturb page layout.
   ============================================================ */
.mia-tour-rail {
  position: absolute;
  left: 6px;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg,
    var(--color-tech, #00c2ff) 0%,
    var(--color-primary, #1976d2) 100%);
  box-shadow: 0 0 18px rgba(var(--color-tech-rgb, 0, 194, 255), 0.55),
              0 0 4px rgba(var(--color-tech-rgb, 0, 194, 255), 0.35);
  pointer-events: none;
  z-index: 999;
  animation: mia-tour-rail-in 0.45s ease-out;
  transform-origin: top;
  /* Promote to its own compositor layer so scroll repaints stay cheap */
  will-change: opacity, transform;
  contain: layout paint;
}
@keyframes mia-tour-rail-in {
  from { opacity: 0; transform: scaleY(0.4); }
  to   { opacity: 1; transform: scaleY(1); }
}
.mia-tour-rail.is-fading {
  opacity: 0;
  transition: opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .mia-tour-rail { animation: none; }
}

.mia-tour-pin {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  background: linear-gradient(180deg, var(--color-tech, #00c2ff) 0%, var(--color-primary, #1976d2) 100%);
  color: #fff;
  font-family: var(--console-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(var(--color-tech-rgb, 0, 194, 255), 0.40),
              0 1px 3px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  animation: mia-tour-pin-in 0.45s ease-out;
}
.mia-tour-pin::before {
  content: '◆';
  color: rgba(255, 255, 255, 0.85);
}
.mia-tour-pin.is-fading {
  opacity: 0;
  transition: opacity 0.3s ease;
}
@keyframes mia-tour-pin-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .mia-tour-pin { animation: none; }
}

/* Section glow — soft halo around the entire current section */
.mia-tour-glow {
  position: absolute;
  left: 0;
  right: 0;
  background: linear-gradient(180deg,
    rgba(var(--color-tech-rgb, 0, 194, 255), 0.06) 0%,
    rgba(var(--color-tech-rgb, 0, 194, 255), 0.02) 60%,
    transparent 100%);
  pointer-events: none;
  z-index: 1;
  animation: mia-tour-glow-in 0.55s ease-out;
  will-change: opacity;
  contain: layout paint;
}
@keyframes mia-tour-glow-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.mia-tour-glow.is-fading {
  opacity: 0;
  transition: opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .mia-tour-glow { animation: none; }
}

/* ============================================================
   Tour overlay — small floating card at the bottom-left during
   a guided tour. Persists across page navigation via session storage.
   ============================================================ */
.mia-console-tour {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 1150;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card, #fff);
  color: var(--text-primary, #1c1c1e);
  border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.18));
  border-left: 3px solid var(--color-tech, #00c2ff);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22), 0 3px 10px rgba(0, 0, 0, 0.10);
  font-family: 'Poppins', system-ui, sans-serif;
  display: none;
  animation: mia-console-tour-in 0.22s ease-out;
}
.mia-console-tour.is-active { display: block; }
@keyframes mia-console-tour-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mia-console-tour-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px;
  font-family: var(--console-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary, #888);
}
.mia-console-tour-head-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-tech, #00c2ff);
  box-shadow: 0 0 6px rgba(var(--color-tech-rgb, 0, 194, 255), 0.6);
}
.mia-console-tour-head-name {
  font-weight: 700;
  color: var(--text-primary, #333);
  letter-spacing: 0.12em;
}
.mia-console-tour-head-step {
  flex: 1;
  text-align: right;
}
.mia-console-tour-title {
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary, #1c1c1e);
}
.mia-console-tour-note {
  padding: 4px 12px 10px;
  font-size: 12.5px;
  color: var(--text-secondary, #555);
  line-height: 1.5;
}
.mia-console-tour-next {
  padding: 4px 12px 8px;
  font-size: 11px;
  font-family: var(--console-mono);
  letter-spacing: 0.04em;
  color: var(--text-secondary, #888);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mia-console-tour-next-arrow {
  color: var(--color-tech, #00c2ff);
  font-weight: 700;
  margin-right: 5px;
}
.mia-console-tour-progress {
  height: 3px;
  background: var(--border-light, rgba(0, 0, 0, 0.08));
  margin: 0 12px;
  border-radius: 2px;
  overflow: hidden;
}
.mia-console-tour-progress-fill {
  height: 100%;
  background: var(--color-tech, #00c2ff);
  width: 0%;
  transition: width 0.4s ease-out;
}
.mia-console-tour-actions {
  display: flex;
  gap: 4px;
  padding: 10px 10px 10px;
  border-top: 1px solid var(--border-light, rgba(0, 0, 0, 0.06));
  margin-top: 10px;
  background: var(--bg-section, rgba(0, 0, 0, 0.03));
  border-radius: 0 0 10px 0;
}
.mia-console-tour-btn {
  flex: 1;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.10));
  color: var(--text-primary, #333);
  padding: 6px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.mia-console-tour-btn:hover {
  border-color: var(--color-primary);
  background: var(--bg-section, rgba(0, 0, 0, 0.04));
}
.mia-console-tour-btn[data-tour="stop"] {
  color: var(--text-secondary, #888);
  flex: 0;
  padding: 6px 10px;
}

@media (max-width: 768px) {
  .mia-console-tour {
    left: 12px; right: 12px; bottom: 80px;
    width: auto;
  }
}

/* Toast — used by share/copy/theme/etc. for "did the thing" confirmation. */
.mia-console-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(20, 22, 32, 0.94);
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 500;
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mia-console-toast::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-tech, #00c2ff);
  flex-shrink: 0;
}
.mia-console-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Highlight on the matched text from `find` */
.mia-console-find-mark {
  background: rgba(var(--color-accent-rgb, 255, 193, 7), 0.55);
  border-radius: 3px;
  padding: 0 2px;
  box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb, 255, 193, 7), 0.35);
  transition: background 1.4s ease, box-shadow 1.4s ease;
}
.mia-console-find-mark.is-fading {
  background: transparent;
  box-shadow: none;
}

@media print {
  #mia-console { display: none !important; }
  .mia-console-toast { display: none !important; }
}
