/* ==========================================================================
   ChiChat · 茗獻
   现代即时通讯界面 · 参考 茗獻和談社 / 茗獻主题
   ========================================================================== */

:root {
  --ink: #0f172a;
  --ink-2: #1e293b;
  --tea: #2f6f5e;
  --tea-soft: #3f8a74;
  --paper: #f7f9fc;
  --paper-raised: #ffffff;
  --paper-deep: #eef2f7;
  --text: #111827;
  --text-soft: #4b5563;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --gold: #2f6f5e;
  --gold-deep: #245a4b;
  --gold-soft: rgba(47, 111, 94, 0.1);
  --cinnabar: #dc2626;
  --cinnabar-soft: rgba(220, 38, 38, 0.09);
  --peer: #ffffff;
  --peer-text: #111827;
  --own: #2f6f5e;
  --own-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.16);
  --serif: "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --sans: "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --rail-w: 76px;
  --side-w: 340px;
  --logo-filter: none;
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #0b0f14;
  --ink-2: #151b24;
  --tea: #6fbf9a;
  --tea-soft: #8bd4b0;
  --paper: #0e1116;
  --paper-raised: #151b24;
  --paper-deep: #1b2430;
  --text: #e6e9ef;
  --text-soft: #b3bdca;
  --muted: #8b95a4;
  --muted-2: #6b7686;
  --line: #232a36;
  --line-strong: #30363d;
  --gold: #6fbf9a;
  --gold-deep: #8bd4b0;
  --gold-soft: rgba(111, 191, 154, 0.12);
  --cinnabar: #f87171;
  --cinnabar-soft: rgba(248, 113, 113, 0.12);
  --peer: #1b2430;
  --peer-text: #e6e9ef;
  --own: #2f6f5e;
  --own-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, 0.5);
  --logo-filter: invert(1) brightness(1.05);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  border: 0;
  outline: 0;
  background: none;
}

::selection {
  background: rgba(201, 169, 110, 0.35);
  color: var(--text);
}

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

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

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--line-strong);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
  background-clip: padding-box;
}

/* ---------------------------------------------------------------- boot */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 38%, rgba(79, 122, 99, 0.28), transparent 38%),
    #0e1a15;
  color: #f6f1e4;
  transition: opacity 0.45s var(--ease), visibility 0.45s;
}

.boot-screen.is-done {
  opacity: 0;
  visibility: hidden;
}

.boot-mark {
  width: 78px;
  height: 78px;
  padding: 3px;
  border: 1px solid rgba(201, 169, 110, 0.45);
  border-radius: 22px;
  animation: breathe 2.2s ease-in-out infinite;
}

.boot-mark img {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  display: block;
}

.boot-screen p {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: 0.08em;
}

.boot-screen span {
  color: rgba(246, 241, 228, 0.55);
  font-size: 12px;
  letter-spacing: 0.18em;
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 0 rgba(201, 169, 110, 0);
  }
  50% {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px 0 rgba(201, 169, 110, 0.12);
  }
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--ink);
  color: #f8f2e4;
  box-shadow: 0 8px 20px rgba(20, 33, 27, 0.18);
}

html[data-theme="dark"] .btn-primary {
  background: var(--gold);
  color: #14211b;
  box-shadow: 0 8px 24px rgba(201, 169, 110, 0.12);
}

.btn-primary:hover {
  background: var(--tea);
}

html[data-theme="dark"] .btn-primary:hover {
  background: #e0c791;
}

.btn-ghost {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-soft);
}

.btn-ghost:hover {
  border-color: var(--gold);
  color: var(--text);
  background: var(--gold-soft);
}

.btn-danger {
  border: 1px solid rgba(178, 86, 63, 0.32);
  color: var(--cinnabar);
  background: var(--cinnabar-soft);
}

.btn-danger:hover {
  background: var(--cinnabar);
  color: #fff8f2;
}

.btn-sm {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 9px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
  min-height: 48px;
  border-radius: 13px;
}

.link-btn {
  color: var(--gold-deep);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.link-btn:hover {
  border-bottom-color: currentColor;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.18s, color 0.18s;
}

.icon-btn:hover {
  background: var(--gold-soft);
  color: var(--text);
}

.icon-btn-accent {
  border: 1px solid var(--line);
  color: var(--gold-deep);
  background: var(--gold-soft);
}

/* ---------------------------------------------------------------- auth */
.auth-screen {
  display: grid;
  grid-template-columns: minmax(420px, 1.04fr) minmax(480px, 0.96fr);
  height: 100dvh;
  background: var(--paper);
}

.auth-art {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: clamp(42px, 6vw, 96px);
  color: #f6f1e4;
  background:
    radial-gradient(ellipse at 12% 8%, rgba(201, 169, 110, 0.18), transparent 36%),
    radial-gradient(ellipse at 88% 92%, rgba(79, 122, 99, 0.3), transparent 45%),
    linear-gradient(152deg, #1d3329 0%, #14211b 52%, #0b1510 100%);
}

.auth-art::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(115deg, transparent 0 38px, rgba(201, 169, 110, 0.035) 38px 39px),
    repeating-linear-gradient(25deg, transparent 0 56px, rgba(201, 169, 110, 0.025) 56px 57px);
  pointer-events: none;
}

.auth-art::after {
  content: "茶";
  position: absolute;
  right: -3vw;
  bottom: -12vw;
  font-family: var(--serif);
  font-size: clamp(240px, 34vw, 560px);
  line-height: 1;
  color: rgba(246, 241, 228, 0.028);
  pointer-events: none;
  user-select: none;
}

.auth-art-inner {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.25);
}

.brand-lockup h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.brand-lockup p {
  margin: 2px 0 0;
  color: rgba(246, 241, 228, 0.6);
  font-size: 11px;
  letter-spacing: 0.24em;
}

.brand-lockup-lg .brand-mark {
  width: 62px;
  height: 62px;
}

.auth-verse {
  margin: clamp(52px, 8vh, 94px) 0 0;
  font-family: var(--serif);
  font-size: clamp(38px, 4vw, 58px);
  font-weight: 500;
  line-height: 1.38;
  letter-spacing: 0.06em;
}

.auth-copy {
  margin: 22px 0 0;
  color: rgba(246, 241, 228, 0.62);
  font-size: 14px;
  line-height: 1.95;
  letter-spacing: 0.03em;
}

.auth-features {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 34px;
}

.auth-features span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(246, 241, 228, 0.72);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.auth-features .icon {
  width: 16px;
  height: 16px;
  color: var(--gold);
}

.palette-dots {
  display: flex;
  gap: 6px;
  margin-top: 44px;
}

.palette-dots i {
  width: 18px;
  height: 4px;
  border-radius: 2px;
}

.palette-dots i:nth-child(1) { background: #14211b; border: 1px solid rgba(246, 241, 228, 0.25); }
.palette-dots i:nth-child(2) { background: #335c49; }
.palette-dots i:nth-child(3) { background: #c9a96e; }
.palette-dots i:nth-child(4) { background: #b2563f; }
.palette-dots i:nth-child(5) { background: #f6f1e4; }

.auth-art-foot {
  margin: 18px 0 0;
  color: rgba(246, 241, 228, 0.32);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px clamp(26px, 5vw, 78px);
  background:
    radial-gradient(ellipse at 80% 0%, rgba(201, 169, 110, 0.09), transparent 40%),
    var(--paper);
  overflow-y: auto;
}

.auth-card {
  width: min(410px, 100%);
  padding: 6px 0;
}

.auth-mobile-brand {
  display: none;
}

.auth-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 3vw, 38px);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink);
}

html[data-theme="dark"] .auth-card h2 {
  color: var(--text);
}

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

.auth-tabs {
  display: flex;
  gap: 26px;
  margin: 30px 0 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  position: relative;
  padding: 0 2px 12px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.auth-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
  transition: background 0.2s;
}

.auth-tab.is-active {
  color: var(--text);
}

.auth-tab.is-active::after {
  background: var(--gold);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

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

.field > span {
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--paper-raised);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.field textarea {
  padding: 12px 14px;
  min-height: 84px;
  resize: vertical;
  line-height: 1.6;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted-2);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.field-with-action {
  position: relative;
}

.field-with-action input {
  padding-right: 58px;
}

.field-action {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.field-action:hover {
  color: var(--gold-deep);
}

.server-config {
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--paper-raised) 60%, transparent);
}

.server-config summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  list-style: none;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.server-config summary::-webkit-details-marker {
  display: none;
}

.server-config summary > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.server-config summary .icon {
  width: 15px;
  height: 15px;
  color: var(--gold-deep);
}

.server-summary {
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 400;
}

.server-config-body {
  padding: 4px 13px 13px;
  border-top: 1px solid var(--line);
}

.server-config-body .field {
  margin-top: 11px;
}

.server-config-body .field input {
  min-height: 40px;
  font-size: 12.5px;
}

.server-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
}

.server-status {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.server-status.is-ok {
  color: var(--tea-soft);
}

.server-status.is-bad {
  color: var(--cinnabar);
}

.form-error {
  margin: 0;
  padding: 9px 12px;
  border-left: 2px solid var(--cinnabar);
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
  font-size: 12px;
  line-height: 1.55;
  border-radius: 0 7px 7px 0;
}

.auth-hint {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.auth-version {
  margin: 26px 0 0;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-align: center;
}

/* ---------------------------------------------------------------- app shell */
.app-screen {
  display: grid;
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  background: var(--paper);
  position: relative;
}

/* ---------------------------------------------------------------- rail */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 18px 0 16px;
  background:
    linear-gradient(180deg, rgba(201, 169, 110, 0.09), transparent 28%),
    var(--ink);
  color: rgba(246, 241, 228, 0.52);
  border-right: 1px solid rgba(246, 241, 228, 0.06);
  z-index: 5;
}

.rail-brand {
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
}

.rail-brand img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
}

.rail-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 58px;
  padding: 9px 0 7px;
  border-radius: 13px;
  color: rgba(246, 241, 228, 0.46);
  transition: color 0.18s, background 0.18s;
}

.rail-btn .icon {
  width: 21px;
  height: 21px;
}

.rail-label {
  font-size: 9.5px;
  letter-spacing: 0.06em;
}

.rail-btn:hover {
  color: rgba(246, 241, 228, 0.85);
  background: rgba(246, 241, 228, 0.06);
}

.rail-btn.is-active {
  color: var(--gold);
  background: rgba(201, 169, 110, 0.12);
}

.rail-btn.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 2px;
  height: 22px;
  border-radius: 2px;
  background: var(--gold);
  transform: translateY(-50%);
}

.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.rail-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: rgba(246, 241, 228, 0.5);
}

.rail-theme:hover {
  color: var(--gold);
  background: rgba(246, 241, 228, 0.06);
}

.rail-theme .icon {
  width: 18px;
  height: 18px;
}

.rail-theme .icon-sun { display: none; }
html[data-theme="dark"] .rail-theme .icon-sun { display: block; }
html[data-theme="dark"] .rail-theme .icon-moon { display: none; }

.rail-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(201, 169, 110, 0.32);
  padding: 2px;
}

.rail-avatar .avatar {
  width: 100%;
  height: 100%;
  font-size: 13px;
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--cinnabar);
  color: #fff8f2;
  font-size: 9px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--ink);
}

.nav-badge-dot {
  min-width: 7px;
  width: 7px;
  height: 7px;
  padding: 0;
  border-radius: 50%;
  top: 7px;
  right: 12px;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper-raised);
  border-right: 1px solid var(--line);
  z-index: 4;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 22px 14px;
}

.sidebar-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.sidebar-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 18px 12px;
  padding: 0 11px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--muted);
  transition: border-color 0.18s, background 0.18s;
}

.search-box:focus-within {
  border-color: var(--gold);
  background: var(--paper-raised);
}

.search-box .icon {
  width: 16px;
  height: 16px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--muted-2);
}

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--muted);
}

.search-clear:hover {
  background: var(--line);
  color: var(--text);
}

.search-clear .icon {
  width: 12px;
  height: 12px;
}

.sidebar-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chips {
  display: flex;
  gap: 7px;
  padding: 2px 18px 10px;
}

.chip {
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}

.chip:hover {
  color: var(--text);
}

.chip.is-active {
  border-color: var(--line-strong);
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.conversation-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 9px 16px;
}

.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 11px;
  border-radius: 12px;
  text-align: left;
  transition: background 0.16s;
}

.conv-item:hover {
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}

.conv-item.is-active {
  background: var(--gold-soft);
}

.conv-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 2px;
  border-radius: 2px;
  background: var(--gold);
}

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #fbf8f0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  user-select: none;
  overflow: visible;
}

.avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.avatar .avatar-letter {
  position: relative;
  z-index: 1;
  line-height: 1;
  transform: translateY(-1px);
}

.avatar-md {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 17px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 12px;
}

.avatar-xl {
  width: 92px;
  height: 92px;
  border-radius: 28px;
  font-size: 36px;
}

.avatar .presence-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--paper-raised);
  border-radius: 50%;
  background: var(--muted-2);
  z-index: 2;
}

.avatar .presence-dot.is-online {
  background: #5f9b71;
}

.avatar .group-mark {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 2px solid var(--paper-raised);
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  z-index: 2;
}

.avatar .group-mark .icon {
  width: 9px;
  height: 9px;
  stroke-width: 2.2;
}

.av-0 { background: linear-gradient(145deg, #4f7a63, #2c5140); }
.av-1 { background: linear-gradient(145deg, #d1b47a, #9e7b3e); color: #2a2113; }
.av-2 { background: linear-gradient(145deg, #c0664d, #8e3f31); }
.av-3 { background: linear-gradient(145deg, #93ad98, #5e7a66); }
.av-4 { background: linear-gradient(145deg, #75847b, #47564f); }
.av-5 { background: linear-gradient(145deg, #a07d5c, #6a4f3a); }
.av-6 { background: linear-gradient(145deg, #627486, #3b4b58); }
.av-7 { background: linear-gradient(145deg, #866571, #59414a); }

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

.conv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  overflow: hidden;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-time {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.conv-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.conv-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-preview .prefix {
  color: var(--muted-2);
}

.conv-unread {
  flex: 0 0 auto;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--cinnabar);
  color: #fff8f2;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.conv-pin {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--gold-deep);
  font-size: 9px;
}

.conv-pin .icon {
  width: 10px;
  height: 10px;
}

.list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
}

.list-empty img {
  width: 96px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.list-empty p {
  margin: 0;
  color: var(--text-soft);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.05em;
}

.list-empty span {
  max-width: 220px;
  margin: 5px 0 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.contact-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 9px 16px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 11px;
  text-align: left;
  transition: background 0.16s;
}

.contact-item:hover {
  background: color-mix(in srgb, var(--gold) 8%, transparent);
}

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

.contact-name {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-sub {
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-sub.is-online {
  color: #5f9b71;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 9px 20px 6px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.section-label b {
  color: var(--gold-deep);
  font-size: 9.5px;
}

.request-section {
  margin: 2px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.request-card {
  margin: 0 12px 7px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
}

.request-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.request-text {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.5;
}

.request-text b {
  color: var(--text);
  font-weight: 600;
}

.request-actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
  padding-left: 41px;
}

.request-actions .btn {
  flex: 1;
  min-height: 30px;
  font-size: 11.5px;
}

.connection-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: background 0.2s;
}

.connection-dot.is-online {
  background: #5f9b71;
  box-shadow: 0 0 0 3px rgba(95, 155, 113, 0.12);
}

.connection-dot.is-connecting {
  background: var(--gold);
  animation: pulse-dot 1.4s infinite;
}

.connection-dot.is-offline {
  background: var(--cinnabar);
}

#connection-retry {
  margin-left: auto;
  font-size: 10px;
}

@keyframes pulse-dot {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------------------------------------------------------------- main */
.main {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(201, 169, 110, 0.06), transparent 42%),
    var(--paper);
}

.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 42px;
  overflow-y: auto;
}

.welcome-inner {
  width: min(620px, 100%);
  text-align: center;
}

.welcome-logo {
  width: 84px;
  height: 84px;
  border-radius: 23px;
  box-shadow: 0 18px 40px rgba(20, 33, 27, 0.16);
  margin-bottom: 24px;
}

.welcome h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.welcome h2 span {
  color: var(--tea);
}

html[data-theme="dark"] .welcome h2 span {
  color: var(--gold);
}

.welcome-quote {
  margin: 13px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin: 34px 0 0;
  text-align: left;
}

.quick-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 17px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}

.quick-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
}

.quick-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 9px;
  border-radius: 10px;
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.quick-icon .icon {
  width: 17px;
  height: 17px;
}

.quick-card b {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.quick-card small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.welcome-foot {
  margin: 28px 0 0;
  color: var(--muted-2);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

/* ---------------------------------------------------------------- chat */
.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;
}

.chat.is-dragging::after {
  content: "松手，把图片放进这盏茶里";
  position: absolute;
  inset: 14px;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gold);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  color: var(--gold-deep);
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.08em;
  pointer-events: none;
  backdrop-filter: blur(3px);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
  min-height: 74px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-raised) 78%, transparent);
  backdrop-filter: blur(12px);
  z-index: 3;
}

.chat-back {
  display: none;
}

.chat-title-wrap {
  flex: 1;
  min-width: 0;
}

.chat-title-wrap h2 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title-wrap p {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title-wrap p.is-online {
  color: #5f9b71;
}

.chat-title-wrap p .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.messages-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 27px 20px;
  scroll-behavior: auto;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.load-more {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10.5px;
  background: var(--paper-raised);
}

.load-more:hover {
  color: var(--gold-deep);
  border-color: var(--gold);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 980px;
  margin: 0 auto;
  padding-top: 4px;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: var(--muted-2);
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 2px 0;
  animation: msg-in 0.22s var(--ease);
}

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

.msg.is-own {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 29px;
  height: 29px;
  margin-bottom: 3px;
  border-radius: 9px;
  font-size: 11px;
  visibility: hidden;
}

.msg.is-group-peer .msg-avatar {
  visibility: visible;
}

.msg.is-continuation .msg-avatar {
  visibility: hidden;
}

.msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(72%, 640px);
  min-width: 0;
}

.msg.is-own .msg-body {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 4px 4px;
  color: var(--muted);
  font-size: 9.5px;
}

.msg-meta .sender {
  color: var(--gold-deep);
  font-weight: 600;
}

.msg.is-continuation .msg-meta {
  display: none;
}

.bubble {
  position: relative;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  background: var(--peer);
  color: var(--peer-text);
  font-size: 13.5px;
  line-height: 1.68;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(20, 33, 27, 0.03);
}

.msg.is-own .bubble {
  border-color: transparent;
  border-radius: 14px 4px 14px 14px;
  background: var(--own);
  color: var(--own-text);
}

.msg.is-continuation .bubble {
  border-radius: 14px;
}

.msg.is-own.is-continuation .bubble {
  border-radius: 14px;
}

.bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(201, 169, 110, 0.65);
  text-underline-offset: 2px;
}

.bubble a:hover {
  color: var(--gold);
}

.msg-image {
  display: block;
  width: fit-content;
  max-width: min(340px, 68vw);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(120deg, var(--line), transparent 55%),
    var(--paper-deep);
  cursor: zoom-in;
  overflow: hidden;
  line-height: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.msg.is-own .msg-image {
  border-color: transparent;
}

.msg-image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.msg-image::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  border-radius: inherit;
}

.msg-image.is-uploading img {
  opacity: 0.6;
}

.msg-image.is-uploading::before {
  content: "上传中…";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(20, 33, 27, 0.72);
  color: #f6f1e4;
  font-size: 9px;
  line-height: 16px;
  transform: translate(-50%, -50%);
}

.chat-sticker {
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(20, 33, 27, 0.12));
  user-select: none;
}

.msg.is-pending .chat-sticker {
  opacity: 0.62;
}

.msg.is-failed .msg-image,
.msg.is-failed .chat-sticker {
  outline: 2px solid var(--cinnabar);
  outline-offset: 2px;
}

.lightbox {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 4px;
}

.lightbox img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
}

.msg-time {
  margin: 4px 4px 0;
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.msg-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 9px;
}

.msg-status .icon {
  width: 12px;
  height: 12px;
  color: var(--tea-soft);
}

.msg.is-pending .bubble {
  opacity: 0.7;
}

.msg.is-failed .bubble {
  border: 1px solid var(--cinnabar);
}

.msg-retry {
  margin-top: 3px;
  color: var(--cinnabar);
  font-size: 9.5px;
  font-weight: 600;
}

.msg-system {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.msg-system span {
  max-width: 88%;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  text-align: center;
}

.chat-end {
  height: 4px;
}

.new-msg-pill {
  position: absolute;
  left: 50%;
  bottom: 116px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-raised);
  color: var(--gold-deep);
  font-size: 10.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}

.new-msg-pill .icon {
  width: 12px;
  height: 12px;
}

.typing-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 20px;
  padding: 0 34px;
  color: var(--muted);
  font-size: 10px;
}

.typing-dots {
  display: inline-flex;
  gap: 2px;
}

.typing-dots i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold-deep);
  animation: typing 1.2s infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%,
  60%,
  100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-2px); opacity: 1; }
}

/* ---------------------------------------------------------------- composer */
.composer {
  position: relative;
  flex: 0 0 auto;
  padding: 0 24px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper);
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  max-width: 980px;
  margin: 0 auto;
  padding: 7px 8px 7px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft), var(--shadow-sm);
}

.composer-image,
.composer-emoji {
  width: 34px;
  height: 34px;
  margin-bottom: 2px;
  color: var(--muted);
}

.composer-image .icon,
.composer-emoji .icon {
  width: 18px;
  height: 18px;
}

#message-input {
  flex: 1;
  min-width: 0;
  max-height: 148px;
  min-height: 36px;
  padding: 8px 2px 7px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  resize: none;
  overflow-y: auto;
}

#message-input::placeholder {
  color: var(--muted-2);
  font-size: 12.5px;
}

.char-count {
  align-self: flex-end;
  padding-bottom: 7px;
  color: var(--muted-2);
  font-size: 9px;
  opacity: 0;
  transition: opacity 0.2s;
}

.char-count.is-visible {
  opacity: 1;
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin-bottom: 1px;
  border-radius: 11px;
  background: var(--ink);
  color: #f8f2e4;
  transition: background 0.18s, transform 0.18s, opacity 0.18s;
}

html[data-theme="dark"] .send-btn {
  background: var(--gold);
  color: var(--ink);
}

.send-btn:hover {
  background: var(--tea);
  transform: translateY(-1px);
}

html[data-theme="dark"] .send-btn:hover {
  background: #e1c993;
}

.send-btn .icon {
  width: 17px;
  height: 17px;
}

.send-btn.is-empty {
  opacity: 0.45;
}

.composer-hint {
  max-width: 980px;
  margin: 6px auto 0;
  color: var(--muted-2);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-align: center;
}

.emoji-panel {
  position: absolute;
  left: max(24px, calc(50% - 490px));
  bottom: calc(100% - 2px);
  z-index: 8;
  display: flex;
  flex-direction: column;
  width: 326px;
  max-height: min(430px, 66vh);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.emoji-tabs {
  display: flex;
  gap: 4px;
  padding: 1px 2px 7px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.emoji-tab {
  padding: 4px 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.emoji-tab.is-active {
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: 2px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 72px);
  gap: 7px;
  padding: 3px 3px 5px;
  max-height: 324px;
  overflow-y: auto;
}

.emoji-grid button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 19px;
}

.emoji-grid button:hover {
  background: var(--gold-soft);
  transform: scale(1.12);
}

.sticker-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--paper);
  transition: transform 0.16s var(--ease), border-color 0.16s, background 0.16s;
}

.sticker-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  background: var(--gold-soft);
}

.sticker-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------------------------------------------------------------- contact detail */
.detail-view {
  height: 100%;
  overflow-y: auto;
  padding: 54px 40px;
}

.detail-inner {
  width: min(520px, 100%);
  margin: 0 auto;
  text-align: center;
}

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
}

.profile-hero h2 {
  margin: 20px 0 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.profile-handle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.06em;
}

.profile-online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 9px 0 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-size: 10px;
  font-weight: 600;
}

.profile-online.is-online {
  color: #4f8a61;
  background: rgba(95, 155, 113, 0.1);
}

.profile-bio {
  width: min(400px, 100%);
  margin: 24px auto 0;
  color: var(--text-soft);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.9;
}

.detail-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  background: var(--line);
  text-align: left;
}

.detail-meta div {
  padding: 14px 16px;
  background: var(--paper-raised);
}

.detail-meta span {
  display: block;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.detail-meta b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- members panel */
.members-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(370px, 92vw);
  padding: 22px 20px;
  border-left: 1px solid var(--line);
  background: var(--paper-raised);
  box-shadow: -18px 0 50px rgba(20, 33, 27, 0.12);
  animation: slide-in 0.28s var(--ease);
}

@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}

.members-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.members-panel h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.members-actions {
  display: flex;
  gap: 7px;
  margin: 16px 0 10px;
}

.members-actions .btn {
  flex: 1;
}

.members-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: 4px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
}

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

.member-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.member-name .owner-tag {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.member-sub {
  color: var(--muted);
  font-size: 10px;
}

.member-me {
  color: var(--muted-2);
  font-size: 9.5px;
}

.members-foot {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.members-foot p {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 10px;
}

.members-foot .btn {
  width: 100%;
}

/* ---------------------------------------------------------------- modal */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 18, 13, 0.52);
  backdrop-filter: blur(5px);
  animation: fade 0.22s ease;
}

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

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: min(86dvh, 760px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.28s var(--ease);
  overflow: hidden;
}

.modal.modal-wide {
  width: min(700px, 100%);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 0;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}

.modal-close {
  margin: -4px -6px 0 0;
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 24px 4px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-form .field input {
  min-height: 42px;
  font-size: 13px;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 3px;
  border-bottom: 1px solid var(--line);
}

.search-result:last-child {
  border-bottom: 0;
}

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

.search-result-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.search-result-sub {
  color: var(--muted);
  font-size: 10.5px;
}

.search-result .btn {
  min-width: 82px;
  min-height: 31px;
  font-size: 11px;
}

.modal-empty {
  padding: 26px 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 290px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  cursor: pointer;
}

.check-item:hover {
  background: var(--gold-soft);
}

.check-item input {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--paper-raised);
  position: relative;
}

.check-item input:checked {
  border-color: var(--tea);
  background: var(--tea);
}

.check-item input:checked::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fbf8f0;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.check-item span {
  font-size: 12.5px;
}

.settings-section {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section:first-child {
  padding-top: 0;
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.profile-edit {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-edit .avatar {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  font-size: 22px;
}

.profile-edit-body {
  flex: 1;
}

.profile-edit-body .field input {
  min-height: 38px;
  font-size: 13px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.swatch.is-active {
  border-color: var(--gold);
  transform: scale(1.06);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 0;
}

.setting-row-text b {
  display: block;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.setting-row-text small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10.5px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
}

.segmented button {
  padding: 5px 11px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.segmented button.is-active {
  background: var(--paper-raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--line-strong);
  transition: background 0.2s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffdf7;
  transition: transform 0.2s var(--ease);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.toggle.is-on {
  background: var(--tea);
}

.toggle.is-on::after {
  transform: translateX(18px);
}

.about-card {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
}

.about-card p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.7;
}

.about-card code {
  color: var(--gold-deep);
  font-size: 10px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.mini-palette {
  display: flex;
  gap: 4px;
  margin-top: 9px;
}

.mini-palette i {
  width: 23px;
  height: 5px;
  border-radius: 2px;
}

.server-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 10.5px;
  word-break: break-all;
}

.server-line .connection-dot {
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------- toast */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(420px, 88vw);
  padding: 10px 15px;
  border: 1px solid rgba(201, 169, 110, 0.28);
  border-radius: 11px;
  background: rgba(20, 33, 27, 0.94);
  color: #f6f1e4;
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  animation: toast-in 0.25s var(--ease);
}

.toast.is-leaving {
  animation: toast-out 0.25s ease forwards;
}

.toast .icon {
  width: 15px;
  height: 15px;
  color: var(--gold);
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------------------------------------------------------------- loading / skeleton */
.skeleton-wrap {
  padding: 26px;
}

.skeleton-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  opacity: 0.6;
}

.skeleton {
  border-radius: 9px;
  background: linear-gradient(90deg, var(--line), var(--gold-soft), var(--line));
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to { background-position: -220% 0; }
}

.skeleton-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.skeleton-lines {
  flex: 1;
}

.skeleton-line {
  height: 9px;
  margin: 7px 0;
}

.skeleton-line.short {
  width: 46%;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 1.6px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  :root {
    --side-w: 312px;
  }

  .messages-scroll {
    padding-left: 22px;
    padding-right: 22px;
  }

  .composer {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 960px) {
  :root {
    --side-w: 292px;
  }

  .auth-screen {
    grid-template-columns: minmax(340px, 0.9fr) minmax(430px, 1.1fr);
  }

  .auth-verse {
    font-size: 40px;
  }

  .quick-grid {
    gap: 8px;
  }

  .quick-card {
    padding: 14px 12px;
  }
}

@media (max-width: 860px) {
  :root {
    --mobile-nav: calc(60px + env(safe-area-inset-bottom));
  }

  html,
  body {
    overflow: hidden;
  }

  .auth-screen {
    display: block;
    overflow-y: auto;
    background:
      radial-gradient(ellipse at 70% 0%, rgba(201, 169, 110, 0.12), transparent 40%),
      var(--paper);
  }

  .auth-art {
    display: none;
  }

  .auth-panel {
    min-height: 100dvh;
    padding: 30px 24px 38px;
    align-items: flex-start;
  }

  .auth-card {
    width: min(430px, 100%);
    margin: auto;
    padding-top: 4px;
  }

  .auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    color: var(--ink);
    font-family: var(--serif);
    font-size: 22px;
    letter-spacing: 0.03em;
  }

  html[data-theme="dark"] .auth-mobile-brand {
    color: var(--text);
  }

  .auth-mobile-brand img {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .auth-card h2 {
    font-size: 30px;
  }

  .auth-version {
    margin-top: 22px;
  }

  .app-screen {
    display: block;
    height: 100dvh;
  }

  .rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    height: var(--mobile-nav);
    padding: 5px 10px env(safe-area-inset-bottom);
    border-top: 1px solid rgba(246, 241, 228, 0.08);
    border-right: 0;
    gap: 0;
  }

  .rail-brand,
  .rail-theme,
  .rail-bottom {
    display: none;
  }

  .rail-nav {
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
  }

  .rail-btn {
    width: 66px;
    padding: 5px 0;
    gap: 2px;
  }

  .rail-btn .icon {
    width: 20px;
    height: 20px;
  }

  .rail-label {
    font-size: 9px;
  }

  .rail-btn.is-active::before {
    left: 50%;
    top: -5px;
    width: 18px;
    height: 2px;
    transform: translateX(-50%);
  }

  .nav-badge {
    top: 0;
    right: 12px;
  }

  .sidebar {
    height: calc(100dvh - var(--mobile-nav));
    border-right: 0;
  }

  .sidebar-head {
    padding: 20px 18px 10px;
  }

  .sidebar-head h1 {
    font-size: 24px;
  }

  .search-box {
    margin: 0 14px 10px;
  }

  .chips {
    padding-left: 14px;
    padding-right: 14px;
  }

  .conversation-list,
  .contact-list {
    padding-bottom: 12px;
  }

  .main {
    position: fixed;
    inset: 0 0 var(--mobile-nav) 0;
    z-index: 55;
    transform: translateX(100%);
    transition: transform 0.3s var(--ease);
    background: var(--paper);
  }

  .app-screen.chat-open .main {
    transform: none;
  }

  .welcome {
    display: none;
  }

  .chat-head {
    min-height: 62px;
    padding: 9px 12px;
    padding-top: max(9px, env(safe-area-inset-top));
  }

  .chat-back {
    display: inline-flex;
    margin-left: -4px;
  }

  .chat-title-wrap h2 {
    font-size: 16px;
  }

  .chat-actions .icon-btn {
    width: 34px;
    height: 34px;
  }

  .chat-actions #chat-info-btn {
    display: none;
  }

  .messages-scroll {
    padding: 6px 14px 14px;
  }

  .message-list {
    padding-top: 0;
  }

  .msg-body {
    max-width: 80%;
  }

  .msg-avatar {
    width: 26px;
    height: 26px;
  }

  .bubble {
    font-size: 13.5px;
    padding: 8px 12px;
  }

  .composer {
    padding: 0 10px calc(7px + env(safe-area-inset-bottom));
  }

  .composer-box {
    border-radius: 14px;
  }

  .composer-hint {
    display: none;
  }

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

  .new-msg-pill {
    bottom: 100px;
  }

  .emoji-panel {
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 60vh;
    bottom: calc(100% - 4px);
  }

  .emoji-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .emoji-grid button {
    width: 100%;
    height: 38px;
  }

  .sticker-grid {
    grid-template-columns: repeat(4, 1fr);
    max-height: 42vh;
  }

  .sticker-btn {
    width: 100%;
    height: 68px;
  }

  .chat-sticker {
    width: 112px;
    height: 112px;
  }

  .msg-image {
    max-width: min(250px, 72vw);
  }

  .members-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    border-left: 0;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 90;
  }

  .detail-view {
    display: none;
  }

  .modal-root {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    animation: sheet-in 0.28s var(--ease);
  }

  @keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: none; }
  }

  .modal-head {
    padding: 20px 20px 0;
  }

  .modal-body {
    padding: 16px 20px 4px;
  }

  .modal-foot {
    padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  }

  .toast-root {
    bottom: calc(var(--mobile-nav) + 14px);
  }

  .settings-section {
    padding: 13px 0;
  }
}

@media (max-width: 380px) {
  .auth-panel {
    padding-left: 18px;
    padding-right: 18px;
  }

  .rail-btn {
    width: 58px;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) and (max-height: 680px) {
  .auth-panel {
    padding-top: 18px;
    padding-bottom: 22px;
  }

  .auth-mobile-brand {
    margin-bottom: 14px;
  }

  .auth-card h2 {
    font-size: 26px;
  }

  .auth-sub {
    margin-top: 3px;
  }

  .auth-tabs {
    margin: 16px 0 13px;
  }

  .auth-form {
    gap: 10px;
  }

  .field input {
    min-height: 42px;
  }

  .server-config summary {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .auth-hint {
    margin-top: 12px;
  }

  .auth-version {
    display: none;
  }
}

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ======================================================================
   Modern Mingxian UI
   Clean, product-style interface based on 茗獻和談社 / 茗獻主题.
   ====================================================================== */

::selection {
  background: rgba(47, 111, 94, 0.18);
  color: var(--text);
}

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

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
}

/* ---- brand ---------------------------------------------------------- */
.brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.brand-logo {
  display: block;
  width: min(250px, 72%);
  height: auto;
  filter: var(--logo-filter);
}

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-name span {
  color: var(--gold-deep);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

html[data-theme="dark"] .brand-name { color: var(--text); }

/* ---- authentication ------------------------------------------------- */
.auth-screen {
  grid-template-columns: minmax(440px, 1.02fr) minmax(460px, 0.98fr);
  background: var(--paper);
}

.auth-art {
  align-items: center;
  padding: clamp(42px, 6vw, 92px);
  color: var(--text);
  background: var(--paper-deep);
}

.auth-art::before,
.auth-art::after {
  display: none;
  content: none;
}

.auth-art-inner {
  width: min(540px, 100%);
}

.auth-verse {
  margin: clamp(54px, 8vh, 92px) 0 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.04em;
}

.auth-copy {
  margin: 22px 0 0;
  max-width: 430px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.8;
  letter-spacing: 0;
}

.auth-features {
  gap: 10px 22px;
  margin-top: 30px;
}

.auth-features span {
  color: var(--text-soft);
  font-size: 12px;
  letter-spacing: 0;
}

.auth-features .icon {
  width: 17px;
  height: 17px;
  color: var(--gold);
}

.auth-art-foot {
  margin: 42px 0 0;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.auth-panel {
  background: var(--paper-raised);
  border-left: 1px solid var(--line);
}

.auth-card {
  width: min(390px, 100%);
}

.auth-card h2 {
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(28px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

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

.auth-tabs {
  gap: 22px;
  margin: 30px 0 22px;
}

.auth-tab {
  padding-bottom: 11px;
  font-size: 13px;
  letter-spacing: 0;
}

.auth-tab.is-active {
  color: var(--gold-deep);
}

.auth-tab.is-active::after {
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
}

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

.auth-version {
  color: var(--muted-2);
  letter-spacing: 0.02em;
}

/* ---- boot ----------------------------------------------------------- */
.boot-screen {
  gap: 12px;
  background:
    radial-gradient(circle at 50% 38%, rgba(47, 111, 94, 0.1), transparent 40%),
    var(--paper);
  color: var(--text);
}

.boot-mark {
  width: 72px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

.boot-mark img {
  border-radius: 20px;
}

.boot-screen p {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.boot-screen span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ---- shell / rail --------------------------------------------------- */
.app-screen {
  grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr);
  background: var(--paper);
}

.rail {
  gap: 16px;
  padding: 16px 0 14px;
  background: var(--paper-raised);
  color: var(--muted);
  border-right: 1px solid var(--line);
}

.rail-brand {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

.rail-brand img {
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.rail-btn {
  width: 56px;
  padding: 8px 0 7px;
  border-radius: 10px;
  color: var(--muted);
}

.rail-label {
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.rail-btn:hover {
  color: var(--text);
  background: var(--paper-deep);
}

.rail-btn.is-active {
  color: var(--gold-deep);
  background: var(--gold-soft);
}

.rail-btn.is-active::before {
  display: none;
}

.rail-theme {
  color: var(--muted);
}

.rail-theme:hover {
  color: var(--text);
  background: var(--paper-deep);
}

.rail-avatar {
  border-color: var(--line-strong);
}

.nav-badge {
  background: var(--cinnabar);
  color: #fff;
  box-shadow: 0 0 0 2px var(--paper-raised);
}

/* ---- sidebar -------------------------------------------------------- */
.sidebar {
  background: var(--paper-raised);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  padding: 22px 20px 12px;
}

.sidebar-head h1 {
  font-family: var(--sans);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.sidebar-head p {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
}

.search-box {
  height: 40px;
  margin: 0 16px 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--paper-deep);
}

.search-box:focus-within {
  border-color: var(--gold);
  background: var(--paper-raised);
}

.chip {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.chip.is-active {
  border-color: var(--line);
  background: var(--paper-raised);
  color: var(--text);
}

.conversation-list {
  padding-left: 10px;
  padding-right: 10px;
}

.conv-item {
  border-radius: 10px;
}

.conv-item:hover {
  background: var(--paper-deep);
}

.conv-item.is-active {
  background: var(--gold-soft);
}

.conv-item.is-active::before {
  display: none;
}

.connection-bar {
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* ---- chat ----------------------------------------------------------- */
.chat-head {
  min-height: 68px;
  padding: 11px 22px;
  background: color-mix(in srgb, var(--paper-raised) 92%, transparent);
  border-bottom-color: var(--line);
}

.chat-title-wrap h2 {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chat-title-wrap p {
  font-size: 11px;
  letter-spacing: 0;
}

.chat-title-wrap p.is-online {
  color: var(--gold);
}

.messages-scroll {
  padding: 14px 26px 20px;
  background: var(--paper);
}

.message-list {
  gap: 4px;
}

.day-sep {
  margin: 14px 0;
  font-size: 10px;
  letter-spacing: 0;
}

.bubble {
  padding: 9px 13px;
  border-radius: 16px 16px 16px 4px;
  border-color: var(--line);
  background: var(--peer);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  line-height: 1.6;
}

.msg.is-own .bubble {
  border-radius: 16px 16px 4px 16px;
  background: var(--own);
  box-shadow: 0 4px 14px rgba(47, 111, 94, 0.18);
}

.msg.is-continuation .bubble,
.msg.is-own.is-continuation .bubble {
  border-radius: 16px;
}

.msg-meta {
  font-size: 10px;
  letter-spacing: 0;
}

.msg-meta .sender {
  color: var(--gold-deep);
}

.msg-image {
  border-radius: 12px;
}

.chat-sticker {
  width: 128px;
  height: 128px;
  filter: drop-shadow(0 5px 12px rgba(15, 23, 42, 0.12));
}

.chat.is-dragging::after {
  content: "松手发送图片";
  border-color: var(--gold);
  color: var(--gold-deep);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  font-family: var(--sans);
  font-size: 16px;
  letter-spacing: 0;
}

/* ---- composer ------------------------------------------------------- */
.composer {
  padding: 0 22px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
}

.composer-box {
  border-color: var(--line);
  border-radius: 12px;
  background: var(--paper-deep);
  box-shadow: none;
}

.composer-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

#message-input {
  font-size: 13.5px;
}

.send-btn {
  border-radius: 9px;
  background: var(--gold);
  color: #fff;
}

html[data-theme="dark"] .send-btn {
  background: var(--gold);
  color: var(--ink);
}

.send-btn:hover,
html[data-theme="dark"] .send-btn:hover {
  background: var(--gold-deep);
  color: #fff;
}

.composer-hint {
  color: var(--muted-2);
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.emoji-panel {
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

/* ---- welcome / cards ------------------------------------------------ */
.welcome {
  background:
    radial-gradient(circle at 70% 10%, var(--gold-soft), transparent 42%),
    var(--paper);
}

.welcome-logo {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.welcome h2 {
  font-family: var(--sans);
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.welcome h2 span {
  color: var(--gold-deep);
}

.welcome-quote {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
}

.quick-card {
  border-color: var(--line);
  border-radius: 12px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
}

.quick-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
}

.quick-icon {
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.quick-card b {
  font-size: 13px;
}

.quick-card small {
  color: var(--muted);
  letter-spacing: 0;
}

.welcome-foot {
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* ---- buttons / fields / modal -------------------------------------- */
.btn {
  border-radius: 9px;
  font-weight: 600;
  letter-spacing: 0;
}

.btn-primary {
  background: var(--gold);
  color: #fff;
  box-shadow: 0 4px 12px rgba(47, 111, 94, 0.2);
}

html[data-theme="dark"] .btn-primary {
  background: var(--gold);
  color: var(--ink);
  box-shadow: none;
}

.btn-primary:hover,
html[data-theme="dark"] .btn-primary:hover {
  background: var(--gold-deep);
  color: #fff;
}

.btn-ghost {
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.btn-danger {
  border-color: rgba(220, 38, 38, 0.28);
}

.field input,
.field textarea {
  border-radius: 8px;
  background: var(--paper);
  border-color: var(--line);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.auth-form .field input {
  min-height: 44px;
}

.btn-block {
  min-height: 46px;
  border-radius: 9px;
}

.link-btn {
  color: var(--gold-deep);
}

.icon-btn:hover {
  background: var(--paper-deep);
}

.icon-btn-accent {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

.modal,
.sheet {
  border-radius: 14px;
}

.modal-head h2,
.sheet-head h2 {
  font-family: var(--sans);
  letter-spacing: -0.03em;
}

.setting-row {
  border-radius: 10px;
}

.setting-row:hover {
  background: var(--paper-deep);
}

.mini-palette {
  display: none;
}

/* ---- responsive auth ------------------------------------------------ */
@media (max-width: 900px) {
  .auth-screen {
    grid-template-columns: 1fr;
  }

  .auth-art {
    display: none;
  }

  .auth-panel {
    border-left: 0;
    background: var(--paper);
  }

  .auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .auth-mobile-brand img {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .auth-mobile-brand em {
    color: var(--gold-deep);
    font-size: 11px;
    font-style: normal;
    letter-spacing: 0.08em;
  }

  .rail {
    background: var(--paper-raised);
  }
}
/* brand wordmark on the welcome screen */
.welcome-logo.welcome-wordmark {
  width: 188px;
  height: auto;
  border-radius: 0;
  box-shadow: none;
  filter: var(--logo-filter);
}
.about-logo {
  display: block;
  width: min(180px, 64%);
  height: auto;
  margin: 0 0 14px;
  filter: var(--logo-filter);
}
@media (max-width: 900px) {
  .auth-mobile-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .auth-mobile-brand .mobile-wordmark {
    width: 188px;
    height: auto;
    border-radius: 0;
    filter: var(--logo-filter);
  }
  .auth-mobile-brand span {
    font-size: 20px;
  }
}
/* avatar / media / custom stickers */
.avatar-img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  object-fit: cover;
}

.msg-image-wrap,
.chat-sticker-wrap {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
}

.msg-image {
  max-width: min(148px, 42vw);
}

.msg-image img {
  max-height: 148px;
}

.msg-download {
  position: absolute;
  right: 4px;
  top: 4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg-image-wrap:hover .msg-download,
.chat-sticker-wrap:hover .msg-download,
.msg-download:focus-visible {
  opacity: 1;
}

.chat-sticker-btn {
  display: block;
  border-radius: 10px;
}

.custom-sticker {
  position: relative;
}

.custom-sticker-delete {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cinnabar);
  color: #fff;
  font-size: 13px;
  line-height: 18px;
  z-index: 2;
}

.custom-sticker-empty {
  grid-column: 1 / -1;
  margin: 12px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.sticker-upload-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 3px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
