:root {
  color-scheme: dark;
  --bg: #080816;
  --panel: rgba(23, 27, 45, 0.88);
  --panel-2: rgba(35, 46, 60, 0.88);
  --bubble-in: #243241;
  --bubble-out: #315d8a;
  --text: #f2f0ff;
  --muted: #a9a2c9;
  --line: rgba(205, 176, 255, 0.18);
  --accent: #c97cff;
  --accent-2: #22b8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(4, 5, 18, 0.82), rgba(4, 5, 18, 0.58)),
    url("/landing/assets/nith_splash_bg.jpg") left center / cover fixed,
    var(--bg);
}

a {
  color: #79cfff;
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(7, 10, 24, 0.64);
  backdrop-filter: blur(18px);
}

.brand,
.row,
.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 24px;
  font-weight: 900;
}

.logo img,
.empty-card img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(201, 124, 255, 0.5));
}

.site-link,
.apk-link {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(23, 27, 45, 0.78);
  text-decoration: none;
  font-weight: 800;
}

.panel,
.thread-head,
.composer {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.panel {
  padding: 14px;
}

.panel.chats {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.panel h1,
.panel h2,
.thread-head h2 {
  margin: 0;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid rgba(205, 176, 255, 0.24);
  border-radius: 14px;
  outline: 0;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(8, 12, 28, 0.92);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 124, 255, 0.16);
}

button,
.site-link,
.apk-link {
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease;
}

button:hover,
.site-link:hover,
.apk-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px) scale(0.98);
}

.primary,
.send {
  border: 0;
  border-radius: 14px;
  color: #070817;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
}

.primary {
  width: 100%;
  margin-top: 16px;
  padding: 13px 14px;
}

.icon {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(8, 12, 28, 0.78);
}

.hint,
.thread-head p,
.preview,
.time {
  color: var(--muted);
}

.search {
  margin: 14px 0;
}

.chat-list {
  display: grid;
  flex: 1;
  min-height: 0;
  gap: 8px;
  align-content: start;
  grid-auto-rows: min-content;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: none;
  padding-right: 4px;
}

.chat {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 9px;
  align-items: center;
  min-width: 0;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.chat > span {
  min-width: 0;
}

.chat:hover,
.chat.active {
  background: rgba(201, 124, 255, 0.16);
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #8730f5, #22b8ff);
  font-weight: 900;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-title,
.bubble-author {
  font-weight: 900;
}

.chat-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
  font-size: 13px;
}

.badge {
  min-width: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #06111a;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.thread {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  width: 100%;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  padding: 12px;
  gap: 14px;
}

.thread-head {
  padding: 14px 16px;
}

.messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 8px 24px;
}

.messages.drag-ready {
  outline: 2px dashed var(--accent-2);
  outline-offset: -10px;
  background: rgba(34, 184, 255, 0.08);
}

.messages.empty {
  display: grid;
  place-items: center;
}

.empty-card {
  max-width: 320px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  text-align: center;
}

.bubble {
  width: fit-content;
  max-width: min(680px, 82%);
  min-width: 0;
  margin: 8px 0;
  padding: 10px 12px 8px;
  border-radius: 16px;
  background: var(--bubble-in);
}

.bubble.mine {
  margin-left: auto;
  background: var(--bubble-out);
}

.bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.42;
}

.message-link {
  display: inline;
  color: #b8e4ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.media-card {
  display: grid;
  gap: 8px;
  min-width: min(320px, 72vw);
}

.media-card img,
.media-card video {
  display: block;
  width: 100%;
  max-height: 360px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.28);
}

.media-card audio {
  width: 100%;
}

.media-title {
  color: var(--text);
  font-weight: 900;
}

.media-subtitle,
.media-card a {
  color: rgba(242, 240, 255, 0.78);
  font-size: 13px;
}

.reply-box {
  display: grid;
  gap: 2px;
  margin-bottom: 6px;
  padding: 6px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.reply-box strong {
  color: var(--accent);
  font-size: 13px;
}

.reply-box span {
  color: rgba(242, 240, 255, 0.82);
  font-size: 13px;
}

.bubble-meta {
  margin-top: 5px;
  color: rgba(242, 240, 255, 0.72);
  font-size: 12px;
  text-align: right;
}

.composer {
  display: grid;
  grid-template-columns: 42px 42px 1fr 48px;
  gap: 8px;
  padding: 10px;
  min-width: 0;
  position: sticky;
  bottom: 0;
  overflow: visible;
}

.composer input[type="text"],
.composer input:not([type]) {
  min-width: 0;
}

.composer.uploading::after {
  content: "Загрузка...";
  position: absolute;
  right: 70px;
  bottom: 68px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(23, 27, 45, 0.96);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.send,
.tool-button {
  width: 48px;
  height: 48px;
}

.tool-button {
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(8, 12, 28, 0.78);
}

.emoji-panel {
  position: absolute;
  left: 10px;
  bottom: 72px;
  display: grid;
  grid-template-columns: repeat(8, 36px);
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(23, 27, 45, 0.98);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

.emoji-panel button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 20px;
}

.hidden {
  display: none !important;
}

.load-more {
  display: block;
  margin: 4px auto 14px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(35, 46, 60, 0.9);
  font-weight: 800;
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-list {
    max-height: 240px;
  }

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

  .bubble {
    max-width: 94%;
  }
}
