
.stacked-modal-demo-page { padding: 20px; border: 1px solid var(--ui-border); background: var(--ui-subtle); }
.stacked-modal-demo-page h3 { margin: 0 0 4px; }
.stacked-modal-demo-rows { margin: 12px 0 0; padding: 0; list-style: none; }
.stacked-modal-demo-rows li { padding: 12px 0; border-bottom: 1px solid var(--ui-border); }


html:has(.ui-stacked-modal[open]) { overflow: hidden; }
.ui-stacked-modal-host { display: contents; }
.ui-stacked-modal-page { transition: transform .34s cubic-bezier(.22, 1, .36, 1), border-radius .34s; }
.ui-stacked-modal {
  position: fixed; inset: max(44px, calc(env(safe-area-inset-top) + 16px)) 0 var(--ui-stacked-modal-kb, 0px) 0; box-sizing: border-box; flex-direction: column;
  width: 100%; max-width: none; height: auto; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0;
  border-radius: calc(var(--ui-radius) + 8px) calc(var(--ui-radius) + 8px) 0 0; background: var(--ui-surface); color: var(--ui-fg);
  box-shadow: 0 -4px 24px rgba(15, 14, 24, .18), 0 160px 0 0 var(--ui-surface); font: 15px/1.5 var(--ui-font); overscroll-behavior: contain;
  transform-origin: 50% 0; transform: translateY(105%); will-change: transform;
  transition: transform .34s cubic-bezier(.22, 1, .36, 1), filter .34s, overlay .34s allow-discrete, display .34s allow-discrete;
}
.ui-stacked-modal[open] { display: flex; transform: translateY(var(--ui-stacked-modal-y, 0px)) scale(var(--ui-stacked-modal-scale, 1)); filter: brightness(var(--ui-stacked-modal-dim, 1)); }
@starting-style { .ui-stacked-modal[open] { transform: translateY(105%); } }
.ui-stacked-modal::backdrop { background: var(--ui-overlay); opacity: .7; }
.ui-stacked-modal-grip { display: flex; flex: none; align-items: center; justify-content: center; height: 22px; touch-action: none; }
.ui-stacked-modal-grip span { width: 40px; height: 5px; border-radius: 999px; background: var(--ui-strong); }
.ui-stacked-modal-head {
  display: flex; align-items: center; gap: 8px; flex: none; padding: 0 8px 6px 20px; border-bottom: 1px solid var(--ui-border);
  touch-action: none; -webkit-touch-callout: none; user-select: none;
}
.ui-stacked-modal-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.ui-stacked-modal-close {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--ui-radius-sm);
  background: transparent; color: var(--ui-muted); cursor: pointer;
}
@media (hover: hover) { .ui-stacked-modal-close:hover { background: var(--ui-subtle); color: var(--ui-fg); } }
.ui-stacked-modal-close:focus-visible { outline: none; box-shadow: var(--ui-focus); }
.ui-stacked-modal-close svg { width: 18px; height: 18px; }
.ui-stacked-modal-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); }
.ui-stacked-modal-body > :first-child { margin-top: 0; }
.ui-stacked-modal-body > :last-child { margin-bottom: 0; }
/* A <dialog> sits over the whole window, so the window's width is the right one to ask, Split View included. */
@media (min-width: 600px) {
  .ui-stacked-modal {
    inset: 8dvh 0 calc(8dvh + var(--ui-stacked-modal-kb, 0px)) 0; width: min(600px, calc(100vw - 48px)); margin: 0 auto; border: 1px solid var(--ui-border);
    border-radius: calc(var(--ui-radius) + 6px); box-shadow: var(--ui-shadow-lg);
  }
}
@media (prefers-reduced-motion: reduce) { .ui-stacked-modal, .ui-stacked-modal-page { transition: none; } }


.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--ui-radius-sm);
  font: 500 14px/1 var(--ui-font); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  --b: var(--ui-accent); --bf: var(--ui-accent-fg); --bs: var(--ui-accent-soft);
}
.ui-btn:focus-visible { outline: none; box-shadow: var(--ui-focus); }
.ui-btn[disabled], .ui-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.ui-btn-neutral { --b: var(--ui-fg); --bf: var(--ui-bg); --bs: var(--ui-subtle); }
.ui-btn-danger { --b: var(--ui-danger); --bf: #fff; --bs: var(--ui-danger-soft); }
.ui-btn-solid { background: var(--b); color: var(--bf); }
.ui-btn-solid:hover { background: color-mix(in srgb, var(--b) 88%, var(--ui-fg)); }
.ui-btn-soft { background: var(--bs); color: var(--b); }
.ui-btn-soft:hover { background: color-mix(in srgb, var(--bs) 80%, var(--b)); }
.ui-btn-outline { background: transparent; color: var(--b); border-color: var(--ui-border); }
.ui-btn-outline:hover { border-color: var(--b); background: var(--bs); }
.ui-btn-ghost { background: transparent; color: var(--b); }
.ui-btn-ghost:hover { background: var(--bs); }
.ui-btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.ui-btn-lg { height: 46px; padding: 0 22px; font-size: 16px; }
.ui-btn-full { display: flex; width: 100%; }
.ui-btn-spin { width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ui-btn-spin .7s linear infinite; }
@keyframes ui-btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ui-btn-spin { animation-duration: 2s; } }

