/* Crystal AI 95% Workspace Modal Styles */
#crystal_modal_bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 99998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  /* MUST be display:none while closed, NOT just opacity:0 + pointer-events:none.
     Safari/WebKit picks the scroll target for a wheel gesture from the compositing
     layer tree, which ignores pointer-events — so an always-present full-viewport
     fixed layer silently ate every wheel event aimed at the /home tab-pane iframes
     beneath it. Chrome honours pointer-events here, which is why it only broke in
     Safari. Verified in WebKit: display:flex → chat won't scroll; display:none → it
     does. crystal-drawer.js adds `.shown` a frame before `.active` so the fade
     still runs, and drops it after the close transition. */
  display: none;
  align-items: center;
  justify-content: center;
}
/* mounted (occupies the viewport) — set one frame before .active so opacity can animate */
#crystal_modal_bg.shown {
  display: flex;
}
#crystal_modal_bg.active {
  opacity: 1;
  pointer-events: auto;
}

#crystal_modal {
  width: 95vw;
  height: 92vh;
  max-width: 1440px;
  background: #09090d;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#crystal_modal_bg.active #crystal_modal {
  transform: scale(1);
}

.cm-header {
  padding: 10px 20px;
  background: rgba(18, 22, 30, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cm-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* History toggle: only needed on mobile, where the workspace sidebar is a drawer.
   On desktop the sidebar is docked inside the iframe, so hide the button. */
.cm-hist {
  display: none;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.cm-hist:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
@media (max-width: 680px) {
  .cm-hist { display: inline-flex; align-items: center; justify-content: center; }
}
.cm-actions { display: flex; align-items: center; gap: 4px; }
.cm-call {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: all 0.15s;
}
.cm-call:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.cm-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 24px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: all 0.15s;
}
.cm-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Persistent Header Button */
.btn-crystal-global {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #e2e8f0;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-crystal-global:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(168, 85, 247, 0.4));
  border-color: #a855f7;
  color: #fff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}
