:root {
  color-scheme: light;
  --canvas: #f5f7fb;
  --surface: #fff;
  --subtle: #f1f5f9;
  --hover: #f8fafc;
  --border: #e2e8f0;
  --strong-border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;
  --on-accent: #fff;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 1px 2px rgb(15 23 42 / 4%);
  --shadow-raised: 0 18px 40px -12px rgb(15 23 42 / 24%);
  --small-radius: 8px;
  --card-radius: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b1120;
  --surface: #111827;
  --subtle: #1e293b;
  --hover: #172033;
  --border: #293449;
  --strong-border: #475569;
  --text: #f8fafc;
  --muted: #a5b4c8;
  --accent: #5f61ef;
  --accent-hover: #5458d8;
  --accent-soft: #262b55;
  --accent-text: #c7d2fe;
  --on-accent: #fff;
  --success-bg: #12332f;
  --success-text: #6ee7b7;
  --warn-bg: #382714;
  --warn-border: #715125;
  --warn-text: #fcd34d;
  --danger: #fca5a5;
  --danger-soft: #421e2a;
  --shadow: 0 1px 2px rgb(0 0 0 / 25%);
  --shadow-raised: 0 24px 48px -12px rgb(0 0 0 / 60%);
}

* { box-sizing: border-box; }

.portal-page {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.portal-page :where(h1, h2, p) { margin: 0; }
.portal-page button, .portal-page input, .portal-page select { font: inherit; }
.portal-page :where(button, a, summary) { touch-action: manipulation; }
.portal-page [hidden] { display: none !important; }

.portal-page :where(button, input, select) {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--small-radius);
  background: var(--surface);
  color: var(--text);
}

.portal-page button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
}

.portal-page :where(button, summary, input, select, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.portal-page button:hover { background: var(--subtle); border-color: var(--strong-border); }
.portal-page button:disabled { opacity: .55; cursor: not-allowed; }
.portal-page .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.portal-page .primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.portal-page .danger { color: var(--danger); }
.portal-page .danger:hover { background: var(--danger-soft); }
.portal-page :where(input:not([type="radio"]), select) {
  min-height: 36px;
  max-width: 100%;
  padding: 7px 11px;
  font-size: 13px;
}
.portal-page input::placeholder { color: var(--muted); opacity: 1; }
.portal-page select { cursor: pointer; }

.portal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner, .portal-page main {
  width: min(100%, 1080px);
  margin-inline: auto;
  padding-inline: 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding-block: 8px;
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-icon {
  display: grid;
  place-items: center;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--small-radius);
  background: var(--accent);
  color: var(--on-accent);
}
.brand-icon .icon { width: 16px; height: 16px; }

.account {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  min-width: 0;
}
#identity { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
#identity:empty { display: none; }
.account button { min-height: 32px; }
#theme-toggle { width: 34px; padding: 0; }

.portal-page .language-bar {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.portal-page > .language-bar { justify-content: center; padding: 8px 16px; }
.portal-page .language-bar label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.portal-page .language-bar select {
  width: auto;
  height: auto;
  min-height: 32px;
  padding: 5px 8px;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.portal-page main { padding-block: 32px 64px; }
.page-heading { margin-bottom: 22px; }
.page-heading h1, #login h1 { font-size: 26px; letter-spacing: -.02em; }
.page-heading p { margin-top: 4px; color: var(--muted); font-size: 14px; }

.summary {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(2, minmax(0, 1fr));
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 18px 22px;
}
.summary-item > div { min-width: 0; }

.summary-item:not(:last-child)::after {
  position: absolute;
  inset: 22% 0 22% auto;
  border-right: 1px solid var(--border);
  content: "";
}

.summary-item > .icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  mask-image: none;
}

.summary-item > .icon::before, .device-name > .icon::before {
  position: absolute;
  inset: 9px;
  background: currentColor;
  mask: center / contain no-repeat var(--icon);
  content: "";
}

.summary-label { color: var(--muted); font-size: 12px; }
.summary-value { margin-top: 1px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.summary-value small { margin-inline-start: 5px; color: var(--muted); font-size: 11px; font-weight: 400; }

.list-toolbar, .list-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.list-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.list-toolbar h2 { font-size: 17px; font-weight: 650; }
.list-controls { max-width: 100%; }
.search-field { position: relative; min-width: 0; }
.search-field .icon { position: absolute; top: 50%; left: 11px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { width: 250px; padding-inline-start: 34px; }
#client-filter { width: clamp(132px, 19vw, 208px); text-overflow: ellipsis; }
#add { flex: none; }
.availability, .notice, .warn-banner {
  border: 1px solid var(--warn-border);
  border-radius: var(--small-radius);
  background: var(--warn-bg);
  color: var(--warn-text);
}
.availability { margin-bottom: 12px; padding: 10px 12px; font-size: 13px; }

.subscription-table {
  width: 100%;
  border: 1px solid var(--border);
  border-spacing: 0;
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  table-layout: fixed;
}
.subscription-table th {
  padding: 13px 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: start;
}
.subscription-table th:first-child { width: 24%; }
.subscription-table th:nth-child(2) { width: 18%; }
.subscription-table th:nth-child(3) { width: 20%; }
.subscription-table th:nth-child(4) { width: 11%; }
.subscription-table td {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}
.subscription-table tbody tr:hover > td { background: var(--hover); }
.subscription-table tbody tr:last-child > td:first-child { border-bottom-left-radius: var(--card-radius); }
.subscription-table tbody tr:last-child > td:last-child { border-bottom-right-radius: var(--card-radius); }

.device-name { display: flex; align-items: center; gap: 12px; }
.device-name > div { min-width: 0; }
.device-name strong { display: block; font-size: 14px; font-weight: 600; }
.device-name > .icon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--subtle);
  color: var(--accent-text);
  mask-image: none;
}
.created { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.client-badge, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.client-badge { background: var(--subtle); }
.badge { background: var(--success-bg); color: var(--success-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge .icon { width: 13px; height: 13px; }

.device-actions { display: flex; align-items: center; gap: 8px; }
.device-actions > button { min-height: 32px; padding: 5px 8px; font-size: 12.5px; }
.device-actions .copy-button { border-color: transparent; background: var(--accent-soft); color: var(--accent-text); }
.device-actions .copy-button:hover { border-color: var(--accent); }
.device-actions .icon { width: 15px; height: 15px; }
.subscription-more { position: relative; flex: none; }
.subscription-more summary {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--small-radius);
  background: var(--surface);
  list-style: none;
  cursor: pointer;
}
.subscription-more summary:hover, .subscription-more[open] summary { background: var(--subtle); }
.subscription-more summary::-webkit-details-marker { display: none; }
.subscription-more button {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  width: max-content;
  min-width: 130px;
  max-width: 220px;
  box-shadow: var(--shadow-raised);
  overflow-wrap: anywhere;
}
.result-count { min-height: 18px; margin: 10px 4px 24px; color: var(--muted); font-size: 12px; }
.empty {
  padding: 26px 20px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
  color: var(--muted);
  overflow-wrap: anywhere;
}
.empty strong { display: block; margin-bottom: 4px; color: var(--text); }

.help-section {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.help-section > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 16px 20px;
  font-size: 14.5px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.help-section > summary::-webkit-details-marker { display: none; }
.help-section > summary .chevron-down { margin-inline-start: auto; color: var(--muted); }
.help-section[open] > summary .chevron-down { transform: rotate(180deg); }
.help-body { padding: 14px 20px 18px 48px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.help-body ol { display: grid; gap: 6px; margin: 0 0 8px; padding-inline-start: 18px; }
.audit-row + .audit-row { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.footer-note, .service-notice { margin-top: 12px; color: var(--muted); font-size: 12px; }
.service-notice > summary { width: fit-content; cursor: pointer; }
.service-notice p { margin-top: 6px; overflow-wrap: anywhere; }
#message {
  position: fixed;
  inset: 76px 24px auto auto;
  z-index: 30;
  max-width: min(400px, calc(100% - 48px));
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--small-radius);
  background: var(--surface);
  color: var(--danger);
  box-shadow: var(--shadow-raised);
  font-size: 13px;
  overflow-wrap: anywhere;
}
#message:empty { padding: 0; border: 0; }
#message.success { color: var(--success-text); }

#session-check {
  margin: 36px auto;
  text-align: center;
  color: var(--muted);
}
#session-retry { margin-top: 12px; }

#login {
  max-width: 450px;
  margin: 36px auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
#login > p { margin-top: 8px; color: var(--muted); }
#login-form { display: grid; gap: 14px; margin-block: 20px; }
#login-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
#login-form :where(input, button) { width: 100%; min-height: 44px; }
#login .notice { padding: 11px 12px; color: var(--warn-text); font-size: 13px; }

#dialog {
  width: min(460px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(var(--portal-viewport-height, 100dvh) - 24px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-raised);
}
#dialog[open] { display: flex; flex-direction: column; }
#dialog::backdrop, .portal-page .language-confirm::backdrop { background: rgb(15 23 42 / 55%); backdrop-filter: blur(4px); }
.portal-page .language-confirm { background: var(--surface); color: var(--text); border-color: var(--border); }
.dialog-head {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.dialog-head > div { min-width: 0; }
.dialog-head h2 { font-size: 16px; font-weight: 650; }
#dialog-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#dialog .dialog-head #close {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 20px;
}

#dialog-body {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 13.5px;
}
#dialog-body label { display: block; }
#dialog-body label input:not([type="radio"]), #dialog-body label select { display: block; width: 100%; margin-top: 5px; }
#dialog-body > img, .qr-box { width: min(188px, 100%); justify-self: center; }
#dialog-body > img, .qr-box {
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.qr-box img { display: block; width: 100%; height: auto; }
.url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--small-radius);
  background: var(--subtle);
}
.clipboard-selection {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.secret {
  min-width: 0;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
  user-select: all;
}
#dialog-body > .secret { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--small-radius); background: var(--subtle); }
.warn-banner, #dialog-body .notice { padding: 9px 11px; font-size: 12.5px; }
.warn-banner { display: flex; align-items: flex-start; gap: 8px; }
.warn-banner .icon { margin-top: 1px; }
#dialog-feedback:empty { display: none; }
#dialog-feedback { color: var(--muted); }
#dialog-feedback.success { color: var(--success-text); }
#dialog-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
#dialog-actions:empty { display: none; }

#new-form { display: grid; gap: 13px; }
.form-group { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.form-group > label, .form-group legend, .form-label { color: var(--text); font-size: 13px; font-weight: 650; }
.form-group legend { margin-bottom: 6px; padding: 0; }
.form-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.radio-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.radio-stack { display: grid; gap: 8px; }
#dialog-body .radio-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
#dialog-body .radio-card:hover { border-color: var(--strong-border); }
#dialog-body .radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.radio-card input { flex: none; width: 14px; height: 14px; margin: 3px 0 0; accent-color: var(--accent); }
.radio-card-icon { flex: none; color: var(--accent-text); }
.radio-card-content { min-width: 0; }
.radio-card-title { display: block; color: var(--text); font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.radio-card-desc { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.badge-rec { display: inline-block; margin-inline-start: 4px; padding: 2px 5px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-text); font-size: 10px; }

.icon {
  display: inline-block;
  width: 17px;
  height: 17px;
  flex: none;
  background: currentColor;
  mask: center / contain no-repeat var(--icon);
}
.route { --icon: url('/static/icons/route.svg'); }
.calendar { --icon: url('/static/icons/calendar.svg'); }
.layers { --icon: url('/static/icons/layers.svg'); }
.search { --icon: url('/static/icons/search.svg'); }
.plus { --icon: url('/static/icons/plus.svg'); }
.device-mobile { --icon: url('/static/icons/device-mobile.svg'); }
.device-laptop { --icon: url('/static/icons/device-laptop.svg'); }
.copy { --icon: url('/static/icons/copy.svg'); }
.qrcode { --icon: url('/static/icons/qrcode.svg'); }
.dots { --icon: url('/static/icons/dots.svg'); }
.help { --icon: url('/static/icons/help.svg'); }
.history { --icon: url('/static/icons/history.svg'); }
.chevron-down { --icon: url('/static/icons/chevron-down.svg'); }
.circle-check { --icon: url('/static/icons/circle-check.svg'); }

@media (min-width: 861px) {
  #client-filter { width: auto; max-width: 208px; padding-inline: 12px 28px; }
  .device-actions > button { min-height: 32px; padding-inline: 11px; }
  .device-actions .copy-button { border-color: var(--border); background: var(--surface); color: var(--text); }
  .device-actions .copy-button:hover { background: var(--subtle); border-color: var(--strong-border); }
}

@media (max-width: 860px) {
  .subscription-table { display: block; border: 0; background: transparent; box-shadow: none; }
  .subscription-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .subscription-table tbody { display: grid; gap: 12px; }
  .subscription-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .subscription-table td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    font-size: 13px;
  }
  .subscription-table tbody tr:hover > td { background: transparent; }
  .subscription-table td:first-child { grid-column: 1 / -1; }
  .subscription-table .status-cell { grid-column: 1 / -1; }
  .subscription-table .actions-cell { grid-column: 1 / -1; margin-top: 2px; padding-top: 11px; border-top: 1px solid var(--border); }
  .subscription-table td[data-label]::before {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
    content: attr(data-label);
  }
  .subscription-table .line-cell::before { content: attr(data-label); }
  .device-actions > button { flex: 1; min-height: 44px; overflow-wrap: anywhere; }
  .subscription-more summary { width: 44px; min-height: 44px; }
}

@media (max-width: 600px) {
  .header-inner, .portal-page main {
    padding-inline-start: max(16px, env(safe-area-inset-left, 0px));
    padding-inline-end: max(16px, env(safe-area-inset-right, 0px));
  }
  .portal-header { padding-top: env(safe-area-inset-top, 0px); }
  .header-inner { align-items: flex-start; flex-direction: column; gap: 7px; padding-block: 10px; }
  .account { justify-content: flex-start; gap: 8px; width: 100%; }
  #identity { flex-basis: 100%; font-size: 12px; }
  .account button, .portal-page .language-bar select { min-height: 36px; }
  .portal-page main { padding-block: 22px 44px; }
  .page-heading { margin-bottom: 16px; }
  .page-heading h1 { font-size: 24px; }

  .summary { grid-template-columns: minmax(0, 1fr); margin-bottom: 22px; }
  .summary-item { padding: 11px 14px; }
  .summary-item:not(:last-child)::after { inset: auto 14px 0; border-right: 0; border-bottom: 1px solid var(--border); }

  .list-toolbar, .list-controls { gap: 8px; }
  .list-controls { flex-wrap: wrap; width: 100%; }
  .search-field { flex-basis: 100%; }
  .search-field input { width: 100%; }
  #client-filter { flex: 1; width: 1px; }
  .list-controls > :where(button, select), .search-field input { min-height: 44px; }
  .device-name { gap: 9px; }
  .created { font-size: 11px; }
  .help-section > summary { padding-inline: 14px; }
  .help-body { padding-inline: 14px; }
  #message { inset: auto 16px 16px auto; max-width: calc(100% - 32px); }

  #login { margin: 10px auto; padding: 18px; }
  .portal-page input:not([type="radio"]), .portal-page select { font-size: 16px; }
  .portal-page .language-bar select { font-size: 16px; }
  .dialog-head, #dialog-actions { padding: 10px 14px; }
  #dialog-body { padding: 14px; }
  #dialog .dialog-head #close { width: 44px; min-height: 44px; }
  #dialog-actions button { min-height: 44px; }

  #dialog[data-kind="add"] {
    position: fixed;
    inset: auto 0 var(--portal-viewport-bottom, 0px);
    width: min(100%, 460px);
    max-height: calc(100vh - 12px);
    max-height: calc(var(--portal-viewport-height, 100dvh) - 12px);
    margin: 0 auto;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
  }
  #dialog[data-kind="add"] #dialog-actions {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 390px) {
  .radio-grid { grid-template-columns: minmax(0, 1fr); }
  #dialog[data-kind="add"] {
    min-height: min(500px, calc(var(--portal-viewport-height, 100dvh) - 12px));
    border-inline: 0;
  }
}

@media (max-height: 460px) {
  .dialog-head, #dialog-actions { padding-block: 8px; }
  #dialog-body { padding-block: 10px; }
}
