:root {
  font-size: 16px;
}

* {
  transition: color, background 0.3s ease-out;
  /* scrollbar-width: thin; */
  /* scrollbar-color: #42424b #262427; */
}

/* для Chrome/Edge/Safari */
*::-webkit-scrollbar {
  height: 0.5rem;
  width: 0.5rem;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid;
  background-color: #42424b;
  border-radius: 5px;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-height: 100dvh;
  max-width: 100dvw;
  width: 100dvw;
  height: 100dvh;
}

body {
  color: var(--text);
  background-color: var(--bg__main);
  font-family: "Inter";
}

/* ==Typography== */

.heading-one {
  font-size: 1.6rem;
}

.regular {
  font-weight: 300;
}

.light {
  font-weight: 200;
}

.medium {
  font-weight: 400;
}

.icon {
  fill: inherit;
  width: 1em;
  height: 1em;
}

.icon--big {
  width: 1.6em;
  height: 1.6em;
}

.icon--small {
  width: 0.7em;
  height: 0.7em;
}

.chats__title,
.chats__link,
.chats__list,
.chats__nav,
.chats__typo,
.chats {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main,
.header,
.header__actions,
.header__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==END== */
.wrapper {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 3fr;
  justify-content: stretch;
  overflow: hidden;
}

.header {
  background-color: var(--bg__light-third);
  box-shadow: 0px 0px 15px 0px rgba(28, 28, 31, 0.3);
  padding: 0.6em;
  display: flex;
  align-content: space-between;
  justify-content: space-between;
}

.header__actions {
  display: flex;
  flex-direction: row;
  gap: 0.4em;
}

.header__actions:hover > .header__text {
  text-decoration: underline;
}

.header__text {
  font-size: inherit;
  font-weight: inherit;
}

.header__icon {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header--center {
  justify-content: center;
}

.header--border {
  border-right: 0.1rem solid var(--border);
}

/* Sidebar */
.chats {
  background: var(--bg__secondary);
}

.chat__nav {
  height: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 73dvh;
  height: 100%;
  overflow-y: auto;
  scroll-behavior: auto;
}

.chats__list {
  margin-bottom: 1rem;
  position: relative;
  overflow: visible;
  width: 100%;
  display: flex;
  flex-direction: column;
  list-style: none;
}

.chats__list:vertical {
  position: absolute;
}

.chats__typo {
  display: flex;
  flex-direction: row;
  gap: 0.6em;
}

.chats__link {
  height: fit-content;
  cursor: pointer;
  padding: 0.6em;
  font-weight: 200;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.chats__link:hover:not(.chats__link--active) {
  background: var(--bg__light-second);
}

.chats__link--active {
  font-weight: 400;
  background: var(--bg__light-third);
}

.chats__icon,
.chats__close {
  display: flex;
  align-items: center;
}

.menu,
.hamburger {
  display: none;
}

.chats__title {
  width: inherit;
  text-wrap: nowrap;
  text-overflow: ellipsis;
}

.chats__add-button {
  /* position: absolute; */
  z-index: 2;
  bottom: 6rem;
  display: flex;
  align-items: center;
  background-color: var(--bg__light-third);
  border-radius: 1.3em;
  gap: 0.6em;
}

.theme {
  position: absolute;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 5fr;
  width: 100%;
  height: unset;
  justify-content: stretch;
  align-items: stretch;
  background: var(--bg__light-third);
}

.theme__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: var(--bg__light-fourth);
}

.theme__title {
  flex-grow: 1;
  padding: 0.6em;
  text-align: center;
  white-space: wrap;
}

.theme__panel {
  background: var(--bg__form);
  padding: 0.6em;
  border-radius: 0.6rem;
}

/* GPT-4 Chat */
.main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg__light-second);
}

.main__chat {
  height: 80dvh;
  width: inherit;
  overflow: hidden;
}

.content {
  width: inherit;
  flex-grow: 1;
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  padding: 0.6rem;
  gap: 0.6em;
}

/* Messages */

.message__list {
  height: inherit;
  width: inherit;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  scroll-behavior: auto;
  list-style: none;
}

.message__item {
  max-width: 100%;
  word-wrap: break-word;
}

.message__item,
.qa__text {
  width: inherit;
  height: fit-content;
  text-wrap: balance;
  white-space: normal;
}

.message__item--question {
  align-self: end;
}

.message__item--answer {
  background: unset;
  align-self: start;
}

/* Markdown styles */
.message__item > h1,
.message__item > h2,
.message__item > h3,
.message__item > h4,
.message__item > h5,
.message__item > h6 {
  font-size: 1rem;
  margin: 0;
  padding-block: 0.5rem;
  font-weight: bold;
}

.message__item > ol,
.message__item > ul {
  padding-inline-start: 1.5rem;
}
.message__item li {
  padding-block: 0.2rem;
}

/* End - Messages */

.form {
  max-height: 6rem;
  height: fit-content;
  width: 100%;
  display: grid;
  border-radius: 0 0 0.6rem 0.6rem;
  grid-template-columns: 9fr 1fr;
  /* align-items: center; */
  overflow: hidden;
  gap: 2em;
}

.form__textaria {
  max-height: 5rem;
}

.change-name__textaria {
  height: 100%;
}

.form__textaria,
.change-name__textaria {
  resize: none;
  background: none;
  flex-grow: 1;
}

.form__button {
  position: relative;
  fill: var(--border);
  border-left: 0.1em solid var(--border);
  height: 50%;
}

.form__button:hover,
.form__button:focus {
  background: rgba(255, 255, 255, 0.2);
}

.form.disabled > * {
  color: gray;
  fill: gray;
  border-color: gray;
}

.form__icon {
  width: 2rem;
  height: inherit;
  transform: translateX(5px);
}

/* QA panel */

.qa {
  margin-inline: auto;
  max-width: min(400px, 80%);
}

.qa__icon > svg {
  transform: translateY(15%);
}

/* Change Name panel */

.change-name,
.delete-chat {
  z-index: 2;
  position: absolute;
  width: 80%;
  top: 50%;
  left: 50%;
  transform: translateX(-50%);
}

.change-name__theme {
  background: var(--bg__light-third);
}

/* Delete chat panel */

.delete-chat__text {
  margin-bottom: 1rem;
}

.delete-chat__panel {
  grid-template-columns: 1fr 1fr !important;
}

/* Adaptive Telegram WebApp */
@media screen and (max-height: 560px) and (max-width: 400px) {
  .main__chat {
    height: 80dvh;
  }
}

/* Adaptive mobile */
@media screen and (max-height: 600px) {
  .header {
    font-size: 1rem;
  }
  .main__chat {
    height: 60dvh;
  }
}

@media screen and (max-width: 1024px) {
  .theme {
    grid-template-columns: 1fr 2fr;
  }
  .theme__title {
    padding: 0.2em;
    text-align: left;
    font-size: 1.3rem;
  }

  .form {
    border-radius: 0.6em;
    grid-template-columns: 8fr 1fr;
    height: fit-content;
  }
  .form__textaria {
    height: fit-content;
  }
  .form__button {
    height: 100%;
  }
  .form__icon {
    height: 1.3em;
  }
}

@media screen and (max-width: 768px) {
  :root {
    font-size: 16px;
  }

  .main__chat {
    height: 76dvh;
  }

  .theme {
    grid-template-columns: 1fr 3fr;
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 2rem;
    overflow: hidden;
    width: 80%;
  }
  .theme__title {
    padding: 0.5em;
    font-size: 0.9rem;
    text-align: center;
  }
  .theme__icon .icon {
    width: 1.3rem;
    height: 1.3rem;
  }

  .header--border {
    border-right-color: transparent;
  }

  .chats {
    transition: transform 0.3s ease;
    transform: translateX(-100%);
    z-index: 2;
    text-align: center;
    position: absolute;
    left: 0;
    top: 0;
    height: inherit;
    width: 70%;
  }

  .shadow {
    position: absolute;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
  }

  .chats__add-button .chats__title {
    display: none;
  }
  .wrapper {
    grid-template-columns: 1fr;
  }
  .edit,
  .close,
  .model {
    display: none;
  }
  .menu,
  .hamburger {
    display: flex;
  }
  .menu__list {
    z-index: 2;
    position: absolute;
    right: 1rem;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    list-style: none;
  }

  .menu__button {
    display: flex;
    gap: 1rem;
  }
}
