:root {
  --bg: #08090b;
  --surface: #101216;
  --surface2: #15171c;
  --surface3: #1b1e24;

  --text: #f4f4f5;
  --muted: #9297a1;
  --dim: #626771;

  --yellow: #f4c84b;
  --yellow2: #ffd967;

  --red: #ff5d5d;
  --green: #55d98b;

  --border: rgba(255,255,255,.08);
  --border2: rgba(255,255,255,.14);

  --sidebar: 260px;
  --topbar: 64px;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Inter",
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;
}

/* =========================
   RESET
========================= */

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #30343c transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: inherit;
  background: none;
}

.hidden {
  display: none !important;
}

/* =========================
   SVG
========================= */

svg.mi {
  display: block !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;

  flex: 0 0 20px;

  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 1.9 !important;
  stroke-linecap: round;
  stroke-linejoin: round;

  color: inherit;
  pointer-events: none;
}

.nav svg.mi {
  width: 19px !important;
  height: 19px !important;
  min-width: 19px !important;
  min-height: 19px !important;
  flex-basis: 19px;
  margin-right: 10px;
}

.icon svg.mi {
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
}

/* =========================
   GENERAL BUTTONS
========================= */

.icon {
  width: 42px;
  height: 42px;
  min-width: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  color: var(--muted);
  border-radius: 11px;

  transition:
    background .15s ease,
    color .15s ease,
    transform .12s ease;
}

.icon:hover {
  color: var(--text);
  background: var(--surface3);
}

.icon:active {
  transform: scale(.94);
}

.primary {
  background: var(--yellow) !important;
  color: #111 !important;
  font-weight: 700;
}

.primary:hover {
  background: var(--yellow2) !important;
}

/* =========================
   AUTH
========================= */

.auth {
  position: fixed;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background:
    radial-gradient(
      circle at 50% 15%,
      rgba(244,200,75,.08),
      transparent 35%
    ),
    var(--bg);

  overflow-y: auto;
}

.auth-card {
  width: 420px;
  max-width: 100%;

  padding: 34px;

  background: rgba(16,18,22,.96);

  border: 1px solid var(--border2);
  border-radius: 22px;

  box-shadow: 0 30px 100px rgba(0,0,0,.5);
}

.brand {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.5px;
}

.auth-card .muted {
  margin: 8px 0 26px;
  color: var(--muted);
  font-size: 14px;
}

.auth-card input {
  width: 100%;
  height: 50px;

  margin-bottom: 11px;
  padding: 0 14px;

  background: #0b0d10;

  border: 1px solid var(--border2);
  border-radius: 11px;

  color: var(--text);
  outline: none;
}

.auth-card input::placeholder {
  color: var(--dim);
}

.auth-card input:focus {
  border-color: rgba(244,200,75,.55);
  box-shadow: 0 0 0 3px rgba(244,200,75,.08);
}

.auth-card .row {
  display: flex;
  gap: 9px;
  margin-top: 5px;
}

.auth-card .row button {
  flex: 1;
  height: 48px;

  border-radius: 11px;

  background: var(--surface3);
  color: var(--text);
}

#authStatus {
  display: block;
  min-height: 18px;
  margin-top: 14px;

  color: var(--muted);
  font-size: 12px;
}

/* =========================
   MAIN
========================= */

#mainView {
  width: 100%;
  height: 100%;
  position: relative;
}

/* =========================
   TOPBAR
========================= */

.topbar {
  position: fixed;

  top: 0;
  left: var(--sidebar);
  right: 0;

  height: var(--topbar);

  z-index: 100;

  display: flex;
  align-items: center;

  padding: 0 14px;

  background: rgba(12,14,18,.94);
  border-bottom: 1px solid var(--border);

  backdrop-filter: blur(18px);
}

.topbar strong {
  font-size: 17px;
  font-weight: 750;
}

.topbar > .icon {
  display: none;
}

.top-actions {
  margin-left: auto;

  display: flex;
  align-items: center;

  gap: 3px;
}

/* =========================
   SIDEBAR
========================= */

.sidebar {
  position: fixed;

  left: 0;
  top: 0;
  bottom: 0;

  width: var(--sidebar);

  z-index: 150;

  display: flex;
  flex-direction: column;

  padding: 15px 11px;

  background: var(--surface);
  border-right: 1px solid var(--border);

  overflow-y: auto;
}

.profile-mini {
  display: flex;
  align-items: center;

  gap: 11px;

  padding: 9px;
  margin-bottom: 16px;
}

.profile-mini > div:last-child {
  min-width: 0;

  display: flex;
  flex-direction: column;
}

.profile-mini b {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  font-size: 14px;
}

.profile-mini small {
  margin-top: 3px;
  color: var(--dim);
  font-size: 12px;
}

.nav {
  width: 100%;
  min-height: 46px;

  display: flex;
  align-items: center;

  padding: 0 13px;
  margin: 2px 0;

  border-radius: 10px;

  color: var(--muted);

  font-size: 14px;
  font-weight: 500;

  text-align: left;
}

.nav:hover {
  background: var(--surface3);
  color: var(--text);
}

.nav.active {
  background: rgba(244,200,75,.11);
  color: var(--yellow);
}

.nav.danger {
  margin-top: auto;
  color: var(--red);
}

/* =========================
   AVATAR
========================= */

.avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: var(--surface3);
  border: 1px solid var(--border2);

  color: var(--text);
  font-weight: 700;
}

.avatar.big {
  width: 48px;
  height: 48px;
  min-width: 48px;
}

/* =========================
   CONTENT
========================= */

#content {
  position: absolute;

  top: 0;
  right: 0;
  bottom: 0;
  left: var(--sidebar);

  padding-top: var(--topbar);

  overflow-y: auto;
  overflow-x: hidden;

  -webkit-overflow-scrolling: touch;
}

.page {
  width: 100%;
  max-width: 1050px;

  min-height: 100%;

  margin: 0 auto;

  padding: 28px;
}

.page-head {
  width: 100%;
  min-height: 45px;

  display: flex;
  align-items: center;

  gap: 10px;

  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;

  color: var(--text);

  font-size: 24px;
  font-weight: 750;

  letter-spacing: -.5px;
}

.page-head > button {
  margin-left: auto;
}

/* =========================
   LISTS
========================= */

.list,
#groupList,
#channelList,
#botList {
  width: 100%;
  min-width: 0;

  display: flex;
  flex-direction: column;

  gap: 10px;

  overflow: visible;
}

/* =========================
   CHAT ITEMS
========================= */

.chat-item {
  width: 100%;
  min-height: 70px;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 10px;

  background: transparent;

  border-radius: 13px;

  color: var(--text);

  text-align: left;
}

.chat-item:hover {
  background: var(--surface);
}

/* =========================
   GROUP / CHANNEL CARDS
========================= */

.cards {
  width: 100%;

  display: grid;

  grid-template-columns:
    repeat(auto-fill, minmax(240px, 1fr));

  gap: 12px;
}

.cards .card {
  width: 100%;
  min-width: 0;

  min-height: 150px;

  display: block;

  padding: 17px;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 14px;

  color: var(--text);

  overflow: visible;
}

.cards .card h3 {
  display: block;

  margin: 0 0 8px;

  color: var(--text);

  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
}

.cards .card p {
  display: block;

  margin: 0 0 10px;

  color: var(--muted);

  font-size: 13px;
  line-height: 1.5;
}

.cards .card small {
  display: block;

  color: var(--dim);

  font-size: 12px;
}

/* verified */
.verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 17px;
  height: 17px;

  margin-left: 3px;

  border-radius: 50%;

  background: var(--yellow);
  color: #111;

  font-size: 10px;
  font-weight: 900;
}

/* =========================
   CREATE BUTTONS
========================= */

#createGroupBtn,
#createChannelBtn,
#createBotBtn {
  width: auto !important;
  min-width: 150px;
  height: 42px;

  display: inline-flex !important;
  align-items: center;
  justify-content: center;

  gap: 8px;

  padding: 0 15px;

  background: var(--yellow) !important;
  color: #111 !important;

  border-radius: 10px;

  font-size: 13px;
  font-weight: 700;

  transition:
    background .15s ease,
    transform .12s ease;
}

#createGroupBtn::after {
  content: "Создать группу";
}

#createChannelBtn::after {
  content: "Создать канал";
}

#createBotBtn::after {
  content: "Создать бота";
}

#createGroupBtn:hover,
#createChannelBtn:hover,
#createBotBtn:hover {
  background: var(--yellow2) !important;
}

#createGroupBtn:active,
#createChannelBtn:active,
#createBotBtn:active {
  transform: scale(.97);
}

/* =========================
   SETTINGS
========================= */

#page-settings {
  width: 100%;
  min-width: 0;

  padding-bottom: 80px;
}

.settings-list {
  width: 100%;
  max-width: 720px;

  display: flex;
  flex-direction: column;

  gap: 6px;

  padding: 7px;

  background: var(--surface);

  border: 1px solid var(--border);
  border-radius: 16px;

  overflow: visible;
}

.setting {
  width: 100%;
  min-height: 58px;

  flex: 0 0 auto;

  display: flex !important;
  align-items: center;

  gap: 12px;

  padding: 0 14px;

  background: transparent !important;

  border-radius: 11px;

  color: var(--text) !important;

  text-align: left;
}

.setting:hover {
  background: var(--surface3) !important;
}

.setting span {
  flex: 1;

  color: var(--text) !important;

  font-size: 14px;
  font-weight: 600;
}

.setting b {
  color: var(--dim);

  font-size: 22px;
  font-weight: 400;
}

.setting svg.mi {
  color: var(--muted);
}

/* =========================
   CHAT PANEL
========================= */

.chat-panel {
  position: fixed;

  inset: 0 0 0 var(--sidebar);

  z-index: 200;

  display: flex;
  flex-direction: column;

  background: var(--bg);
}

.chat-head {
  height: var(--topbar);
  min-height: var(--topbar);

  flex: 0 0 auto;

  display: flex;
  align-items: center;

  padding: 0 10px;

  background: rgba(12,14,18,.96);
  border-bottom: 1px solid var(--border);
}

.chat-head > div:nth-child(2) {
  min-width: 0;

  display: flex;
  flex-direction: column;
}

.chat-head b {
  font-size: 14px;
}

.chat-head small {
  margin-top: 3px;

  color: var(--dim);

  font-size: 11px;
}

/* =========================
   MESSAGES
========================= */

.messages {
  flex: 1;
  min-height: 0;

  overflow-y: auto;

  display: flex;
  flex-direction: column;

  gap: 5px;

  padding: 18px;
}

.message {
  max-width: 75%;

  padding: 9px 12px;

  border-radius: 14px;

  font-size: 14px;

  word-break: break-word;
}

.message.incoming {
  align-self: flex-start;

  background: var(--surface2);

  border-bottom-left-radius: 5px;
}

.message.outgoing {
  align-self: flex-end;

  background: var(--yellow);

  color: #151515;

  border-bottom-right-radius: 5px;
}

/* =========================
   COMPOSER
========================= */

.composer {
  flex: 0 0 auto;

  display: flex;
  align-items: center;

  gap: 6px;

  padding: 9px;

  background: var(--surface);

  border-top: 1px solid var(--border);
}

#messageInput {
  flex: 1;
  min-width: 0;

  height: 42px;

  padding: 0 13px;

  background: var(--surface2);

  border: 1px solid var(--border);
  border-radius: 11px;

  color: var(--text);

  outline: none;
}

#messageInput:focus {
  border-color: rgba(244,200,75,.4);
}

#sendBtn {
  background: var(--yellow) !important;
  color: #111 !important;
}

/* =========================
   MODAL
========================= */

.modal {
  position: fixed;
  inset: 0;

  z-index: 500;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 18px;

  background: rgba(0,0,0,.7);

  backdrop-filter: blur(8px);

  overflow-y: auto;
}

.modal-card {
  position: relative;

  width: min(500px, 100%);
  max-height: 90vh;

  overflow-y: auto;

  padding: 26px;

  background: var(--surface);

  border: 1px solid var(--border2);
  border-radius: 18px;

  box-shadow: 0 30px 100px rgba(0,0,0,.55);
}

.modal-close {
  position: absolute;

  top: 10px;
  right: 10px;

  width: 35px;
  height: 35px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--surface3);

  border-radius: 9px;

  color: var(--muted);

  font-size: 22px;
}

.modal-card input,
.modal-card textarea,
.modal-card select {
  width: 100%;

  min-height: 44px;

  margin-bottom: 10px;

  padding: 0 13px;

  background: var(--bg);

  border: 1px solid var(--border);

  border-radius: 10px;

  color: var(--text);

  outline: none;
}

.modal-card textarea {
  min-height: 90px;
  padding: 12px 13px;
  resize: vertical;
}

.modal-card input:focus,
.modal-card textarea:focus,
.modal-card select:focus {
  border-color: rgba(244,200,75,.45);
}

.modal-card h2 {
  margin-top: 0;
  color: var(--text);
}

/* =========================
   TOAST
========================= */

#toast {
  position: fixed;

  left: 50%;
  bottom: 24px;

  z-index: 1000;

  max-width: calc(100% - 30px);

  padding: 11px 16px;

  background: #1b1e24;

  border: 1px solid var(--border2);
  border-radius: 10px;

  color: var(--text);

  font-size: 13px;

  opacity: 0;
  pointer-events: none;

  transform: translate(-50%, 15px);

  transition: .2s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================
   SCROLLBAR
========================= */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #30343c;
  border-radius: 20px;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 800px) {

  :root {
    --sidebar: 255px;
    --topbar: 58px;
  }

  .topbar {
    left: 0;
  }

  .topbar > .icon {
    display: flex !important;

    width: 42px;
    height: 42px;

    margin-right: 6px;
  }

  .sidebar {
    transform: translateX(-105%);

    transition: transform .22s ease;

    box-shadow: 20px 0 70px rgba(0,0,0,.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #content {
    left: 0;

    padding-top: var(--topbar);

    overflow-y: auto;
  }

  .page {
    padding: 20px 13px 60px;
  }

  .page-head h2 {
    font-size: 21px;
  }

  .chat-panel {
    inset: 0;
  }

  .message {
    max-width: 84%;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  #createGroupBtn,
  #createChannelBtn,
  #createBotBtn {
    width: 42px !important;
    min-width: 42px !important;

    padding: 0 !important;
  }

  #createGroupBtn::after,
  #createChannelBtn::after,
  #createBotBtn::after {
    content: none;
  }

  .settings-list {
    max-width: none;
  }
}

/* =========================
   IPHONE
========================= */

@media (max-width: 430px) {

  .auth {
    align-items: flex-start;
    padding-top: 16vh;
  }

  .auth-card {
    padding: 20px 5px;

    background: transparent;

    border: 0;

    box-shadow: none;
  }

  .brand {
    font-size: 29px;
  }

  .page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .messages {
    padding: 12px 9px;
  }

  .composer {
    padding:
      7px
      max(7px, env(safe-area-inset-right))
      calc(7px + env(safe-area-inset-bottom))
      max(7px, env(safe-area-inset-left));
  }

  #attachBtn,
  #recordBtn {
    width: 37px !important;
    height: 37px !important;
    min-width: 37px !important;
  }

  #messageInput {
    height: 40px;
  }
}