/* Murr Mall: shared foundations and controls */

  * { margin:0; padding:0; box-sizing:border-box; }
  html, body { height:100%; }
  /* Controls take the page's font instead of the browser's own. */
  button, input, select, textarea { font-family:inherit; }
  body {
    font-family:var(--ui-font);
    background:#2b241c; overflow:hidden;
    -webkit-user-select:none; user-select:none;
  }
  #home, #app, #fx {
    opacity:1; transition:opacity .22s ease;
  }
  #app-loader {
    position:fixed; inset:0; z-index:1000; display:grid; place-items:center;
    background:
      radial-gradient(620px 360px at 50% 42%, var(--ui-accent-soft), transparent 72%),
      var(--ui-bg);
    color:var(--ui-text-secondary); opacity:0; visibility:hidden; pointer-events:none;
    transition:opacity .22s ease, visibility 0s linear .22s;
  }
  .app-loader-content {
    display:flex; flex-direction:column; align-items:center; gap:12px;
    font-size:14px; font-weight:650; letter-spacing:.025em;
  }
  .app-loader-mark {
    font-size:28px; animation:app-loader-pulse 1.1s ease-in-out infinite alternate;
  }
  .app-loader-en { display:none; }
  html[lang="en"] .app-loader-ru { display:none; }
  html[lang="en"] .app-loader-en { display:inline; }
  .app-loader-help, .app-loader-slow, .app-loader-failed { display:none; }
  .app-loader-help {
    max-width:320px; padding:0 20px; flex-direction:column; align-items:center; gap:14px;
    text-align:center; font-weight:500; line-height:1.45; letter-spacing:0;
  }
  .app-loader-help p { margin:0; }
  html.app-booting.app-boot-slow .app-loader-help,
  html.app-booting.app-boot-failed .app-loader-help { display:flex; }
  html.app-booting.app-boot-slow:not(.app-boot-failed) .app-loader-slow,
  html.app-booting.app-boot-failed .app-loader-failed { display:block; }
  html.app-booting.app-boot-failed .app-loader-status { display:none; }
  html.app-booting.app-boot-failed .app-loader-mark { animation:none; }
  html.app-booting #app-loader,
  body.app-navigating #app-loader {
    opacity:1; visibility:visible; pointer-events:auto; transition:opacity .16s ease;
  }
  /* Between pages that share the street scene (js/navigation.js) the street stays: only
     the page's own content fades out and in, and the paws come over the street only if
     the next page is slow to start. */
  body.app-navigating-scene #app-loader,
  html.app-scene-arrival.app-booting #app-loader {
    background:transparent;
    animation:app-loader-late .2s ease .6s both;
  }
  body.app-navigating-scene .app-loader-content,
  html.app-scene-arrival .app-loader-content {
    padding:14px 20px; border-radius:16px;
    background:var(--ui-surface); box-shadow:var(--ui-shadow-md);
  }
  @keyframes app-loader-late {
    from { opacity:0; visibility:hidden; }
    to { opacity:1; visibility:visible; }
  }
  html.app-booting #home,
  html.app-booting #app,
  html.app-booting #fx {
    opacity:0; visibility:hidden;
  }
  body.app-navigating #home,
  body.app-navigating #app,
  body.app-navigating #fx {
    opacity:0; pointer-events:none;
  }
  /* Along the street the content is gone before the page leaves (80 ms later,
     js/navigation.js): the browser keeps the last frame up until the next page draws,
     and a half-faded card would hang there. The next page fades its own in. */
  body.app-navigating-scene #home {
    transition:opacity .07s ease-out;
  }
  @keyframes app-loader-pulse {
    from { transform:translateY(0) scale(.96); opacity:.72; }
    to { transform:translateY(-3px) scale(1.04); opacity:1; }
  }
  @media (prefers-reduced-motion: reduce) {
    #home, #app, #fx, #app-loader { transition:none; }
    body.app-navigating-scene #app-loader,
    html.app-scene-arrival.app-booting #app-loader { animation-duration:0s; }
    .app-loader-mark { animation:none; }
  }
  /* ============ ДИАЛОГ ============ */
  dialog {
    border:none; border-radius:16px; padding:22px; width:min(430px, 92vw);
    background:#fdf9f1; box-shadow:0 20px 60px rgba(40,25,10,.4);
    margin:auto;
  }
  dialog::backdrop { background:rgba(40,28,14,.55); }
  dialog[open] {
    transform-origin:center;
    animation:dialog-enter .18s cubic-bezier(.2,.8,.2,1) both;
  }
  dialog[open]::backdrop {
    animation:dialog-backdrop-enter .18s ease-out both;
  }
  dialog[open].dialog-closing {
    pointer-events:none;
    animation:dialog-exit .15s ease-in both;
  }
  dialog[open].dialog-closing::backdrop {
    animation:dialog-backdrop-exit .15s ease-in both;
  }
  @keyframes dialog-enter {
    from { opacity:0; transform:translate3d(0, 8px, 0) scale(.985); }
    to { opacity:1; transform:translate3d(0, 0, 0) scale(1); }
  }
  @keyframes dialog-exit {
    from { opacity:1; transform:translate3d(0, 0, 0) scale(1); }
    to { opacity:0; transform:translate3d(0, 5px, 0) scale(.99); }
  }
  @keyframes dialog-backdrop-enter {
    from { opacity:0; }
    to { opacity:1; }
  }
  @keyframes dialog-backdrop-exit {
    from { opacity:1; }
    to { opacity:0; }
  }
  @media (prefers-reduced-motion: reduce) {
    dialog[open],
    dialog[open]::backdrop,
    dialog[open].dialog-closing,
    dialog[open].dialog-closing::backdrop { animation:none; }
  }
  dialog h2 { font-size:16px; color:#46392a; margin-bottom:14px; }
  dialog label { display:block; font-size:12px; color:#7d6a4f; margin-bottom:10px; font-weight:600; }
  dialog input, dialog textarea, dialog .field-select {
    display:block; width:100%; margin-top:4px; padding:9px 10px; font-size:13.5px;
    border:1px solid #d9c9ac; border-radius:8px; background:#fff; color:#3c3226;
  }
  dialog textarea { min-height:92px; resize:vertical; line-height:1.45; font-family:inherit; }
  dialog input:focus, dialog textarea:focus, dialog .field-select:focus {
    outline:2px solid rgba(217,165,78,.5); border-color:#d9a54e;
  }
  #fetch-status { font-size:11.5px; color:#a08a68; min-height:15px; margin-top:-2px; }
  .price-row { display:flex; gap:8px; margin-top:4px; }
  .price-row input { width:auto; flex:1; min-width:0; margin-top:0; }
  .price-row select {
    flex-shrink:0; width:104px; padding:9px 6px; font-size:13.5px;
    border:1px solid #d9c9ac; border-radius:8px; background:#fff; color:#3c3226; margin-top:0;
  }
  .price-row select:focus { outline:2px solid rgba(217,165,78,.5); border-color:#d9a54e; }
  .dlg-btns { display:flex; gap:8px; justify-content:flex-end; margin-top:16px; }
  .dlg-btns button[hidden] { display:none; }
  html[data-theme="dark"] body { background:#0c111a; }
  html[data-theme="dark"] body.ods-active { background:#091321; }
  html[data-theme="dark"] #auth-form input,
  html[data-theme="dark"] #list-form input,
  html[data-theme="dark"] .profile-field input,
  html[data-theme="dark"] .profile-field textarea {
    background:#111926; border-color:#3c495d; color:#f1e9dc;
  }
  html[data-theme="dark"] #auth-form input::placeholder,
  html[data-theme="dark"] #list-form input::placeholder,
  html[data-theme="dark"] .profile-field input::placeholder,
  html[data-theme="dark"] .profile-field textarea::placeholder,
  html[data-theme="dark"] dialog input::placeholder,
  html[data-theme="dark"] dialog textarea::placeholder { color:#7f8998; }
  html[data-theme="dark"] dialog {
    background:#19222e; color:#eee7dc; box-shadow:0 20px 65px rgba(0,0,0,.58);
  }
  html[data-theme="dark"] dialog::backdrop { background:rgba(3,8,15,.72); }
  html[data-theme="dark"] dialog h2 { color:#f2eadc; }
  html[data-theme="dark"] dialog label { color:#cbbda8; }
  html[data-theme="dark"] dialog input,
  html[data-theme="dark"] dialog textarea,
  html[data-theme="dark"] dialog .field-select,
  html[data-theme="dark"] .price-row select {
    background:#111925; border-color:#3d4a5d; color:#f0e8dc;
  }
  html[data-theme="dark"] #fetch-status { color:#a99d8d; }
@media (max-width: 880px) {
    dialog input, dialog textarea, dialog select { font-size:16px; }
}
  body { background:var(--ui-bg); color:var(--ui-text); }
  #auth-form input,
  #list-form input,
  .profile-field input,
  .profile-field textarea,
  dialog input,
  dialog textarea,
  dialog .field-select,
  .price-row select,
  html[data-theme="dark"] #auth-form input,
  html[data-theme="dark"] #list-form input,
  html[data-theme="dark"] .profile-field input,
  html[data-theme="dark"] .profile-field textarea,
  html[data-theme="dark"] dialog input,
  html[data-theme="dark"] dialog textarea,
  html[data-theme="dark"] dialog .field-select,
  html[data-theme="dark"] .price-row select {
    border:1px solid var(--ui-border); border-radius:11px; background:var(--ui-surface);
    color:var(--ui-text); box-shadow:0 1px 2px rgba(18,24,40,.025);
    transition:border-color .16s ease, box-shadow .16s ease, background .16s ease;
  }
  #auth-form input, #list-form input,
  .profile-field input, .profile-field textarea { padding:12px 14px; font-size:16px; }
  #auth-form input { min-height:46px; }
  #auth-form input::placeholder,
  #list-form input::placeholder,
  .profile-field input::placeholder,
  .profile-field textarea::placeholder,
  dialog input::placeholder,
  dialog textarea::placeholder,
  html[data-theme="dark"] #auth-form input::placeholder,
  html[data-theme="dark"] #list-form input::placeholder,
  html[data-theme="dark"] .profile-field input::placeholder,
  html[data-theme="dark"] .profile-field textarea::placeholder,
  html[data-theme="dark"] dialog input::placeholder,
  html[data-theme="dark"] dialog textarea::placeholder { color:color-mix(in srgb, var(--ui-text-secondary) 76%, transparent); }
  #auth-form input:focus,
  #list-form input:focus,
  .profile-field input:focus,
  .profile-field textarea:focus,
  dialog input:focus,
  dialog textarea:focus,
  dialog .field-select:focus,
  .price-row select:focus,
  html[data-theme="dark"] #auth-form input:focus,
  html[data-theme="dark"] #list-form input:focus,
  html[data-theme="dark"] .profile-field input:focus,
  html[data-theme="dark"] .profile-field textarea:focus,
  html[data-theme="dark"] dialog input:focus,
  html[data-theme="dark"] dialog textarea:focus,
  html[data-theme="dark"] dialog .field-select:focus,
  html[data-theme="dark"] .price-row select:focus {
    outline:none; border-color:var(--ui-accent); box-shadow:0 0 0 3px var(--ui-focus);
  }
  .profile-field input[readonly],
  html[data-theme="dark"] .profile-field input[readonly] {
    background:var(--ui-surface-subtle); color:var(--ui-text-secondary); box-shadow:none;
  }
  .profile-field textarea { min-height:124px; }

  /* Murr Mall's social accounts (js/app-social.js): round icon links in the muted text
     colour, olive on hover. */
  .app-social { display:flex; flex-wrap:wrap; align-items:center; gap:2px; }
  .app-social a {
    width:36px; height:36px; display:inline-grid; place-items:center; border-radius:999px;
    color:var(--ui-text-secondary); font-size:17px; text-decoration:none;
    transition:color .15s ease, background .15s ease;
  }
  .app-social a:hover { color:var(--ui-accent); background:var(--pill-hover); }
  .app-social a:focus-visible { outline:2px solid var(--ui-accent); outline-offset:1px; }
  .app-social:empty { display:none; }
  /* Buttons are round pills: olive for the main action, white for the rest,
     a soft red for what can't be undone. Pressing one gives a little. */
  .primary-btn, .quiet-btn, .danger-btn,
  .dlg-btns button {
    min-height:44px; display:inline-flex; align-items:center; justify-content:center; gap:7px;
    border:1px solid transparent; border-radius:999px; padding:10px 20px;
    font-size:14px; line-height:1.2; font-weight:700; cursor:pointer;
    transition:background .15s ease, box-shadow .15s ease, transform .12s ease;
  }
  :is(.primary-btn, .quiet-btn, .danger-btn, .dlg-btns button):active:not(:disabled) { transform:scale(.96); }
  .primary-btn,
  .dlg-btns .primary,
  html[data-theme="dark"] .primary-btn,
  html[data-theme="dark"] .dlg-btns .primary {
    background:var(--pill-primary); border-color:transparent; color:#fff; box-shadow:var(--pill-glow);
  }
  .primary-btn:hover,
  .dlg-btns .primary:hover,
  html[data-theme="dark"] .primary-btn:hover,
  html[data-theme="dark"] .dlg-btns .primary:hover {
    background:var(--pill-primary-hover); border-color:transparent; color:#fff;
  }
  .quiet-btn,
  #dlg-cancel,
  #list-dlg-cancel,
  html[data-theme="dark"] .quiet-btn,
  html[data-theme="dark"] #dlg-cancel,
  html[data-theme="dark"] #list-dlg-cancel {
    background:var(--pill); border-color:transparent; color:var(--pill-text); box-shadow:var(--pill-ring);
  }
  .quiet-btn:hover,
  #dlg-cancel:hover,
  #list-dlg-cancel:hover,
  html[data-theme="dark"] .quiet-btn:hover {
    background:var(--pill-hover); border-color:transparent; color:var(--pill-text);
  }
  .danger-btn,
  html[data-theme="dark"] .danger-btn {
    background:var(--pill-danger-bg); border-color:transparent; color:var(--pill-danger); box-shadow:none;
  }
  .danger-btn:hover,
  html[data-theme="dark"] .danger-btn:hover { background:var(--pill-danger-hover); border-color:transparent; }
  :is(.primary-btn, .quiet-btn, .danger-btn).icon-only { width:44px; min-width:44px; padding:0; }
  button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
  [role="button"]:focus-visible {
    outline:3px solid var(--ui-focus); outline-offset:2px;
  }
  button:disabled, .primary-btn:disabled {
    opacity:.5; cursor:not-allowed; transform:none; box-shadow:none;
  }

  #auth-status,
  :is(#dashboard-status, #archive-status),
  html[data-theme="dark"] #auth-status,
  html[data-theme="dark"] :is(#dashboard-status, #archive-status) { color:var(--ui-text-secondary); }
  #auth-status.error, #profile-status.error, #list-dlg-error { color:var(--ui-danger); }
  #file-warning,
  html[data-theme="dark"] #file-warning {
    border:1px solid color-mix(in srgb, var(--ui-warning) 22%, transparent);
    background:var(--ui-warning-soft); color:var(--ui-warning);
  }
  #demo-link,
  html[data-theme="dark"] #demo-link {
    color:var(--ui-accent); text-decoration-color:color-mix(in srgb, var(--ui-accent) 35%, transparent);
    text-underline-offset:3px;
  }
  #demo-link:hover { color:var(--ui-accent-hover); }
  /* Формы и диалоги */
  dialog,
  html[data-theme="dark"] dialog {
    width:min(500px, calc(100vw - 32px)); max-height:calc(100dvh - 32px); padding:28px;
    border:1px solid var(--ui-border); border-radius:20px; background:var(--ui-surface);
    color:var(--ui-text); box-shadow:var(--ui-shadow-lg);
  }
  dialog::backdrop,
  html[data-theme="dark"] dialog::backdrop {
    background:rgba(25,31,40,.48); backdrop-filter:blur(4px);
  }
  dialog h2,
  html[data-theme="dark"] dialog h2 {
    margin-bottom:20px; color:var(--ui-text); font-family:var(--ui-subheading-font);
    font-size:25px; line-height:1.16; font-weight:var(--ui-subheading-weight); letter-spacing:-.3px;
  }
  dialog label,
  html[data-theme="dark"] dialog label {
    margin-bottom:14px; color:var(--ui-text); font-size:13px; line-height:1.3; font-weight:700;
  }
  dialog input, dialog textarea, dialog .field-select {
    min-height:42px; margin-top:7px; padding:10px 12px; font-size:15px; font-weight:400;
  }
  dialog textarea { min-height:100px; }
  #fetch-status,
  html[data-theme="dark"] #fetch-status {
    min-height:18px; margin:-5px 0 10px; color:var(--ui-text-secondary); font-size:12.5px; line-height:1.35;
  }
  #fetch-status:empty { display:none; }
  .price-row { gap:9px; margin-top:7px; }
  .price-row input { margin-top:0; }
  .price-row select { width:112px; min-height:42px; padding:9px 8px; }

  /* A wish's picture: a photo of one's own first, a link folded away under it. */
  .item-photo-field { margin-bottom:14px; color:var(--ui-text); font-size:13px; line-height:1.3; font-weight:700; }
  .item-photo {
    display:flex; align-items:center; gap:12px; margin-top:7px; padding:10px;
    border:1px dashed var(--ui-border); border-radius:12px; transition:border-color .15s, background .15s;
  }
  /* Dialog inputs are blocks, which would otherwise show the hidden file picker. */
  .item-photo[hidden], #item-photo-input { display:none; }
  .item-photo.dragging {
    border-color:var(--ui-accent); background:color-mix(in srgb, var(--ui-accent) 8%, transparent);
  }
  .item-photo-preview {
    flex:none; width:72px; height:72px; overflow:hidden; border:1px solid var(--ui-border); border-radius:10px;
    background:#fff;
  }
  .item-photo-preview[hidden] { display:none; }
  .item-photo-preview img { width:100%; height:100%; object-fit:cover; display:block; }
  .item-photo-body { flex:1; min-width:0; }
  .item-photo-actions { display:flex; flex-wrap:wrap; gap:6px; }
  .item-photo-actions .quiet-btn {
    display:inline-flex; align-items:center; gap:6px; min-height:36px; padding:7px 11px;
    border:1px solid var(--ui-border); font-size:13px;
  }
  .item-photo-actions .quiet-btn[hidden] { display:none; }
  .item-photo-hint, .item-photo-status {
    margin:6px 0 0; color:var(--ui-text-secondary); font-size:12px; font-weight:500; line-height:1.4;
  }
  /* Empty, the box is one centred invitation; with a picture, its tile and what to do with it. */
  .item-photo:not(.has-photo) { justify-content:center; padding:18px 12px; text-align:center; }
  .item-photo:not(.has-photo) .item-photo-body { flex:none; }
  .item-photo:not(.has-photo) .item-photo-actions { justify-content:center; }
  .item-photo.has-photo .item-photo-hint { display:none; }
  .item-photo-status { color:var(--ui-danger, #b7402d); }
  .item-photo-status[hidden] { display:none; }
  /* Dropping a file needs a mouse, so a phone is not told about it. */
  @media (hover:none) { .item-photo-hint { display:none; } }
  .item-photo-link { margin-top:8px; }
  .item-photo-link summary {
    width:max-content; color:var(--ui-text-secondary); font-size:12.5px; font-weight:650; cursor:pointer;
  }
  .item-photo[hidden] + .item-photo-link { margin-top:0; }
  .dlg-btns { gap:9px; margin-top:22px; padding-top:18px; border-top:1px solid var(--ui-border); }
  .dlg-btns button { min-width:104px; }
  /* A short question, so it stays a card on phones too. */
  #confirm-dlg { width:min(440px, calc(100vw - 32px)); }
  #confirm-dlg h2 { margin-bottom:10px; }
  #confirm-dlg .dlg-btns .quiet-btn { border-color:var(--ui-border); }
  #confirm-dlg-text { color:var(--ui-text-secondary); font-size:14.5px; line-height:1.5; overflow-wrap:anywhere; }
  /* Every dialog but a yes/no question has the same plain cross in its top right corner. */
  .dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:13px; }
  dialog .dialog-head h2,
  html[data-theme="dark"] dialog .dialog-head h2 { margin:0; }
  dialog:is(#dlg, #list-dlg) .dialog-head { margin-bottom:20px; }
  #crop-dlg .dialog-head { margin-bottom:6px; }
  .dialog-close,
  html[data-theme="dark"] .dialog-close {
    flex-shrink:0; width:34px; height:34px; min-width:0; margin:-6px -6px 0 0; padding:0;
    display:grid; place-items:center; border:none; border-radius:10px; background:none; box-shadow:none;
    color:var(--ui-text-secondary); font-size:19px; line-height:1; cursor:pointer;
  }
  .dialog-close:hover,
  html[data-theme="dark"] .dialog-close:hover { color:var(--ui-text); background:var(--ui-surface-subtle); }
  /* Framing a profile photo: also a card on phones. */
  #crop-dlg { width:min(440px, calc(100vw - 32px)); }
  #crop-dlg .dlg-btns .quiet-btn { border-color:var(--ui-border); }
  #crop-dlg-hint { margin-bottom:16px; color:var(--ui-text-secondary); font-size:14.5px; line-height:1.5; }
  #crop-stage {
    position:relative; width:min(100%, 340px); aspect-ratio:1; margin:0 auto;
    overflow:hidden; border-radius:14px; background:var(--ui-surface-subtle);
    cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
  }
  #crop-stage:active { cursor:grabbing; }
  #crop-stage:focus-visible { outline:2px solid var(--ui-accent); outline-offset:2px; }
  /* The circle is what the avatar will show; the corners only help to place it. */
  #crop-stage::after {
    content:""; position:absolute; inset:0; border-radius:50%; pointer-events:none;
    box-shadow:0 0 0 999px rgba(16,20,28,.52), inset 0 0 0 2px rgba(255,255,255,.9);
  }
  #crop-dlg.crop-square #crop-stage::after { border-radius:0; }
  #crop-image {
    position:absolute; top:0; left:0; display:block; max-width:none; pointer-events:none;
    -webkit-user-drag:none;
  }
  .crop-zoom {
    display:flex; align-items:center; gap:12px; width:min(100%, 340px); margin:16px auto 0;
    color:var(--ui-text-secondary); font-size:12px;
  }
  .crop-zoom-large { font-size:18px; }
  #crop-zoom,
  html[data-theme="dark"] #crop-zoom {
    flex:1; min-width:0; width:auto; min-height:28px; margin:0; padding:0;
    border:none; border-radius:0; background:none; box-shadow:none; accent-color:var(--ui-accent);
  }
  #crop-zoom:focus { box-shadow:none; }
  #crop-zoom:focus-visible { outline:2px solid var(--ui-accent); outline-offset:3px; }
  /* A phone on its side has no height for a column: the photo goes beside the controls. */
  @media (max-height: 560px) and (orientation: landscape) {
    #crop-dlg[open] {
      width:min(720px, calc(100vw - 32px)); padding:20px; overflow:hidden;
      display:grid; grid-template-columns:auto minmax(0,1fr); grid-template-rows:auto auto 1fr auto; column-gap:22px;
    }
    #crop-stage { grid-column:1; grid-row:1 / -1; width:calc(100dvh - 74px); margin:0; }
    #crop-dlg .dialog-head, #crop-dlg-hint, .crop-zoom, #crop-dlg .dlg-btns { grid-column:2; }
    #crop-dlg .dlg-btns { grid-row:4; }
    .crop-zoom { margin:0; }
    #crop-dlg-hint { margin-bottom:10px; }
  }

@media (max-width: 560px) {
    dialog,
    html[data-theme="dark"] dialog {
      width:calc(100vw - 16px); max-height:calc(100dvh - 16px); padding:22px 18px;
      border-radius:18px;
    }
    dialog h2, html[data-theme="dark"] dialog h2 { font-size:23px; }
    .dlg-btns { align-items:stretch; }
    .dlg-btns button { flex:1; min-width:0; }
}

/* ============ ДИАЛОГИ: фон и телефон ============ */
  /* The page under an open dialog does not scroll. */
  html.dialog-open, html.dialog-open body { overflow:hidden; }
  /* dialogs.js measures the scrollbar that overflow:hidden took away; the padding keeps its place. */
  html.dialog-open body { padding-right:var(--dialog-scrollbar, 0px); }
  dialog { overscroll-behavior:contain; }

/* On phones every dialog is a full screen sheet: a header that stays on top,
   content that scrolls, and buttons that stay at the bottom, above the keyboard
   (dialogs.js keeps --vv-height and --vv-top at the visible part of the screen). */
@media (max-width: 640px) {
    :root:root dialog:is(#dlg, #list-dlg, #item-detail-dlg, #import-dlg, #share-dlg, #stamp-dlg, #reservations-dlg, #add-target-dlg, #feedback-dlg, #whats-new-dlg) {
      inset:var(--vv-top, 0px) 0 auto 0; width:100vw; max-width:100vw;
      height:var(--vv-height, 100dvh); max-height:var(--vv-height, 100dvh); margin:0;
      padding:calc(16px + env(safe-area-inset-top)) 18px 0; border:none; border-radius:0;
      overflow-y:auto; box-shadow:none;
    }
    :root:root dialog:is(#dlg, #list-dlg, #item-detail-dlg, #import-dlg, #share-dlg, #stamp-dlg, #reservations-dlg, #add-target-dlg, #feedback-dlg, #whats-new-dlg)[open] {
      animation:dialog-sheet-enter .24s cubic-bezier(.2,.8,.2,1) both;
    }
    :root:root dialog:is(#dlg, #list-dlg, #item-detail-dlg, #import-dlg, #share-dlg, #stamp-dlg, #reservations-dlg, #add-target-dlg, #feedback-dlg, #whats-new-dlg)[open].dialog-closing {
      animation:dialog-sheet-exit .18s ease-in both;
    }
    @keyframes dialog-sheet-enter {
      from { opacity:.4; transform:translate3d(0, 28px, 0); }
      to { opacity:1; transform:translate3d(0, 0, 0); }
    }
    @keyframes dialog-sheet-exit {
      from { opacity:1; transform:translate3d(0, 0, 0); }
      to { opacity:0; transform:translate3d(0, 24px, 0); }
    }
    /* Sticky offsets count from inside the dialog's padding, hence the negative top. */
    dialog:not(#crop-dlg) .dialog-head {
      position:sticky; top:calc(-16px - env(safe-area-inset-top)); z-index:3;
      margin:calc(-16px - env(safe-area-inset-top)) -18px 16px;
      padding:calc(16px + env(safe-area-inset-top)) 18px 12px;
      background:var(--ui-surface); border-bottom:1px solid var(--ui-border);
    }
    /* A short form still keeps its buttons at the bottom of the screen. */
    :root:root dialog:is(#dlg, #list-dlg, #feedback-dlg) > form { min-height:100%; display:flex; flex-direction:column; }
    :root:root :is(#feedback-fields, #feedback-done):not([hidden]) { flex:1; display:flex; flex-direction:column; }
    :root:root #feedback-done { padding:0; }
    :root:root #feedback-done > .paw { margin-top:auto; }
    :root:root #whats-new-dlg[open] { display:flex; flex-direction:column; }
    :root:root #whats-new-dlg .whats-new-list { max-height:none; overflow:visible; margin-bottom:22px; }
    dialog .dlg-btns {
      position:sticky; bottom:0; z-index:3;
      margin:auto -18px 0; padding:12px 18px calc(12px + env(safe-area-inset-bottom));
      background:var(--ui-surface); border-top:1px solid var(--ui-border);
    }
    /* Room for the site address iOS lays over the bottom edge above the keyboard. */
    html.keyboard-open dialog .dlg-btns { padding-bottom:max(36px, 12px + env(safe-area-inset-bottom)); }
    :root:root #share-dlg { padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
    :root:root #confirm-dlg .dlg-btns,
    :root:root #crop-dlg .dlg-btns { position:static; margin:22px 0 0; padding:18px 0 0; }
}
@media (max-width: 900px) and (max-height: 560px) and (orientation: landscape) {
    :root:root #crop-dlg .dlg-btns { margin-top:12px; padding-top:12px; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
    :root:root dialog[open], :root:root dialog[open].dialog-closing { animation:none; }
}

/* The product window on phones: the photo runs edge to edge under a close button
   that stays in reach, and the actions stay at the bottom. */
@media (max-width: 640px) {
    :root:root dialog#item-detail-dlg { padding:0; }
    :root:root #item-detail-close {
      position:sticky; top:calc(12px + env(safe-area-inset-top)); z-index:4;
      display:grid; place-items:center; margin:calc(12px + env(safe-area-inset-top)) 12px -46px auto;
      /* Here the cross sits on the photo, so it keeps a light backing to stay readable. */
      background:color-mix(in srgb, var(--ui-surface) 88%, transparent); backdrop-filter:blur(8px);
    }
    :root:root #item-detail-content { min-height:100%; display:flex; flex-direction:column; }
    :root:root .item-detail-layout { display:flex; flex-direction:column; flex:1; }
    :root:root .item-detail-media { height:min(300px, 42vh); min-height:0; border-right:none; border-bottom:1px solid var(--ui-border); }
    :root:root .item-detail-media img { max-height:none; }
    :root:root .item-detail-body { flex:1; padding:22px 18px 0; }
    :root:root .item-detail-description { max-height:none; overflow:visible; }
    :root:root #item-detail-dlg .item-detail-actions {
      position:sticky; bottom:0; z-index:3; margin:auto -18px 0; padding:12px 18px calc(12px + env(safe-area-inset-bottom));
      background:var(--ui-surface); border-top:1px solid var(--ui-border);
    }
    :root:root #item-detail-dlg .item-detail-actions { flex-wrap:nowrap; }
    :root:root #item-detail-dlg .item-detail-actions > :not(.detail-icon) { flex:1 1 0; min-width:0; }
    /* The bar has room for one text button, so a release gets a row of its own. */
    :root:root #item-detail-dlg .item-detail-actions:has(> .detail-release) { flex-wrap:wrap; }
    :root:root #item-detail-dlg .item-detail-actions > .detail-release { order:-1; flex:1 0 100%; }
    :root:root #item-detail-dlg .item-detail-actions:has(> .detail-secret) { flex-wrap:wrap; row-gap:8px; }
    :root:root #item-detail-dlg .item-detail-actions > .detail-secret { order:1; flex:1 0 100%; justify-content:center; }
    /* Chip in gets a row of its own under the reservation, above the notes. */
    :root:root #item-detail-dlg .item-detail-actions:has(> .detail-support) { flex-wrap:wrap; row-gap:8px; }
    :root:root #item-detail-dlg .item-detail-actions > .detail-support { order:1; flex:1 0 100%; }
    /* Beside a text button and icon buttons the shop link shrinks to its icon too. */
    :root:root #item-detail-dlg .item-detail-actions:has(.detail-icon):has(> button:not(.detail-icon)) .item-detail-link {
      flex:0 0 42px; width:42px; min-width:42px; padding:0;
    }
    :root:root #item-detail-dlg .item-detail-actions:has(.detail-icon):has(> button:not(.detail-icon)) .item-detail-link .detail-text {
      position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap;
    }
}
