:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --bg: #0b0d12;
  --panel: #0f1320;
  --panel2: #0b0f1b;
  --border: #1e2430;
  --text: #e6e8ef;
  --muted: #b7c0d6;
  --accent: #4f7cff;
  --accent2: #2f5bff;
  --danger: #ff4772;
  --dangerBg: rgba(255, 71, 114, 0.12);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rowWrap {
  flex-wrap: wrap;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px;
}

.topTitle {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.appName {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
}

.cardInner {
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  padding: 12px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 720px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btnPrimary {
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-color: rgba(79, 124, 255, 0.5);
}

.btnPrimary:hover {
  background: linear-gradient(180deg, #6b8eff, var(--accent2));
}

.btnGhost {
  background: transparent;
}

.btnDanger {
  background: var(--dangerBg);
  border-color: rgba(255, 71, 114, 0.35);
  color: #ffd2dc;
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
}

.textarea {
  resize: vertical;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}

.tabActive {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin: 12px 12px 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.bannerError {
  border-color: rgba(255, 71, 114, 0.35);
  background: var(--dangerBg);
}

.bannerText {
  font-size: 13px;
  line-height: 1.3;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modalCard {
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 6px 12px;
  position: sticky;
  top: 0;
  background: rgba(15, 19, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.modalTitle {
  font-weight: 700;
}

.modalBody {
  padding: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.toggle {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toggleLabel {
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}

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

.tag {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--muted);
}

.linkBtn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}

.spacer {
  flex: 1;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 19, 32, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.sidebar,
.main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.main {
  overflow: hidden;
}

.sidebar {
  overflow: auto;
  padding-bottom: 12px;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebarHidden {
    display: none;
  }
  .mainHidden {
    display: none;
  }
}

.convItem {
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  color: var(--text);
}

.convActive {
  border-color: rgba(79, 124, 255, 0.5);
  background: rgba(79, 124, 255, 0.08);
}

.convTitle {
  font-weight: 650;
}

.convMeta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.convId {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.9;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.chatHeader {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
}

.chatTitle {
  font-weight: 700;
  font-size: 15px;
}

.chatBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.messageList {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: var(--radius);
  padding: 12px;
}

.messageRow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.messageMine {
  align-items: flex-end;
}

.messageMeta {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.messageSender {
  font-size: 13px;
  font-weight: 650;
}

.messageTime {
  font-size: 11px;
  color: var(--muted);
}

.messageBubble {
  max-width: min(760px, 100%);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 10px 11px;
}

.messageMine .messageBubble {
  background: rgba(79, 124, 255, 0.11);
  border-color: rgba(79, 124, 255, 0.35);
}

.messageText {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.35;
}

.messageDeleted {
  opacity: 0.7;
}

.messageActions {
  width: 100%;
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reactionChip,
.reactionAdd {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.reactionMine {
  border-color: rgba(79, 124, 255, 0.5);
  background: rgba(79, 124, 255, 0.1);
}

.reactionCount {
  color: var(--muted);
}

.composer {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px;
}

.composerRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

@media (max-width: 720px) {
  .composerRow {
    grid-template-columns: 1fr;
  }
}

.composerButtons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.uploadBar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  margin-bottom: 10px;
}

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

.attachment {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachmentImageBtn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.attachmentImage {
  display: block;
  max-width: min(360px, 80vw);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.attachmentAudio {
  width: min(420px, 82vw);
}

.attachmentFile {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.attachmentFileMeta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attachmentFileName {
  font-weight: 650;
}

.imagePreview {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(720px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 19, 32, 0.95);
  backdrop-filter: blur(10px);
  font-size: 13px;
  color: var(--text);
  text-align: center;
}
