.shared-menu-panel {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 60;
  min-width: 220px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(9, 14, 28, 0.95);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  padding: 10px;
  display: none;
  overflow: visible;
}

.shared-menu-panel.open {
  display: block;
}

.shared-quick-links {
  position: fixed;
  top: 16px;
  right: 72px;
  display: flex;
  gap: 8px;
  z-index: 59;
}

/* ── Safe-area: push page content below the fixed quick-links bar ── */
body:has(.shared-quick-links) {
  min-height: 100vh;
  padding-top: max(72px, var(--body-padding-top, 72px)) !important;
}
/* Pages that already handle their own top spacing can opt out */
body[data-no-quick-link-spacing]:has(.shared-quick-links) {
  padding-top: revert !important;
}

.shared-quick-links a,
.shared-quick-links button {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(9, 14, 28, 0.9);
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.2rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.shared-quick-links a:hover,
.shared-quick-links button:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.95);
}

:root.theme-day .shared-quick-links a,
:root.theme-day .shared-menu-panel a,
:root.theme-day .shared-menu-panel button,
:root.theme-day .shared-submenu a,
:root.theme-day .shared-submenu button {
  color: #0f172a !important;
  background: transparent !important;
}

:root.theme-day .shared-menu-panel a:hover,
:root.theme-day .shared-menu-panel button:hover,
:root.theme-day .shared-submenu a:hover,
:root.theme-day .shared-submenu button:hover {
  background: #eef2ff !important;
  border-color: #cbd5e1 !important;
}

:root.theme-day .shared-menu-user {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

:root.theme-day .shared-menu-item.has-submenu > button {
  background: transparent !important;
  color: #0f172a !important;
}

:root.theme-day .shared-menu-item.has-submenu > button:hover {
  background: #eef2ff !important;
}

:root.theme-day input,
:root.theme-day select,
:root.theme-day textarea {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

:root.theme-day .pill,
:root.theme-day .pill.compact,
:root.theme-day .persona-control,
:root.theme-day .file-pill,
:root.theme-day .file-row,
:root.theme-day #doc-summary li,
.shared-menu-panel a,
.shared-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  color: #e2e8f0;
  background: transparent;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.shared-menu-panel a:hover,
.shared-menu-panel button:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.25);
}

.shared-menu-item {
  position: relative;
}

.shared-menu-item.has-submenu > button::after {
  content: '▾';
  float: right;
  color: #94a3b8;
}

.shared-submenu {
  position: static;
  width: 100%;
  margin-top: 8px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(9, 14, 28, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  padding: 8px;
  display: none;
  z-index: 61;
}

.shared-menu-item.has-submenu.open .shared-submenu {
  display: block;
}

.shared-menu-separator {
  height: 1px;
  background: rgba(148, 163, 184, 0.25);
  margin: 10px 0;
}

:root.theme-day .shared-menu-separator {
  background: rgba(15, 23, 42, 0.15);
}

@media (max-width: 720px) {
  .shared-menu-panel {
    top: 60px;
    right: 12px;
    left: 12px;
    width: auto;
    min-width: 0;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  .card {
    padding: 14px !important;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-line {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .persona-control {
    width: 100%;
    justify-content: space-between;
  }

  .voice-shell {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }

  .voice-center {
    order: -1;
    width: 100%;
  }

  .voice-left {
    order: 0;
    width: 100%;
  }

  .voice-right {
    order: 1;
    width: 100%;
  }

  .voice-controls {
    justify-content: center !important;
    width: 100%;
  }

  .voice-controls button,
  .voice-controls select,
  .voice-controls a {
    width: 100%;
    max-width: 100%;
  }

  #connect {
    width: 120px !important;
    height: 120px !important;
  }

  .file-pill {
    width: 100%;
    justify-content: center;
  }

  .knowledge-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  #doc-summary {
    max-height: none;
  }

  .history-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .history-actions button {
    width: 100%;
  }
}

:root.theme-day {
  color-scheme: light;
  background: #f7fafc;
  color: #0f172a;

  /* ── Override common dark CSS custom-properties used across pages ── */
  /* Generic surface / background variables */
  --bg: #f8fafc;
  --bg-dark: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface2: #f1f5f9;
  --surface-3: #e2e8f0;
  --surface3: #e2e8f0;

  /* Input / form field backgrounds */
  --bg-input: #ffffff;
  --input-bg: #ffffff;

  /* Component-level backgrounds (used by luca-ai-agent, infra-keeper, etc.) */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;

  /* App-scoped variables (used by custom-apps) */
  --app-bg: #ffffff;
  --app-card: #f1f5f9;
  --app-border: rgba(15, 23, 42, 0.12);
  --app-text: #0f172a;
  --app-muted: #64748b;

  /* Card/container backgrounds (many pages use --card instead of --bg-card) */
  --card: #ffffff;
  --card-bg: #ffffff;
  --card-hover: #f1f5f9;

  /* Sidebar & panel backgrounds */
  --sidebar-bg: #f8fafc;
  --sidebar-hover: #f1f5f9;
  --panel: #f8fafc;
  --panel-strong: #f1f5f9;
  --header-bg: #ffffff;
  --bg-header: #ffffff;
  --channel-active: #eff6ff;

  /* Input background aliases */
  --inp: #ffffff;
  --readonly-bg: #f1f5f9;

  /* Additional background aliases */
  --bg-alt: #f1f5f9;
  --bg-subtle: #f8fafc;
  --hover-bg: #f1f5f9;
  --bg1: #ffffff;
  --bg2: #f8fafc;
  --bg3: #f1f5f9;
  --surface-hover: #f1f5f9;
  --surface-light: #ffffff;
  --bg-surface: #f8fafc;

  /* Border variables */
  --border: rgba(15, 23, 42, 0.15);
  --border-color: rgba(15, 23, 42, 0.15);

  /* Text variables */
  --text: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-dim: #64748b;
  --dim: #64748b;
  --dimmer: #94a3b8;
  --muted: #64748b;
}

:root.theme-day body {
  background: linear-gradient(165deg, #f8fafc 0%, #eef2ff 44%, #e0f2fe 100%) !important;
  color: #0f172a;
}

:root.theme-day body,
:root.theme-day a,
:root.theme-day span,
:root.theme-day div,
:root.theme-day li,
:root.theme-day small,
:root.theme-day strong,
:root.theme-day em,
:root.theme-day button,
:root.theme-day select,
:root.theme-day option,
:root.theme-day label {
  color: #0f172a !important;
}

:root.theme-day svg {
  color: #0f172a;
  stroke: currentColor;
}

:root.theme-day header,
:root.theme-day .hero,
:root.theme-day main.page {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

:root.theme-day .top-bar,
:root.theme-day .status-line {
  background: transparent !important;
}

:root.theme-day h1,
:root.theme-day h2,
:root.theme-day h3,
:root.theme-day h4,
:root.theme-day h5,
:root.theme-day h6,
:root.theme-day p,
:root.theme-day label,
:root.theme-day .hint,
:root.theme-day .status,
:root.theme-day .error,
:root.theme-day .eyebrow,
:root.theme-day .subtle,
:root.theme-day .history-subhead,
:root.theme-day .shared-menu-user,
:root.theme-day .menu-item {
  color: #0f172a !important;
}

:root.theme-day .card,
:root.theme-day .knowledge-card,
:root.theme-day .history-card,
:root.theme-day .transcript-card,
:root.theme-day .control-card,
:root.theme-day .file-row,
:root.theme-day .file-list,
:root.theme-day .modal-card,
:root.theme-day .modal-content,
:root.theme-day .crm-card,
:root.theme-day .stat-card,
:root.theme-day .app-card,
:root.theme-day .summary-card,
:root.theme-day .status-card,
:root.theme-day .shared-menu-panel,
:root.theme-day .shared-submenu {
  background: #ffffff !important;
  color: #0f172a;
  border-color: #cbd5e1 !important;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08) !important;
}

:root.theme-day .section,
:root.theme-day .settings-section,
:root.theme-day .page-section,
:root.theme-day .section-panel,
:root.theme-day .panel-section,
:root.theme-day .page-header,
:root.theme-day .ws-sidebar,
:root.theme-day .mini-card,
:root.theme-day .bar-wrap,
:root.theme-day .tab-panel.active {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

:root.theme-day [contenteditable="true"] {
  background: #ffffff !important;
  color: #0f172a !important;
}

:root.theme-day .shared-menu-panel a,
:root.theme-day .shared-menu-panel button,
:root.theme-day .shared-submenu a,
:root.theme-day .shared-submenu button {
  color: #0f172a !important;
  background: transparent !important;
}

:root.theme-day .shared-menu-panel a:hover,
:root.theme-day .shared-menu-panel button:hover,
:root.theme-day .shared-submenu a:hover,
:root.theme-day .shared-submenu button:hover {
  background: #eef2ff !important;
  border-color: #cbd5e1 !important;
}

:root.theme-day .shared-menu-user {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

:root.theme-day .shared-menu-item.has-submenu > button {
  background: transparent !important;
  color: #0f172a !important;
}

:root.theme-day .shared-menu-item.has-submenu > button:hover {
  background: #eef2ff !important;
}

:root.theme-day input,
:root.theme-day select,
:root.theme-day textarea {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
}

:root.theme-day .pill,
:root.theme-day .pill.compact,
:root.theme-day .persona-control,
:root.theme-day .file-pill,
:root.theme-day .file-row,
:root.theme-day #doc-summary li,
:root.theme-day .conversation-item {
  background: #f8fafc !important;
  color: #0f172a;
  border-color: #cbd5e1 !important;
}

:root.theme-day .pill .dot {
  background: #0ea5e9;
  box-shadow: none;
}

:root.theme-day button,
:root.theme-day .icon-button,
:root.theme-day .ghost-btn,
:root.theme-day .secondary,
:root.theme-day .file-row button,
:root.theme-day .knowledge-controls button,
:root.theme-day .history-actions button,
:root.theme-day .collapse-btn {
  color: #0f172a;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08) !important;
}

:root.theme-day button:not(.secondary):not(.ghost-btn):not(.collapse-btn),
:root.theme-day .icon-button:not(.secondary):not(.ghost-btn) {
  background: linear-gradient(120deg, #4f46e5, #0ea5e9) !important;
  color: #f8fafc !important;
  border-color: #4f46e5 !important;
}

/* Override gradient for ALL menu buttons */
:root.theme-day .shared-menu-panel button:not(.fake-class),
:root.theme-day .shared-submenu button:not(.fake-class),
:root.theme-day .shared-menu-item button:not(.fake-class),
:root.theme-day .shared-menu-panel .shared-menu-item button:not(.fake-class),
:root.theme-day .shared-menu-item.has-submenu > button:not(.fake-class),
:root.theme-day .shared-menu-panel > button:not(.fake-class),
:root.theme-day .shared-menu-panel button[role="menuitem"]:not(.fake-class) {
  background: #ffffff !important;
  background-image: none !important;
  color: #0f172a !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

:root.theme-day .shared-menu-panel button:hover:not(.fake-class),
:root.theme-day .shared-submenu button:hover:not(.fake-class),
:root.theme-day .shared-menu-item button:hover:not(.fake-class),
:root.theme-day .shared-menu-item.has-submenu > button:hover:not(.fake-class),
:root.theme-day .shared-menu-panel > button:hover:not(.fake-class),
:root.theme-day .shared-menu-panel button[role="menuitem"]:hover:not(.fake-class) {
  background: #eef2ff !important;
  background-image: none !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

:root.theme-day .secondary,
:root.theme-day .ghost-btn,
:root.theme-day .icon-button.secondary,
:root.theme-day .collapse-btn {
  background: #eef2ff !important;
  color: #0f172a !important;
}

:root.theme-day a,
:root.theme-day .text-link {
  color: #0f172a !important;
}

:root.theme-day .modal {
  background: rgba(15, 23, 42, 0.3) !important;
}

:root.theme-day pre,
:root.theme-day #logs-body,
:root.theme-day #prompt-modal-text {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

:root.theme-day .messages-panel {
  background: linear-gradient(180deg, rgba(79, 70, 229, 0.06), rgba(248, 250, 252, 0.95)) !important;
  color: #0f172a !important;
}

:root.theme-day .status {
  color: #0f172a !important;
}

:root.theme-day .error {
  color: #b91c1c !important;
}

/* System Menu Overlay */
.system-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dashboard-card {
  background: rgba(9, 14, 28, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 16px 12px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 170px;
  text-align: center;
  cursor: pointer;
}

.system-menu-content {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(9, 14, 28, 0.98));
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 25px 100px rgba(0, 0, 0, 0.7);
  max-width: 1400px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.system-menu-header {
  padding: 24px 32px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.system-menu-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.system-menu-close {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.system-menu-close:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  transform: scale(1.05);
}

.system-menu-grid {
  padding: 24px 32px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  flex: 1;
  grid-auto-rows: minmax(170px, auto);
}

.system-menu-item {
  cursor: pointer;
}

.system-menu-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  border-color: rgba(99, 102, 241, 0.6);
}

.system-menu-item.persona {
  border-color: rgba(220, 38, 38, 0.4);
}

.system-menu-item.persona:hover {
  border-color: rgba(220, 38, 38, 0.6);
  box-shadow: 0 20px 50px rgba(220, 38, 38, 0.25);
}

.system-menu-item.ai {
  border-color: rgba(22, 163, 74, 0.4);
}

.system-menu-item.ai:hover {
  border-color: rgba(22, 163, 74, 0.6);
  box-shadow: 0 20px 50px rgba(22, 163, 74, 0.25);
}

.system-menu-item.maintenance {
  border-color: rgba(37, 99, 235, 0.4);
}

.system-menu-item.maintenance:hover {
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 20px 50px rgba(37, 99, 235, 0.25);
}

.system-menu-item.document {
  border-color: rgba(147, 51, 234, 0.4);
}

.system-menu-item.document:hover {
  border-color: rgba(147, 51, 234, 0.6);
  box-shadow: 0 20px 50px rgba(147, 51, 234, 0.25);
}

.system-menu-item.other {
  border-color: rgba(75, 85, 99, 0.4);
}

.system-menu-item.other:hover {
  border-color: rgba(75, 85, 99, 0.6);
  box-shadow: 0 20px 50px rgba(75, 85, 99, 0.25);
}

.system-menu-icon {
  font-size: 1.9rem;
  line-height: 1;
}

.system-menu-label {
  font-weight: 600;
  font-size: 1.1rem;
  color: #f8fafc;
}

.system-menu-description {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.4;
  margin: 0;
}

.system-menu-pagination {
  padding: 20px 32px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.system-menu-pagination button {
  background: rgba(79, 70, 229, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.system-menu-pagination button:hover:not(:disabled) {
  background: rgba(79, 70, 229, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.system-menu-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.system-menu-pagination span {
  color: #cbd5e1;
  font-weight: 600;
}

/* Light mode styles */
:root.theme-day .system-menu-overlay {
  background: rgba(15, 23, 42, 0.3);
}

:root.theme-day .system-menu-content {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
  border-color: rgba(15, 23, 42, 0.15);
}

:root.theme-day .system-menu-header {
  border-bottom-color: rgba(15, 23, 42, 0.1);
}

:root.theme-day .system-menu-item {
  background: rgba(248, 250, 252, 0.96);
  border-color: rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

:root.theme-day .system-menu-item.persona {
  border-color: rgba(220, 38, 38, 0.4);
}

:root.theme-day .system-menu-item.persona:hover {
  border-color: rgba(220, 38, 38, 0.6);
  box-shadow: 0 12px 24px rgba(220, 38, 38, 0.25);
}

:root.theme-day .system-menu-item.ai {
  border-color: rgba(22, 163, 74, 0.4);
}

:root.theme-day .system-menu-item.ai:hover {
  border-color: rgba(22, 163, 74, 0.6);
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.25);
}

:root.theme-day .system-menu-item.maintenance {
  border-color: rgba(37, 99, 235, 0.4);
}

:root.theme-day .system-menu-item.maintenance:hover {
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

:root.theme-day .system-menu-item.document {
  border-color: rgba(147, 51, 234, 0.4);
}

:root.theme-day .system-menu-item.document:hover {
  border-color: rgba(147, 51, 234, 0.6);
  box-shadow: 0 12px 24px rgba(147, 51, 234, 0.25);
}

:root.theme-day .system-menu-item.other {
  border-color: rgba(107, 114, 128, 0.4);
}

:root.theme-day .system-menu-item.other:hover {
  border-color: rgba(107, 114, 128, 0.6);
  box-shadow: 0 12px 24px rgba(107, 114, 128, 0.25);
}

:root.theme-day .system-menu-label {
  color: #0f172a;
}

:root.theme-day .system-menu-description {
  color: #475569;
}

:root.theme-day .system-menu-pagination {
  border-top-color: rgba(15, 23, 42, 0.1);
}

:root.theme-day .system-menu-pagination span {
  color: #475569;
}
