/* Responsive browser platform shell.
   Telegram WebApp keeps the approved compact canvas; ordinary browser widths
   gain a persistent rail/sidebar and fluid page lanes. */
.platform-sidebar {
  display: none;
}

.platform-sidebar__badge[hidden] {
  display: none;
}

.platform-sidebar__new-chat-slot,
.platform-sidebar__opened-group,
.platform-sidebar__workspace-group {
  display: none;
}

.new-chat-desktop-stage {
  display: contents;
}

.new-chat-desktop-statusbar {
  display: none;
}

@media (min-width: 768px) {
  body:not(.login-only):not(.tg-webapp) {
    --platform-shell-sidebar-width: var(--nf-platform-rail-width);
    overflow: hidden;
  }

  body:not(.login-only):not(.tg-webapp) .root-shell {
    display: grid;
    grid-template-columns: var(--platform-shell-sidebar-width) minmax(0, 1fr);
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    justify-content: stretch;
    overflow: hidden;
  }

  body:not(.login-only):not(.tg-webapp) .platform-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    width: var(--platform-shell-sidebar-width);
    height: 100dvh;
    min-width: 0;
    flex-direction: column;
    gap: 24px;
    padding: 18px 12px 16px;
    overflow: hidden;
    border-right: 1px solid var(--nf-platform-sidebar-border);
    background: var(--nf-platform-sidebar-background);
  }

  .platform-sidebar__brand,
  .platform-sidebar__link,
  .platform-sidebar__topup,
  .platform-sidebar__account {
    position: relative;
    display: flex;
    min-width: 0;
    align-items: center;
    border: 0;
    color: var(--nf-color-text);
    text-decoration: none;
  }

  .platform-sidebar__brand:visited,
  .platform-sidebar__link:visited,
  .platform-sidebar__topup:visited {
    color: var(--nf-color-text);
  }

  .platform-sidebar__brand {
    min-height: 44px;
    justify-content: center;
    gap: 10px;
    padding: 0 8px;
  }

  .platform-sidebar__brand-mark {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
  }

  .platform-sidebar__brand-name,
  .platform-sidebar__label,
  .platform-sidebar__topup span,
  .platform-sidebar__account-copy,
  .platform-sidebar__account-more {
    display: none;
  }

  .platform-sidebar__nav {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 6px;
  }

  .platform-sidebar__link {
    min-height: 48px;
    justify-content: center;
    gap: 12px;
    padding: 0 12px;
    border-radius: 14px;
    color: var(--nf-color-text-muted);
    font: var(--nf-weight-medium) 14px/20px var(--nf-font-ui);
    transition: color 160ms ease, background-color 160ms ease, transform 120ms ease;
  }

  .platform-sidebar__link:hover,
  .platform-sidebar__link:focus-visible {
    color: var(--nf-color-text);
    background: var(--nf-alpha-white-05);
    outline: none;
  }

  .platform-sidebar__link:active {
    transform: scale(0.98);
  }

  .platform-sidebar__link[aria-current="page"] {
    color: var(--nf-color-text);
    background: var(--nf-alpha-white-10);
    box-shadow: inset 0 0 0 1px var(--nf-alpha-white-07);
  }

  .platform-sidebar__icon {
    display: grid;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    place-items: center;
  }

  .platform-sidebar__icon img,
  .platform-sidebar__topup img {
    display: block;
    width: 22px;
    height: 22px;
    object-fit: contain;
    opacity: 0.88;
  }

  .platform-sidebar__link[data-platform-nav-target="chat"] .platform-sidebar__icon img,
  .platform-sidebar__link[data-platform-nav-target="shop"] .platform-sidebar__icon img,
  .platform-sidebar__topup img {
    filter: brightness(0) invert(1);
  }

  .platform-sidebar__badge {
    position: absolute;
    top: 7px;
    right: 8px;
    display: grid;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    place-items: center;
    border-radius: 999px;
    background: var(--nf-color-purple-500);
    color: #fff;
    font: var(--nf-weight-bold) 10px/1 var(--nf-font-ui);
  }

  .platform-sidebar__footer {
    display: grid;
    gap: 8px;
  }

  .platform-sidebar__topup {
    min-height: 44px;
    justify-content: center;
    gap: 10px;
    padding: 0 12px;
    border-radius: 13px;
    background: rgba(117, 78, 255, 0.16);
    color: #c8b7ff;
    font: var(--nf-weight-bold) 13px/18px var(--nf-font-ui);
  }

  .platform-sidebar__account {
    min-height: 48px;
    justify-content: center;
    gap: 10px;
    padding: 5px;
    border-radius: 14px;
    background: transparent;
    cursor: pointer;
  }

  .platform-sidebar__account:hover,
  .platform-sidebar__account:focus-visible,
  .platform-sidebar__account[aria-expanded="true"] {
    background: var(--nf-alpha-white-05);
    outline: none;
  }

  .platform-sidebar__avatar {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    overflow: hidden;
    place-items: center;
    border: 1px solid var(--nf-alpha-white-07);
    border-radius: 11px;
    background: var(--nf-alpha-white-10);
    color: var(--nf-color-text);
    font: var(--nf-weight-bold) 12px/1 var(--nf-font-ui);
  }

  .platform-sidebar__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  body:not(.login-only):not(.tg-webapp) .page {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 100dvh;
    min-height: 0;
    padding: 0 var(--nf-platform-page-gutter) calc(24px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
  }

  body:not(.login-only):not(.tg-webapp) .page.page-chat-single-scroll {
    overflow: hidden;
  }

  /* Keep populated Chat on the same centered platform canvas as its composer.
     The legacy Chat rule caps this page at 840px and otherwise pins it to the
     left edge of the post-sidebar column. */
  body:not(.login-only):not(.tg-webapp) .page.page-chat-single-scroll:has(#chat.active #chat-main.has-messages) {
    max-width: none;
    justify-self: stretch;
  }

  /* The runtime may report Telegram-capable browser classes at tablet width
     even outside a real WebApp. Real Telegram is identified by `.tg-webapp`;
     ordinary browsers must still receive the platform lane. */
  body:not(.tg-webapp).chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll {
    padding-inline: var(--nf-platform-page-gutter);
  }

  body:not(.login-only):not(.tg-webapp) .section {
    width: min(100%, var(--nf-platform-content-max));
    min-height: 100%;
    margin-inline: auto;
  }

  body:not(.login-only):not(.tg-webapp) .top-bar [data-section-back],
  body:not(.login-only):not(.tg-webapp) .top-bar > .app-menu-launcher,
  body:not(.login-only):not(.tg-webapp) #chat .chat-history-entry,
  body:not(.login-only):not(.tg-webapp) #chat .top-bar > .app-menu-launcher,
  body:not(.login-only):not(.tg-webapp) #chat_history .history-return {
    display: none !important;
  }

  body:not(.login-only):not(.tg-webapp) .app-section-header.top-bar {
    min-height: 72px;
    padding: 18px 0 12px;
  }

  body:not(.login-only):not(.tg-webapp) .app-section-header .title {
    font-size: 20px;
    line-height: 28px;
  }

  body:not(.login-only):not(.tg-webapp) #assets {
    width: min(100%, var(--nf-platform-content-max));
  }

  body:not(.login-only):not(.tg-webapp) .assets-shell,
  body:not(.login-only):not(.tg-webapp) .transactions-shell {
    width: 100%;
    margin-inline: 0;
    padding-inline: 0;
  }

  body:not(.login-only):not(.tg-webapp) .assets-controls-row {
    grid-template-columns: max-content minmax(260px, 1fr) 44px;
    gap: 12px;
    min-height: 44px;
  }

  body:not(.login-only):not(.tg-webapp) .assets-search {
    position: relative;
    inset: auto;
    width: 100%;
    height: 44px;
    min-height: 44px;
    border-radius: 12px;
    box-shadow: none;
    transition: border-color 160ms ease, background-color 160ms ease;
  }

  body:not(.login-only):not(.tg-webapp) .assets-controls-row:has(.assets-search:focus-within) .assets-tabs,
  body:not(.login-only):not(.tg-webapp) .assets-controls-row:has(#assets-search:not(:placeholder-shown)) .assets-tabs,
  body:not(.login-only):not(.tg-webapp) .assets-controls-row:has(.assets-search:focus-within) .assets-view-toggle,
  body:not(.login-only):not(.tg-webapp) .assets-controls-row:has(#assets-search:not(:placeholder-shown)) .assets-view-toggle {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  body:not(.login-only):not(.tg-webapp) .assets-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
  }

  body:not(.login-only):not(.tg-webapp) #transactions {
    width: min(100%, var(--nf-platform-content-max));
  }

  body:not(.login-only):not(.tg-webapp) .transaction-row,
  body:not(.login-only):not(.tg-webapp) .transaction-row-skeleton {
    min-height: 84px;
    padding: 16px 12px;
    border-radius: 12px;
  }

  body:not(.login-only):not(.tg-webapp) .transaction-row:hover {
    background: var(--nf-alpha-white-03);
  }

  body:not(.login-only):not(.tg-webapp) #chat_history {
    --history-content-width: 100%;
    --history-inline-padding: 0px;
    width: min(100%, var(--nf-platform-content-max));
    min-height: 100%;
    margin-inline: auto;
    overflow: visible;
  }

  body:not(.login-only):not(.tg-webapp) #chat_history .history-top-bar {
    min-height: 72px;
    grid-template-columns: minmax(0, 1fr);
    padding: 18px 0 12px;
  }

  body:not(.login-only):not(.tg-webapp) #chat_history .history-top-bar .title {
    font-size: 20px;
    line-height: 28px;
  }

  body:not(.login-only):not(.tg-webapp) .history-shell {
    height: calc(100dvh - 72px);
    padding: 12px 0 96px;
  }

  body:not(.login-only):not(.tg-webapp) #chat.section.active {
    display: flex;
    width: min(100%, var(--nf-platform-chat-max));
    height: 100dvh;
    min-height: 0;
    flex-direction: column;
    margin-inline: auto;
    overflow: visible;
  }

  body:not(.login-only):not(.tg-webapp) #chat .chat-head-wrap,
  body:not(.login-only):not(.tg-webapp):not(.chat-shell-mobile) #chat .chat-head-wrap {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: var(--chat-text-header-height);
    flex: 0 0 auto;
    margin: 0;
    padding-inline: 0;
    transform: none;
  }

  body:not(.tg-webapp).chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat.section.active .chat-head-wrap {
    width: 100% !important;
    max-width: none !important;
    padding-inline: 0;
  }

  body:not(.login-only):not(.tg-webapp) #chat .chat-head-wrap > .top-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  body:not(.login-only):not(.tg-webapp) #chat .chat-title {
    grid-column: 1;
    justify-self: center;
    font-size: 14px;
  }

  body:not(.login-only):not(.tg-webapp) #chat-main,
  body:not(.login-only):not(.tg-webapp).chat-shell-mobile #chat-main,
  body:not(.login-only):not(.tg-webapp).chat-shell-text #chat-main {
    position: relative;
    display: grid;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    grid-template-rows: minmax(0, 1fr) auto;
    padding-top: 0;
    overflow: hidden;
  }

  body:not(.tg-webapp).chat-shell-telegram.chat-shell-mobile.chat-shell-text .page.page-chat-single-scroll #chat-main.chat-body:not(.image-mode) {
    width: 100% !important;
    max-width: none !important;
  }

  body:not(.login-only):not(.tg-webapp) #chat-main.hello-active:not(.image-mode) {
    --new-chat-lane-max: min(var(--nf-platform-composer-max), 100%);
    --new-chat-inline-gutter: 0px;
  }

  body:not(.login-only):not(.tg-webapp) #chat-main.hello-active:not(.image-mode) .new-chat-hero {
    top: clamp(84px, 20dvh, 195px);
  }

  body:not(.login-only):not(.tg-webapp) #chat-main.hello-active:not(.image-mode) .new-chat-bottom-stack {
    bottom: 98px;
    width: min(100%, var(--nf-platform-composer-max));
  }

  body:not(.login-only):not(.tg-webapp):not(.chat-shell-mobile) #chat-main:not(.image-mode) .input-toolbar.chat-composer,
  body:not(.login-only):not(.tg-webapp):not(.chat-shell-mobile) #chat-main:not(.image-mode) .input-toolbar.chat-composer.is-resting,
  body:not(.login-only):not(.tg-webapp):not(.chat-shell-mobile) #chat-main:not(.image-mode) .input-toolbar.chat-composer[data-composer-state="recording"] {
    right: auto;
    left: calc(var(--platform-shell-sidebar-width) + ((100vw - var(--platform-shell-sidebar-width)) / 2));
    width: min(100%, var(--nf-platform-composer-max));
    max-width: var(--nf-platform-composer-max);
  }

  /* The platform composer is the visible surface, not just a wider transparent
     toolbar. Remove the compact 560px surface cap whenever the browser owns the
     760px lane; compact tablet/mobile states keep their authored width. */
  body:not(.login-only):not(.tg-webapp):not(.chat-shell-mobile) #chat-main:not(.image-mode) .input-toolbar.chat-composer > .chat-composer-container {
    width: 100%;
  }

  body:not(.tg-webapp).chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat-main.hello-active:not(.image-mode) .input-toolbar.chat-composer,
  body:not(.tg-webapp).chat-shell-telegram.chat-shell-mobile.chat-shell-text #chat-main.hello-active:not(.image-mode) .input-toolbar.chat-composer.is-resting {
    width: min(100%, var(--nf-platform-composer-max)) !important;
    max-width: var(--nf-platform-composer-max) !important;
  }

  body:not(.login-only):not(.tg-webapp) .input-toolbar.chat-composer::before {
    width: calc(100% + 48px);
  }

  body:not(.login-only):not(.tg-webapp) #chat-main.image-mode {
    display: block;
    overflow-y: auto;
  }

  body:not(.login-only):not(.tg-webapp) .image-generation-surface {
    width: min(100%, var(--nf-platform-chat-max));
    margin-inline: auto;
    padding-inline: 0;
  }

  body:not(.login-only):not(.tg-webapp) .image-generation-submit {
    left: calc(var(--platform-shell-sidebar-width) + ((100vw - var(--platform-shell-sidebar-width)) / 2));
    width: min(calc(100vw - var(--platform-shell-sidebar-width) - 64px), var(--nf-platform-composer-max));
    max-width: var(--nf-platform-composer-max);
  }

  body:not(.login-only):not(.tg-webapp) .model-modal .model-modal-card {
    width: min(280px, calc(100dvw - var(--platform-shell-sidebar-width) - 32px));
    max-height: min(var(--model-picker-max-height, 620px), 80dvh);
  }

  body:not(.login-only):not(.tg-webapp) .app-bottom-sheet:not(.model-modal-card),
  body:not(.login-only):not(.tg-webapp) .history-sheet {
    position: fixed !important;
    top: auto;
    left: calc(var(--platform-shell-sidebar-width) + ((100vw - var(--platform-shell-sidebar-width)) / 2));
    right: auto;
    bottom: 24px;
    width: min(560px, calc(100vw - var(--platform-shell-sidebar-width) - 48px));
    max-width: 560px;
    max-height: min(760px, calc(100dvh - 48px));
    border-radius: 22px;
    transform: translateX(-50%);
  }

  body:not(.login-only):not(.tg-webapp) .app-bottom-sheet.is-closing,
  body:not(.login-only):not(.tg-webapp) .history-sheet.is-closing {
    transform: translate(-50%, 18px);
  }
}

@media (min-width: 1200px) {
  body:not(.login-only):not(.tg-webapp) {
    --platform-shell-sidebar-width: var(--nf-platform-sidebar-width);
  }

  body:not(.login-only):not(.tg-webapp) .platform-sidebar {
    gap: 14px;
    padding: 18px 14px 16px;
  }

  .platform-sidebar__new-chat-slot,
  .platform-sidebar__opened-group,
  .platform-sidebar__workspace-group {
    display: block;
  }

  .platform-sidebar__new-chat-slot {
    min-height: 44px;
  }

  .platform-sidebar__new-chat-slot:empty {
    display: none;
  }

  .platform-sidebar__new-chat-slot .chat-open-add {
    display: flex;
    width: 100%;
    height: 44px;
    min-height: 44px;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 0 14px;
    border: 1px solid var(--nf-alpha-white-07);
    border-radius: 13px;
    background: var(--nf-alpha-white-05);
    color: var(--nf-color-text);
    box-shadow: none;
  }

  .platform-sidebar__new-chat-slot .chat-open-add:hover,
  .platform-sidebar__new-chat-slot .chat-open-add:focus-visible,
  .platform-sidebar__new-chat-slot .chat-open-add[aria-expanded="true"] {
    border-color: var(--nf-alpha-white-10);
    background: var(--nf-alpha-white-10);
    outline: none;
  }

  .platform-sidebar__new-chat-slot .chat-open-add-text {
    display: block;
    color: var(--nf-color-text);
    font: var(--nf-weight-medium) 14px/20px var(--nf-font-ui);
  }

  .platform-sidebar__new-chat-slot .chat-open-add-icon {
    display: grid;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    place-items: center;
  }

  .platform-sidebar__new-chat-slot .chat-open-add-icon img {
    max-width: 16px;
    max-height: 16px;
  }

  .platform-sidebar__brand {
    justify-content: flex-start;
    padding-inline: 12px;
  }

  .platform-sidebar__brand-name,
  .platform-sidebar__label,
  .platform-sidebar__topup span,
  .platform-sidebar__account-copy,
  .platform-sidebar__account-more {
    display: block;
  }

  .platform-sidebar__brand-name {
    font: var(--nf-weight-extrabold) 18px/24px var(--nf-font-ui);
    letter-spacing: -0.02em;
  }

  .platform-sidebar__link,
  .platform-sidebar__topup {
    justify-content: flex-start;
  }

  .platform-sidebar__nav {
    min-height: auto;
    flex: 0 0 auto;
  }

  .platform-sidebar__opened-group {
    display: flex;
    min-height: 0;
    flex: 0 0 auto;
    flex-direction: column;
    padding: 2px 0 0;
    overflow: hidden;
  }

  .platform-sidebar__opened-group[hidden] {
    display: none;
  }

  .platform-sidebar__opened-group.is-open {
    flex: 1 1 auto;
  }

  .platform-sidebar__opened-heading {
    display: flex;
    min-height: 24px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    padding-inline: 8px;
    border: 0;
    background: transparent;
    color: var(--nf-color-text-muted);
    font: var(--nf-weight-medium) 11px/16px var(--nf-font-ui);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .platform-sidebar__opened-heading:hover,
  .platform-sidebar__opened-heading:focus-visible {
    color: var(--nf-color-text);
    outline: none;
  }

  .platform-sidebar__opened-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .platform-sidebar__opened-count {
    color: var(--nf-color-text-muted);
    font-variant-numeric: tabular-nums;
  }

  .platform-sidebar__opened-chevron {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 160ms ease;
  }

  .platform-sidebar__opened-heading[aria-expanded="false"] .platform-sidebar__opened-chevron {
    transform: rotate(-90deg);
  }

  .platform-sidebar__opened-slot {
    min-height: 0;
    flex: 1 1 auto;
    margin-top: 4px;
    overflow: hidden;
  }

  .platform-sidebar__opened-group:not(.is-open) .platform-sidebar__opened-slot {
    display: none;
  }

  .platform-sidebar__opened-slot .chat-opened-stack {
    position: relative;
    inset: auto;
    display: flex;
    width: 100%;
    max-height: var(--chat-opened-safe-max-height, 100%);
    padding: 0 2px 4px 0;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .platform-sidebar__opened-slot .chat-opened-stack:not(.open) {
    display: none;
  }

  .platform-sidebar__opened-slot .chat-opened-item {
    height: 42px;
    min-height: 42px;
    padding: 7px 8px;
    border-radius: 11px;
  }

  .platform-sidebar__opened-slot .chat-opened-title {
    font-size: 12px;
    line-height: 16px;
  }

  .platform-sidebar__link[aria-current="page"]::before {
    position: absolute;
    left: 0;
    width: 3px;
    height: 20px;
    border-radius: 999px;
    background: #9c80ff;
    content: "";
  }

  .platform-sidebar__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .platform-sidebar__badge {
    position: static;
    margin-left: auto;
  }

  .platform-sidebar__account {
    justify-content: flex-start;
    padding: 6px 8px;
  }

  .platform-sidebar__account-copy {
    min-width: 0;
    flex: 1;
    text-align: left;
  }

  .platform-sidebar__account-name,
  .platform-sidebar__account-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .platform-sidebar__account-name {
    color: var(--nf-color-text);
    font: var(--nf-weight-medium) 13px/18px var(--nf-font-ui);
  }

  .platform-sidebar__account-meta {
    color: var(--nf-color-text-muted);
    font: var(--nf-weight-regular) 11px/15px var(--nf-font-ui);
  }

  .platform-sidebar__account-more {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    place-items: center;
    color: var(--nf-color-text-muted);
  }

  .platform-sidebar__account-more-icon {
    display: block;
    width: 4px;
    height: 16px;
    opacity: 0.72;
    transform: rotate(90deg);
  }

  .platform-sidebar__footer {
    margin-top: auto;
  }

  .platform-sidebar__workspace-group {
    min-height: 0;
    flex: 0 0 auto;
    padding: 10px 8px 0;
    overflow: visible;
  }

  .platform-sidebar__workspace-group[hidden] {
    display: none;
  }

  .platform-sidebar__workspace-heading {
    display: flex;
    min-height: 24px;
    align-items: center;
    justify-content: space-between;
    padding-inline: 6px;
    color: var(--nf-color-text-muted);
    font: var(--nf-weight-medium) 11px/16px var(--nf-font-ui);
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .platform-sidebar__workspace-count {
    color: var(--nf-color-text-muted);
    font-variant-numeric: tabular-nums;
  }

  .platform-sidebar__workspace-slot {
    position: relative;
    margin-top: 4px;
  }

  .platform-sidebar__workspace-slot .chat-workspace-status {
    position: relative;
    z-index: 16;
    display: block;
    width: 100%;
    height: auto;
    min-height: 44px;
    margin: 0;
    padding: 0;
  }

  .platform-sidebar__workspace-slot .chat-workspace-status[hidden] {
    display: none;
  }

  .platform-sidebar__workspace-slot .chat-workspace-status__trigger {
    width: 100%;
    max-width: none;
    height: 44px;
    justify-content: space-between;
    gap: 8px;
    padding: 0 8px;
    border-radius: 11px;
    color: var(--nf-color-text);
  }

  .platform-sidebar__workspace-slot .chat-workspace-status__trigger:hover,
  .platform-sidebar__workspace-slot .chat-workspace-status__trigger:focus-visible,
  .platform-sidebar__workspace-slot .chat-workspace-status__trigger[aria-expanded="true"] {
    background: var(--nf-alpha-white-05);
    outline: none;
  }

  .platform-sidebar__workspace-slot .chat-workspace-status__title {
    max-width: 136px;
    font: var(--nf-weight-medium) 13px/18px var(--nf-font-ui);
  }

  .platform-sidebar__workspace-slot .chat-workspace-status__label {
    display: none;
  }

  .platform-sidebar__workspace-slot .chat-workspace-menu {
    top: 48px;
    right: 0;
    left: 0;
    width: 100%;
    min-width: 0;
  }

  body.platform-desktop-shell #chat {
    --chat-text-header-base-height: 64px;
    --chat-project-header-height: 64px;
  }

  body.platform-desktop-shell:has(#chat.active) #chat.has-active-workspace {
    --chat-text-header-base-height: 64px;
  }

  body.platform-desktop-shell #chat .chat-head-wrap > .top-bar {
    min-height: 64px;
    padding: 10px 0;
  }

  body.platform-desktop-empty-chat #chat .chat-head-wrap,
  body.platform-desktop-empty-chat #chat .chat-head-wrap > .top-bar {
    height: 0 !important;
    min-height: 0 !important;
    flex-basis: 0 !important;
    padding-block: 0 !important;
  }

  body.platform-desktop-active-chat #chat .chat-head-wrap,
  body.platform-desktop-active-chat #chat .chat-head-wrap > .top-bar {
    height: 0 !important;
    min-height: 0 !important;
    flex-basis: 0 !important;
    padding-block: 0 !important;
  }

  body.platform-desktop-active-chat {
    --chat-composer-bottom-offset: 52px;
  }

  /* Active desktop Chat is one centered canvas inside the space that remains
     after the sidebar. The legacy populated-chat rule caps `.page` at 840px;
     overriding that cap here prevents the thread from anchoring left while the
     fixed composer centers against the full platform area. */
  body.platform-desktop-active-chat:not(.login-only):not(.tg-webapp) .page.page-chat-single-scroll:has(#chat.active #chat-main.has-messages) {
    width: 100%;
    max-width: none;
    justify-self: stretch;
    padding-inline: var(--nf-platform-page-gutter);
    padding-bottom: 0;
  }

  body.platform-desktop-active-chat:not(.login-only):not(.tg-webapp) #chat.section.active {
    width: min(100%, var(--nf-platform-chat-max));
    max-width: var(--nf-platform-chat-max);
    margin-inline: auto;
  }

  body.platform-desktop-active-chat #chat-main:not(.image-mode) .messages-container {
    box-sizing: border-box;
    padding: 24px 40px calc(
      var(--chat-composer-height, 56px)
      + var(--chat-composer-bottom-offset, 52px)
      + 24px
    );
    scroll-padding: 24px 0 calc(
      var(--chat-composer-height, 56px)
      + var(--chat-composer-bottom-offset, 52px)
      + 24px
    );
  }

  body.platform-desktop-empty-chat .page.page-chat-single-scroll {
    padding-bottom: 0;
  }

  body.platform-desktop-shell:not(.login-only):not(.tg-webapp) #chat .chat-title {
    justify-self: start;
  }

  body.platform-desktop-shell #chat .chat-hero {
    height: 0;
    margin: 0;
  }

  body.platform-desktop-shell #chat .chat-open-bar {
    display: none;
  }

  body.platform-desktop-shell:not(.login-only):not(.tg-webapp) .model-modal .model-modal-card {
    width: min(344px, calc(100dvw - var(--platform-shell-sidebar-width) - 32px));
  }

  /* Empty desktop Chat is one composition. The real hero, shortcut stack and
     composer are relocated here; no duplicate input or chat state is created. */
  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    box-sizing: border-box;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 0;
    pointer-events: none;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .new-chat-hero {
    position: relative;
    top: auto;
    left: auto;
    flex: 0 0 auto;
    margin: 0 0 48px;
    opacity: 1;
    transform: none;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .new-chat-bottom-stack {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    width: min(100%, var(--nf-platform-composer-max));
    flex: 0 0 auto;
    margin: 0 0 20px;
    transform: none;
    pointer-events: auto;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .new-chat-bottom-stack:has(.new-chat-resume[hidden]) {
    margin-bottom: 0;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .input-toolbar.chat-composer,
  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .input-toolbar.chat-composer.is-resting,
  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .input-toolbar.chat-composer[data-composer-state="recording"] {
    position: relative !important;
    inset: auto !important;
    width: min(100%, var(--nf-platform-composer-max));
    max-width: var(--nf-platform-composer-max);
    flex: 0 0 auto;
    margin: 0;
    transform: none !important;
    pointer-events: auto;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-stage > .new-chat-desktop-statusbar {
    display: grid;
    width: min(100%, var(--nf-platform-composer-max));
    min-height: 30px;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    pointer-events: auto;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-shortcuts-slot {
    min-width: 0;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-shortcuts-slot > .new-chat-shortcuts {
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-shortcuts-slot .new-chat-section-label {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-shortcuts-slot .new-chat-shortcuts__list {
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: row;
    gap: 6px;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-shortcuts-slot .new-chat-shortcut {
    width: auto;
    height: 30px;
    min-height: 30px;
    flex: 0 1 auto;
    justify-content: center;
    gap: 0;
    padding: 0 10px;
    border-radius: 9px;
    font: var(--nf-weight-regular) 12px/16px var(--nf-font-ui);
    white-space: nowrap;
  }

  body.platform-desktop-shell #chat-main.hello-active:not(.image-mode) .new-chat-desktop-shortcuts-slot .new-chat-shortcut img {
    display: none;
  }

  body.platform-desktop-text-chat #chat-main:not(.image-mode) .new-chat-desktop-model-slot {
    display: flex;
    justify-content: flex-end;
  }

  body.platform-desktop-text-chat #chat-main:not(.image-mode) .new-chat-desktop-model-slot > .chat-title {
    position: relative;
    width: auto;
    height: 30px;
    min-height: 30px;
    justify-self: auto;
    padding: 0 10px;
    border-radius: 10px;
    font: var(--nf-weight-medium) 12px/16px var(--nf-font-ui);
  }

  /* Active Chat uses one dock owner. Keeping composer and status as relative
     children prevents their widths and center calculations from drifting. */
  body.platform-desktop-active-chat #chat-main:not(.image-mode) .new-chat-desktop-stage {
    position: fixed;
    right: auto;
    bottom: 12px;
    left: calc(var(--platform-shell-sidebar-width) + ((100vw - var(--platform-shell-sidebar-width)) / 2));
    z-index: 10;
    display: flex;
    width: min(calc(100vw - var(--platform-shell-sidebar-width) - 64px), var(--nf-platform-composer-max));
    max-width: var(--nf-platform-composer-max);
    flex-direction: column;
    gap: 10px;
    transform: translateX(-50%);
    pointer-events: none;
  }

  body.platform-desktop-active-chat #chat-main:not(.image-mode) .new-chat-desktop-stage > .input-toolbar.chat-composer,
  body.platform-desktop-active-chat #chat-main:not(.image-mode) .new-chat-desktop-stage > .input-toolbar.chat-composer.is-resting,
  body.platform-desktop-active-chat #chat-main:not(.image-mode) .new-chat-desktop-stage > .input-toolbar.chat-composer[data-composer-state="recording"] {
    position: relative !important;
    inset: auto !important;
    width: 100%;
    max-width: var(--nf-platform-composer-max);
    flex: 0 0 auto;
    transform: none !important;
    pointer-events: auto;
  }

  body.platform-desktop-active-chat #chat-main:not(.image-mode) .new-chat-desktop-stage > .new-chat-desktop-statusbar {
    position: relative;
    inset: auto;
    display: grid;
    width: 100%;
    max-width: var(--nf-platform-composer-max);
    min-height: 30px;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    transform: none;
    pointer-events: auto;
  }

  body.platform-desktop-active-chat #chat-main:not(.image-mode) .new-chat-desktop-shortcuts-slot {
    display: none;
  }

  body.platform-desktop-shell #chat-main:not(.hello-active) .new-chat-desktop-stage > .new-chat-hero,
  body.platform-desktop-shell #chat-main:not(.hello-active) .new-chat-desktop-stage > .new-chat-bottom-stack,
  body.platform-desktop-shell #chat-main.image-mode .new-chat-desktop-stage > .new-chat-hero,
  body.platform-desktop-shell #chat-main.image-mode .new-chat-desktop-stage > .new-chat-bottom-stack {
    display: none;
  }

  body.platform-desktop-shell #chat-main.image-mode .new-chat-desktop-stage > .new-chat-desktop-statusbar {
    display: none;
  }

  body.platform-desktop-shell #chat_history #start-chat-btn {
    display: none !important;
  }

  body.platform-desktop-shell #chat_history .history-shell {
    padding-bottom: 24px;
  }

  /* Desktop uses a focused dialog; the Figma bottom sheet remains untouched
     below this breakpoint for tablet, phone and Telegram WebView. */
  body.platform-desktop-shell #chat-opened-add-modal {
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 48px 48px 48px calc(var(--platform-shell-sidebar-width) + 48px);
    background: rgba(8, 10, 16, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  body.platform-desktop-shell #chat-opened-add-modal.open {
    background: rgba(8, 10, 16, 0.62);
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-card {
    position: relative !important;
    inset: auto !important;
    width: min(640px, 100%);
    height: min(560px, calc(100dvh - 96px));
    max-width: 640px;
    max-height: calc(100dvh - 96px);
    padding: 28px;
    gap: 20px;
    border: 1px solid var(--nf-alpha-white-10);
    border-radius: 20px;
    background: #181b24;
    box-shadow: 0 28px 72px rgba(0, 0, 0, 0.42), inset 0 1px 0 var(--nf-alpha-white-05);
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    transform-origin: center;
  }

  body.platform-desktop-shell #chat-opened-add-modal.open.is-positioned .chat-opened-add-card {
    opacity: 1;
    transform: none;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-handle {
    display: none;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-close {
    top: 24px;
    right: 24px;
    display: grid;
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-step-viewport,
  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-step--history {
    height: 100%;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-step--history {
    gap: 20px;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-header {
    padding-right: 48px;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-title {
    font: var(--nf-weight-extrabold) 20px/26px var(--nf-font-ui);
    letter-spacing: -0.02em;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-search {
    width: 100%;
    height: 44px;
    flex-basis: 44px;
    padding: 0 14px;
    border-color: var(--nf-alpha-white-10);
    background: var(--nf-alpha-white-03);
    box-shadow: none;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-list {
    margin-inline: 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--nf-alpha-white-07);
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-group__label,
  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-group__rows {
    padding-inline: 0;
  }

  body.platform-desktop-shell #chat-opened-add-modal .chat-opened-add-empty {
    display: grid;
    min-height: 100%;
    place-items: center;
    padding: 0;
    color: var(--nf-color-text-muted);
    font: var(--nf-weight-regular) 14px/20px var(--nf-font-ui);
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  body:not(.login-only):not(.tg-webapp) .platform-sidebar {
    overflow: visible;
  }

  .platform-sidebar__link::after,
  .platform-sidebar__topup::after {
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    z-index: 60;
    padding: 7px 10px;
    border: 1px solid var(--nf-alpha-white-07);
    border-radius: 9px;
    background: rgba(28, 31, 42, 0.98);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
    color: var(--nf-color-text);
    content: attr(data-platform-label);
    font: var(--nf-weight-medium) 12px/16px var(--nf-font-ui);
    opacity: 0;
    pointer-events: none;
    transform: translate(-4px, -50%);
    transition: opacity 120ms ease, transform 120ms ease;
    white-space: nowrap;
  }

  .platform-sidebar__link:hover::after,
  .platform-sidebar__link:focus-visible::after,
  .platform-sidebar__topup:hover::after,
  .platform-sidebar__topup:focus-visible::after {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .platform-sidebar__link,
  .platform-sidebar__account,
  .platform-sidebar__topup {
    transition-duration: 1ms;
  }
}
