:root {
  --bg-app: #0f1722;
  --bg-sidebar: #17212b;
  --bg-sidebar-soft: #202b36;
  --bg-chat: #d7e4ef;
  --bg-chat-pattern: rgba(72, 113, 153, 0.07);
  --panel: rgba(255, 255, 255, 0.98);
  --line: rgba(15, 23, 34, 0.08);
  --ink: #1d2733;
  --muted: #708499;
  --accent: #3390ec;
  --accent-strong: #2481db;
  --accent-soft: #dceeff;
  --bubble-own: #e9f7d9;
  --bubble-other: #ffffff;
  --bubble-status: #fff4cf;
  --success: #27946a;
  --warning: #ca8a1d;
  --danger: #cb4f4f;
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow: 0 16px 36px rgba(15, 23, 34, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Aptos", "Segoe UI Variable Text", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, #15212d 0%, #0f1722 100%);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
video {
  display: block;
  max-width: 100%;
}

code {
  font-family: "Cascadia Code", "Consolas", monospace;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  background: linear-gradient(180deg, var(--bg-sidebar), #131c26);
  color: #f3f7fb;
  padding: 14px 12px;
  display: grid;
  gap: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 2px;
}

.brand-mark,
.room-avatar,
.self-avatar,
.message-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}

.brand-mark {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #59b1ff, #2481db);
  color: white;
  box-shadow: 0 10px 24px rgba(51, 144, 236, 0.28);
}

.sidebar-kicker,
.section-label,
.side-note {
  margin: 0;
  color: rgba(243, 247, 251, 0.72);
}

.sidebar h1 {
  margin: 2px 0 0;
  font-size: 1.5rem;
}

.panel {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.profile-card,
.search-card,
.room-list,
.network-card,
.presence-card {
  background: rgba(32, 43, 54, 0.96);
  padding: 14px;
}

.search-card {
  position: relative;
}

.search-card::before {
  content: "\1F50D";
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(243, 247, 251, 0.42);
  font-size: 1rem;
  pointer-events: none;
}

.search-card input {
  background: rgba(255, 255, 255, 0.08);
  padding-left: 42px;
}

.profile-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
}

.self-avatar {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #48a1ff, #8860ff);
  color: white;
  font-size: 1.15rem;
}

.profile-fields {
  display: grid;
  gap: 12px;
}

.auth-card,
.auth-form,
.account-card,
.account-primary {
  display: grid;
  gap: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.auth-tab {
  border: 0;
  border-radius: 999px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(243, 247, 251, 0.88);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
}

.account-primary strong {
  color: white;
  font-size: 1rem;
}

.account-login {
  color: rgba(243, 247, 251, 0.72);
  font-size: 0.92rem;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 0.88rem;
  color: rgba(243, 247, 251, 0.74);
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 15, 24, 0.3);
  color: #f3f7fb;
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(243, 247, 251, 0.48);
}

input:focus,
textarea:focus {
  border-color: rgba(78, 164, 246, 0.8);
  box-shadow: 0 0 0 3px rgba(78, 164, 246, 0.18);
}

.primary-button,
.send-button,
.icon-button,
.ghost-button,
.install-hint {
  border: 0;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.primary-button,
.send-button {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.primary-button:hover,
.send-button:hover,
.icon-button:hover,
.ghost-button:hover,
.install-hint:hover {
  transform: translateY(-1px);
}

.notice {
  margin-top: 14px;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.94rem;
  line-height: 1.45;
}

.notice.info {
  background: rgba(63, 138, 224, 0.18);
  color: #dbeeff;
}

.notice.success {
  background: rgba(39, 148, 106, 0.2);
  color: #c6f6e5;
}

.notice.warning {
  background: rgba(202, 138, 29, 0.18);
  color: #fde68a;
}

.notice.error {
  background: rgba(203, 79, 79, 0.18);
  color: #fecaca;
}

.room-list {
  padding-bottom: 8px;
}

.room-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
}

.room-card:hover,
.room-card.active {
  background: linear-gradient(180deg, rgba(51, 144, 236, 0.22), rgba(51, 144, 236, 0.12));
  border-color: rgba(112, 186, 255, 0.28);
  transform: translateY(-1px);
}

.room-avatar {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #56a8ff, #2481db);
  color: white;
  font-size: 0.95rem;
}

.room-avatar.large {
  width: 54px;
  height: 54px;
  font-size: 1.15rem;
}

.room-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  color: white;
}

.room-time,
.room-snippet,
.side-note,
.muted-line {
  font-size: 0.9rem;
}

.room-snippet {
  margin: 6px 0 0;
  color: rgba(243, 247, 251, 0.76);
  line-height: 1.4;
}

.share-list,
.presence-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.share-list {
  display: grid;
  gap: 10px;
}

.share-item {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 11px 12px;
  line-height: 1.4;
  word-break: break-word;
}

.side-note {
  margin-top: 12px;
  line-height: 1.45;
}

.presence-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.member-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(78, 164, 246, 0.18);
  color: white;
  font-weight: 700;
}

.presence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.presence-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 0.92rem;
}

.presence-pill.muted {
  color: rgba(243, 247, 251, 0.68);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  min-height: 100vh;
  background:
    radial-gradient(circle at 24px 24px, var(--bg-chat-pattern) 1.5px, transparent 0) 0 0 / 36px 36px,
    linear-gradient(180deg, #dce8f2 0%, #cfdfea 100%);
  padding: 0;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-topbar,
.composer-media,
.recording-panel,
.message-form {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(14px);
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 0;
  border-bottom: 1px solid rgba(15, 23, 34, 0.08);
  box-shadow: 0 6px 16px rgba(15, 23, 34, 0.06);
}

.chat-title-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-topbar h2 {
  margin: 0;
  font-size: 1.3rem;
}

.chat-topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.connection-badge,
.install-hint {
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.92rem;
}

.connection-badge.online {
  background: rgba(39, 148, 106, 0.14);
  color: var(--success);
}

.connection-badge.offline {
  background: rgba(203, 79, 79, 0.14);
  color: var(--danger);
}

.install-hint {
  background: rgba(51, 144, 236, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
}

.messages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 14px;
  min-height: 0;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.system-line {
  align-self: center;
  max-width: min(580px, 100%);
  background: rgba(23, 33, 43, 0.24);
  color: white;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  backdrop-filter: blur(6px);
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.message-row.own {
  justify-content: flex-end;
}

.message-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #56a8ff, #2481db);
  color: white;
  flex: none;
}

.message-bubble {
  max-width: min(680px, 82%);
  background: var(--bubble-other);
  border-radius: 18px 18px 18px 8px;
  padding: 10px 12px 8px;
  box-shadow: 0 8px 20px rgba(15, 36, 58, 0.09);
}

.message-row.own .message-bubble {
  background: var(--bubble-own);
  border-radius: 18px 18px 8px 18px;
}

.message-row.status .message-bubble {
  background: var(--bubble-status);
}

.message-author {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.95rem;
}

.message-text {
  margin: 0;
  line-height: 1.48;
  white-space: normal;
  overflow-wrap: anywhere;
}

.message-footer {
  margin-top: 6px;
  text-align: right;
  color: var(--muted);
  font-size: 0.8rem;
}

.message-image,
.message-video,
.composer-preview-image,
.composer-preview-video {
  width: min(360px, 100%);
  border-radius: 18px;
  overflow: hidden;
  background: #0c131b;
}

.message-image,
.composer-preview-image {
  object-fit: cover;
}

.video-note {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  background: #0c131b;
}

.composer-media,
.recording-panel,
.message-form {
  padding: 12px 14px;
  border-radius: 0;
  border-top: 1px solid rgba(15, 23, 34, 0.08);
}

.composer-media,
.recording-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.media-preview {
  flex: none;
}

.media-meta {
  display: grid;
  gap: 10px;
}

.media-caption,
.recording-copy p {
  margin: 0;
  color: var(--muted);
}

.ghost-button {
  justify-self: start;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(14, 22, 33, 0.06);
  color: var(--ink);
}

.profile-card .ghost-button {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.recording-copy {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recording-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.16);
}

.recording-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: #0c131b;
}

.message-form {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  box-shadow: 0 -8px 20px rgba(15, 23, 34, 0.05);
}

.icon-button,
.send-button {
  min-height: 48px;
}

.icon-button {
  width: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(51, 144, 236, 0.12);
  color: var(--accent-strong);
  font-size: 1.2rem;
}

.icon-button.recording {
  background: rgba(239, 68, 68, 0.14);
  color: #b91c1c;
}

.composer-field {
  display: block;
}

.message-form textarea {
  min-height: 48px;
  max-height: 180px;
  resize: none;
  background: rgba(15, 23, 34, 0.04);
  color: var(--ink);
  border-color: rgba(14, 22, 33, 0.08);
  border-radius: 24px;
  padding-top: 13px;
  padding-bottom: 13px;
}

.message-form textarea::placeholder {
  color: var(--muted);
}

button:disabled,
textarea:disabled,
input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.send-button {
  width: 48px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-size: 1.08rem;
  box-shadow: 0 10px 22px rgba(51, 144, 236, 0.26);
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .chat-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .sidebar {
    padding: 14px;
  }

  .chat-panel {
    padding: 0;
  }

  .chat-topbar,
  .composer-media,
  .recording-panel,
  .message-form {
    border-radius: 0;
  }

  .chat-topbar,
  .composer-media,
  .recording-panel {
    flex-direction: column;
    align-items: stretch;
  }

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

  .video-note,
  .recording-preview {
    width: 180px;
    height: 180px;
  }
}
