pe-dialog,
pe-tooltip,
pe-popover,
pe-tabs,
pe-accordion,
pe-collapsible {
  display: contents;
}

:root {
  color-scheme: light;

  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --max-width: 72rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.container {
  width: min(var(--max-width), calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.8);
  backdrop-filter: blur(8px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.625rem;
  font-weight: 700;
}

.page-main {
  padding-block: 2rem 3rem;
}

.hero {
  margin-bottom: 2rem;
}

.hero__eyebrow {
  margin: 0 0 0.5rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  font-weight: 500;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.875rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.hero__lead {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 1rem;
  line-height: 1.625;
}

.panel {
  padding: 1.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: var(--shadow-sm);
}

.panel--wide {
  margin-bottom: 1.5rem;
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel__header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.panel__header p {
  margin: 0.25rem 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.demo-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 960px) {
  .demo-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.variant {
  padding: 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.25);
}

.variant + .variant {
  margin-top: 1rem;
}

.variant__label {
  margin: 0 0 0.75rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
}

.variant__label code {
  padding: 0.125rem 0.375rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--background));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

.variant-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .variant-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.button:hover {
  background: hsl(240 5.9% 20%);
}

.button--ghost {
  border-color: hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

.button--ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.button--small {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

.button--destructive {
  border-color: hsl(var(--destructive));
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.button--destructive:hover {
  background: hsl(0 84.2% 55%);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-button {
  height: 2rem;
  padding: 0 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.chip-button:hover {
  background: hsl(var(--accent));
}

.muted {
  margin: 0.5rem 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

[data-disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Tabs */
.tabs-list {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted));
}

.tabs-list button {
  position: relative;
  z-index: 1;
  height: 2rem;
  padding: 0 0.75rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.tabs-list button:hover:not(:disabled):not([data-disabled]) {
  color: hsl(var(--foreground));
}

.tabs-list button:disabled,
.tabs-list button[data-disabled] {
  cursor: not-allowed;
  opacity: 0.5;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.tabs-list:has([data-tabs-indicator]) button[aria-selected="true"] {
  color: hsl(var(--foreground));
}

.tabs-list:not(:has([data-tabs-indicator])) button[aria-selected="true"] {
  border-color: hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-sm);
}

.tabs-indicator {
  position: absolute;
  bottom: 0.25rem;
  left: var(--active-tab-left);
  width: var(--active-tab-width);
  height: calc(100% - 0.5rem);
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--background));
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  transition: left 0.15s ease, width 0.15s ease;
}

.vertical-tabs {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 1rem;
}

.tabs-list-vertical {
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 0;
}

.tabs-list-vertical button {
  width: 100%;
  text-align: left;
}

.tabs-panel {
  padding: 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* Accordion */
.accordion-native details {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
}

.accordion-native details + details {
  margin-top: 0.5rem;
}

.accordion-native details[open] {
  box-shadow: var(--shadow-sm);
}

.accordion-native summary {
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  list-style: none;
}

.accordion-native summary::-webkit-details-marker {
  display: none;
}

.accordion-native details p {
  margin: 0;
  padding: 0.875rem 1rem 1rem;
  border-top: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  line-height: 1.5;
}

pe-accordion.managed-accordion {
  display: block;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
}

.managed-accordion [data-accordion-item] {
  border-bottom: 1px solid hsl(var(--border));
}

.managed-accordion [data-accordion-item]:last-child {
  border-bottom: 0;
}

.managed-accordion h3 {
  margin: 0;
}

.managed-accordion [data-accordion-trigger] {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
}

.managed-accordion [data-accordion-trigger]::after {
  color: hsl(var(--muted-foreground));
  content: "+";
}

.managed-accordion [data-accordion-trigger][data-state="open"]::after {
  content: "−";
}

.managed-accordion [data-accordion-panel] {
  height: var(--accordion-panel-height);
  overflow: hidden;
  transition: height 160ms ease;
}

.managed-accordion [data-accordion-panel][data-starting-style],
.managed-accordion [data-accordion-panel][data-ending-style] {
  height: 0;
}

.managed-accordion-panel-content {
  padding: 0 1rem 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Collapsible */
pe-collapsible.collapsible-example {
  display: block;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
}

.collapsible-example [data-collapsible-trigger] {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
}

.collapsible-example [data-collapsible-panel] {
  padding: 0;
}

.collapsible-example [data-collapsible-panel][hidden]:not([hidden="until-found"]) {
  display: none;
}

.collapsible-panel-content {
  padding: 0 1rem 1rem;
}

.collapsible-panel-content p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  line-height: 1.5;
}

.collapsible-panel-content p + p {
  margin-top: 0.5rem;
}

.collapsible-example--animated .collapsible-example__icon {
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
  transition: transform 150ms ease-out;
}

.collapsible-example--animated
  [data-collapsible-trigger][data-state="open"]
  .collapsible-example__icon {
  transform: rotate(90deg);
}

.collapsible-example--animated [data-collapsible-panel] {
  box-sizing: border-box;
  display: flex;
  height: var(--collapsible-panel-height);
  flex-direction: column;
  justify-content: end;
  padding: 0;
  overflow: hidden;
  transition: height 150ms ease-out;
}

.collapsible-example--animated [data-collapsible-panel][data-starting-style],
.collapsible-example--animated [data-collapsible-panel][data-ending-style] {
  height: 0;
}

.collapsible-stack {
  display: grid;
  gap: 0.5rem;
}

/* Dialog */
dialog::backdrop {
  background: rgb(0 0 0 / 0.8);
}

dialog {
  margin: auto;
  padding: 0;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  background: hsl(var(--background));
  box-shadow: var(--shadow-md);
  color: hsl(var(--foreground));
}

.dialog-body {
  min-width: min(28rem, calc(100vw - 2rem));
  padding: 1.5rem;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.dialog-body > [data-dialog-description],
dialog > [data-dialog-description] {
  margin: 0 0 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  line-height: 1.5;
}

.dialog-close {
  height: 2rem;
  padding: 0 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
}

.dialog-close:hover {
  background: hsl(var(--accent));
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.dialog-card-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
}

.dialog-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
}

.dialog-card__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.dialog-card__note {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  line-height: 1.4;
}

/* Tooltip & Popover */
[data-tooltip-content]:not([data-state="open"]) {
  display: none;
}

[data-tooltip-content] {
  max-width: 16rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.75rem;
  line-height: 1.4;
  box-shadow: var(--shadow-md);
  overflow: visible;
  z-index: 20;
}

[data-popover-content] {
  min-width: 12rem;
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  box-shadow: var(--shadow-md);
  overflow: visible;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.popover-header h2,
.popover-header h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

[data-popover-content] p {
  margin: 0 0 0.75rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  line-height: 1.5;
}

[data-tooltip-arrow],
[data-popover-arrow] {
  position: absolute;
  display: block;
  width: 12px;
  height: 6px;
  overflow: clip;
  pointer-events: none;
}

[data-tooltip-arrow]::before,
[data-popover-arrow]::before {
  position: absolute;
  bottom: 0;
  left: 50%;
  box-sizing: border-box;
  width: calc(6px * sqrt(2));
  height: calc(6px * sqrt(2));
  content: "";
  transform: translate(-50%, 50%) rotate(45deg);
}

[data-tooltip-arrow]::before {
  border: 1px solid hsl(var(--primary));
  background: hsl(var(--primary));
}

[data-popover-arrow]::before {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover));
}

[data-tooltip-arrow][data-side="top"],
[data-popover-arrow][data-side="top"] {
  bottom: -6px;
  rotate: 180deg;
}

[data-tooltip-arrow][data-side="bottom"],
[data-popover-arrow][data-side="bottom"] {
  top: -6px;
}

[data-tooltip-arrow][data-side="left"],
[data-popover-arrow][data-side="left"] {
  right: -9px;
  rotate: 90deg;
}

[data-tooltip-arrow][data-side="right"],
[data-popover-arrow][data-side="right"] {
  left: -9px;
  rotate: -90deg;
}

.placement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(5rem, 1fr));
  gap: 0.5rem;
  max-width: 14rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Event log */
.event-stream {
  display: grid;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-stream li {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--muted) / 0.35);
  font-size: 0.8125rem;
}

.event-stream__source {
  color: hsl(var(--foreground));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

.event-stream__message {
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-stream__time {
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .managed-accordion [data-accordion-panel],
  .collapsible-example--animated [data-collapsible-panel],
  .tabs-indicator {
    transition-duration: 0s;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 1rem;
  }

  .vertical-tabs {
    grid-template-columns: 1fr;
  }

  .event-stream li {
    grid-template-columns: 1fr;
  }
}
