/* Opt-in layout. No overrides to the standard layout or the mobile workspace. */
#compact-rail, .compact-only { display: none; }
.theme-selector.layout-selector { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 821px) {
  html[data-layout="compact"] { --compact-rail-width: 64px; }
  html[data-layout="compact"].compact-menu-expanded { --compact-rail-width: 224px; }
  html[data-layout="compact"] body:has(#workspace:not(.hidden)) #compact-rail {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--compact-rail-width);
    display: flex; flex-direction: column; gap: 12px; padding: 10px 7px;
    background: var(--sidebar); border-right: 1px solid var(--line);
  }
  html[data-layout="compact"] #compact-rail > img { width: 48px; height: 40px; object-fit: cover; border-radius: 8px; }
  html[data-layout="compact"] #compact-rail .primary-nav {
    display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 7px;
    width: 100%; margin: 0; padding: 2px 0; border: 0; overflow: auto; background: transparent;
  }
  html[data-layout="compact"] #compact-rail button {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 44px; width: 46px; min-width: 0; height: 44px; min-height: 44px;
    margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px;
    background: transparent; color: var(--text); font-size: 22px; cursor: pointer;
  }
  html[data-layout="compact"] #compact-rail button.active {
    background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  }
  html[data-layout="compact"] #compact-rail button:hover { box-shadow: inset 0 0 0 1px var(--accent); }
  html[data-layout="compact"] #compact-rail .nav-label { display: none; }
  html[data-layout="compact"] #compact-rail .primary-nav .section-icon { display: inline-flex; }
  html[data-layout="compact"] #compact-rail svg { width: 21px; height: 21px; }
  html[data-layout="compact"] #compact-rail .nav-count { position: absolute; top: -2px; right: -1px; margin: 0; min-width: 17px; height: 17px; font-size: 10px; }
  html[data-layout="compact"] .compact-rail-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
  html[data-layout="compact"] #workspace { margin-left: var(--compact-rail-width); width: calc(100% - var(--compact-rail-width)); }
  html[data-layout="compact"].compact-menu-expanded #compact-rail button {
    width: 100%; justify-content: flex-start; gap: 10px; padding: 0 12px;
    font-size: 13px; text-align: left; white-space: nowrap;
  }
  html[data-layout="compact"].compact-menu-expanded #compact-rail .nav-label {
    display: inline; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  }
  html[data-layout="compact"] #compact-rail :is(svg, .section-icon, .notification-glyph, .compact-action-icon) { flex-shrink: 0; }
  html[data-layout="compact"] #compact-rail .compact-action-icon { width: 21px; text-align: center; font-size: 22px; }
  html[data-layout="compact"].compact-menu-expanded #compact-menu-toggle svg { transform: rotate(180deg); }
  html[data-layout="compact"] #compact-rail button:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
  html[data-layout="compact"] #workspace [data-main-nav],
  html[data-layout="compact"] #workspace .section-header-actions { display: none !important; }
  html[data-layout="compact"] #workspace .section-brand-row {
    display: flex; min-height: 38px; margin: 0; padding: 0;
  }
  html[data-layout="compact"] #workspace .section-brand-row :is(.brand-logo, .eyebrow) { display: none; }
  html[data-layout="compact"] #workspace .section-brand-row h1 { font-size: 20px; }
  html[data-layout="compact"] #workspace[data-view="dialogs"] { grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  html[data-layout="compact"] #workspace[data-view="dialogs"] .dialogs-header { display: none; }
  html[data-layout="compact"] #workspace[data-view="dialogs"] :is(#sidebar, #chat-panel) { grid-row: 1; }
  html[data-layout="compact"] #workspace[data-view="dialogs"].compact-focus { grid-template-columns: minmax(0, 1fr); }
  html[data-layout="compact"] #workspace[data-view="dialogs"].compact-focus #sidebar { display: none; }
  html[data-layout="compact"] #workspace[data-view="dialogs"].compact-focus #chat-panel { grid-column: 1; }
  html[data-layout="compact"] #chat-content { display: flex; flex-direction: column; }
  html[data-layout="compact"] #chat-content > :not(#messages) { flex-shrink: 0; }
  html[data-layout="compact"] #messages { flex: 1 1 0; min-height: 0; padding: 18px 22px; }
  html[data-layout="compact"] #chat-content .compact-only { display: inline-flex; align-items: center; justify-content: center; }
  html[data-layout="compact"] #chat-content .chat-header { padding: 10px 12px; gap: 7px; flex-wrap: wrap; }
  html[data-layout="compact"] #active-avatar { width: 38px; height: 38px; flex: 0 0 38px; }
  html[data-layout="compact"] #chat-content .client-heading { flex: 1 1 185px; }
  html[data-layout="compact"] #chat-content .client-subline { flex-wrap: wrap; gap: 4px 7px; margin-top: 3px; }
  html[data-layout="compact"] #active-city { font-size: 11px; margin: 2px 0; }
  html[data-layout="compact"] #chat-content .chat-header button {
    width: auto; min-width: 34px; min-height: 34px; height: auto; margin: 0; padding: 7px 9px;
    font-size: 12px; border-radius: 9px; flex-shrink: 0;
  }
  html[data-layout="compact"] #chat-content .chat-header .presence-button { min-height: 0; padding: 0; font-size: 10px; }
  html[data-layout="compact"] #chat-content .chat-header .icon-button { width: 34px; height: 34px; padding: 0; font-size: 20px; }
  html[data-layout="compact"] #chat-content:has(#session-summary-block.hidden) #compact-sessions,
  html[data-layout="compact"] #chat-content:has(#booking-button.hidden) #compact-book { display: none; }
  html[data-layout="compact"] #session-bar { padding: 8px 12px; }
  html[data-layout="compact"] #session-bar #booking-button { display: none; }
  html[data-layout="compact"] #session-bar #message-search-toggle { display: none; }
  html[data-layout="compact"] #chat-content:not(.compact-sessions-open) #session-bar { display: none; }
  html[data-layout="compact"] #chat-content:not(.compact-search-open) #message-history-tools { display: none; }
  html[data-layout="compact"] #chat-content:not(.compact-search-open) #message-history-tools:has(#message-older-button:not(.hidden), #message-latest-button:not(.hidden)) { display: flex; }
  html[data-layout="compact"] #chat-content:not(.compact-search-open) #message-history-tools :is(.message-search-box, .message-date-field, #message-date-go) { display: none; }
  html[data-layout="compact"] #message-history-tools { padding: 7px 12px; }
  html[data-layout="compact"] #composer-form { padding: 10px 12px 6px; gap: 7px; }
  html[data-layout="compact"] #composer-form :is(.composer-left-actions, .composer-actions) { display: flex; align-items: center; gap: 5px; align-self: end; }
  html[data-layout="compact"] #composer-form :is(.composer-left-actions, .composer-actions) button { width: 36px; height: 40px; min-height: 40px; margin: 0; padding: 0; border-radius: 9px; font-size: 20px; }
  html[data-layout="compact"] #composer-form .composer-field { min-height: 42px; padding: 7px 10px; margin: 0; }
  html[data-layout="compact"] #composer-label { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  html[data-layout="compact"] #reply-input { min-height: 24px; max-height: 120px; padding: 0; font-size: 14px; line-height: 24px; }
  html[data-layout="compact"] #composer-note { margin: 0; font-size: 10px; line-height: 14px; }
  html[data-layout="compact"] #sidebar .sidebar-toolbar { padding: 12px 10px; gap: 8px; }
  html[data-layout="compact"] #sidebar .conversation-filter { min-height: 30px; padding: 5px 8px; font-size: 11px; }
  html[data-layout="compact"] #sidebar .conversation { padding: 10px; }
  html[data-layout="compact"] #sidebar .conversation .avatar { width: 38px; height: 38px; flex-basis: 38px; }
  html[data-layout="compact"] #sidebar .conversation strong { font-size: 13px; }
  html[data-layout="compact"] #sidebar .conversation-preview { font-size: 12px; }
}

@media (min-width: 821px) and (max-width: 1100px) {
  html[data-layout="compact"] #workspace[data-view="dialogs"] { grid-template-columns: 240px minmax(0, 1fr); }
  html[data-layout="compact"] #workspace[data-view="dialogs"].compact-focus { grid-template-columns: minmax(0, 1fr); }
}
