.mashia-fab {
  position: fixed;
  right: 18px;
  bottom: 140px;
  z-index: 91;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(124, 58, 237, 0.24);
  border-radius: 14px;
  background: #fbf7ef;
  color: #4c1d95;
  box-shadow: 0 12px 28px rgba(42, 26, 74, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

body.experience-landing-focus .mashia-fab {
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 74px);
  width: 42px;
  height: 42px;
  border-radius: 13px;
}

.mashia-fab:hover,
.mashia-fab:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.42);
  box-shadow: 0 16px 32px rgba(42, 26, 74, 0.2);
}

.mashia-fab-icon {
  width: 23px;
  height: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mashia-fab svg,
.mashia-avatar svg {
  width: 100%;
  height: 100%;
}

body.theme-dark .mashia-fab {
  border-color: rgba(167, 139, 250, 0.28);
  background: rgba(24, 18, 42, 0.94);
  color: #ddd6fe;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

.mashia-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(430px, calc(100vw - 24px));
  height: 100vh;
  z-index: 140;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background: rgba(255, 251, 245, 0.98);
  border-left: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: -18px 0 42px rgba(15, 23, 42, 0.18);
  transform: translateX(105%);
  transition: transform 0.22s ease;
}

.mashia-panel.is-open {
  transform: translateX(0);
}

body.theme-dark .mashia-panel {
  background: rgba(11, 18, 32, 0.98);
  border-left-color: rgba(148, 163, 184, 0.22);
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.34);
}

.mashia-panel-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
}

.mashia-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: #5b21b6;
  background: #f3e8ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.theme-dark .mashia-avatar {
  color: #ddd6fe;
  background: rgba(91, 33, 182, 0.24);
}

.mashia-panel-head strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.mashia-panel-head span {
  display: block;
  color: #64748b;
  font-size: 13px;
  line-height: 1.35;
}

body.theme-dark .mashia-panel-head span {
  color: #94a3b8;
}

.mashia-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.mashia-status {
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(248, 250, 252, 0.86);
  color: #334155;
  font-size: 13px;
}

.mashia-status--connected {
  border-color: rgba(20, 184, 166, 0.35);
  background: rgba(204, 251, 241, 0.55);
  color: #0f766e;
}

.mashia-status--not_configured {
  border-color: rgba(234, 179, 8, 0.35);
  background: rgba(254, 249, 195, 0.55);
  color: #854d0e;
}

body.theme-dark .mashia-status {
  background: rgba(15, 23, 42, 0.8);
  color: #cbd5e1;
}

.mashia-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.mashia-message {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.45;
}

.mashia-message--assistant {
  align-self: flex-start;
  background: rgba(241, 245, 249, 0.9);
}

.mashia-message--user {
  align-self: flex-end;
  background: rgba(237, 233, 254, 0.9);
  border-color: rgba(124, 58, 237, 0.22);
}

body.theme-dark .mashia-message--assistant {
  background: rgba(15, 23, 42, 0.82);
}

body.theme-dark .mashia-message--user {
  background: rgba(76, 29, 149, 0.34);
}

.mashia-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.mashia-action-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 8px 10px;
  color: inherit;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.72);
}

body.theme-dark .mashia-action-link {
  background: rgba(15, 23, 42, 0.72);
}

.mashia-composer {
  display: grid;
  gap: 8px;
}

.mashia-composer textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
}

.mashia-settings {
  border-top: 1px solid rgba(148, 163, 184, 0.24);
  padding-top: 10px;
}

.mashia-settings summary {
  cursor: pointer;
  font-weight: 700;
}

.mashia-connect {
  margin: 10px 0;
}

.mashia-permissions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.mashia-permission {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
}

.mashia-settings-status {
  min-height: 18px;
  color: #0f766e;
  font-size: 13px;
}

.mashia-settings-status.is-error {
  color: #dc2626;
}

@media (max-width: 640px) {
  .mashia-fab {
    right: 12px;
    bottom: 128px;
  }

  body.experience-landing-focus .mashia-fab {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 68px);
  }

  .mashia-panel {
    width: 100vw;
  }

  .mashia-permissions {
    grid-template-columns: 1fr;
  }
}
