/* AI Markdown parallel view — floating FAB + panel */

.ai-md-fab {
  position: fixed;
  right: max(0.85rem, env(safe-area-inset-right));
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem 0.55rem 0.65rem;
  border-radius: 999px;
  border: 1px solid oklch(70% 0.04 255 / 0.35);
  background: oklch(14% 0.03 255 / 0.88);
  color: #e8eefc;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 32px oklch(0% 0 0 / 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.ai-md-fab:hover,
.ai-md-fab:focus-visible {
  transform: translateY(-1px);
  border-color: oklch(75% 0.1 230 / 0.7);
  background: oklch(18% 0.04 255 / 0.95);
  outline: none;
}

.ai-md-fab:focus-visible {
  box-shadow: 0 0 0 2px oklch(70% 0.12 230);
}

.ai-md-fab__ico {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  opacity: 0.9;
}

.ai-md-fab__txt {
  line-height: 1;
}

body.ai-md-open {
  overflow: hidden;
}

.ai-md-panel {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: grid;
  place-items: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.ai-md-panel[hidden] {
  display: none !important;
}

.ai-md-panel__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(4% 0.02 255 / 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.ai-md-panel__card {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid oklch(70% 0.03 255 / 0.2);
  background: oklch(12% 0.02 255);
  color: inherit;
  box-shadow: 0 24px 80px oklch(0% 0 0 / 0.5);
  overflow: hidden;
}

.ai-md-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.1rem 0.75rem;
  border-bottom: 1px solid oklch(70% 0.03 255 / 0.12);
}

.ai-md-panel__head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.ai-md-panel__sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  opacity: 0.75;
  line-height: 1.35;
}

.ai-md-panel__x {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid oklch(70% 0.03 255 / 0.18);
  background: transparent;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.ai-md-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid oklch(70% 0.03 255 / 0.1);
}

.ai-md-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid oklch(70% 0.03 255 / 0.22);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.ai-md-btn:hover,
.ai-md-btn:focus-visible {
  border-color: oklch(75% 0.1 230 / 0.55);
  background: oklch(100% 0 0 / 0.05);
  outline: none;
}

.ai-md-btn--primary {
  background: oklch(72% 0.12 230 / 0.18);
  border-color: oklch(72% 0.12 230 / 0.45);
}

.ai-md-panel__pre {
  margin: 0;
  padding: 1rem 1.15rem 1.25rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: oklch(8% 0.015 255);
  color: oklch(92% 0.02 255);
}

:root[data-theme="light"] .ai-md-fab {
  background: oklch(98% 0.01 255 / 0.95);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.15);
}

:root[data-theme="light"] .ai-md-panel__card {
  background: #f8fafc;
  color: #0f172a;
}

:root[data-theme="light"] .ai-md-panel__pre {
  background: #0f172a;
  color: #e2e8f0;
}

@media (max-width: 520px) {
  .ai-md-fab__txt {
    /* keep label — useful on mobile too */
  }
  .ai-md-panel__actions {
    padding-bottom: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-md-fab {
    transition: none;
  }
}
