/* M04–07, M50–56: dimensions from windows/boards.css. Real content scrolls;
   the full-screen photo viewer stays outside these sheet rules. */
#dialog:not(:has(.order-photo-gallery)){
  box-sizing:border-box;border:0;background:var(--surface);color:var(--ink);
  padding:26px 28px 28px;border-radius:28px;box-shadow:0 30px 80px rgb(15 27 45 / 35%);
  width:min(480px,calc(100% - 32px));max-height:90dvh;overflow-y:auto;
  overscroll-behavior:contain;font-size:15px;line-height:1.45;
}
#dialog::backdrop{background:rgb(15 27 45 / 48%);backdrop-filter:none;-webkit-backdrop-filter:none}
@media (min-width:821px){
  #dialog[open]:has(.order-detail-v2-map:not([data-unavailable]) > #order-detail-map-expanded){
    display:grid;
    grid-template-rows:auto minmax(0,1fr);
    width:min(1120px,calc(100% - 48px));
    max-width:none;
    height:min(800px,90dvh);
  }
  #dialog .dialog-body:has(> .order-detail-v2-map > #order-detail-map-expanded){
    min-height:0;
  }
  #dialog .order-detail-v2-map:has(> #order-detail-map-expanded):not([data-unavailable]),
  #dialog #order-detail-map-expanded{height:100%}
  #dialog[open]:has(#order-location-map-panel:not([hidden])){
    display:grid;
    grid-template-rows:auto minmax(0,1fr);
    width:min(960px,calc(100% - 48px));
    max-width:none;
    height:min(760px,90dvh);
  }
  #dialog .dialog-body:has(#order-location-map-panel:not([hidden])){min-height:0}
}
/* На телефоне карта заказа и выбор точки рукой занимают весь экран: в нижней половине экрана карту не разглядеть. */
@media (max-width:820px){
  #dialog[open]:is(:has(.order-detail-v2-map:not([data-unavailable]) > #order-detail-map-expanded),:has(#order-location-map-panel:not([hidden]))){
    display:grid;
    grid-template-rows:auto minmax(0,1fr);
    inset:0;
    width:100%;
    max-width:100%;
    height:100dvh;
    max-height:100dvh;
    padding:max(12px,env(safe-area-inset-top)) 12px max(12px,var(--app-safe-bottom));
    border-radius:0;
  }
  #dialog:is(:has(.order-detail-v2-map:not([data-unavailable]) > #order-detail-map-expanded),:has(#order-location-map-panel:not([hidden])))::before{display:none}
  #dialog .dialog-body:is(:has(> .order-detail-v2-map > #order-detail-map-expanded),:has(#order-location-map-panel:not([hidden]))){min-height:0}
  #dialog .order-detail-v2-map:has(> #order-detail-map-expanded):not([data-unavailable]),
  #dialog #order-detail-map-expanded{height:100%}
}
/* M14: the viewer fills the display even when the photograph is short.
   Only the image is scaled by the existing pinch handler, never the page. */
#dialog:has(.order-gallery-frameless){--order-photo-width:100vw;--order-photo-height:100dvh;
  inset:0;margin:0;width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;
  padding:0;border:0;border-radius:0;background:#0B1220;overflow:hidden;box-shadow:none}
#dialog:has(.order-gallery-frameless)::backdrop{background:#0B1220}
#dialog:has(.order-gallery-frameless) .dialog-body,#dialog .order-gallery-frameless{width:100%;height:100%;margin:0}
#dialog .order-gallery-frameless .order-gallery-stage{width:100%;height:100%;background:#0B1220}
#dialog .order-gallery-frameless .order-gallery-image{object-fit:contain}
#dialog:has(.order-gallery-frameless) .dialog-head{top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));bottom:auto;left:auto}
#dialog .order-gallery-frameless .order-gallery-thumbnails{bottom:max(18px,var(--app-safe-bottom))}
#dialog:not(:has(.order-photo-gallery)) .dialog-head{align-items:flex-start;gap:12px;margin-bottom:10px}
#dialog:not(:has(.order-photo-gallery)) .dialog-head h2{flex:1;min-width:0;margin:0;font-size:23px;line-height:1.2;letter-spacing:-.4px;font-weight:800}
#dialog:not(:has(.order-photo-gallery)) .dialog-head .iconbtn{position:relative;flex:none;width:34px;height:34px;min-width:34px;min-height:34px;padding:0;border:0;border-radius:50%;background:var(--bg);color:var(--muted);box-shadow:none}
/* Keep the 34px reference circle and a comfortable 44px touch target. */
#dialog:not(:has(.order-photo-gallery)) .dialog-head .iconbtn::after{content:"";position:absolute;inset:-5px}
#dialog:not(:has(.order-photo-gallery)) .dialog-head .iconbtn svg{width:16px;height:16px}
#dialog:not(:has(.order-photo-gallery)) .dialog-body{min-width:0}
#dialog:not(:has(.order-photo-gallery)) .dialog-body p{font-size:14.5px;line-height:1.45;margin:0 0 12px;overflow-wrap:anywhere}
#dialog:not(:has(.order-photo-gallery)) .dialog-body .small,#dialog:not(:has(.order-photo-gallery)) .dialog-body p.muted{font-size:13px}
#dialog:not(:has(.order-photo-gallery)) .dialog-body .tiny{font-size:12px;margin-top:10px}
#dialog:not(:has(.order-photo-gallery)) .dialog-body h3{font-size:15px;margin:14px 0 8px}
#dialog:not(:has(.order-photo-gallery)) .dialog-body label{font-size:14px;margin-bottom:6px}
#dialog:not(:has(.order-photo-gallery)) .dialog-body .input{box-sizing:border-box;width:100%;min-width:0;border:1px solid var(--line);border-radius:14px;background:var(--surface);padding:12px 14px;margin:0 0 14px;font-size:16px;line-height:1.45}
#dialog:not(:has(.order-photo-gallery)) .dialog-body .input[aria-invalid="true"]{border-color:#F97066;background:color-mix(in srgb,var(--surface) 95%,#D92D20)}
#dialog:not(:has(.order-photo-gallery)) .dialog-body :is(button.primary,button.secondary,a.primary,a.secondary){box-sizing:border-box;min-height:48px;padding:13px 16px;border-radius:14px;font-size:15px;font-weight:600;line-height:1.45;white-space:normal;text-align:center}
#dialog:not(:has(.order-photo-gallery)) .dialog-body :is(.danger-action,button.primary.danger){background:#D92D20;color:white;border-color:#D92D20;box-shadow:none}
#dialog:not(:has(.order-photo-gallery)) .dialog-actions{display:flex;gap:10px;margin-top:16px;align-items:stretch}
#dialog:not(:has(.order-photo-gallery)) .dialog-actions>*{min-width:0;flex:1}
#dialog:not(:has(.order-photo-gallery)) .dialog-body .error{font-size:13px;line-height:1.4}
#dialog:not(:has(.order-photo-gallery)) .dialog-body .error:empty{display:none}

/* Real checkboxes, keyboard focus rings and disclosure behaviour are preserved. */
#dialog .account-settings{gap:12px}
#dialog .account-top-back{display:none}
#dialog .account-settings[data-settings-page="notifications"]{gap:0}
#dialog .settings-row{padding:12px 0;min-height:60px;gap:12px}
#dialog .settings-row>div{min-width:0;flex:1}
#dialog .settings-row strong{font-size:14.5px;line-height:1.4}
#dialog .settings-row p{font-size:13px!important;line-height:1.4;margin:2px 0 0!important}
#dialog .account-settings :is(.account-box,.account-note){padding:4px 14px;border:0;border-radius:16px;background:var(--bg)}
#dialog .account-settings .account-note{padding:12px 14px}
#dialog .account-settings .account-note p{font-size:13px;margin:3px 0 0}
#dialog .account-group{border:1px solid var(--line);border-radius:14px;background:var(--surface)}
#dialog .account-group summary{padding:12px 14px;min-height:60px}
#dialog .account-group summary strong{font-size:14.5px}
#dialog .account-group summary small{margin-top:3px;line-height:1.4}
#dialog .account-group-body{padding:0 14px 12px;gap:8px}
#dialog .account-toggle{margin:0!important;gap:12px;min-height:62px;padding:12px 0}
#dialog .account-toggle strong{font-size:14.5px;line-height:1.4;font-weight:600}
#dialog .account-toggle small{font-size:12.5px;line-height:1.4;margin-top:3px}
#dialog .toggle{position:relative;flex:none;box-sizing:border-box;width:44px;height:26px;border:0;border-radius:13px;background:#D0D5DD}
#dialog .toggle.on{background:var(--accent)}
#dialog .toggle::after{width:20px;height:20px;top:3px;left:3px;background:white;box-shadow:0 1px 3px rgb(0 0 0 / 20%)}
#dialog .toggle.on::after{left:21px}
#dialog .account-toggle input{width:44px;height:44px;right:0}
#dialog .account-notification-options .account-toggle{border-bottom:1px solid var(--line);border-top:0}
#dialog .account-notification-options .account-toggle:last-child{border-bottom:0}
#dialog .account-notification-options>.textbtn{font-size:14.5px;justify-content:flex-start;min-height:36px;padding:4px 0 6px;color:var(--accent)}
#dialog .account-settings[data-settings-page="documents"],#dialog .account-settings[data-settings-page="privacy"]{gap:0}
#dialog .account-settings[data-settings-page="privacy"] .account-note{padding:11px 0;background:transparent;border-bottom:1px solid var(--line);border-radius:0}
#dialog .account-settings .settings-row>svg:first-child,#dialog .account-note>svg{box-sizing:content-box;padding:10px;width:20px;height:20px;border-radius:12px;background:var(--accent-soft);color:var(--accent)}
#dialog .account-settings .settings-row>svg:last-child{width:20px;height:20px;color:var(--muted)}

/* M50: compact options and colour circles, not four form fields. */
#dialog .appearance-picker{gap:16px}
#dialog .appearance-picker legend{font-size:14px;margin-bottom:6px}
#dialog .appearance-options{display:flex;gap:8px;flex-wrap:wrap}
#dialog .appearance-options .appearance-choice{width:auto;min-height:38px;padding:8px 14px;gap:0;border:1px solid var(--line);border-radius:999px;font-size:14px;font-weight:500;line-height:1.45}
#dialog .appearance-options .appearance-choice[aria-pressed="true"]{background:var(--accent-soft);color:var(--accent);border-color:var(--accent);box-shadow:none}
#dialog .appearance-options .appearance-choice>span[aria-hidden]{display:none}
#dialog .appearance-colors{display:flex;gap:12px;align-items:flex-start;flex-wrap:wrap}
#dialog .appearance-color{position:relative;display:flex;flex-direction:column;justify-content:flex-start;gap:8px;width:auto;min-width:50px;min-height:70px;padding:4px 0 0;border:0;background:transparent!important;box-shadow:none!important;font-size:12px;color:var(--muted)}
#dialog .appearance-color .appearance-swatch{width:44px;height:44px;border-radius:50%}
#dialog .appearance-color[aria-pressed="true"] .appearance-swatch{outline:2px solid var(--accent);outline-offset:3px}
#dialog .appearance-color .appearance-check{position:absolute;top:12px;left:50%;transform:translateX(-50%);margin:0;color:white;font-size:20px;font-weight:700;line-height:28px}
#dialog .appearance-color[data-appearance-value="green"]{order:1}
#dialog .appearance-color[data-appearance-value="blue"]{order:2}
#dialog .appearance-color[data-appearance-value="plum"]{order:3}
#dialog .appearance-color[data-appearance-value="sand"]{order:4}
#dialog .dialog-language-list{display:grid}
#dialog .dialog-language-list button{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:46px;padding:11px 0;border:0;border-bottom:1px solid var(--line);border-radius:0;background:transparent;color:var(--ink);font-size:15px;font-weight:500;text-align:left}
#dialog .dialog-language-list button i{display:block;flex:none;box-sizing:border-box;width:20px;height:20px;border:2px solid #D0D5DD;border-radius:50%}
#dialog .dialog-language-list button[aria-checked="true"] i{border:6px solid var(--accent)}

/* M04/M05: title, order, event and next action. */
#dialog .notice-row{display:flex;align-items:flex-start;gap:12px;padding:12px 0;border:0;border-bottom:1px solid var(--line);border-radius:0;background:transparent;box-shadow:none}
#dialog .notice-row:last-child{border-bottom:0}
#dialog .notice-row .order-symbol{flex:none;width:36px;height:36px;border-radius:12px;background:var(--cta-soft);color:var(--cta);margin:0}
#dialog .notice-row .order-symbol.is-chat{background:var(--accent-soft);color:var(--accent)}
#dialog .notice-row .order-symbol svg{width:18px;height:18px}
#dialog .notice-row strong{display:block;font-size:14.5px;font-weight:700;line-height:1.4}
#dialog .notice-row .notice-copy p{font-size:13px;line-height:1.4;margin:3px 0 0;font-weight:400}
#dialog .notice-row .notice-copy .notice-task-title{color:var(--muted)}
#dialog .notice-row .notice-next{color:var(--accent);font-size:13.5px;font-weight:700;line-height:1.4;margin-top:4px}
#dialog .notice-row>.chat-unread-dot{align-self:flex-start;width:9px;height:9px;margin-top:6px;background:var(--cta)}
#dialog .notice-row>.chat-unread-dot::after{animation:none}
#dialog .notice-toolbar{margin:0 0 2px}
#dialog .notice-toolbar .textbtn{padding:0;min-height:34px;font-size:14.5px}
#dialog .notice-action-card{gap:12px}
#dialog .notice-action-card>p{margin:0!important}
#dialog .notice-action-card .notice-action-task{padding:9px 12px;background:var(--bg);border-radius:12px;font-size:14px;font-weight:600}
#dialog .notice-action-buttons{gap:10px;margin-top:4px}
#dialog .notice-action-buttons .primary{background:var(--cta);color:var(--cta-ink);border-color:var(--cta);box-shadow:0 8px 18px rgb(255 122 26 / 18%)}
#dialog .notice-action-buttons .textbtn{justify-content:center;font-size:14.5px;font-weight:600;min-height:44px;color:var(--accent)}
#dialog [data-action="confirm-cancel"],#dialog [data-action="confirm-withdraw"]{background:#D92D20!important;color:white!important;border-color:#D92D20!important;box-shadow:none!important}
#dialog .journey-help-steps{counter-reset:help-step;list-style:none;display:grid;gap:0;padding:0;margin:0 0 12px}
#dialog .journey-help-steps li{counter-increment:help-step;display:flex;align-items:flex-start;gap:12px;padding:8px 0;font-size:14px;line-height:1.45}
#dialog .journey-help-steps li::before{content:counter(help-step);display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:50%;background:var(--ink);color:var(--surface);font-size:14px;font-weight:700}
#dialog .notice-action-result{display:block;width:auto;max-width:100%;height:auto;max-height:min(40dvh,320px);margin-inline:auto;border-radius:14px}
#dialog:not(:has(.order-photo-gallery)) .dialog-task-title{padding:9px 12px;background:var(--bg);border-radius:12px;font-size:14px;font-weight:600}
#dialog .dialog-key-values{margin:0 0 12px;padding:4px 14px;background:var(--bg);border-radius:16px;font-size:14px}
#dialog .dialog-key-values>div{display:flex;gap:12px;padding:10px 0}
#dialog .dialog-key-values dt{color:var(--muted);width:104px;flex:none;font-size:13px}
#dialog .dialog-key-values dd{margin:0;font-weight:700}
#dialog .dialog-price-input{position:relative}
#dialog:not(:has(.order-photo-gallery)) .dialog-price-input .input{padding-right:42px;font-weight:700}
#dialog .dialog-price-input>span{position:absolute;right:14px;top:13px;font-size:14px;font-weight:700;pointer-events:none}
#dialog:not(:has(.order-photo-gallery)) #price-reason{min-height:84px;resize:vertical}
#dialog .rating-stars button{width:44px;height:44px;padding:2px}
#dialog .rating-stars svg{width:40px;height:40px}

@media(max-width:820px){
  /* На телефоне окно стоит посередине экрана, а не у нижнего края: его нижние кнопки не оказываются под пальцем, которым держат телефон. Окно выше экрана занимает экран почти целиком и прокручивается внутри. Карта по-прежнему раскрывается на весь экран (правила выше). */
  #dialog:not(:has(.order-photo-gallery)){inset:0;margin:auto;width:calc(100% - 24px);max-width:480px;height:fit-content;max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px) - var(--app-safe-bottom));padding:20px 20px 22px}
  #dialog:not(:has(.order-photo-gallery))::before{display:none}
  /* Высокие списки — «События», языки, страницы настроек — остаются шторкой от нижнего края во всю высоту экрана, с «ручкой». */
  #dialog:is(:has(.dialog-language-list),:has(.notice-row),:has(.account-top-back)){inset:auto 0 0;margin:0;width:100%;max-width:100%;height:calc(100dvh - 44px);max-height:calc(100dvh - 44px);padding:10px 20px max(24px,var(--app-safe-bottom));border-radius:28px 28px 0 0;box-shadow:0 -10px 40px rgb(15 27 45 / 25%)}
  #dialog:is(:has(.dialog-language-list),:has(.notice-row),:has(.account-top-back))::before{content:"";display:block;width:44px;height:5px;border-radius:3px;background:#D0D5DD;margin:0 auto 14px}
  /* Окно «Заказ создан!» уже остальных и с большим полем сверху: таким оно задано в brand-entry.css. */
  #dialog:has(.brand-order-created){width:calc(100% - 40px);max-width:400px;padding:32px 18px 24px}
  /* Альбом портфолио — окно с фотографиями в рамке — тоже стоит посередине: общее старое правило прижимало его к нижнему и левому краю. Просмотр фото на весь экран этим правилом не затронут. */
  #dialog:has(.order-photo-gallery):not(:has(.order-gallery-frameless)){inset:0;margin:auto;height:fit-content;max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px) - var(--app-safe-bottom));border-radius:24px}
  #dialog:has(.order-photo-gallery):not(:has(.order-gallery-frameless))::before{display:none}
  #dialog:not(:has(.order-photo-gallery)) .dialog-head h2{font-size:21px}
  #dialog .account-top-back{display:flex;justify-content:flex-start;gap:8px;margin:0 0 8px;padding:0;min-height:20px;font-size:13.5px;color:var(--muted)}
  #dialog .account-top-back svg{width:16px;height:16px}
  #dialog:not(:has(.order-photo-gallery)) .dialog-actions{flex-direction:row}
}
/* An iPhone blurs the top of the screen while a window is open (see style.css): the windows keep below that band.
   A window in the middle is centred in what is left of the screen; a tall list starts under the band; the map and
   the photograph over the whole screen keep their heading and the photograph itself out of it. */
@supports (-webkit-touch-callout:none){
  @media (max-width:820px){
    #dialog:not(:has(.order-photo-gallery)){inset:calc(var(--app-safe-top) + var(--app-top-band)) 0 var(--app-safe-bottom);max-height:calc(100dvh - 24px - var(--app-safe-top) - var(--app-top-band) - var(--app-safe-bottom))}
    #dialog:is(:has(.dialog-language-list),:has(.notice-row),:has(.account-top-back)){inset:auto 0 0;height:calc(100dvh - var(--app-safe-top) - var(--app-top-band) - 8px);max-height:calc(100dvh - var(--app-safe-top) - var(--app-top-band) - 8px)}
    #dialog:has(.order-photo-gallery):not(:has(.order-gallery-frameless)){inset:calc(var(--app-safe-top) + var(--app-top-band)) 0 var(--app-safe-bottom);max-height:calc(100dvh - 24px - var(--app-safe-top) - var(--app-top-band) - var(--app-safe-bottom))}
    #dialog[open]:is(:has(.order-detail-v2-map:not([data-unavailable]) > #order-detail-map-expanded),:has(#order-location-map-panel:not([hidden]))){inset:0;max-height:100dvh;padding-top:calc(var(--app-safe-top) + var(--app-top-band))}
    #dialog:has(.order-gallery-frameless){--order-photo-height:calc(100dvh - var(--app-safe-top) - var(--app-top-band));inset:0;max-height:100dvh;padding-top:calc(var(--app-safe-top) + var(--app-top-band))}
    #dialog:has(.order-gallery-frameless) .dialog-head{top:calc(var(--app-safe-top) + var(--app-top-band) + 8px)}
  }
}

@media(max-width:360px){#dialog:not(:has(.order-photo-gallery)) .dialog-actions{flex-wrap:wrap}#dialog:not(:has(.order-photo-gallery)) .dialog-actions>*{flex-basis:135px}}
/* Фото из переписки — само фото на тёмном поле, без полей окна: так оно задано в chat-layout.css. Общие правила окна выше давали ему поля и ширину обычного окна, и фото обрезалось справа. */
#dialog:has(.chat-photo-lightbox){width:fit-content;max-width:var(--chat-photo-width);max-height:var(--chat-photo-height);padding:0;background:#141a20;overflow:hidden}
.large-text #dialog:not(:has(.order-photo-gallery)) .dialog-body p,.large-text #dialog:not(:has(.order-photo-gallery)) .dialog-body label,.large-text #dialog .account-toggle strong,.large-text #dialog .appearance-choice{font-size:18px}
.large-text #dialog:not(:has(.order-photo-gallery)) .dialog-head h2{font-size:27px}
.large-text #dialog:not(:has(.order-photo-gallery)) .dialog-body :is(button.primary,button.secondary){font-size:18px}
.large-text #dialog .account-toggle small,.large-text #dialog .account-group summary small{font-size:16px}
.large-text #dialog .settings-row strong,.large-text #dialog .appearance-picker legend,.large-text #dialog .dialog-language-list button,.large-text #dialog .notice-row strong{font-size:18px}
.large-text #dialog .settings-row p,.large-text #dialog .notice-row .notice-copy p{font-size:16px!important}


/* M54 reads the same authenticated session list directly inside Security. */
#dialog .account-settings[data-settings-page=security] .account-note{padding:11px 0;border-bottom:1px solid var(--line);background:transparent;border-radius:0}
#dialog .account-settings[data-settings-page=security] h4{font-size:15px;margin:2px 0 0}
#dialog .account-sessions-heading{padding:0;font-size:15px;font-weight:700;color:var(--ink);min-height:30px}
#dialog .account-settings[data-settings-page=security] .account-session{padding:11px 0;align-items:center;gap:0}
#dialog .account-settings[data-settings-page=security] .account-session>svg{display:none}
#dialog .account-settings[data-settings-page=security] .account-session>div{display:flex;justify-content:space-between;gap:14px;align-items:center;flex:1;min-width:0}
#dialog .account-settings[data-settings-page=security] .account-session strong{font-size:14px;font-weight:400;color:var(--muted)}
#dialog .account-settings[data-settings-page=security] .account-session p{font-size:13px;margin:0;text-align:right}
.large-text #dialog .account-settings[data-settings-page=security] .account-session strong,
.large-text #dialog .account-settings[data-settings-page=security] .account-session p{font-size:17px}

#account-name-form label{display:block;font-size:14px;margin-bottom:6px}
#account-name-form .account-name-actions{margin:-4px 0 14px}
#account-name-form .account-name-actions[hidden]{display:none}

#dialog .appearance-color{width:44px;min-width:44px;min-height:44px;padding:0;gap:0}
#dialog .appearance-color>span:not([aria-hidden]){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
#dialog .appearance-color .appearance-check{top:8px}
#dialog .appearance-color[aria-pressed="true"] .appearance-swatch{outline-color:var(--ink)}
#dialog .appearance-color-legend{font-size:12px;color:var(--muted);margin:8px 0 0;line-height:1.4}

#dialog:not(:has(.order-photo-gallery)) .dialog-body p.appearance-color-legend{font-size:12px;line-height:1.4;margin:8px 0 0}
/* The window that asks a guest to sign in: «Войти или зарегистрироваться» goes on top across the window, so that the
   long word fits a narrow phone. */
#dialog .dialog-actions.guest-signin-actions{flex-direction:column-reverse}
#dialog .dialog-actions.guest-signin-actions>*{flex:none}
