/* ==========================================================================
   Surface: dashboard app shell (owned by dashboard-core)
   --------------------------------------------------------------------------
   Markup is built by account-shell.js on #studio.app-shell[data-shell="158"]:
     a.skip-link · aside.sidebar#studioSidebar (.sidebar-head,
     nav.app-nav > .nav-group > .nav-group-title + button.nav-item[data-page],
     .sidebar-foot > .upgrade-card, .sidebar-help, button.user-card)
     header.app-topbar (.mobile-nav, .topbar-brand, .topbar-title > #pageLabel,
     .topbar-actions > .draft-pill, #openProfile, .url-chip, #saveBtn)
     .workspace#main[role=main] > section.page(.active)
     nav.app-tabbar (≤900px) · #sidebarBackdrop
   Also: .toast-stack (app.js notify), #actionDialog footer order, popovers
   (.user-menu .share-pop .draft-pop .link-menu), the share dialog (.share-dialog,
   dash-share.js). Release 174: the dashboard search (Ctrl+K palette) was removed.
   Breakpoints: ≥1280 full sidebar · 901–1279 icon rail · ≤900 drawer + tab bar.
   ========================================================================== */

@layer surfaces {
  /* ---- Frame ---------------------------------------------------------------- */
  .app-shell {
    --shell-side: var(--nv-sidebar-w);
    --nv-tabbar-h: 0px; /* height of the mobile bottom tab bar (editor.css reads it) */
    display: grid;
    grid-template-columns: var(--shell-side) minmax(0, 1fr);
    grid-template-rows: var(--nv-topbar-h) minmax(0, 1fr);
    grid-template-areas: "side top" "side main";
    min-height: 100dvh;
    background: var(--nv-bg);
  }

  .app-shell > .workspace {
    grid-area: main;
    min-width: 0;
    overflow-x: clip;
    outline: none;
  }

  .app-shell .page {
    display: none;
    width: 100%;
    max-width: calc(var(--nv-w-content) + 2 * var(--nv-gutter));
    margin: 0 auto;
    padding: var(--nv-space-8) var(--nv-gutter) var(--nv-space-16);
  }

  .app-shell .page.active {
    display: block;
    animation: shell-page-in var(--nv-dur-3) var(--nv-ease);
  }

  /* ---- Sidebar -------------------------------------------------------------- */
  .sidebar {
    grid-area: side;
    position: sticky;
    top: 0;
    z-index: var(--nv-z-sidebar);
    display: flex;
    flex-direction: column;
    gap: var(--nv-space-3);
    height: 100dvh;
    padding: var(--nv-space-4) var(--nv-space-3) var(--nv-space-3) max(var(--nv-space-3), env(safe-area-inset-left, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--nv-line);
    background: var(--nv-bg-deep);
    scrollbar-width: thin;
  }

  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nv-space-2);
    min-height: 40px;
    padding: 0 var(--nv-space-2);
  }

  .sidebar-head .brand {
    --brand-mark: 24px;
    --brand-text: 18px;
  }

  .sidebar-close {
    display: none;
  }

  /* r181 rhythm: rows 36px with 2px between them; a section label sits 24px under the group above and
     8px over its own first row. */
  .app-nav {
    display: grid;
    gap: var(--nv-space-6);
  }

  .nav-group {
    display: grid;
    gap: 2px;
  }

  .nav-group-title {
    margin: 0 0 6px;
    padding: 0 var(--nv-space-3);
    color: var(--nv-text-3);
    font-size: var(--nv-fs-eyebrow);
    font-weight: var(--nv-fw-medium);
    letter-spacing: var(--nv-tracking-eyebrow);
    line-height: 16px;
    text-transform: none;
  }

  .nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: var(--nv-h-nav);
    padding: 0 var(--nv-space-3);
    border-radius: var(--nv-r-sm);
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    text-align: left;
    transition: background-color var(--nv-dur-1) var(--nv-ease), color var(--nv-dur-1) var(--nv-ease);
  }

  .nav-item > :is(.nav-icon, .nv-icon, svg) {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--nv-text-3);
    transition: color var(--nv-dur-1) var(--nv-ease);
  }

  .nav-item .nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-item:hover {
    background: rgb(239 233 227 / 4%);
    color: var(--nv-text);
  }

  .nav-item:hover > :is(.nav-icon, .nv-icon, svg) {
    color: var(--nv-text-2);
  }

  /* The current page: one surface step up with a hairline; text and icon in the primary role. */
  .nav-item.active {
    background: var(--nv-surface-1);
    color: var(--nv-text);
    box-shadow: inset 0 0 0 1px var(--nv-line);
  }

  .nav-item.active > :is(.nav-icon, .nv-icon, svg) {
    color: var(--nv-text);
  }

  .sidebar-foot {
    display: grid;
    gap: var(--nv-space-2);
    margin-top: auto;
    padding-top: var(--nv-space-3);
  }

  /* Premium offer for Free accounts: a quiet card (surface step + hairline); the crown in the accent ink
     is its only colour. */
  .upgrade-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: var(--nv-space-2) var(--nv-space-3);
    overflow: hidden;
    text-align: left;
    transition: background-color var(--nv-dur-1) var(--nv-ease), border-color var(--nv-dur-1) var(--nv-ease);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-1);
  }

  .upgrade-card:hover {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-2);
  }

  .upgrade-copy {
    display: grid;
    flex: 1;
    min-width: 0;
  }

  .upgrade-copy small {
    overflow: hidden;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-12);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .upgrade-arrow {
    flex: none;
    width: 16px;
    height: 16px;
    color: var(--nv-text-3);
  }

  .upgrade-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 20px;
    height: 20px;
    color: var(--nv-accent-text);
  }

  .upgrade-icon .nv-icon {
    width: 18px;
    height: 18px;
  }

  .upgrade-copy b {
    display: block;
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
  }

  .upgrade-copy p {
    margin-top: 2px;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-12);
    line-height: var(--nv-lh-ui);
  }

  .sidebar-help {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--nv-h-nav);
    padding: 0 var(--nv-space-3);
    border-radius: var(--nv-r-sm);
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
  }

  .sidebar-help:hover {
    background: rgb(239 233 227 / 4%);
    color: var(--nv-text-2);
    text-decoration: none;
  }

  .sidebar-help .nv-icon {
    width: 18px;
    height: 18px;
  }


  .user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: var(--nv-space-2);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-1);
    text-align: left;
    transition: border-color var(--nv-dur-1) var(--nv-ease), background-color var(--nv-dur-1) var(--nv-ease);
  }

  .user-card:hover,
  .user-card[aria-expanded="true"] {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-2);
  }

  /* r174: Настройки live in the account menu, so the card marks that page (a surface step, like a nav row). */
  .user-card.active {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-2);
  }

  .user-card .avatar {
    --av: 34px;
  }

  .user-meta {
    display: grid;
    flex: 1;
    min-width: 0;
    line-height: 1.25;
  }

  .user-meta b,
  .user-meta small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-meta b {
    color: var(--nv-text);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
  }

  /* The address is the signature (.nv-address: mono, dim host, bright name); «Адрес не выбран» stays in the sans. */
  .user-meta small {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
  }

  .user-line {
    display: flex;
    align-items: center;
    gap: var(--nv-space-1);
    min-width: 0;
  }

  .user-line b {
    min-width: 0;
  }

  .plan-chip {
    flex: none;
    min-height: 18px;
    padding: 0 4px;
    border-radius: var(--nv-r-xs);
    font-size: var(--nv-fs-12);
    letter-spacing: 0;
  }

  .user-caret {
    flex: none;
    width: 16px;
    height: 16px;
    color: var(--nv-text-3);
  }

  /* ---- Top bar -------------------------------------------------------------- */
  .app-topbar {
    grid-area: top;
    position: sticky;
    top: 0;
    z-index: var(--nv-z-header);
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    min-width: 0;
    height: var(--nv-topbar-h);
    padding: 0 var(--nv-gutter);
    border-bottom: 1px solid var(--nv-line);
    background: var(--nv-bg);
  }

  .app-topbar .mobile-nav,
  .topbar-brand {
    display: none;
  }

  .topbar-title {
    flex: 1;
    min-width: 0;
  }

  .topbar-heading {
    overflow: hidden;
    color: var(--nv-text);
    font-size: var(--nv-fs-16);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: var(--nv-space-2);
  }

  .draft-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--nv-space-2);
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-control);
    background: transparent;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    white-space: nowrap;
    transition: border-color var(--nv-dur-1) var(--nv-ease), background-color var(--nv-dur-1) var(--nv-ease);
  }

  .draft-pill:hover,
  .draft-pill[aria-expanded="true"] {
    border-color: var(--nv-line-strong);
    background: var(--nv-surface-2);
    color: var(--nv-text);
  }

  .draft-pill:is([data-state="dirty"], [data-state="new"]) {
    border-color: var(--nv-warning-line);
    color: var(--nv-text);
  }

  /* r181: when everything is published the disabled «Опубликовано» button already says so; the status pill
     shows only while there is something to publish (it is not repeated next to the button). */
  .draft-pill[data-state="clean"] {
    display: none;
  }

  /* Language pill (globe + code). i18n.js turns the inner switcher into a native select, stretched invisibly over
     the pill, so a tap opens the system's own list of all 15 languages. */
  .topbar-lang {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px 0 10px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-control);
    color: var(--nv-text-2);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
    letter-spacing: .04em;
  }

  .topbar-lang:hover,
  .topbar-lang:focus-within {
    border-color: var(--nv-line-strong);
    color: var(--nv-text);
  }

  .topbar-lang:has(.nova-language-select:focus-visible) {
    outline: 2px solid var(--nv-focus);
    outline-offset: 2px;
  }

  .topbar-lang .nv-icon {
    width: 16px;
    height: 16px;
  }

  .topbar-lang .nova-language-switcher {
    display: contents;
  }

  .topbar-lang .nova-language-switcher::after {
    display: none;
  }

  .topbar-lang .nova-language-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
  }

  .topbar-preview {
    --btn-h: 36px;
  }

  /* The address in the top bar, set as the signature: mono, the host dim, the name bright. */
  .url-chip {
    display: inline-flex;
    align-items: stretch;
    min-width: 0;
    height: 36px;
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-control);
    background: var(--nv-field);
  }

  .url-chip-main {
    display: inline-flex;
    align-items: center;
    gap: 0;
    min-width: 0;
    max-width: 280px;
    padding: 0 8px 0 12px;
    border-radius: calc(var(--nv-r-control) - 1px) 0 0 calc(var(--nv-r-control) - 1px);
    color: var(--nv-address-name);
    font-family: var(--nv-address-font);
    font-size: var(--nv-fs-13);
    white-space: nowrap;
  }

  .url-chip-host {
    color: var(--nv-address-host);
  }

  .url-chip-slug {
    overflow: hidden;
    color: var(--nv-address-name);
    font-weight: var(--nv-fw-medium);
    text-overflow: ellipsis;
  }

  .url-chip-copy {
    flex: none;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    color: var(--nv-text-3);
    transition: color var(--nv-dur-1) var(--nv-ease);
  }

  .url-chip-main:hover .url-chip-copy {
    color: var(--nv-text);
  }

  .url-chip-menu {
    display: grid;
    place-items: center;
    width: 36px;
    border-left: 1px solid var(--nv-line);
    border-radius: 0 calc(var(--nv-r-control) - 1px) calc(var(--nv-r-control) - 1px) 0;
    color: var(--nv-text-2);
  }

  .url-chip-menu .nv-icon {
    width: 16px;
    height: 16px;
  }

  .url-chip :is(.url-chip-main, .url-chip-menu):hover {
    background: var(--nv-surface-2);
  }

  .url-chip.is-empty .url-chip-main {
    padding-right: 12px;
    border-radius: calc(var(--nv-r-control) - 1px);
    font-family: var(--nv-font-sans);
  }

  .url-chip.is-empty .url-chip-slug {
    color: var(--nv-accent-text);
  }

  .url-chip.is-empty .url-chip-copy {
    display: none;
  }

  .topbar-publish {
    --btn-h: 36px;
    min-width: 128px;
  }

  .topbar-publish::before {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 14.9A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.24'/%3E%3Cpath d='M12 12v9'/%3E%3Cpath d='m16 16-4-4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 14.9A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.24'/%3E%3Cpath d='M12 12v9'/%3E%3Cpath d='m16 16-4-4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  .topbar-publish:is(.is-loading, [aria-busy="true"])::before {
    display: none;
  }

  /* ---- Popovers (user menu, share, draft, link menu) ------------------------- */
  :is(.user-menu, .share-pop, .draft-pop, .link-menu) {
    position: fixed;
    z-index: var(--nv-z-dropdown);
    animation: nv-pop var(--nv-dur-2) var(--nv-ease);
  }

  .user-menu {
    min-width: 252px;
    /* r166 (G9): never runs off the bottom of a phone screen («Выйти» stays reachable). */
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  .user-menu-head {
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    padding: var(--nv-space-2) var(--nv-space-2) var(--nv-space-1);
  }

  .user-menu-head .avatar {
    --av: 36px;
  }

  .user-menu-head div {
    display: grid;
    min-width: 0;
  }

  .user-menu-head b,
  .user-menu-head small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-menu-head small {
    color: var(--nv-text-3);
  }

  .user-menu .menu-item > .chip {
    margin-left: auto;
  }

  .user-menu .menu-item[aria-disabled="true"] {
    opacity: .55;
  }

  .user-menu-lang {
    cursor: default;
  }

  .user-menu-lang .nova-language-switcher {
    margin-left: auto;
  }

  .user-menu-lang:hover {
    background: transparent;
  }

  .share-pop {
    display: grid;
    gap: var(--nv-space-3);
    width: 248px;
    padding: var(--nv-space-3);
  }

  .share-pop-qr {
    padding: var(--nv-space-2);
    border-radius: var(--nv-r-sm);
    background: #fff;
  }

  .share-pop-qr svg {
    width: 100%;
    height: auto;
  }

  .share-pop-url {
    overflow: hidden;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-12);
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .share-pop-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--nv-space-2);
  }

  .draft-pop {
    display: grid;
    gap: var(--nv-space-2);
    width: 300px;
    padding: var(--nv-space-4);
  }

  .draft-pop-title {
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
  }

  .draft-pop-note {
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    line-height: var(--nv-lh-ui);
  }

  .draft-pop-list {
    display: grid;
    gap: 2px;
    max-height: 220px;
    margin: var(--nv-space-1) 0;
    padding: var(--nv-space-1);
    overflow: auto;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-sm);
    background: var(--nv-bg-deep);
    list-style: none;
  }

  .draft-pop-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nv-space-2);
    padding: 6px 8px;
    color: var(--nv-text);
    font-size: var(--nv-fs-13);
  }

  .draft-pop-list li::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--nv-warning);
  }

  .draft-pop-list li span:first-of-type {
    flex: 1;
  }

  .draft-pop-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--nv-space-2);
    margin-top: var(--nv-space-1);
  }

  /* ---- Toasts ---------------------------------------------------------------- */
  .toast-stack {
    position: fixed;
    inset: auto auto max(24px, env(safe-area-inset-bottom)) 50%;
    z-index: var(--nv-z-toast);
    display: grid;
    justify-items: center;
    gap: var(--nv-space-2);
    width: max-content;
    max-width: calc(100vw - 32px);
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    color: inherit;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .toast-stack:empty {
    display: none;
  }

  /* r165: a toast never swallows taps meant for what is under it (drawer items, menus, the last controls of a
     page); only its own ✕ / action buttons take taps. */
  .toast-stack > .toast {
    position: relative;
    inset: auto;
    width: auto;
    max-width: min(480px, calc(100vw - 32px));
    padding: var(--nv-space-2) var(--nv-space-2) var(--nv-space-2) var(--nv-space-3);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
  }

  .toast-stack > .toast :is(.toast-close, .toast-action) {
    pointer-events: auto;
  }

  /* w4: under a modal dialog the toast is inert: a tap on its ✕ / action went to the sheet under it (closed it,
     or pressed «Перейти к оплате»), so they hide until the dialog closes; the toast still leaves on its timer. */
  body:has(dialog:modal) .toast-stack > .toast :is(.toast-close, .toast-action) {
    display: none;
  }

  body.nav-open .toast-stack {
    visibility: hidden;
  }

  .toast-stack > .toast::before {
    display: none;
  }

  .toast-stack > .toast.show {
    opacity: 1;
    transform: none;
  }

  /* The tone shows in the icon itself (meaning, not decoration); no tinted disc behind it. */
  .toast-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 24px;
    height: 24px;
    color: var(--toast-tone, var(--nv-accent));
  }

  .toast-icon .nv-icon {
    width: 18px;
    height: 18px;
  }

  .toast-message {
    flex: 1;
    min-width: 0;
  }

  .toast-action {
    flex: none;
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--nv-r-control);
    background: var(--nv-accent-soft);
    color: var(--nv-accent-text);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
  }

  .toast-action:hover {
    background: var(--nv-accent-soft-2);
    color: var(--nv-accent-text);
  }

  .toast-close {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: var(--nv-r-xs);
    color: var(--nv-text-3);
  }

  .toast-close:hover {
    background: rgb(239 233 227 / 8%);
    color: var(--nv-text);
  }

  .toast-close .nv-icon {
    width: 14px;
    height: 14px;
  }

  /* ---- Dialog footer order: danger far left, secondary, primary last --------- */
  .modal-actions > :is(.secondary, .ghost) {
    order: 1;
  }

  .modal-actions > .primary {
    order: 2;
  }

  .modal-actions > .danger.solid {
    order: 3;
    margin-right: 0;
  }

  dialog .dialog-header {
    margin-bottom: var(--nv-space-5);
  }

  dialog .dialog-close .nv-icon {
    width: 18px;
    height: 18px;
  }

  /* ---- Share dialog (dash-share.js) ------------------------------------------ */
  .share-dialog .dialog-body {
    gap: var(--nv-space-4);
  }

  /* The QR plate on a plain well: no ember wash, no orange shadow. */
  .share-qr-frame {
    display: grid;
    place-items: center;
    padding: var(--nv-space-5);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-lg);
    background: var(--nv-bg-deep);
  }

  .share-qr {
    width: min(240px, 100%);
    padding: 12px;
    border-radius: var(--nv-r-md);
    background: #fff;
  }

  .share-qr svg {
    width: 100%;
    height: auto;
  }

  .share-url .input-prefix .nv-icon {
    width: 16px;
    height: 16px;
  }

  /* w4: clip, not ellipsis: dash-share.js scrolls a narrow field to the slug, and Blink drew the ellipsis
     of the unscrolled line, so only «t…» showed at 320px. */
  .share-url input {
    font-size: var(--nv-fs-13);
    text-overflow: clip;
  }

  .share-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--nv-space-2);
  }

  .share-actions > :is(button, a) {
    --btn-h: var(--nv-h-md);
    --btn-px: 12px;
    font-size: var(--nv-fs-13);
  }

  .share-socials {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--nv-space-2);
  }

  /* r166 (SH1): messenger chips carry their logo. */
  .share-socials > .chip {
    gap: 6px;
  }

  .share-socials > .chip > img {
    flex: none;
    width: 16px;
    height: 16px;
  }

  /* The phone's own share sheet (when there is one) leads, full width. */
  .share-actions > [data-share-native].primary {
    grid-column: 1 / -1;
  }

  .share-logo-toggle {
    min-height: 52px;
  }

  @media (max-width: 640px) {
    .share-actions > [data-share-svg] {
      display: none;
    }

    .share-actions > :is(button, a) {
      --btn-h: var(--nv-hit);
    }

    .share-socials {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .share-socials > .chip {
      justify-content: center;
      min-height: var(--nv-hit);
      padding-inline: 12px;
    }
  }

  /* ---- Icon rail (901–1279px) ------------------------------------------------ */
  @media (min-width: 901px) and (max-width: 1279px) {
    .app-shell {
      --shell-side: var(--nv-rail-w);
    }

    .sidebar {
      align-items: center;
      padding: var(--nv-space-4) var(--nv-space-2) var(--nv-space-3);
      overflow: visible;
    }

    .sidebar-head {
      justify-content: center;
      padding: 0;
    }

    .sidebar-head .nova-brand-name,
    .nav-group-title,
    .upgrade-copy,
    .user-meta,
    .plan-chip,
    .user-caret {
      display: none;
    }

    .nav-item,
    .sidebar-help {
      justify-content: center;
      width: 48px;
      min-height: var(--nv-h-nav);
      padding: 0;
    }

    .app-nav {
      gap: var(--nv-space-2);
      justify-items: center;
    }

    .nav-group + .nav-group {
      padding-top: var(--nv-space-2);
      border-top: 1px solid var(--nv-line-soft);
    }

    /* Labels become tooltips (real text, so i18n still translates them). */
    :is(.nav-item, .sidebar-help) .nav-label {
      position: absolute;
      top: 50%;
      left: calc(100% + 12px);
      z-index: var(--nv-z-tooltip);
      flex: none;
      padding: 6px 10px;
      border: 1px solid var(--nv-line-strong);
      border-radius: var(--nv-r-sm);
      background: var(--nv-surface-4);
      color: var(--nv-text);
      font-size: var(--nv-fs-12);
      font-weight: var(--nv-fw-medium);
      box-shadow: var(--nv-shadow-2);
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transform: translate(-4px, -50%);
      transition: opacity var(--nv-dur-2) var(--nv-ease), transform var(--nv-dur-2) var(--nv-ease), visibility var(--nv-dur-2);
    }

    :is(.nav-item, .sidebar-help) {
      position: relative;
    }

    :is(.nav-item, .sidebar-help):is(:hover, :focus-visible) .nav-label {
      opacity: 1;
      visibility: visible;
      transform: translate(0, -50%);
    }

    .sidebar-foot {
      justify-items: center;
      width: 100%;
    }

    .upgrade-card {
      justify-content: center;
      width: 48px;
      min-height: 48px;
      padding: 0;
    }

    .upgrade-arrow {
      display: none;
    }

    .user-card {
      justify-content: center;
      width: 52px;
      min-height: 52px;
      padding: 0;
    }

    .topbar-preview span {
      display: none;
    }

    .topbar-preview {
      width: 36px;
      padding: 0;
    }
  }

  /* ---- Tablet/phone: drawer + bottom tab bar (≤900px) ------------------------- */
  .app-tabbar {
    display: none;
  }

  @media (max-width: 900px) {
    .app-shell {
      --nv-tabbar-h: calc(64px + env(safe-area-inset-bottom));
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "top" "main";
    }

    .sidebar {
      position: fixed;
      inset: 0 auto 0 0;
      width: min(300px, 86vw);
      height: 100dvh;
      padding-bottom: max(var(--nv-space-3), env(safe-area-inset-bottom));
      box-shadow: var(--nv-shadow-3);
      transform: translateX(-104%);
      visibility: hidden;
      transition: transform var(--nv-dur-3) var(--nv-ease), visibility var(--nv-dur-3);
    }

    .sidebar.open {
      transform: none;
      visibility: visible;
    }

    .sidebar-close {
      display: grid;
    }

    /* The drawer keeps 44px rows for thumbs, so its groups sit closer (12 above a label, 8 under it) and
       the account card still reaches the first screen on a 568px phone as before. */
    .app-nav {
      gap: var(--nv-space-3);
    }

    .nav-item,
    .sidebar-help {
      min-height: var(--nv-hit);
    }

    .app-topbar {
      gap: var(--nv-space-2);
      padding: 0 max(var(--nv-space-3), env(safe-area-inset-right, 0px)) 0 max(var(--nv-space-4), env(safe-area-inset-left, 0px));
    }

    .topbar-brand {
      display: inline-flex;
      --brand-mark: 24px;
    }

    .draft-pill,
    .url-chip,
    .topbar-preview span {
      display: none;
    }

    .topbar-preview {
      width: 40px;
      min-width: 40px;
      padding: 0;
      --btn-h: 40px;
    }

    .topbar-lang {
      height: 40px;
    }

    .topbar-publish {
      --btn-h: 40px;
      --btn-px: 12px;
      min-width: 0;
    }

    .app-shell[data-draft="dirty"] .topbar-publish::after,
    .app-shell[data-draft="new"] .topbar-publish::after {
      content: "";
      position: absolute;
      top: -2px;
      right: -2px;
      width: 10px;
      height: 10px;
      border: 2px solid var(--nv-bg);
      border-radius: 50%;
      background: var(--nv-warning);
    }

    .app-shell .page {
      padding: var(--nv-space-6) max(var(--nv-space-4), env(safe-area-inset-right, 0px)) calc(var(--nv-space-12) + 64px + env(safe-area-inset-bottom) + var(--toast-h, 0px)) max(var(--nv-space-4), env(safe-area-inset-left, 0px));
    }

    .app-tabbar {
      position: fixed;
      inset: auto 0 0;
      z-index: var(--nv-z-header);
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      height: calc(64px + env(safe-area-inset-bottom));
      padding: 0 max(var(--nv-space-1), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--nv-space-1), env(safe-area-inset-left));
      border-top: 1px solid var(--nv-line);
      background: var(--nv-bg);
    }

    .app-tabbar > button {
      position: relative;
      display: grid;
      place-items: center;
      align-content: center;
      gap: 4px;
      min-width: 0;
      min-height: var(--nv-hit);
      color: var(--nv-text-3);
      font-size: var(--nv-fs-11);
      font-weight: var(--nv-fw-medium);
      letter-spacing: 0;
      transition: color var(--nv-dur-1) var(--nv-ease);
    }

    /* r180: a long label (fr «Vue d’ensemble», vi, ja) wraps to a second line instead of ending in «…». */
    .app-tabbar > button span {
      display: -webkit-box;
      max-width: 100%;
      overflow: hidden;
      line-height: 1.1;
      text-align: center;
      text-overflow: ellipsis;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

    .app-tabbar > button .nv-icon {
      width: 22px;
      height: 22px;
    }

    /* The current tab: the selection is the one place the accent ink shows in the bar. No indicator line. */
    .app-tabbar > button.active {
      color: var(--nv-accent-text);
    }

    .toast-stack {
      bottom: calc(76px + env(safe-area-inset-bottom));
    }
  }

  /* ---- Phones: compact (r160) ---------------------------------------------------
     Shorter top bar (token) and tab bar so the bars eat less of the viewport; both stay
     solid (r181), like the desktop bar. */
  @media (max-width: 640px) {
    .app-shell {
      --nv-tabbar-h: calc(56px + env(safe-area-inset-bottom));
    }

    .app-topbar {
      padding: 0 max(var(--nv-space-2), env(safe-area-inset-right, 0px)) 0 max(var(--nv-space-4), env(safe-area-inset-left, 0px));
    }

    .topbar-preview {
      width: 40px;
      min-width: 40px;
    }

    /* w4: --toast-h (account-shell.js: height of the toasts at the bottom, 0 without) lets the last rows scroll above them. */
    .app-shell .page {
      padding: var(--nv-space-4) max(var(--nv-space-4), env(safe-area-inset-right, 0px)) calc(var(--nv-space-8) + 56px + env(safe-area-inset-bottom) + var(--toast-h, 0px)) max(var(--nv-space-4), env(safe-area-inset-left, 0px));
    }

    .app-tabbar {
      height: calc(56px + env(safe-area-inset-bottom));
    }

    .app-tabbar > button {
      gap: 2px;
    }

    .app-tabbar > button .nv-icon {
      width: 20px;
      height: 20px;
    }

    .toast-stack {
      bottom: calc(66px + env(safe-area-inset-bottom));
    }

    /* r166 (G12): every toast has the same width (a short success toast no longer floats narrower than
       an error under it); app.js keeps at most two on a phone. */
    .toast-stack {
      width: calc(100vw - 32px);
    }

    .toast-stack > .toast {
      width: 100%;
    }

    /* The editor adds its own bar (Посмотреть страницу · Опубликовать, ~61px) above the tab bar:
       toasts sit above both so they never cover those buttons (r165). */
    body:has(#studio[data-shell-page="editor"]) .toast-stack {
      bottom: calc(56px + 72px + env(safe-area-inset-bottom));
    }

    .sidebar {
      gap: var(--nv-space-2);
    }

    /* Share sheet: smaller QR on an off-white plate (still high contrast for scanners). */
    .share-qr-frame {
      padding: var(--nv-space-3);
    }

    .share-qr {
      width: min(196px, 100%);
      padding: 8px;
      background: #f2eee9;
    }

    /* r166 (G7): «Опубликовать» shows in the top bar only while a published page has unpublished changes,
       and with its label. A page that was never published starts from «Выбрать адрес» (overview) instead,
       and the editor has its own bar (Посмотреть страницу · Опубликовать) — no duplicates there. */
    #studio:not([data-draft="dirty"]) .topbar-publish,
    #studio[data-shell-page="editor"] :is(.topbar-publish, .topbar-preview) {
      display: none;
    }

    /* r166 (G9): «Ещё» lists what the tab bar does not have — no second Обзор / Аналитика / Редактор /
       Ссылки — so the account card and «Выйти» fit on the first screen of the drawer. */
    .sidebar .nav-item:is([data-page="overview"], [data-page="analytics"], [data-page="editor"], [data-page="links"]) {
      display: none;
    }

    .sidebar .nav-group:not(:has(.nav-item:not([data-page="overview"], [data-page="analytics"], [data-page="editor"], [data-page="links"], [hidden]))) {
      display: none;
    }
  }

  @media (max-width: 420px) {
    .topbar-publish {
      --btn-px: 12px;
      gap: 0;
    }

    .topbar-publish::before {
      display: none;
    }

    .topbar-heading {
      font-size: var(--nv-fs-14);
    }
  }

  /* r180: with «Опубликовать» in the top bar a small phone keeps room for the page title; the language
     stays in the user menu and Settings. */
  @media (max-width: 400px) {
    .app-shell:is([data-draft="dirty"], [data-draft="new"]) .topbar-lang {
      display: none;
    }
  }

  /* r180: phones in landscape: slimmer top and tab bars (icon beside its label), so the fixed bars no
     longer take a third of a 390px-high screen. */
  @media (max-width: 900px) and (max-height: 500px) {
    .app-shell {
      --nv-topbar-h: 48px;
      --nv-tabbar-h: calc(48px + env(safe-area-inset-bottom));
    }

    .app-tabbar {
      height: calc(48px + env(safe-area-inset-bottom));
    }

    /* w4: centred tracks: with justify-content normal the two auto tracks stretched, so each label sat nearer
       the next tab's icon than its own (a long label still shrinks and clamps). */
    .app-tabbar > button {
      grid-auto-flow: column;
      justify-content: center;
      align-items: center;
      gap: 6px;
    }
  }

  /* r181: one rule for page titles on phones (portrait and landscape). The top bar names the page (#pageLabel),
     so every page's own h1 is for screen readers only and its section label goes; the line under the title and
     the page actions stay. (The overview hides its whole header in overview.css.) */
  @media (max-width: 640px), (max-width: 900px) and (max-height: 500px) {
    .app-shell .page :is(.page-header, .admin-header) h1 {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    .app-shell .page :is(.page-header, .admin-header) .eyebrow {
      display: none;
    }
  }

  /* r180: while typing on a short screen (landscape, or a keyboard that shrinks the viewport) the bottom
     bars step aside, so they never cover the focused field. */
  @media (pointer: coarse) and (max-height: 520px) {
    body:has(:is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"]), textarea, [contenteditable="true"]):focus) :is(.app-tabbar, .ed-mobilebar) {
      display: none;
    }
  }

  /* r180: the toast ✕ keeps its 28px look with a 44px touch area. */
  @media (pointer: coarse) {
    .toast-close {
      position: relative;
    }

    .toast-close::after {
      content: "";
      position: absolute;
      inset: -8px;
    }

    .toast-action {
      min-height: var(--nv-h-sm);
    }

    .topbar-brand,
    .sidebar-head .brand {
      position: relative;
    }

    .topbar-brand::after,
    .sidebar-head .brand::after {
      content: "";
      position: absolute;
      inset: -10px;
    }
  }

  /* r180: a short phone (568–640px high) shows its one toast under the top bar: at the bottom it covered the
     fields of a sheet and the editor's working area (app.js keeps one toast there). */
  @media (max-width: 640px) and (max-height: 640px) {
    .toast-stack,
    body:has(#studio[data-shell-page="editor"]) .toast-stack {
      inset: calc(var(--nv-topbar-h) + 8px) auto auto 50%;
    }

    /* w4: over a tall sheet that spot is the sheet's header: the toast leaves the ✕ column (right 56px) free. */
    body:has(dialog:modal) .toast-stack {
      width: calc(100vw - 88px);
      margin-left: -28px;
    }
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--nv-z-sidebar) - 1);
    background: var(--nv-scrim);
  }

  /* Deep link target in the editor (dash-router.js focusField): an accent outline, no halo. */
  .field-spotlight {
    border-radius: var(--nv-r-sm);
    outline: 2px solid var(--nv-accent);
    outline-offset: 4px;
    transition: outline-color var(--nv-dur-4) var(--nv-ease);
  }

  body.is-link-dragging {
    cursor: grabbing;
    user-select: none;
  }
}

/* Opacity only (r165): a transform on .page makes it the containing block of the editor's fixed phone bar, which
   then sat off-screen for the first ~250 ms and swallowed a quick tap on «Опубликовать». */
@keyframes shell-page-in {
  from { opacity: 0; }
}
