:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f3;
  --surface-3: #e9e9eb;
  --line: #e8e8ea;
  --line-strong: #d8d8dc;
  --text: #0b0b0c;
  --text-2: #4a4a4f;
  --muted: #8b8b91;
  --ink: #101012;
  --ink-hover: #29292e;
  --on-ink: #ffffff;
  --chat-bg: #f2f2f3;
  --bubble-in: #ffffff;
  --bubble-out: #17171a;
  --on-bubble-out: #ffffff;
  --bubble-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  --glass: rgba(255, 255, 255, 0.86);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --hover-veil: rgba(0, 0, 0, 0.055);
  --focus-ring: rgba(0, 0, 0, 0.65);
  --focus-glow: rgba(16, 16, 18, 0.08);
  --placeholder: #a9a9af;
  --dot-idle: #cfcfd4;
  --dot-ring: rgba(16, 16, 18, 0.12);
  --system-bg: rgba(0, 0, 0, 0.055);
  --system-fg: #74747a;
  --sticker-bg: #ffffff;
  --toast-bg: rgba(16, 16, 18, 0.94);
  --toast-fg: #ffffff;
  --toast-error-bg: rgba(140, 44, 40, 0.95);
  --toast-error-fg: #ffffff;
  --scroll-thumb: rgba(0, 0, 0, 0.12);
  --scroll-thumb-hover: rgba(0, 0, 0, 0.22);
  --danger: #a33a34;
  --radius: 8px;
  --radius-sm: 8px;
  --drawer-h: 268px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0f;
  --surface: #17171a;
  --surface-2: #202024;
  --surface-3: #2b2b30;
  --line: #26262b;
  --line-strong: #38383f;
  --text: #f3f3f5;
  --text-2: #b8b8bf;
  --muted: #84848c;
  --ink: #f3f3f5;
  --ink-hover: #ffffff;
  --on-ink: #101012;
  --chat-bg: #101013;
  --bubble-in: #1e1e22;
  --bubble-out: #f2f2f4;
  --on-bubble-out: #101012;
  --bubble-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --glass: rgba(23, 23, 26, 0.86);
  --glass-strong: rgba(23, 23, 26, 0.94);
  --hover-veil: rgba(255, 255, 255, 0.09);
  --focus-ring: rgba(255, 255, 255, 0.7);
  --focus-glow: rgba(255, 255, 255, 0.12);
  --placeholder: #6e6e76;
  --dot-idle: #3a3a41;
  --dot-ring: rgba(255, 255, 255, 0.16);
  --system-bg: rgba(255, 255, 255, 0.08);
  --system-fg: #9a9aa2;
  --sticker-bg: #f6f6f7;
  --toast-bg: rgba(243, 243, 245, 0.96);
  --toast-fg: #101012;
  --toast-error-bg: #b0504a;
  --toast-error-fg: #ffffff;
  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.26);
  --danger: #d4736c;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 18px 44px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

svg.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

::selection {
  background: var(--ink);
  color: var(--on-ink);
}

body,
.top-nav,
.panel,
.chat-shell,
.chat-header,
.connection-banner,
.messages,
.bubble,
.composer,
.sticker-item,
.drawer {
  transition: background-color 0.34s var(--ease), border-color 0.34s var(--ease),
    color 0.34s var(--ease);
}

/* ------------------------------ 视图切换 ------------------------------ */

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: view-in 0.28s var(--ease-out);
}

#view-chat.is-active {
  display: flex;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  background: var(--chat-bg);
  animation: none;
}

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

/* ------------------------------- 首页 ------------------------------- */

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.3s var(--ease-out);
}

.brand:hover .brand-mark {
  transform: rotate(-6deg) scale(1.04);
}

.brand-name {
  font-size: 16.5px;
  font-weight: 600;
}

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

.server-state {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot-idle);
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.dot.is-online {
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--dot-ring);
}

.dot.is-offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(163, 58, 52, 0.14);
}

.home-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 44px 22px 64px;
}

.intro {
  max-width: 620px;
  margin-bottom: 32px;
  animation: view-in 0.4s var(--ease-out);
}

.intro h1 {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.intro p {
  margin: 0;
  color: var(--text-2);
  font-size: 15px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.panel:hover {
  border-color: var(--line-strong);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.panel-head svg.lucide {
  width: 18px;
  height: 18px;
  color: var(--text);
}

.panel-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

.panel-desc {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 13.5px;
}

.identity-panel {
  margin-bottom: 18px;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.entry-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12.5px;
}

.feature-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.feature-list svg.lucide {
  width: 14px;
  height: 14px;
  color: var(--text-2);
}

.entry-panel .btn-block {
  margin-top: auto;
}

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

/* ------------------------------- 表单 ------------------------------- */

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

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 12.5px;
  color: var(--text-2);
}

.field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.field input:hover {
  background: var(--surface-3);
}

.field input:focus {
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

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

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

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

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

.ghost-icon {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.ghost-icon:hover {
  background: var(--hover-veil);
  color: var(--text);
}

.ghost-icon svg.lucide {
  width: 16px;
  height: 16px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.seg-btn {
  padding: 8px 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
    box-shadow 0.25s var(--ease), transform 0.2s var(--ease);
}

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

.seg-btn.is-active {
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

.room-form {
  margin-top: 2px;
}

/* ------------------------------- 按钮 ------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    color 0.25s var(--ease), transform 0.18s var(--ease-out), box-shadow 0.25s var(--ease);
}

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

.btn:active {
  transform: scale(0.985);
}

.btn svg.lucide {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: var(--ink-hover);
  border-color: var(--ink-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

/* ------------------------------ 聊天界面 ------------------------------ */

.chat-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  height: 100%;
  background: var(--chat-bg);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.chat-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.18s var(--ease-out);
}

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

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

.chat-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.chat-title strong {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
}

.chat-sub svg.lucide {
  width: 12px;
  height: 12px;
}

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

.connection-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
  animation: view-in 0.25s var(--ease-out);
}

.connection-banner svg.lucide {
  width: 14px;
  height: 14px;
}

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: msg-in 0.32s var(--ease-out);
}

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

.msg.mine {
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  user-select: none;
  transition: transform 0.25s var(--ease-out);
}

.msg:hover .avatar {
  transform: translateY(-1px);
}

.msg-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: calc(100% - 60px);
}

.msg.mine .msg-main {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11.5px;
}

.msg-meta .who {
  color: var(--text-2);
  font-weight: 500;
}

.msg.mine .msg-meta {
  flex-direction: row-reverse;
}

.bubble {
  position: relative;
  padding: 10px 13px;
  background: var(--bubble-in);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg.mine .bubble {
  background: var(--bubble-out);
  color: var(--on-bubble-out);
  box-shadow: var(--bubble-shadow);
}

.msg.emoji-only .bubble {
  background: transparent;
  box-shadow: none;
  padding: 0;
  font-size: 38px;
  line-height: 1.2;
}

.msg.mine.emoji-only .bubble {
  color: inherit;
}

.bubble-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.msg.mine .bubble-link {
  color: var(--on-bubble-out);
}

.msg-sticker {
  display: block;
  max-width: 168px;
  max-height: 168px;
  border-radius: 6px;
  background: var(--sticker-bg);
  cursor: zoom-in;
  transition: transform 0.25s var(--ease-out);
}

.msg-sticker:hover {
  transform: scale(1.015);
}

.msg.system {
  justify-content: center;
  animation: fade-in 0.3s var(--ease-out);
}

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

.msg.system .system-text {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--system-bg);
  color: var(--system-fg);
  font-size: 11.5px;
}

.typing-line {
  min-height: 20px;
  padding: 0 18px 6px;
  color: var(--muted);
  font-size: 11.5px;
  transition: opacity 0.25s var(--ease);
}

.composer {
  flex: 0 0 auto;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}

.composer-tools {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.tool-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  transition: background 0.22s var(--ease), color 0.22s var(--ease), transform 0.18s var(--ease-out);
}

.tool-btn:hover {
  background: var(--hover-veil);
  color: var(--text);
}

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

.tool-btn.is-active {
  background: var(--ink);
  color: #fff;
}

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

#message-input {
  flex: 1 1 auto;
  max-height: 132px;
  min-height: 44px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  resize: none;
  outline: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

#message-input::placeholder {
  color: var(--placeholder);
}

#message-input:focus {
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.btn-send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
}

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

/* ------------------------------ 表情面板 ------------------------------ */

.drawer {
  flex: 0 0 auto;
  height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid transparent;
  transition: height 0.3s var(--ease-out), opacity 0.24s var(--ease),
    border-color 0.3s var(--ease);
  opacity: 0;
}

.drawer.is-open {
  height: var(--drawer-h);
  opacity: 1;
  border-top-color: var(--line);
}

.drawer-tabs {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.drawer-tabs::-webkit-scrollbar {
  display: none;
}

.drawer-tab {
  position: relative;
  flex: 0 0 auto;
  padding: 12px 1px 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  transition: color 0.22s var(--ease);
}

.drawer-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transform: scaleX(0);
  transition: transform 0.28s var(--ease-out);
}

.drawer-tab:hover {
  color: var(--text-2);
}

.drawer-tab.is-active {
  color: var(--text);
  font-weight: 600;
}

.drawer-tab.is-active::after {
  transform: scaleX(1);
}

.drawer-tabs-inner {
  gap: 16px;
  padding: 0 0 10px;
  border-bottom: 0;
}

.drawer-tabs-inner .drawer-tab {
  padding: 4px 1px 8px;
  font-size: 12.5px;
}

.drawer-tabs-inner .drawer-tab::after {
  bottom: 2px;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px 16px;
}

.drawer-body::-webkit-scrollbar {
  width: 8px;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
}

.emoji-grid,
.sticker-grid {
  display: grid;
  gap: 4px;
}

.emoji-grid {
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
}

.sticker-grid {
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.emoji-item {
  display: grid;
  place-items: center;
  height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 24px;
  line-height: 1;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease-out);
}

.emoji-item:hover {
  background: var(--surface-2);
  transform: scale(1.12);
}

.emoji-item:active {
  transform: scale(0.96);
}

.sticker-item {
  position: relative;
  display: grid;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sticker-bg);
  transition: border-color 0.22s var(--ease), transform 0.22s var(--ease-out),
    box-shadow 0.22s var(--ease);
}

.sticker-item:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.sticker-item img {
  width: 100%;
  height: 72px;
  object-fit: contain;
}

.sticker-item.is-emoji {
  font-size: 38px;
  line-height: 1;
  height: 86px;
}

.sticker-item .sticker-del {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  opacity: 0;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease-out);
  transform: scale(0.9);
}

.sticker-item:hover .sticker-del,
.sticker-item:focus-within .sticker-del {
  opacity: 1;
  transform: scale(1);
}

.sticker-item .sticker-del:hover {
  background: #000;
}

.sticker-item .sticker-del svg.lucide {
  width: 12px;
  height: 12px;
}

.drawer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.drawer-empty svg.lucide {
  width: 24px;
  height: 24px;
  color: var(--text-2);
}

/* ------------------------------- 提示条 ------------------------------- */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(86vw, 420px);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.34s var(--ease-out);
}

.toast.is-error {
  background: var(--toast-error-bg);
  color: var(--toast-error-fg);
}

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

/* ------------------------------- 图片预览 ------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  background: rgba(12, 12, 14, 0.86);
  backdrop-filter: blur(6px);
  animation: fade-in 0.24s var(--ease-out);
}

.lightbox img {
  max-width: min(88vw, 520px);
  max-height: 70vh;
  border-radius: var(--radius);
  background: #fff;
  animation: zoom-in 0.34s var(--ease-out);
}

@keyframes zoom-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transition: background 0.22s var(--ease), transform 0.22s var(--ease-out);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: rotate(90deg);
}

.lightbox-actions {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.34);
  color: #fff;
}

.lightbox-actions:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 760px) {
  :root {
    --drawer-h: 244px;
  }

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

  .home-main {
    padding: 28px 16px 48px;
  }

  .intro h1 {
    font-size: 25px;
  }

  .chat-shell {
    max-width: none;
    border-left: 0;
    border-right: 0;
  }

  .messages {
    padding: 16px 12px 6px;
    gap: 14px;
  }

  .msg-main {
    max-width: calc(100% - 54px);
  }

  .avatar {
    width: 34px;
    height: 34px;
    font-size: 13.5px;
  }
}

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