.rishai-modal-root {
  --rishai-ink: #f4f8ff;
  --rishai-muted: #aebbd0;
  --rishai-border: rgba(138, 167, 211, 0.28);
  --rishai-accent: #28c7c9;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

.rishai-launcher {
  position: fixed;
  z-index: 9997;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(88px, calc(env(safe-area-inset-bottom) + 16px));
  display: grid;
  width: 54px;
  height: 54px;
  padding: 5px;
  place-items: center;
  border: 1px solid rgba(98, 225, 221, 0.56);
  border-radius: 15px;
  background: #0a2028;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42), 0 0 0 3px rgba(40, 199, 201, 0.1);
  cursor: pointer;
  overflow: visible;
}

.rishai-launcher:hover { transform: translateY(-2px); border-color: #72eeeb; }
.rishai-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.rishai-launcher img { display: block; width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.rishai-modal-backdrop[hidden],
.rishai-modal-panel[hidden] { display: none !important; }
.rishai-modal-root[data-open="true"] .rishai-launcher {
  z-index: 10000;
  border-color: #ffb4a8;
  background: #321713;
}
.rishai-modal-root[data-open="true"] .rishai-launcher::after {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid #0b1524;
  border-radius: 999px;
  background: #ff6b57;
  color: #180705;
  content: "×";
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.rishai-modal-backdrop {
  position: fixed;
  z-index: 9998;
  inset: 0;
  background: rgba(2, 7, 14, 0.86);
  overscroll-behavior: contain;
}

.rishai-modal-panel {
  position: fixed;
  z-index: 9999;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  width: min(480px, calc(100vw - 24px));
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--rishai-border);
  border-radius: 20px;
  background: #0b1524;
  box-shadow: -18px 0 70px rgba(0, 0, 0, 0.55);
  color: var(--rishai-ink);
}

.rishai-modal-header {
  display: flex;
  min-height: 68px;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rishai-border);
  background: #0e1b2d;
}

.rishai-modal-header img { width: 42px; height: 42px; border-radius: 11px; object-fit: cover; }
.rishai-modal-header h2 { margin: 0; color: var(--rishai-ink); font-size: 22px; line-height: 1; }

.rishai-modal-content { display: flex; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.rishai-modal-content > * { width: 100%; min-width: 0; min-height: 0; }

.rishai-modal-content > .ai-tutor-panel,
.rishai-modal-content > .cs-rishai {
  position: static !important;
  inset: auto !important;
  display: flex !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  border: 0 !important;
  border-radius: 0 !important;
  background: #0b1524 !important;
  box-shadow: none !important;
}

.rishai-modal-content .ai-tutor-body,
.rishai-modal-content .ai-tutor-content,
.rishai-modal-content .cs-rishai-body { display: flex; min-height: 0; flex: 1 1 auto; flex-direction: column; }
.rishai-modal-content .ai-chat-shell,
.rishai-modal-content .cs-rishai-thread { min-height: 0; flex: 1 1 auto; }
.rishai-modal-content .cs-rishai-body { padding: 14px; }
.rishai-modal-content .cs-rishai-thread { max-height: none; }

body.rishai-modal-open { overscroll-behavior: none; }

.rishai-modal-root[data-active-layout="workspace"] .rishai-modal-backdrop {
  background: transparent;
  pointer-events: none;
}

.rishai-modal-root[data-active-layout="workspace"] .rishai-modal-panel {
  top: var(--rishai-panel-top);
  right: auto;
  bottom: auto;
  left: var(--rishai-panel-left);
  width: var(--rishai-panel-width);
  height: var(--rishai-panel-height);
  max-width: none;
  border-radius: 14px;
  pointer-events: auto;
}

.rishai-modal-root[data-open="true"][data-active-layout="workspace"] .rishai-launcher {
  right: var(--rishai-close-right);
  bottom: var(--rishai-close-bottom);
}

.rishai-modal-root[data-open="true"] .rishai-modal-content {
  padding-bottom: 64px;
}

@media (max-width: 700px) {
  .rishai-launcher {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(82px, calc(env(safe-area-inset-bottom) + 14px));
    width: 52px;
    height: 52px;
  }
  .rishai-modal-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .rishai-modal-root[data-open="true"] .rishai-launcher {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  .rishai-modal-header {
    min-height: calc(62px + env(safe-area-inset-top));
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .rishai-modal-content .ai-composer,
  .rishai-modal-content .cs-rishai-form { margin-bottom: env(safe-area-inset-bottom); }
}

@media (prefers-reduced-motion: reduce) {
  .rishai-launcher { transition: none; }
}
