:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#site-header,
#demo-header {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1200;
  flex-shrink: 0;
}

#site-header[sticky="false"],
#demo-header[sticky="false"] {
  position: static;
  top: auto;
}

.demo-footer-slot,
#page-footer {
  position: sticky;
  bottom: 0;
  width: 100%;
  z-index: 1200;
  flex-shrink: 0;
  margin-top: auto;
}

.demo-footer-slot[sticky="false"],
#page-footer[sticky="false"] {
  position: static;
  bottom: auto;
}

body[data-demo-palette='default'] {
  background: none;
}

body.theme-light,
body[data-mpr-theme='light'] {
  background-color: #f8fafc;
  color: var(--mpr-color-text-primary, #0f172a);
}

body.theme-dark,
body[data-mpr-theme='dark'] {
  background-color: #0f172a;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

main {
  flex: 1 0 auto;
  padding: 6rem 1.5rem 6rem;
  max-width: 960px;
  margin: 0 auto;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

h1,
h2 {
  color: var(--mpr-color-accent, #38bdf8);
}

section {
  margin-bottom: 3rem;
  padding: 1.5rem;
  border: 1px solid var(--mpr-color-border, rgba(148, 163, 184, 0.35));
  border-radius: 0.75rem;
  background: var(--mpr-color-surface-primary, rgba(15, 23, 42, 0.65));
  color: var(--mpr-color-text-primary, #e2e8f0);
  backdrop-filter: blur(4px);
}

.custom-elements-preview {
  margin-top: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  padding: 1.5rem;
  background: var(--mpr-color-surface-elevated, rgba(15, 23, 42, 0.85));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.2);
}

.custom-elements-preview mpr-header,
.custom-elements-preview mpr-footer {
  display: block;
}

pre {
  background: var(--mpr-color-surface-elevated, rgba(15, 23, 42, 0.85));
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1rem 0;
  color: var(--mpr-color-text-primary, #e2e8f0);
  border: 1px solid var(--mpr-color-border, rgba(148, 163, 184, 0.35));
}

code {
  font-family: 'Fira Code', 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

.auth-card {
  display: grid;
  gap: 1rem;
  background: var(--mpr-color-surface-elevated, rgba(30, 41, 59, 0.6));
  border-radius: 0.75rem;
  padding: 1.5rem;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

.auth-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

#google-signin-container {
  display: inline-flex;
  align-items: center;
}

button {
  background: var(--mpr-color-accent, #38bdf8);
  color: var(--mpr-color-accent-contrast, #0f172a);
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
}

.google-button {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid rgba(15, 23, 42, 0.15);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

button.secondary {
  background: var(--mpr-chip-bg, rgba(148, 163, 184, 0.18));
  color: var(--mpr-color-text-primary, #e2e8f0);
}

button:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

body[data-demo-palette='sunrise'],
body[data-demo-palette='forest'] {
  transition: background 0.3s ease, color 0.3s ease;
}

body[data-demo-palette='sunrise'].theme-light,
body[data-demo-palette='sunrise'][data-mpr-theme='light'] {
  --mpr-color-surface-primary: rgba(252, 232, 222, 0.92);
  --mpr-color-surface-elevated: rgba(255, 247, 237, 0.98);
  --mpr-color-text-primary: #7c2d12;
  --mpr-color-text-muted: #9a3412;
  --mpr-color-border: rgba(249, 210, 179, 0.6);
  --mpr-color-divider: rgba(253, 186, 116, 0.6);
  --mpr-chip-bg: rgba(249, 115, 22, 0.18);
  --mpr-chip-hover-bg: rgba(249, 115, 22, 0.28);
  --mpr-menu-hover-bg: rgba(251, 146, 60, 0.18);
  --mpr-color-accent: #f97316;
  --mpr-color-accent-alt: #fb923c;
  --mpr-color-accent-contrast: #fff7ed;
  --mpr-theme-toggle-bg: rgba(251, 191, 36, 0.2);
  --mpr-shadow-elevated: 0 10px 24px rgba(124, 45, 18, 0.18);
  --mpr-shadow-flyout: 0 18px 36px rgba(124, 45, 18, 0.22);
  background-image: linear-gradient(135deg, #fff7ed 0%, #fde68a 100%);
  color: var(--mpr-color-text-primary, #7c2d12);
}

body[data-demo-palette='sunrise'].theme-dark,
body[data-demo-palette='sunrise'][data-mpr-theme='dark'] {
  --mpr-color-surface-primary: rgba(76, 20, 12, 0.92);
  --mpr-color-surface-elevated: rgba(111, 38, 22, 0.96);
  --mpr-color-text-primary: #ffedd5;
  --mpr-color-text-muted: #fed7aa;
  --mpr-color-border: rgba(251, 191, 36, 0.45);
  --mpr-color-divider: rgba(249, 115, 22, 0.4);
  --mpr-chip-bg: rgba(251, 146, 60, 0.24);
  --mpr-chip-hover-bg: rgba(251, 146, 60, 0.35);
  --mpr-menu-hover-bg: rgba(182, 73, 38, 0.35);
  --mpr-color-accent: #fb923c;
  --mpr-color-accent-alt: #f97316;
  --mpr-color-accent-contrast: #431407;
  --mpr-theme-toggle-bg: rgba(251, 146, 60, 0.25);
  --mpr-shadow-elevated: 0 10px 24px rgba(67, 20, 7, 0.45);
  --mpr-shadow-flyout: 0 18px 36px rgba(67, 20, 7, 0.55);
  background-image: linear-gradient(135deg, #7c2d12 0%, #431407 100%);
  color: var(--mpr-color-text-primary, #ffedd5);
}

body[data-demo-palette='forest'].theme-light,
body[data-demo-palette='forest'][data-mpr-theme='light'] {
  --mpr-color-surface-primary: rgba(220, 252, 231, 0.92);
  --mpr-color-surface-elevated: rgba(240, 253, 244, 0.98);
  --mpr-color-text-primary: #064e3b;
  --mpr-color-text-muted: #047857;
  --mpr-color-border: rgba(16, 185, 129, 0.35);
  --mpr-color-divider: rgba(74, 222, 128, 0.35);
  --mpr-chip-bg: rgba(52, 211, 153, 0.2);
  --mpr-chip-hover-bg: rgba(52, 211, 153, 0.32);
  --mpr-menu-hover-bg: rgba(187, 247, 208, 0.35);
  --mpr-color-accent: #10b981;
  --mpr-color-accent-alt: #059669;
  --mpr-color-accent-contrast: #ecfdf5;
  --mpr-theme-toggle-bg: rgba(52, 211, 153, 0.18);
  --mpr-shadow-elevated: 0 10px 24px rgba(15, 118, 110, 0.35);
  --mpr-shadow-flyout: 0 18px 36px rgba(15, 118, 110, 0.45);
  background-image: linear-gradient(135deg, #d1fae5 0%, #86efac 100%);
  color: var(--mpr-color-text-primary, #064e3b);
}

body[data-demo-palette='forest'].theme-dark,
body[data-demo-palette='forest'][data-mpr-theme='dark'] {
  --mpr-color-surface-primary: rgba(17, 42, 36, 0.94);
  --mpr-color-surface-elevated: rgba(13, 35, 30, 0.98);
  --mpr-color-text-primary: #dcfce7;
  --mpr-color-text-muted: #86efac;
  --mpr-color-border: rgba(134, 239, 172, 0.3);
  --mpr-color-divider: rgba(34, 197, 94, 0.4);
  --mpr-chip-bg: rgba(34, 197, 94, 0.2);
  --mpr-chip-hover-bg: rgba(34, 197, 94, 0.32);
  --mpr-menu-hover-bg: rgba(21, 128, 61, 0.35);
  --mpr-color-accent: #22c55e;
  --mpr-color-accent-alt: #16a34a;
  --mpr-color-accent-contrast: #052e16;
  --mpr-theme-toggle-bg: rgba(34, 197, 94, 0.18);
  --mpr-shadow-elevated: 0 10px 24px rgba(5, 46, 22, 0.4);
  --mpr-shadow-flyout: 0 18px 36px rgba(5, 46, 22, 0.5);
  background-image: linear-gradient(135deg, #022c22 0%, #065f46 100%);
  color: var(--mpr-color-text-primary, #dcfce7);
}

.event-log {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--mpr-color-border, rgba(148, 163, 184, 0.25));
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: var(--mpr-color-surface-elevated, rgba(15, 23, 42, 0.85));
  font-size: 0.85rem;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

dt {
  font-weight: 600;
  color: #38bdf8;
}

footer {
  flex-shrink: 0;
}

/* Theme toggle switch styling */
input[type="checkbox"][data-mpr-theme-toggle="control"] {
  --mpr-theme-toggle-track-width: 48px;
  --mpr-theme-toggle-track-height: 24px;
  --mpr-theme-toggle-offset: 3px;
  --mpr-theme-toggle-knob-size: 18px;
  --mpr-theme-toggle-travel: calc(
    var(--mpr-theme-toggle-track-width) -
      (var(--mpr-theme-toggle-offset) * 2) -
      var(--mpr-theme-toggle-knob-size)
  );
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  position: relative;
  width: var(--mpr-theme-toggle-track-width);
  height: var(--mpr-theme-toggle-track-height);
  background: var(--mpr-theme-toggle-bg, rgba(148, 163, 184, 0.18));
  border-radius: calc(var(--mpr-theme-toggle-track-height) / 2);
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
  box-shadow: none;
  box-sizing: border-box;
}

input[type="checkbox"][data-mpr-theme-toggle="control"]:focus-visible {
  outline: none;
}

input[type="checkbox"][data-mpr-theme-toggle="control"]::before {
  content: '';
  position: absolute;
  top: var(--mpr-theme-toggle-offset);
  left: var(--mpr-theme-toggle-offset);
  width: var(--mpr-theme-toggle-knob-size);
  height: var(--mpr-theme-toggle-knob-size);
  background: var(--mpr-color-text-primary, #0f172a);
  border-radius: 50%;
  transition: transform 0.2s ease-out, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: none;
}

input[type="checkbox"][data-mpr-theme-toggle="control"]:focus-visible::before {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.65);
}

input[type="checkbox"][data-mpr-theme-toggle="control"]:checked::before {
  transform: translateX(var(--mpr-theme-toggle-travel));
  background: var(--mpr-color-accent, #38bdf8);
}

input[type="checkbox"][data-mpr-theme-toggle="control"]:checked {
  background: var(--mpr-color-accent, #38bdf8);
}

[data-mpr-theme-toggle="control"][data-variant="square"] {
  --mpr-theme-square-size: 28px;
  --mpr-theme-square-dot-size: 6px;
  --mpr-theme-square-border: var(--mpr-color-border, rgba(148, 163, 184, 0.35));
  --mpr-theme-square-dot-color: var(--mpr-color-text-primary, #0f172a);
  --mpr-theme-square-dot-contrast: #ffffff;
  inline-size: auto;
  block-size: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: color 0.2s ease;
}

[data-mpr-theme-toggle="control"][data-variant="square"]::before,
[data-mpr-theme-toggle="control"][data-variant="square"]::after {
  content: none;
  display: none;
  inline-size: 0;
  block-size: 0;
}

[data-mpr-footer="theme-toggle"][data-mpr-theme-toggle-variant="square"] {
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}

.mpr-footer__theme-checkbox[data-variant="square"] {
  inline-size: auto;
  block-size: auto;
  border: none;
  border-radius: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0;
  box-shadow: none;
}

[data-mpr-theme-toggle="control"][data-variant="square"]:focus-visible {
  outline: none;
}

[data-mpr-theme-toggle="control"][data-variant="square"]:focus-visible
  [data-mpr-theme-toggle="grid"] {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

[data-mpr-theme-toggle="grid"] {
  position: relative;
  inline-size: var(--mpr-theme-square-size);
  block-size: var(--mpr-theme-square-size);
  border: 1px solid var(--mpr-theme-square-border);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  border-radius: 0.45rem;
  overflow: hidden;
}

[data-mpr-theme-toggle="grid"]::before,
[data-mpr-theme-toggle="grid"]::after {
  content: '';
  position: absolute;
  background: var(--mpr-theme-square-border);
  pointer-events: none;
}

[data-mpr-theme-toggle="grid"]::before {
  inline-size: 1px;
  block-size: 100%;
  left: 50%;
  transform: translateX(-0.5px);
}

[data-mpr-theme-toggle="grid"]::after {
  block-size: 1px;
  inline-size: 100%;
  top: 50%;
  transform: translateY(-0.5px);
}

[data-mpr-theme-toggle="quad"] {
  inline-size: 100%;
  block-size: 100%;
  transition: opacity 0.2s ease;
}

[data-mpr-theme-toggle="quad"][data-quad-index="0"] {
  background: var(--mpr-theme-square-quad-0, #ffffff);
}

[data-mpr-theme-toggle="quad"][data-quad-index="1"] {
  background: var(--mpr-theme-square-quad-1, #fef08a);
}

[data-mpr-theme-toggle="quad"][data-quad-index="2"] {
  background: var(--mpr-theme-square-quad-2, #0f172a);
}

[data-mpr-theme-toggle="quad"][data-quad-index="3"] {
  background: var(--mpr-theme-square-quad-3, #a7f3d0);
}

[data-mpr-theme-toggle="quad"][data-quad-enabled="false"] {
  opacity: 0.35;
}

[data-mpr-theme-toggle="quad"].is-active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

[data-mpr-theme-toggle="dot"] {
  position: absolute;
  inline-size: var(--mpr-theme-square-dot-size);
  block-size: var(--mpr-theme-square-dot-size);
  border-radius: 50%;
  background: var(--mpr-theme-square-dot-color);
  top: calc((var(--mpr-theme-square-row, 0) * 50%) + 25%);
  left: calc((var(--mpr-theme-square-col, 0) * 50%) + 25%);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
  transition: top 0.2s ease, left 0.2s ease, background 0.2s ease;
}

[data-mpr-theme-toggle="dot"][data-contrast="light"] {
  background: var(--mpr-theme-square-dot-contrast);
}

footer.mpr-footer [data-mpr-footer="layout"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}

footer.mpr-footer [data-mpr-footer="brand"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  margin-left: auto;
}
[data-mpr-modal="container"] {
  position: fixed;
  top: var(--mpr-modal-top-offset, 72px);
  right: 0;
  bottom: var(--mpr-modal-bottom-offset, 72px);
  left: 0;
  z-index: 2000;
  display: none;
  min-height: 200px;
}

[data-mpr-modal="container"][data-mpr-modal-open="true"] {
  display: block;
}

[data-mpr-modal="backdrop"] {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(6px);
}

[data-mpr-modal="dialog"] {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  width: min(720px, 92vw);
  max-height: calc(
    100vh - var(--mpr-modal-top-offset, 72px) - var(--mpr-modal-bottom-offset, 72px)
  );
  background: var(--mpr-color-surface-elevated, rgba(15, 23, 42, 0.98));
  color: var(--mpr-color-text-primary, #e2e8f0);
  border-radius: 1rem;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--mpr-shadow-flyout, 0 16px 32px rgba(15, 23, 42, 0.28));
  overflow: hidden;
}

[data-mpr-modal="header"] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

[data-mpr-modal="title"] {
  margin: 0;
  font-size: 1.35rem;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

[data-mpr-modal="close"] {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}

[data-mpr-modal="body"] {
  flex: 1;
  border: 1px dashed var(--mpr-color-border, rgba(148, 163, 184, 0.35));
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--mpr-color-text-muted, #94a3b8);
  font-size: 0.95rem;
  text-align: center;
  min-height: 180px;
  overflow-y: auto;
}

[data-mpr-header="settings-modal"][data-mpr-modal="container"] {
  z-index: 2100;
}

footer.mpr-footer [data-mpr-footer="privacy-modal"][data-mpr-modal="container"] {
  z-index: 2050;
}

[data-mpr-header="settings-modal-placeholder-title"] {
  margin: 0;
  font-weight: 600;
  color: var(--mpr-color-text-primary, #e2e8f0);
}

[data-mpr-header="settings-modal-placeholder-subtext"] {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

@media (max-width: 640px) {
  [data-mpr-modal="dialog"] {
    padding: 1.25rem;
  }
}
