dialog#luna-dialog:not([open]) {
  display: none;
}

dialog#luna-dialog {
  position: fixed;
  inset: auto calc(24px + env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(432px, calc(100vw - 48px));
  height: min(640px, calc(100dvh - 120px - env(safe-area-inset-bottom, 0px)));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 120px - env(safe-area-inset-bottom, 0px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #dce8e2;
  border-radius: 22px;
  background: #fffefa;
  color: #193b36;
  text-align: left;
  box-shadow: 0 24px 64px rgb(17 42 36 / 18%);
}

dialog#luna-dialog[open] {
  display: grid;
  animation: luna-post-panel-in 180ms ease-out both;
}

dialog#luna-dialog > #floating-luna {
  position: fixed;
  z-index: 10002;
  right: calc(17px + env(safe-area-inset-right, 0px));
  bottom: calc(17px + env(safe-area-inset-bottom, 0px));
}

dialog#luna-dialog::backdrop {
  background: rgb(16 40 35 / 35%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.luna-post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #dce8e2;
}

#dialog-orb.dialog-orb {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  margin: 0;
  border: 1px solid rgb(255 255 255 / 75%);
  box-shadow: 0 2px 8px rgb(25 59 54 / 12%);
}

.luna-post-heading {
  display: grid;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.luna-post-heading .eyebrow {
  margin: 0;
  color: #193b36;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.luna-post-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #536d66;
  font-size: 12px;
}

.luna-post-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa9a2;
  content: "";
}

dialog[data-call-state="connecting"] .luna-post-status::before {
  background: #d39a3a;
  animation: luna-post-pulse 1.1s ease-in-out infinite;
}

dialog[data-call-state="connected"] .luna-post-status::before,
dialog[data-call-state="speaking"] .luna-post-status::before {
  background: #32836c;
}

dialog[data-call-state="speaking"] #dialog-orb {
  animation: orbreathe 1.4s ease-in-out infinite;
}

.luna-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #193b36;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}

.luna-panel-icon:hover,
.luna-panel-icon:focus-visible {
  background: #f2f7f3;
}

.luna-post-body {
  min-height: 0;
  overflow: auto;
  padding: 24px;
  overscroll-behavior: contain;
}

.luna-post-body h2 {
  margin: 0;
  color: #193b36;
  font-family: "Manrope", "DM Sans", system-ui, sans-serif;
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -0.045em;
  line-height: 1.18;
}

.luna-post-body > p:not(.small) {
  margin: 13px 0 0;
  color: #536d66;
  font-size: 13px;
  line-height: 1.7;
}

dialog#luna-dialog .live-message {
  margin: 22px 0 16px;
  padding: 13px 14px;
  border: 1px solid #dce8e2;
  border-radius: 12px;
  background: #f2f7f3;
  color: #536d66;
  font-size: 12px;
  line-height: 1.6;
}

.luna-post-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.luna-call-start,
.luna-call-control,
.luna-call-end {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 500 13px/1.2 "DM Sans", system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease, border-color 150ms ease;
}

.luna-call-start {
  width: 100%;
  background: #193b36;
  color: #fff;
}

.luna-call-start:hover:not(:disabled) {
  background: #155f52;
}

.luna-call-start:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.luna-call-control {
  flex: 1 1 auto;
  border-color: #dce8e2;
  background: #fff;
  color: #193b36;
}

.luna-call-control[aria-pressed="true"] {
  border-color: #e5d4af;
  background: #fbf5e9;
  color: #865f1f;
}

.luna-call-end {
  flex: 1 1 auto;
  border-color: #ead3d0;
  background: #fff;
  color: #9c3f3c;
}

.luna-call-end:hover {
  background: #fbefee;
}

.luna-post-controls svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.luna-post-body > .text-link {
  margin-top: 20px;
  color: #155f52;
}

.luna-post-body > p.small {
  max-width: none;
  margin: 22px 0 0;
  color: #71827b;
  font-size: 11px;
  line-height: 1.6;
}

.floating-luna.is-live .tiny-orb {
  box-shadow: 0 0 0 4px rgb(50 131 108 / 16%), inset -4px -3px 9px #516bc035, inset 3px 2px 5px #fff8;
}

.floating-luna:focus-visible,
.luna-panel-icon:focus-visible,
.luna-post-controls button:focus-visible {
  outline: 3px solid #287968;
  outline-offset: 3px;
}

@keyframes luna-post-panel-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes luna-post-pulse {
  50% { opacity: 0.45; }
}

@media (max-width: 560px) {
  dialog#luna-dialog {
    inset: auto 12px calc(92px + env(safe-area-inset-bottom, 0px)) 12px;
    width: auto;
    height: min(620px, calc(100dvh - 120px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    max-width: none;
    border-radius: 22px;
  }

  .luna-post-header {
    padding: 12px 14px;
  }

  .luna-post-body {
    padding: 21px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog#luna-dialog[open],
  dialog[data-call-state="connecting"] .luna-post-status::before,
  dialog[data-call-state="speaking"] #dialog-orb {
    animation: none;
  }
}
