/* Runa desktop workspace — rail, drawers and docked context panels. */
@media (min-width: 769px) {
  #app { padding: 0; background: #edf1f4; }

  .desktop-rail {
    position: relative;
    z-index: 430;
    width: 76px;
    flex: 0 0 76px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    color: #c9d6e3;
    background: #24384b;
    border-right: 1px solid rgba(255,255,255,.06);
  }

  .desktop-rail-brand {
    width: 48px;
    height: 48px;
    margin: 10px auto 7px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(255,255,255,.08);
  }
  .desktop-rail-brand:hover { background: rgba(255,255,255,.15); }
  .desktop-rail-brand img { width: 30px; height: 30px; }
  .desktop-rail-nav { min-height: 0; flex: 1; overflow: hidden auto; scrollbar-width: none; }
  .desktop-rail-nav::-webkit-scrollbar { display: none; }
  .desktop-rail-bottom { flex: 0 0 auto; padding-bottom: 8px; border-top: 1px solid rgba(255,255,255,.08); }
  .native-update-button {
    position: fixed;
    z-index: 390;
    left: 88px;
    bottom: 14px;
    min-height: 38px;
    padding: 8px 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    background: #f58220;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(72,42,18,.24);
    font-size: 12px;
    font-weight: 650;
  }
  .native-update-button:hover { background: #e87312; }
  .native-update-button:disabled { cursor: wait; opacity: .92; }
  .native-update-button .runa-icon { width: 17px; height: 17px; }
  .native-update-button.is-busy .runa-icon { animation: nativeUpdateSpin .8s linear infinite; }
  @keyframes nativeUpdateSpin { to { transform: rotate(360deg); } }
  .desktop-rail-folders:empty { display: none; }

  .desktop-rail-item {
    position: relative;
    width: 100%;
    min-height: 66px;
    padding: 8px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #9fb1c2;
    background: transparent;
    border-left: 3px solid transparent;
    font-size: 10px;
    line-height: 1.1;
  }
  .desktop-rail-item:hover { color: #fff; background: rgba(255,255,255,.07); }
  .desktop-rail-item.active { color: #fff; border-left-color: #f58220; background: rgba(245,130,32,.14); }
  .desktop-rail-item .runa-icon { width: 23px; height: 23px; }
  .desktop-rail-item span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
  .desktop-rail-item b {
    position: absolute;
    top: 6px;
    right: 7px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #fff;
    background: #f58220;
    border: 2px solid #24384b;
    font-size: 9px;
  }

  .sidebar {
    width: clamp(340px, 27vw, 500px);
    flex-basis: clamp(340px, 27vw, 500px);
    border-radius: 0;
    border-right: 1px solid #dfe5eb;
    box-shadow: none;
  }
  #app.desktop-drawer-open .sidebar { position: relative; z-index: 421; overflow: visible; }
  .sidebar-toolbar { min-height: 62px; padding: 10px 12px; border-bottom: 1px solid #edf0f3; }
  .sidebar-menu-button { display: none; }
  .sidebar > .filter-tabs { display: none; }
  .chat-list { padding: 4px 7px 82px; }
  .chat-item { border-radius: 8px; }
  .chat-item.active { color: #fff; background: #f58220; }
  .chat-item.active .chat-item-name,
  .chat-item.active .chat-item-time,
  .chat-item.active .chat-item-preview,
  .chat-item.active .chat-state-icon { color: #fff; }
  .chat-item.active .badge { color: #f58220; background: #fff; }
  .chat-item.active .chat-row-menu { color: #fff; }

  .chat-area { min-width: 0; border-left: 0; transition: margin-right .2s ease; }
  .chat-area > .header { height: 62px; }
  .messages { padding-inline: clamp(20px, 5vw, 92px); }

  .desktop-drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 400;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(15,23,42,.48);
    backdrop-filter: blur(1px);
  }
  .sidebar-popover {
    position: fixed;
    inset: 0 auto 0 76px;
    z-index: 420;
    width: clamp(340px, 27vw, 500px);
    min-width: 340px;
    padding: 12px 10px;
    border: 0;
    border-radius: 0;
    overflow-y: auto;
    background: #fff;
    box-shadow: 20px 0 60px rgba(15,23,42,.22);
    animation: desktopDrawerIn .18s ease-out;
  }
  @keyframes desktopDrawerIn { from { transform: translateX(-24px); opacity: .5; } to { transform: none; opacity: 1; } }
  .sidebar-menu-profile { display: flex; align-items: center; gap: 12px; padding: 12px 10px 18px; border-bottom: 1px solid #e8edf2; }
  .sidebar-menu-profile .avatar { width: 52px; height: 52px; }
  .sidebar-menu-profile > div { min-width: 0; display: grid; gap: 2px; }
  .sidebar-menu-profile strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #152033; }
  .sidebar-menu-profile span { color: #8090a2; font-size: 12px; }
  .sidebar-popover button { min-height: 46px; border-radius: 9px; }

  .desktop-settings-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    background: rgba(15,23,42,.54);
    backdrop-filter: blur(2px);
    animation: fadeIn .16s ease-out;
  }
  .desktop-settings-panel {
    width: min(470px, calc(100vw - 40px));
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: #f7f9fb;
    box-shadow: 0 26px 80px rgba(15,23,42,.28);
  }
  .desktop-settings-panel > header {
    min-height: 66px;
    padding: 10px 14px 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8ef;
    background: #fff;
  }
  .desktop-settings-panel > header > div { display: grid; }
  .desktop-settings-panel > header > div { flex: 1; text-align: center; }
  .desktop-settings-panel > header strong { font-size: 18px; }
  .desktop-settings-panel > header span { color: #8795a6; font-size: 11px; }
  .desktop-settings-scroll { min-height: 0; overflow-y: auto; }
  .desktop-settings-scroll .settings { overflow: visible; padding: 16px; }
  .desktop-settings-scroll .settings-card { background: #fff; }
  .desktop-settings-header-spacer,
  .desktop-settings-panel > header > .btn-icon { width: 40px; flex: 0 0 40px; }

  .desktop-settings-home { padding: 14px; display: grid; gap: 12px; }
  .desktop-account-summary {
    width: 100%;
    min-height: 92px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #e1e7ed;
    border-radius: 14px;
    color: #172234;
    background: #fff;
    text-align: left;
  }
  .desktop-account-summary:hover { border-color: #f5b276; background: #fffaf6; }
  .desktop-account-summary .avatar { width: 62px; height: 62px; flex: 0 0 62px; }
  .desktop-account-summary > span { min-width: 0; flex: 1; display: grid; gap: 4px; }
  .desktop-account-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
  .desktop-account-summary small { color: #7c8998; font-size: 13px; }
  .desktop-account-summary > .runa-icon { color: #8794a3; }

  .desktop-settings-group { overflow: hidden; border: 1px solid #e1e7ed; border-radius: 14px; background: #fff; }
  .desktop-settings-group > button,
  .desktop-settings-group > a {
    width: 100%;
    min-height: 58px;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 13px;
    color: #1a2637;
    background: #fff;
    text-align: left;
    text-decoration: none;
    border-bottom: 1px solid #edf0f3;
  }
  .desktop-settings-group > :last-child { border-bottom: 0; }
  .desktop-settings-group > button:hover,
  .desktop-settings-group > a:hover { background: #f6f8fa; }
  .desktop-settings-group > button > .runa-icon:first-child,
  .desktop-settings-group > a > .runa-icon:first-child { width: 22px; height: 22px; color: #f58220; }
  .desktop-settings-group > button > .runa-icon:last-child,
  .desktop-settings-group > a > .runa-icon:last-child { width: 17px; height: 17px; color: #a0aab6; }
  .desktop-settings-group span { min-width: 0; flex: 1; display: grid; gap: 2px; font-weight: 600; }
  .desktop-settings-group small { color: #8995a4; font-size: 11px; font-weight: 400; }
  .desktop-settings-group .desktop-settings-danger { color: #dc3c3c; }
  .desktop-settings-group .desktop-settings-danger > .runa-icon { color: #dc3c3c; }
  .desktop-settings-version { padding: 2px 0 6px; color: #929daa; font-size: 11px; text-align: center; }

  .desktop-profile-editor { padding-bottom: 18px; }
  .desktop-profile-hero {
    position: relative;
    min-height: 205px;
    padding: 28px 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e7ebef;
  }
  .desktop-profile-hero > strong { margin-top: 11px; color: #172234; font-size: 18px; }
  .desktop-profile-hero > span { margin-top: 3px; color: #1494dc; font-size: 13px; }
  .desktop-profile-avatar { position: relative; }
  .desktop-profile-avatar .avatar { width: 92px; height: 92px; font-size: 28px; }
  .desktop-profile-avatar > button {
    position: absolute;
    right: -4px;
    bottom: -2px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 3px solid #fff;
    border-radius: 50%;
    color: #fff;
    background: #f58220;
    box-shadow: 0 5px 15px rgba(245,130,32,.28);
  }
  .desktop-profile-avatar > button .runa-icon { width: 17px; height: 17px; }
  .desktop-avatar-menu {
    position: absolute;
    z-index: 4;
    top: 112px;
    left: calc(50% + 40px);
    width: 225px;
    padding: 6px;
    border: 1px solid #dfe5eb;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(15,23,42,.22);
  }
  .desktop-avatar-menu > button { width: 100%; min-height: 39px; padding: 8px 10px; display: flex; align-items: center; gap: 10px; border-radius: 8px; color: #182435; text-align: left; }
  .desktop-avatar-menu > button:hover { background: #f3f6f8; }
  .desktop-avatar-menu > button .runa-icon { width: 19px; height: 19px; color: #f58220; }
  .desktop-avatar-emoji { padding: 7px; display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; border-top: 1px solid #edf0f3; }
  .desktop-avatar-emoji button { width: 42px; height: 38px; border-radius: 8px; font-size: 23px; }
  .desktop-avatar-emoji button:hover { background: #eef2f5; }
  .desktop-profile-form { margin: 14px; padding: 16px; display: grid; gap: 13px; border: 1px solid #e1e7ed; border-radius: 14px; background: #fff; }
  .desktop-profile-form label { display: grid; gap: 6px; }
  .desktop-profile-form label > span { color: #e86f0b; font-size: 11px; font-weight: 700; text-transform: uppercase; }
  .desktop-profile-form .input { padding-left: 14px; background: #f0f3f6; }
  .desktop-profile-form textarea.input { min-height: 86px; padding-top: 12px; resize: vertical; }
  .desktop-profile-facts { margin: 0 14px; overflow: hidden; border: 1px solid #e1e7ed; border-radius: 14px; background: #fff; }
  .desktop-profile-facts > div { min-height: 62px; padding: 10px 15px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid #edf0f3; }
  .desktop-profile-facts > div:last-child { border-bottom: 0; }
  .desktop-profile-facts > div > .runa-icon { width: 21px; height: 21px; color: #f58220; }
  .desktop-profile-facts span { min-width: 0; display: grid; gap: 3px; }
  .desktop-profile-facts small { color: #8b97a6; }
  .desktop-profile-facts strong { overflow: hidden; color: #273447; text-overflow: ellipsis; }
  .desktop-settings-section { padding: 14px; }
  .desktop-settings-section .settings-card { margin: 0; padding: 18px; border: 1px solid #e1e7ed; border-radius: 14px; }
  .desktop-appearance-preview { display: flex; align-items: center; gap: 16px; }
  .desktop-appearance-preview img { width: 52px; height: 52px; }
  .desktop-appearance-preview div { display: grid; gap: 4px; }
  .desktop-appearance-preview span { color: #7c8998; font-size: 13px; }

  .folder-manager { width: min(440px, 94vw); padding: 0; overflow: hidden; border-radius: 16px; }
  .folder-manager > :not(.desktop-panel-heading) { margin-inline: 20px; }
  .folder-manager .folder-manager-list { max-height: 300px; margin-top: 16px; }
  .folder-manager .modal-actions { margin: 16px 20px 20px; }
  .desktop-panel-heading { min-height: 72px; padding: 13px 14px 12px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e4e9ee; background: #fff; }
  .desktop-panel-heading .modal-title { margin: 0; font-size: 18px; }
  .desktop-panel-heading span { color: #8492a3; font-size: 11px; }

  .up-overlay { background: rgba(15,23,42,.52); backdrop-filter: blur(2px); }
  .up-modal { width: 420px; box-shadow: -18px 0 60px rgba(15,23,42,.22); }
}

@media (min-width: 1180px) {
  #app.desktop-picker-open .chat-area { margin-right: 360px; }
  .sticker-picker {
    position: fixed !important;
    inset: 0 0 0 auto !important;
    z-index: 340;
    width: 360px !important;
    height: 100vh;
    max-height: none !important;
    display: flex !important;
    flex-direction: column;
    border: 0;
    border-left: 1px solid #dfe5eb;
    border-radius: 0;
    box-shadow: -12px 0 40px rgba(15,23,42,.12);
    animation: desktopPickerIn .18s ease-out;
  }
  @keyframes desktopPickerIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
  .sticker-picker-tabs { min-height: 62px; align-items: center; background: #fff; }
  .sticker-picker-body { min-height: 0; flex: 1; }
  .sticker-picker .picker-content { min-height: 0; }
  .sticker-picker .emoji-grid { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 768px) {
  .desktop-rail,
  .desktop-drawer-scrim,
  .sidebar-menu-profile { display: none !important; }
}
