/* Shared appearance for AppModal, UI dialogs and AppFeedback.
   Feature styles own content layout, dimensions and keyboard positioning. */
:root {
  --app-modal-surface: #fff;
  --app-modal-text: #000;
  --app-modal-muted: #73808e;
  --app-modal-border: rgb(0 0 0 / .06);
  --app-modal-soft: #f1f4f8;
  --app-modal-scrim: rgb(0 0 0 / .4);
  --app-modal-radius: 20px;
  --app-modal-confirm-radius: 24px;
  --app-modal-shadow: 0 24px 80px rgb(0 0 0 / .16);
  --app-modal-duration: .18s;
  --app-modal-font: OfferPreview, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}
html[data-theme="dark"] {
  --app-modal-surface: #2c2c2c;
  --app-modal-text: #f6f6f6;
  --app-modal-muted: #aaa;
  --app-modal-border: rgb(255 255 255 / .08);
  --app-modal-soft: #383838;
  --app-modal-shadow: 0 24px 80px rgb(0 0 0 / .4);
}
html.app-modal-locked { overflow: hidden; }
.app-modal-adapter {
  position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh;
  max-height: none; margin: 0; padding: 0; border: 0; background: transparent;
  color: inherit; overflow: visible;
}
/* Fixed roots include the scrollbar gutter without moving the underlying page. */
.app-modal-adapter > .app-modal-root:not(.app-modal-surface) { width: 100vw; height: 100dvh; }
:is(.app-modal-root,.app-modal-managed,.app-modal-surface,.ui-modal) {
  --g-surface: var(--app-modal-surface);
  --g-surface-2: var(--app-modal-soft);
  --g-text: var(--app-modal-text);
  --g-muted: var(--app-modal-muted);
  --g-border: var(--app-modal-border);
  font-family: var(--app-modal-font);
  color: var(--app-modal-text);
}
:is(.app-modal-managed:not(.app-modal-immersive),.app-modal-surface,.ui-modal) {
  box-sizing: border-box; min-width: 0; border: 1px solid var(--app-modal-border);
  border-radius: var(--app-modal-radius); background: var(--app-modal-surface);
  box-shadow: var(--app-modal-shadow); overscroll-behavior: contain;
}
:is(.app-modal-managed,.ui-modal,.app-dialog,.app-loading,.app-modal-adapter)::backdrop {
  background: var(--app-modal-scrim); backdrop-filter: none;
}
/* Custom roots keep their hit target; the native adapter paints one scrim. */
.app-modal-backdrop { background: transparent; backdrop-filter: none; }
.app-modal-immersive {
  position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh;
  max-height: none; margin: 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none;
}
:is(.app-modal-managed,.app-modal-surface).app-modal-sheet { border: 0; border-radius: var(--app-modal-radius) var(--app-modal-radius) 0 0; }
.app-modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
:is(.app-modal-managed,.app-modal-surface) .app-modal-heading :is(h2,h3),.app-modal-title {
  margin: 0; color: var(--app-modal-text); font-size: 18px; line-height: 26px; font-weight: 600;
}
:is(.app-modal-managed,.app-modal-surface) .app-modal-close {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px;
  padding: 0; border: 0; border-radius: 12px; background: transparent;
  color: var(--app-modal-muted); cursor: pointer;
}
:is(.app-modal-managed,.app-modal-surface) .app-modal-close:hover { background: var(--app-modal-soft); color: var(--app-modal-text); }
:is(.app-modal-root,.app-modal-managed,.app-modal-surface,.ui-modal) :focus-visible { outline: 2px solid var(--g-primary, #0092ff); outline-offset: 3px; }
.app-modal-managed[open],.app-modal-adapter[open] .app-modal-surface { animation: app-modal-enter var(--app-modal-duration) ease-out; }
.ui-modal { max-width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; }
.ui-modal-header,.ui-modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px; }
.ui-modal-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.ui-modal-body { min-width: 0; overflow: auto; padding: 0 20px 20px; }
.ui-modal-footer { justify-content: flex-end; }
.app-modal-managed.app-modal-anchored {
  position: fixed; inset: auto; margin: 0; transform: none;
  left: var(--app-modal-anchor-x); top: var(--app-modal-anchor-y);
  max-width: var(--app-modal-available-width); max-height: var(--app-modal-available-height);
  overflow-y: auto;
}
@media (max-width: 767px) {
  :is(.app-modal-managed,.app-modal-surface).app-modal-responsive-sheet { border: 0; border-radius: var(--app-modal-radius) var(--app-modal-radius) 0 0; }
}
/* Opacity preserves feature transforms (anchored menus and centered sheets). */
@keyframes app-modal-enter { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .app-modal-managed[open],.app-modal-adapter[open] .app-modal-surface,.ui-modal { animation: none; transition: none; }
}
