@import url('./styles-v3.css');

:root {
  --bg-base: #f4f7fb;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-card: #ffffff;
  --bg-card-strong: #eef4fb;
  --bg-input: #f2f5f9;
  --bg-chat-in: #ffffff;
  --bg-chat-out: linear-gradient(135deg, #67d6ca, #38b9bd);
  --text-main: #173042;
  --text-soft: #5c7283;
  --text-faint: #8fa0ae;
  --line: rgba(20, 53, 74, 0.1);
  --line-strong: rgba(38, 173, 179, 0.24);
  --accent: #2fc3c0;
  --accent-strong: #18aeaf;
  --accent-ghost: rgba(47, 195, 192, 0.12);
  --danger: #dc6471;
  --shadow: 0 18px 54px rgba(65, 102, 126, 0.12);
}

:root[data-theme='graphite'] {
  --bg-base: #131a23;
  --bg-glass: rgba(19, 26, 35, 0.94);
  --bg-card: #18212d;
  --bg-card-strong: #1d2735;
  --bg-input: #1b2633;
  --bg-chat-in: #202b39;
  --bg-chat-out: linear-gradient(135deg, #3fcac5, #2b98c0);
  --text-main: #f1f5f9;
  --text-soft: #b5c0ca;
  --text-faint: #80909d;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(63, 202, 197, 0.32);
  --shadow: 0 20px 54px rgba(0, 0, 0, 0.3);
}

:root[data-theme='sand'] {
  --bg-base: #f7f1e8;
  --bg-glass: rgba(255, 251, 244, 0.94);
  --bg-card: #fffaf2;
  --bg-card-strong: #f3ead8;
  --bg-input: #f1e8d9;
  --bg-chat-in: #fffaf2;
  --bg-chat-out: linear-gradient(135deg, #74d8b6, #52b59f);
  --text-main: #4f4032;
  --text-soft: #7c6b5b;
  --text-faint: #a49381;
  --line: rgba(102, 76, 46, 0.12);
  --line-strong: rgba(82, 181, 159, 0.28);
}

html,
body {
  height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(91, 201, 209, 0.14), transparent 24%),
    radial-gradient(circle at bottom right, rgba(90, 175, 230, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg-base), #ebf1f7 100%);
  color: var(--text-main);
  overflow: hidden;
}

.compact-auth {
  width: min(440px, 100%);
  grid-template-columns: minmax(0, 1fr);
}

.auth-center-card {
  gap: 18px;
}

.auth-logo {
  width: min(250px, 100%);
  margin: 0 auto 6px;
}

.auth-card.form-card {
  display: grid;
  gap: 18px;
}

.auth-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.auth-tab {
  padding: 10px 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
}

.auth-tab.active {
  background: var(--accent-ghost);
  color: var(--text-main);
  border: 1px solid var(--line-strong);
}

.field-hint {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
}

.auth-forms {
  display: grid;
}

.auth-form-panel {
  display: grid;
}

.composer-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-input {
  display: none;
}

.attachment-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
}

.attachment-preview-chip strong {
  display: block;
  font-size: 13px;
}

.attachment-preview-chip small {
  color: var(--text-faint);
}

.attachment-preview-remove {
  padding: 6px 10px;
}

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

.attachment-card {
  display: block;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.image-card {
  padding: 0;
}

.message-image,
.message-video {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 320px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.18);
}

.message-audio {
  display: block;
  width: min(320px, 100%);
}

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}

.expired-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.attachment-icon {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--accent-ghost);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
}

.attachment-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.attachment-copy small {
  color: var(--text-faint);
}

.call-participants {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
}

.call-participant {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text-soft);
}

.call-participant strong {
  color: var(--text-main);
}

.app-shell {
  grid-template-columns: 310px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  align-items: stretch;
}

.sidebar,
.chat-pane,
.modal-card,
.call-card {
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
}

.sidebar,
.chat-pane {
  min-width: 0;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100vh - 28px);
  min-height: 0;
}

.sidebar > :not(.chat-list) {
  flex: 0 0 auto;
}

.profile-card {
  background: var(--bg-card);
}

.profile-actions {
  display: grid;
  gap: 8px;
}

.primary-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.secondary-actions {
  grid-template-columns: 1fr;
  margin-top: 2px;
}

.profile-actions .ghost-btn,
.toolbar .solid-btn,
.toolbar .ghost-btn,
.search-block .small-btn {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.toolbar,
.search-block,
.filter-bar,
.chat-list {
  margin-top: 12px;
}

.toolbar {
  gap: 8px;
}

.search-block {
  gap: 8px;
}

.search-block input {
  min-height: 40px;
  padding: 10px 12px;
}

.filter-bar {
  gap: 6px;
}

.filter-chip {
  padding: 8px 12px;
}

.chat-row {
  gap: 12px;
  padding: 11px 12px;
  border-radius: 16px;
}

.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(46, 186, 190, 0.14);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.chat-list {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  padding-right: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 28px);
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  padding: 18px 22px;
  background: transparent;
}

.header-actions {
  flex-wrap: wrap;
}

.chat-info-drawer {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 18;
  width: min(320px, calc(100vw - 42px));
  border-radius: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.chat-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-info-body {
  display: grid;
  gap: 12px;
  max-height: 65vh;
  overflow-y: auto;
}

.info-card {
  padding: 14px 15px;
  border-radius: 18px;
  background: var(--bg-card-strong);
  border: 1px solid var(--line);
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-soft);
}

.info-row strong,
.info-card strong {
  color: var(--text-main);
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: inherit;
}

.reply-bar,
.typing-indicator {
  margin: 0 22px;
}

.message-list {
  flex: 1 1 auto;
  padding: 18px 22px 10px;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

.message-card {
  position: relative;
  display: inline-grid;
  width: fit-content;
  max-width: min(390px, 62%);
  min-width: 0;
  padding: 5px 8px 5px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(43, 77, 98, 0.05);
  justify-self: start;
}

.message-card.incoming {
  background: var(--bg-chat-in);
}

.message-card.outgoing {
  background: var(--bg-chat-out);
  color: #083638;
  justify-self: end;
}

.message-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 12px;
  line-height: 1.2;
}

.message-meta.compact {
  justify-content: flex-end;
}

.message-author {
  padding: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-align: left;
}

.message-time {
  opacity: 0.8;
}

.message-body {
  line-height: 1.34;
  word-break: break-word;
}

.message-body a {
  color: #1c6cd3;
  text-decoration: none;
  font-weight: 700;
}

.message-body a:hover {
  text-decoration: underline;
}

.message-body .rich-mention {
  display: inline-flex;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(28, 108, 211, 0.12);
  color: #1c6cd3;
  font-weight: 700;
}

.message-menu-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  opacity: 0;
}

.message-menu-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.message-context-menu {
  position: absolute;
  min-width: 210px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  box-shadow: 0 18px 42px rgba(41, 75, 102, 0.16);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.message-context-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  text-align: left;
}

.message-context-item:hover {
  background: var(--accent-ghost);
}

.message-context-item.danger {
  color: var(--danger);
}

.message-card:hover .message-menu-btn,
.message-menu-btn:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .message-menu-btn {
    opacity: 1;
  }
}

.reaction-row {
  margin-top: 7px;
}

.reaction-chip {
  background: var(--bg-card-strong);
  border: 1px solid var(--line);
  padding: 6px 10px;
  color: inherit;
}

.composer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

.composer-row {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  min-height: 52px;
  max-height: 180px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg-input);
}

.icon-btn,
.send-btn,
.small-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-main);
}

.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  border: 0;
}

.emoji-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 54px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 252px;
  padding: 12px;
  border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.emoji-option {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-card-strong);
}

.composer-hint {
  margin-top: 8px;
  color: var(--text-faint);
  font-size: 12px;
}

.attachment-card {
  background: var(--bg-card-strong);
  border-color: var(--line);
}

.attachment-card.expired {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.7);
}

.avatar-badge[data-avatar-tone='lime'],
.avatar-frame[data-avatar-tone='lime'] {
  background: linear-gradient(135deg, #b7ef6f, #62c95f);
  color: #183c15;
}

.avatar-badge[data-avatar-tone='red'],
.avatar-frame[data-avatar-tone='red'] {
  background: linear-gradient(135deg, #ff9896, #e35f6f);
  color: #4b131e;
}

.avatar-badge[data-avatar-tone='yellow'],
.avatar-frame[data-avatar-tone='yellow'] {
  background: linear-gradient(135deg, #ffe586, #ffc94d);
  color: #5f4300;
}

.avatar-badge[data-avatar-tone='orange'],
.avatar-frame[data-avatar-tone='orange'] {
  background: linear-gradient(135deg, #ffc48a, #ff9354);
  color: #61310c;
}

.avatar-badge[data-avatar-tone='purple'],
.avatar-frame[data-avatar-tone='purple'] {
  background: linear-gradient(135deg, #d1b2ff, #9b6cf2);
  color: #2d1854;
}

.avatar-badge[data-avatar-tone='blue'],
.avatar-frame[data-avatar-tone='blue'] {
  background: linear-gradient(135deg, #9cd3ff, #4e8fff);
  color: #0c2d61;
}

.notes-row .chat-copy {
  gap: 0;
}

.notes-row {
  grid-template-columns: 56px minmax(0, 1fr);
}

.notes-row .chat-headline {
  align-items: center;
}

.notes-row .chat-headline small,
.notes-row .chat-flags {
  display: none;
}

.notes-row .avatar-frame {
  font-size: 18px;
}

.chat-headline,
.chat-copy,
.chat-title,
.result-title,
.result-subtitle {
  min-width: 0;
}

.chat-headline strong,
.result-row strong,
.result-row span {
  display: block;
}

.chat-headline small {
  flex: 0 0 auto;
}

.chat-title {
  font-size: 15px;
}

.chat-subline {
  min-width: 0;
}

.message-status {
  margin-top: 7px;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  opacity: 0.8;
}

[data-overflow-hover] {
  overflow: hidden;
}

.overflow-shell {
  display: block;
  overflow: hidden;
  width: 100%;
}

.overflow-text {
  display: inline-block;
  white-space: nowrap;
  min-width: 100%;
  will-change: transform;
}

[data-overflow-hover].is-overflowing:hover .overflow-text {
  animation: overflow-marquee 2.8s ease-in-out infinite alternate;
}

@keyframes overflow-marquee {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(var(--overflow-shift, 0px) * -1));
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: auto;
  }

  .chat-pane {
    height: calc(100vh - 14px);
  }

  .sidebar {
    height: auto;
  }

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

  .composer-row {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .message-image,
  .message-video,
  .message-audio {
    max-width: 100%;
  }
}
