.app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.app__nav {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 268px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 0.5px solid var(--separator);
}

.app__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  text-decoration: none;
  color: var(--text);
}

.app__mark { width: 36px; height: 36px; border-radius: 10px; }
.app__name { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-top: 6px; }

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 14px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  border: none;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.13s ease;
}

.nav__item:hover { background: var(--field-bg); }
.nav__item:active { opacity: 0.55; }
.nav__item.is-active { color: var(--accent); background: rgba(0, 122, 255, 0.12); }

.nav__icon { width: 24px; height: 24px; flex-shrink: 0; }

.nav__iconwrap { position: relative; display: inline-flex; }

.nav__badge {
  position: absolute;
  top: -3px;
  right: -7px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--danger);
  border-radius: 8px;
  box-shadow: 0 0 0 2px var(--surface);
}

.nav__item--settings { margin-top: auto; }

.nav__search { display: none; }

.app__user {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 14px;
  padding: 12px 10px 4px;
  border-top: 0.5px solid var(--separator);
}

.app__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(150deg, #56b0ff, #1d6ff2);
  background-size: cover;
  background-position: center;
}

.app__userinfo { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.app__username { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app__userhandle { font-size: 12px; color: var(--text-dim); }

.app__main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app__header { padding: 22px 26px 14px; }
.app__title { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }

.app__alerts { margin: 0 26px; }

.app__content { flex: 1; display: flex; padding: 20px 26px; }

.chats { flex: 1; display: flex; flex-direction: column; width: 100%; min-width: 0; }

.searchbar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text-dim);
  cursor: text;
}

.searchbar__icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.searchbar__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 17px;
  color: var(--text);
  padding: 0;
}

.searchbar__input::placeholder { color: var(--text-dim); opacity: 1; }
.searchbar__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.placeholder {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  max-width: 320px;
}

.placeholder__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(150deg, #56b0ff, #1d6ff2);
  box-shadow: 0 10px 24px -10px rgba(29, 111, 242, 0.6);
}

.placeholder__icon svg { width: 38px; height: 38px; }
.placeholder__title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.placeholder__text { margin: 0; font-size: 15px; color: var(--text-dim); line-height: 1.45; }

.badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.12);
}

@media (max-width: 820px) {
  body.is-app { position: fixed; inset: 0; width: 100%; overflow: hidden; }

  .app { height: 100%; flex-direction: column; }

  .app__main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  }

  .app__header { padding: 16px 18px 8px; }
  .app__title { font-size: 26px; }
  .app__alerts { margin: 8px 18px 0; }
  .app__content { padding: 16px 18px; }

  .app__nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    top: auto;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    padding: 0;
    background: none;
    border: none;
    z-index: 50;
  }

  .app__brand, .app__user { display: none; }

  .nav {
    flex: 1;
    flex-direction: row;
    margin-top: 0;
    gap: 0;
    justify-content: space-around;
    padding: 8px 6px;
    background: rgba(255, 255, 255, 0.85);
    border: 0.5px solid rgba(255, 255, 255, 0.6);
    border-radius: 34px;
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8), 0 10px 30px -8px rgba(0, 0, 0, 0.28);
  }

  .nav__item {
    flex: 1;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
    font-size: 10.5px;
    font-weight: 500;
    border-radius: 0;
    text-align: center;
    color: #8e8e93;
    background: none;
  }

  .nav__item:hover { background: none; color: #8e8e93; }
  .nav__item.is-active { background: none; color: #007aff; }
  .nav__item--settings { margin-top: 0; }
  .nav__icon { width: 27px; height: 27px; }
}

@media (max-width: 820px) and (prefers-color-scheme: dark) {
  .nav {
    background: rgba(30, 30, 30, 0.85);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1), 0 10px 30px -8px rgba(0, 0, 0, 0.5);
  }

  .nav__item, .nav__item:hover { color: rgba(235, 235, 245, 0.6); }
  .nav__badge { box-shadow: 0 0 0 2px rgba(30, 30, 30, 0.85); }
}
