:root {
  color-scheme: dark;
  --bg: #050607;
  --panel: #101418;
  --panel-2: #171d23;
  --text: #f4f7f8;
  --muted: #8c99a3;
  --line: #26313a;
  --accent: #2bd4a3;
  --accent-2: #5aa7ff;
  --danger: #ff5f6d;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, -apple-system, sans-serif;
  letter-spacing: 0;
  cursor: default;
  user-select: none;
}

html,
body,
.shell {
  min-height: 100dvh;
}

button,
input,
textarea {
  font: inherit;
}

input,
textarea {
  cursor: text;
  user-select: text;
}

a,
button {
  user-select: none;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.shell {
  overflow-x: hidden;
}

.auth {
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-rows: auto 1fr;
  gap: 48px;
  align-items: center;
  padding: 22px 0;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.language {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b0e;
}

.langButton {
  min-width: 42px;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.langButton.active {
  color: var(--text);
  background: var(--panel-2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 24px;
}

.brandLink,
.account a,
.adminBrand a,
.notFoundLogo {
  color: inherit;
  text-decoration: none;
}

.brand img,
.account img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.brand h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.95;
}

.brand p,
.notice,
.account span,
.chatHeader span,
.message span {
  color: var(--muted);
}

.panel,
.sidebar,
.chat,
.admin {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 24px;
}

.choice,
.authForm {
  align-self: center;
}

.choice {
  display: grid;
  gap: 12px;
}

.authForm h2 {
  margin: 12px 0 22px;
  font-size: 24px;
}

.backButton {
  min-height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.backButton:hover {
  color: var(--text);
}

.ghost,
.search button,
.composer button,
.admin button,
.secondary {
  min-height: 42px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.primary,
.search button,
.composer button {
  background: var(--accent);
  color: #06110e;
}

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

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #080b0e;
  color: var(--text);
  outline: none;
}

input {
  height: 46px;
  line-height: 46px;
  padding: 0 12px;
}

textarea {
  line-height: 20px;
  padding: 13px 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent-2);
}

.primary {
  width: 100%;
  min-height: 46px;
  border-radius: 6px;
  font-weight: 700;
}

.notice {
  min-height: 42px;
  margin: 16px 0 0;
  line-height: 1.45;
}

.seedBox {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid #24594e;
  border-radius: 8px;
  background: #0b1b18;
  color: var(--text);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.seedActions {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 10px;
}

.seedActions .ghost {
  min-width: 180px;
  padding: 0 14px;
}

.seedBox div,
.wordInput {
  min-height: 44px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #080f0d;
}

.seedBox div {
  padding: 0 10px;
}

.seedBox span,
.wordInput span {
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.seedBox strong {
  overflow-wrap: anywhere;
}

.phraseInputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.wordInput {
  margin: 0;
  padding: 0 8px 0 0;
}

.wordInput input {
  height: 42px;
  line-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar,
.chat {
  border-radius: 0;
  border-top: 0;
  border-bottom: 0;
}

.sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border-left: 0;
}

.account {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.accountLink {
  color: inherit;
  text-decoration: none;
}

.accountLink:hover {
  background: #111a20;
}

.account img,
.account video {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.account strong,
.account span {
  display: block;
  overflow-wrap: anywhere;
}

.profilePanel {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.profilePanel label {
  margin-bottom: 10px;
}

.profilePanel .ghost {
  width: 100%;
}

.profileNotice {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.list {
  overflow: auto;
}

.conversation {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 10px;
}

.smallAvatar,
.chatPeerAvatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.conversation.active {
  background: #13231f;
  border-left: 3px solid var(--accent);
}

.sideActions {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.compactActions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  align-self: end;
  padding: 8px 14px 12px;
}

.compactActions .ghost {
  min-height: 30px;
  height: 30px;
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  line-height: 30px;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 0;
}

.chatHeader {
  min-height: 74px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.chatBackButton {
  display: none;
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.chatHeader strong,
.chatHeader span {
  display: block;
}

.chatHeader span:empty {
  display: none;
}

.messages {
  overflow: auto;
  padding: 20px;
}

.message {
  width: fit-content;
  max-width: min(720px, 84%);
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.message.mine {
  margin-left: auto;
  background: #0f2b24;
  border-color: #1e6f5a;
}

.message span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.receipt {
  margin-top: 6px;
  margin-bottom: 0 !important;
  color: var(--muted);
  font-weight: 700;
}

.receipt.read {
  color: var(--accent-2);
}

.message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.messageDelete {
  margin-top: 8px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--danger);
  border: 1px solid rgb(255 95 109 / 45%);
}

.composer {
  display: grid;
  grid-template-columns: 1fr 220px 130px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.composer textarea {
  resize: none;
  min-height: 48px;
  max-height: 140px;
}

.composer button:disabled,
.composer textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 72%);
  padding: 16px;
}

.admin {
  width: min(880px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
}

.admin header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.admin h2 {
  margin: 0;
  font-size: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px;
}

.stats div,
.adminRow {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.stats strong,
.stats span {
  display: block;
}

.stats span {
  color: var(--muted);
}

.adminUsers {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.adminRow {
  display: grid;
  grid-template-columns: 1fr 110px 120px;
  gap: 12px;
  align-items: center;
}

.adminRow span {
  overflow-wrap: anywhere;
}

.adminPage {
  min-height: 100vh;
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.adminLogin {
  width: min(420px, 100%);
  margin: 12vh auto 0;
  padding: 24px;
}

.adminBrand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.adminBrand img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.adminBrand h1,
.adminTop h1 {
  margin: 0;
  font-size: 24px;
}

.adminBrand p,
.adminTop p {
  margin: 4px 0 0;
  color: var(--muted);
}

.adminTop {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.adminDashboard .stats,
.adminDashboard .adminUsers {
  padding-left: 0;
  padding-right: 0;
}

.notFoundPage {
  min-height: 100vh;
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 14px;
}

.notFoundLogo img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.notFoundPage h1 {
  margin: 0;
  font-size: 34px;
}

.notFoundPage p {
  margin: 0;
  color: var(--muted);
}

.notFoundHome {
  display: inline-grid;
  place-items: center;
  width: auto;
  min-width: 160px;
  padding: 0 18px;
  text-decoration: none;
}

.navButton {
  display: grid;
  place-items: center;
  min-height: 42px;
}

.fileInput {
  height: 46px;
  line-height: normal;
  padding: 11px 12px;
}

.attachment {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.attachment img,
.attachment video {
  max-width: min(360px, 100%);
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.attachment a {
  color: var(--accent);
}

.profilePage {
  min-height: 100vh;
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.compactBrand {
  margin-bottom: 24px;
}

.compactBrand img,
.profileAvatar img {
  width: 72px;
  height: 72px;
}

.compactBrand h1 {
  font-size: 34px;
}

.profilePageForm {
  padding: 24px;
}

.profileLogout {
  width: 100%;
  margin-top: 10px;
}

.profileAvatar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.profileAvatar img,
.profileAvatar video {
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.profileAvatar video {
  width: 72px;
  height: 72px;
}

.blockedView {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.blockedPanel {
  width: min(420px, 100%);
  padding: 24px;
}

.checkboxLine {
  display: flex;
  grid-template-columns: none;
  align-items: center;
}

.checkboxLine input {
  width: 18px;
  height: 18px;
}

.adminTabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.adminErrors {
  display: grid;
  gap: 10px;
}

.adminErrors pre {
  overflow: auto;
  white-space: pre-wrap;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

@media (min-width: 821px) and (max-width: 1100px) {
  .app {
    grid-template-columns: 280px 1fr;
  }

  .account,
  .search,
  .conversation,
  .chatHeader,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 170px 104px;
  }
}

@media (max-width: 820px) {
  .auth {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    align-content: center;
    gap: 28px;
    padding: 24px 0;
  }

  .brand {
    align-items: flex-start;
  }

  .brand img {
    width: 72px;
    height: 72px;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    min-height: 100dvh;
  }

  .sidebar {
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app.mobile-list-open .chat {
    display: none;
  }

  .app.mobile-chat-open .sidebar {
    display: none;
  }

  .account {
    padding: 10px 12px;
  }

  .search {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 0 12px 8px;
  }

  .list {
    min-height: 0;
  }

  .conversation {
    min-height: 44px;
    padding: 0 12px;
  }

  .compactActions {
    padding: 6px 12px 8px;
  }

  .chat {
    min-height: 0;
  }

  .chatHeader {
    min-height: 54px;
    padding: 10px 12px;
  }

  .chatBackButton {
    display: inline-flex;
    align-items: center;
  }

  .messages {
    padding: 12px;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 10px 12px 12px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .brand {
    display: grid;
  }

  .brand h1 {
    font-size: 30px;
    line-height: 1;
  }

  .brand p {
    font-size: 13px;
  }

  .search,
  .adminRow,
  .phraseInputs,
  .seedBox {
    grid-template-columns: 1fr;
  }

  .shell,
  .auth {
    width: 100%;
  }

  .auth {
    min-height: 100dvh;
    padding: 12px 8px;
    gap: 18px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand {
    gap: 12px;
  }

  .brand img {
    width: 56px;
    height: 56px;
  }

  .panel {
    padding: 14px;
  }

  .app {
    grid-template-rows: 1fr;
  }

  .sidebar {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .account img,
  .account video {
    width: 40px;
    height: 40px;
  }

  .account,
  .conversation,
  .chatHeader {
    gap: 8px;
  }

  .chatPeerAvatar {
    width: 32px;
    height: 32px;
  }

  .account {
    padding: 10px 12px;
  }

  .search {
    padding: 0 12px 8px;
    gap: 6px;
  }

  .search button,
  .composer button {
    min-height: 40px;
  }

  .compactActions .ghost {
    min-height: 30px;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    line-height: 30px;
  }

  .message {
    padding: 10px 11px;
  }

  .messageMeta {
    gap: 6px;
  }

  .messages {
    padding: 12px;
  }

  .composer {
    padding: 10px 14px 12px;
    gap: 8px;
  }

  .composer textarea {
    min-height: 44px;
  }

  textarea,
  input,
  button {
    font-size: 16px;
  }

  .adminTop {
    align-items: stretch;
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }
}
