/* ==========================================================================
   NB聊天室
   Mobile-first styling, light + dark, no external assets.
   ========================================================================== */

:root {
  --bg: #f6f6fa;
  --surface: #ffffff;
  --surface-2: #fafafd;
  --surface-3: #f0f0f6;
  --border: #e7e7ef;
  --border-strong: #d8d8e4;
  --text: #131319;
  --text-soft: #43434f;
  --muted: #737388;
  --accent: #4f5bd5;
  --accent-2: #8b5cf6;
  --accent-soft: #eeefff;
  --accent-text: #4650c8;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --danger: #d83f4d;
  --danger-soft: #fdeef0;
  --ok: #17a673;
  --shadow-xs: 0 1px 2px rgba(17, 19, 32, 0.05);
  --shadow-sm: 0 2px 6px rgba(17, 19, 32, 0.06), 0 1px 2px rgba(17, 19, 32, 0.04);
  --shadow-md: 0 8px 24px rgba(17, 19, 32, 0.09), 0 2px 6px rgba(17, 19, 32, 0.04);
  --shadow-lg: 0 28px 64px rgba(17, 19, 32, 0.16), 0 4px 12px rgba(17, 19, 32, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 272px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c11;
    --surface: #12141b;
    --surface-2: #171a23;
    --surface-3: #1e222d;
    --border: #232833;
    --border-strong: #313848;
    --text: #eceef4;
    --text-soft: #bcbfcd;
    --muted: #7e8598;
    --accent: #7b84ff;
    --accent-2: #a78bfa;
    --accent-soft: #1a1e3a;
    --accent-text: #a8afff;
    --danger: #ff6b74;
    --danger-soft: #2b191d;
    --ok: #3ecf8e;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 26px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.65), 0 2px 10px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

input,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
  background-clip: content-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.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;
}

/* --------------------------------------------------------------------------
   Boot splash
   -------------------------------------------------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.boot.hide {
  opacity: 0;
  visibility: hidden;
}

.boot-mark {
  width: 56px;
  height: 56px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 26px rgba(79, 91, 213, 0.32);
  animation: breathe 1.9s ease-in-out infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.92;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Auth
   -------------------------------------------------------------------------- */

.auth {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  overflow-y: auto;
  isolation: isolate;
}

.auth-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  z-index: -1;
  pointer-events: none;
}

.auth-glow-a {
  width: 420px;
  height: 420px;
  top: -140px;
  left: -100px;
  background: radial-gradient(circle, rgba(79, 91, 213, 0.42), transparent 68%);
}

.auth-glow-b {
  width: 460px;
  height: 460px;
  bottom: -180px;
  right: -120px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.36), transparent 68%);
}

@media (prefers-color-scheme: dark) {
  .auth-glow {
    opacity: 0.4;
  }
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 34px 28px 26px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
}

.auth-brand {
  text-align: center;
  margin-bottom: 26px;
}

.auth-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 24px rgba(79, 91, 213, 0.3);
}

.auth-brand h1 {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.65;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  margin-top: 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--grad);
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px rgba(79, 91, 213, 0.26);
  transition: transform 0.12s, box-shadow 0.16s, filter 0.16s;
}

.btn-primary:hover {
  filter: brightness(1.07);
  box-shadow: 0 10px 26px rgba(79, 91, 213, 0.34);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.996);
}

.btn-primary[disabled] {
  opacity: 0.62;
  cursor: progress;
  box-shadow: none;
}

.form-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 13px;
  border-radius: 9px;
}

.auth-switch {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  padding: 0 2px;
  color: var(--accent-text);
  font-weight: 650;
}

.link-btn:hover {
  text-decoration: underline;
}

.auth-foot {
  margin: 22px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.75;
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
}

.scrim {
  display: none;
}

/* --- sidebar ------------------------------------------------------------ */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
  z-index: 20;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 58px;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 4px 10px rgba(79, 91, 213, 0.28);
  flex: none;
}

.brand-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 14px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 9px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label .count {
  font-weight: 600;
  letter-spacing: 0;
  opacity: 0.75;
}

.channel-list,
.member-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.channel {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}

.channel .hash {
  color: var(--muted);
  font-weight: 600;
  width: 11px;
  flex: none;
  text-align: center;
  opacity: 0.8;
}

.channel:hover {
  background: var(--surface-3);
  color: var(--text);
}

.channel.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 650;
}

.channel.active .hash {
  color: var(--accent-text);
}

.channel .unread {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: auto;
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
}

.member-avatar {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  flex: none;
}

.member.me .member-avatar {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent);
}

.member .you-tag {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  flex: none;
  min-height: 54px;
}

.foot-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex: none;
  box-shadow: var(--shadow-xs);
}

.foot-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.foot-meta strong {
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foot-meta span {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent);
  transition: background 0.2s, box-shadow 0.2s;
}

.conn-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

/* --- chat --------------------------------------------------------------- */

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 62px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex: none;
  z-index: 4;
}

.chat-head-text {
  min-width: 0;
  flex: 1;
}

.chat-head-text h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head-text p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.head-badge {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: none;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
  background: var(--grad);
  opacity: 0.9;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 18px 22px 6px;
  min-height: 0;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.message-list {
  display: flex;
  flex-direction: column;
}

.msg {
  display: flex;
  gap: 11px;
  padding: 3px 10px 3px 8px;
  border-radius: 11px;
  transition: background 0.12s;
  animation: msg-in 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

.msg:hover {
  background: color-mix(in srgb, var(--surface) 62%, transparent);
}

.msg.gap {
  margin-top: 13px;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  flex: none;
  margin-top: 2px;
  user-select: none;
}

.msg.grouped .msg-avatar {
  visibility: hidden;
  height: 0;
  margin: 0;
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 1px;
}

.msg-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
}

.msg.self .msg-name {
  color: var(--accent-text);
}

.msg-time {
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s;
  font-variant-numeric: tabular-nums;
}

.msg:hover .msg-time {
  opacity: 1;
}

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.62;
}

.msg.self .msg-text {
  color: var(--text);
}

.day-split {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.day-split::before,
.day-split::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.day-split:first-child {
  margin-top: 0;
}

.load-more {
  display: block;
  margin: 0 auto 14px;
  padding: 7px 15px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  box-shadow: var(--shadow-xs);
  transition: color 0.15s, border-color 0.15s;
}

.load-more:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 56px 24px 40px;
  text-align: center;
  animation: rise 0.4s ease-out;
}

.empty-art {
  width: 62px;
  height: 62px;
  color: var(--border-strong);
  stroke-width: 2.4;
  margin-bottom: 10px;
}

.empty-hint p {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text-soft);
}

.empty-hint span {
  font-size: 13px;
  color: var(--muted);
}

.typing-line {
  height: 21px;
  padding: 0 30px;
  font-size: 11.5px;
  color: var(--muted);
  flex: none;
  opacity: 0;
  transition: opacity 0.2s;
  font-style: italic;
}

.typing-line.show {
  opacity: 1;
}

/* --- composer ----------------------------------------------------------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 22px 18px;
  padding: 7px 7px 7px 15px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 19px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, box-shadow 0.18s;
  flex: none;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong));
  box-shadow: 0 0 0 3.5px var(--accent-soft), var(--shadow-sm);
}

.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  padding: 7px 0;
  max-height: 160px;
  line-height: 1.55;
  font-size: 14.5px;
}

.composer textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  border: none;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  flex: none;
  box-shadow: 0 4px 12px rgba(79, 91, 213, 0.26);
  transition: transform 0.12s, opacity 0.16s, filter 0.16s;
}

.send-btn svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.send-btn:hover {
  filter: brightness(1.08);
}

.send-btn:active {
  transform: scale(0.93);
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: default;
  filter: grayscale(0.5);
  box-shadow: none;
}

.new-pill {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: var(--shadow-md);
  z-index: 5;
  animation: rise 0.2s ease-out;
}

/* --------------------------------------------------------------------------
   Icon buttons
   -------------------------------------------------------------------------- */

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
  transition: background 0.14s, color 0.14s;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.tiny {
  width: 24px;
  height: 24px;
}

.icon-btn.tiny svg {
  width: 14px;
  height: 14px;
}

.mobile-only {
  display: none;
}

/* --------------------------------------------------------------------------
   Settings dialog
   -------------------------------------------------------------------------- */

.dialog-wrap {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.44);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  animation: fade 0.18s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.dialog {
  width: 100%;
  max-width: 480px;
  max-height: 84dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.26s cubic-bezier(0.2, 0.8, 0.3, 1);
  overflow: hidden;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 14px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.dialog-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.dialog-body {
  overflow-y: auto;
  padding: 2px 20px 16px;
  -webkit-overflow-scrolling: touch;
}

.dialog-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex: none;
}

.panel {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.panel:last-child {
  border-bottom: none;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 13.5px;
}

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

.kv code {
  font-family: var(--mono);
  font-size: 12.5px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.inline-form input {
  flex: 1 1 140px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 13.5px;
}

.inline-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-ghost {
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s;
}

.btn-ghost:hover {
  background: var(--surface-3);
  border-color: var(--muted);
}

.btn-danger-ghost {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.invite-list,
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.invite-row,
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
}

.invite-code {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  flex: none;
}

.badge {
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  margin-left: auto;
  flex: none;
}

.badge.used {
  background: transparent;
  opacity: 0.7;
}

.row-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.admin-row .badge {
  margin-left: 0;
}

.mini-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 7px;
}

.mini-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.mini-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 19px;
  border-radius: 99px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  animation: rise 0.2s ease-out;
  max-width: 84vw;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Touch devices: no hover affordances, always show timestamps
   -------------------------------------------------------------------------- */

@media (hover: none) {
  .msg:hover {
    background: transparent;
  }
  .msg-time {
    opacity: 0.75;
  }
  .msg.grouped .msg-time {
    opacity: 0;
  }
  .channel:hover,
  .icon-btn:hover {
    background: transparent;
    color: var(--muted);
  }
}

/* --------------------------------------------------------------------------
   Tablet / mobile
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .messages {
    padding: 14px 12px 4px;
  }
}

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

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 84vw;
    max-width: 310px;
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.22, 0.8, 0.3, 1);
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .app.nav-open .sidebar {
    transform: translateX(0);
  }

  .app.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 16, 0.42);
    backdrop-filter: blur(1.5px);
    z-index: 15;
    animation: fade 0.2s;
  }

  .mobile-only {
    display: grid;
  }

  .head-badge {
    display: grid;
  }

  .chat-head {
    height: 56px;
    padding: 0 8px 0 6px;
    gap: 2px;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(56px + env(safe-area-inset-top, 0px));
  }

  .chat-head-text h2 {
    font-size: 15px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .messages {
    padding: 10px 8px 2px;
  }

  .msg {
    padding: 3px 8px 3px 6px;
    gap: 9px;
  }

  .msg-text {
    font-size: 15px;
    line-height: 1.58;
  }

  .msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 12.5px;
  }

  .msg.gap {
    margin-top: 11px;
  }

  .composer {
    margin: 0 10px calc(8px + env(safe-area-inset-bottom, 0px));
    padding: 6px 6px 6px 14px;
    border-radius: 20px;
    gap: 6px;
  }

  .composer textarea {
    /* 16px keeps iOS Safari from zooming the page on focus. */
    font-size: 16px;
    padding: 8px 0;
  }

  .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .send-btn svg {
    width: 18px;
    height: 18px;
  }

  .typing-line {
    padding: 0 20px;
  }

  .new-pill {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }

  .auth-card {
    padding: 28px 22px 22px;
    border-radius: 20px;
  }

  .dialog-wrap {
    padding: 0;
    align-items: flex-end;
  }

  .dialog {
    max-width: none;
    max-height: 88dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    animation: sheet-up 0.28s cubic-bezier(0.22, 0.8, 0.3, 1);
  }

  .dialog-body {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .dialog-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .dialog-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: var(--border-strong);
  }

  .dialog-head {
    position: relative;
    padding-top: 22px;
  }
}

@keyframes sheet-up {
  from {
    opacity: 0.6;
    transform: translateY(24px);
  }
}

@media (max-width: 380px) {
  .msg-text {
    font-size: 14.5px;
  }

  .brand-name {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .messages {
    scroll-behavior: auto;
  }
}
