/* 极简暗黑：黑 / 灰 / 白为主；红色仅用于警告与错误；蓝色仅用于链接与 AI 内容高亮 */

:root {
  color-scheme: dark;

  --bg: #0b0b0c;
  --surface: #121214;
  --surface-hover: #19191c;
  --surface-active: #1e1e22;
  --line: #26262b;
  --line-strong: #34343b;

  --text: #ececf0;
  --text-dim: #b6b6bd;
  --muted: #8a8a92;

  --danger: #e5534b;
  --link: #6ea8fe;
  --highlight: #a9c8ff;
  --highlight-bg: rgba(110, 168, 254, 0.1);

  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* ---------- 整体布局 ---------- */

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- 左侧会话列表 ---------- */

.sidebar {
  flex: 0 0 264px;
  width: 264px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 10px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px 2px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #f2f2f3;
  color: #0b0b0c;
  font-size: 14px;
  font-weight: 700;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.new-chat:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #3f3f47;
}

.new-chat:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

.plus {
  font-size: 15px;
  line-height: 1;
  color: inherit;
}

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px;
}

.session-item {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.session-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.session-item.active {
  background: var(--surface-active);
  color: var(--text);
  font-weight: 500;
}

.session-empty {
  margin: 4px 6px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

/* ---------- 右侧主区 ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.icon-btn.menu-btn {
  display: none;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
}

.icon-btn span {
  display: block;
  width: 15px;
  height: 1.5px;
  background: var(--text-dim);
}

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

.session-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-area {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.nickname {
  max-width: 140px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sep {
  color: var(--line-strong);
}

.balance {
  white-space: nowrap;
}

.balance.low {
  color: var(--danger);
  font-weight: 500;
}

.text-btn {
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

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

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

.login-btn:hover {
  color: var(--link);
  background: var(--surface-hover);
}

/* ---------- 消息区 ---------- */

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 26px 24px 10px;
}

.thread {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  max-width: min(80%, 680px);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: #f1f1f3;
  border: 1px solid #f1f1f3;
  color: #101013;
}

.msg.assistant {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

/* AI 回复内重点高亮（唯一允许的额外浅色） */
.msg.assistant .hl {
  color: var(--highlight);
  background: var(--highlight-bg);
  padding: 0 2px;
  border-radius: 3px;
}

.msg.error {
  align-self: flex-start;
  max-width: min(80%, 680px);
  font-size: 13px;
  color: var(--danger);
  background: rgba(229, 83, 75, 0.06);
  border: 1px solid rgba(229, 83, 75, 0.35);
}

.msg.muted {
  align-self: flex-start;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line-strong);
}

/* 空状态 */
.empty-state {
  margin: auto;
  max-width: 440px;
  padding: 40px 16px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-dim);
}

.empty-state p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--muted);
}

/* ---------- 输入区 ---------- */

.composer-area {
  flex: 0 0 auto;
  padding: 10px 24px 18px;
}

.composer {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}

.composer:focus-within {
  border-color: #4a4a52;
}

#input {
  flex: 1;
  min-height: 38px;
  max-height: 168px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
  overflow-y: auto;
}

#input::-webkit-scrollbar {
  width: 6px;
}

#input::-webkit-scrollbar-thumb {
  background: #2f2f35;
  border-radius: 3px;
}

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

#input:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.send-btn {
  flex: 0 0 auto;
  padding: 8px 15px;
  border: 0;
  border-radius: 9px;
  background: #f2f2f3;
  color: #0b0b0c;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.send-btn:hover:not(:disabled) {
  background: #ffffff;
}

.send-btn:disabled {
  background: #222226;
  color: #6a6a72;
  cursor: not-allowed;
}

.composer-note {
  width: 100%;
  max-width: 760px;
  margin: 8px auto 0;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

.composer-note.warn {
  color: var(--danger);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
}

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

/* ---------- 登录弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.modal-panel {
  position: relative;
  width: min(400px, 100%);
  padding: 22px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
}

.modal-panel h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
}

.modal-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12.5px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  padding: 9px 11px;
  background: #0f0f11;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.field input:focus {
  outline: none;
  border-color: #4a4a52;
}

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

.form-error {
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 12.5px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn-primary {
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: #f2f2f3;
  color: #0b0b0c;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:hover {
  background: #ffffff;
}

.btn-ghost {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

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

.modal-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}

/* ---------- 登录方式 Tabs ---------- */

.login-panel {
  width: min(440px, 100%);
}

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

.auth-tab {
  flex: 1;
  padding: 8px 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.auth-tab:hover {
  color: var(--text-dim);
}

.auth-tab.active {
  color: var(--text);
  border-bottom-color: #f2f2f3;
}

.auth-subtabs {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.auth-subtab {
  padding: 0 0 4px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.auth-subtab.active {
  color: var(--text);
  border-bottom-color: var(--line-strong);
}

.auth-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.auth-primary {
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 9px;
  background: #f2f2f3;
  color: #0b0b0c;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.auth-primary:hover:not(:disabled) {
  background: #ffffff;
}

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

.auth-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-word;
}

.auth-hint.warn {
  color: var(--danger);
}

.form-notice {
  margin: 0 0 10px;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.7;
}

.form-notice a {
  color: var(--link);
  word-break: break-all;
}

.field-inline {
  display: flex;
  gap: 8px;
}

.field-inline input {
  flex: 1;
  min-width: 0;
}

.field-inline .btn-ghost {
  flex: 0 0 auto;
  padding: 0 12px;
}

/* 未验证邮箱提示条 */
.notice-banner {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-bottom: 1px solid rgba(229, 83, 75, 0.35);
  background: rgba(229, 83, 75, 0.06);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
}

.notice-banner .link-btn {
  color: var(--link);
}

/* ---------- 侧边栏底部 / 设置入口 ---------- */

.sidebar-foot {
  flex: 0 0 auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.settings-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

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

.settings-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

/* ---------- 设置抽屉 ---------- */

.drawer-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.6);
}

.drawer-scrim.show {
  display: block;
}

.settings-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line-strong);
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.5);
  transform: translateX(-102%);
  transition: transform 0.16s ease;
}

.settings-drawer.open {
  transform: translateX(0);
}

.settings-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.drawer-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.drawer-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

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

.settings-body::-webkit-scrollbar {
  width: 6px;
}

.settings-body::-webkit-scrollbar-thumb {
  background: #2f2f35;
  border-radius: 3px;
}

.settings-body::-webkit-scrollbar-track {
  background: transparent;
}

.settings-warnings {
  margin-bottom: 6px;
}

.settings-warning {
  margin: 0 0 8px;
  padding: 9px 11px;
  border: 1px solid rgba(229, 83, 75, 0.35);
  border-radius: 8px;
  background: rgba(229, 83, 75, 0.06);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.55;
}

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

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

.settings-section h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.settings-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings-hint.warn {
  color: var(--danger);
}

.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mode-card:hover:not(:disabled) {
  background: var(--surface-hover);
}

.mode-card.active {
  border-color: #5a5a63;
  background: var(--surface-active);
}

.mode-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mode-radio {
  position: relative;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
}

.mode-card.active .mode-radio {
  border-color: #f2f2f3;
}

.mode-card.active .mode-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #f2f2f3;
}

.mode-text {
  min-width: 0;
}

.mode-name {
  display: block;
  margin-bottom: 2px;
  font-size: 13.5px;
  font-weight: 500;
}

.mode-desc {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.resource-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}

.resource-row:last-of-type {
  border-bottom: 0;
}

.resource-label {
  color: var(--muted);
  font-size: 12.5px;
  flex: 0 0 auto;
}

.resource-value {
  color: var(--text);
  text-align: right;
}

.resource-value.low {
  color: var(--danger);
  font-weight: 500;
}

/* ---------- 移动端 ---------- */

.scrim {
  display: none;
}

@media (max-width: 860px) {
  .icon-btn.menu-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: 280px;
    flex-basis: 280px;
    transform: translateX(-102%);
    transition: transform 0.16s ease;
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.5);
  }

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

  .scrim.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.6);
  }

  .topbar {
    padding: 8px 12px;
  }

  .messages {
    padding: 18px 14px 8px;
  }

  .msg {
    max-width: 88%;
    font-size: 14px;
  }

  .composer-area {
    padding: 8px 12px 14px;
  }

  /* iOS 聚焦时避免自动放大 */
  #input {
    font-size: 16px;
  }

  .nickname {
    max-width: 88px;
  }

  .user-meta {
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .session-title {
    font-size: 13px;
  }

  .text-btn {
    padding: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .settings-drawer {
    transition: none;
  }
}

/* ---------- Visual refinement ---------- */

:root {
  --bg: #101112;
  --surface: #18191a;
  --surface-hover: #222324;
  --surface-active: #272829;
  --line: #2c2d2e;
  --line-strong: #414243;
  --text: #f1f2f3;
  --text-dim: #c7c8ca;
  --muted: #9a9c9e;
  --danger: #ef625b;
  --link: #8ab4f8;
  --highlight: #c4d7f5;
  --highlight-bg: rgba(196, 215, 245, 0.1);
  --radius: 8px;
}

body {
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
}

button,
input,
textarea {
  font-family: inherit;
}

button {
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease,
    opacity 140ms ease, transform 140ms ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

:where(button, input, textarea, a):focus-visible {
  outline: 2px solid #d8dadd;
  outline-offset: 2px;
}

.sidebar {
  padding: 18px 12px 12px;
  gap: 12px;
  background: #151617;
  border-right-color: #28292a;
}

.sidebar-head {
  gap: 10px;
  padding: 5px 8px 7px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f2f3f4;
  color: #171819;
  font-size: 13px;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.new-chat {
  min-height: 40px;
  padding: 8px 11px;
  border-color: #3a3b3c;
  border-radius: 8px;
  font-size: 13px;
}

.new-chat:hover:not(:disabled) {
  border-color: #555657;
}

.session-list {
  gap: 3px;
  padding: 0;
}

.session-item {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  transition: background-color 130ms ease, color 130ms ease;
}

.session-item.active {
  background: #292a2b;
  font-weight: 550;
}

.sidebar-foot {
  padding-top: 9px;
  border-top-color: #292a2b;
}

.settings-btn {
  min-height: 38px;
  border-radius: 7px;
  font-size: 13px;
}

.topbar {
  min-height: 58px;
  padding: 10px 24px;
  border-bottom-color: #252627;
}

.session-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  letter-spacing: 0;
}

.user-meta {
  gap: 8px;
  font-size: 12.5px;
}

.nickname {
  color: var(--text-dim);
}

.text-btn {
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 12.5px;
}

.messages {
  padding: 32px 28px 14px;
}

.thread {
  gap: 18px;
}

.msg {
  max-width: min(78%, 700px);
  padding: 12px 15px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
}

.msg.user {
  border-bottom-right-radius: 5px;
  background: #e9eaeb;
  border-color: #e9eaeb;
  color: #171819;
}

.msg.assistant {
  border-bottom-left-radius: 5px;
  background: transparent;
  border-color: #303132;
}

.empty-state h2 {
  color: var(--text);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0;
}

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

.composer-area {
  padding: 12px 28px 22px;
}

.composer {
  gap: 10px;
  padding: 8px 8px 8px 14px;
  background: #1b1c1d;
  border-color: #3a3b3c;
  border-radius: 10px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.composer:focus-within {
  border-color: #6a6b6c;
  background: #1e1f20;
}

#input {
  min-height: 40px;
  font-size: 14px;
}

.send-btn,
.btn-primary,
.auth-primary {
  min-height: 36px;
  border-radius: 8px;
  background: #e9eaeb;
  color: #171819;
  font-size: 13px;
  font-weight: 600;
}

.send-btn:hover:not(:disabled),
.btn-primary:hover,
.auth-primary:hover:not(:disabled) {
  background: #ffffff;
}

.send-btn:disabled {
  background: #2b2c2d;
  color: #828486;
}

.composer-note {
  margin-top: 7px;
  font-size: 11.5px;
}

.notice-banner {
  padding: 9px 24px;
  gap: 8px 12px;
  font-size: 12px;
}

.notice-banner .link-btn {
  font-size: 12px;
}

.modal {
  opacity: 1;
  transition: opacity 160ms ease;
}

.modal[hidden] {
  display: none !important;
}

.modal:not([hidden]) {
  animation: modal-enter 160ms ease both;
}

@keyframes modal-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.66);
  transition: opacity 160ms ease;
}

.modal-panel {
  width: min(440px, 100%);
  padding: 24px 24px 20px;
  background: #1a1b1c;
  border-color: #3b3c3d;
  border-radius: 12px;
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.38);
  animation: panel-enter 180ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-panel h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.modal-sub {
  margin-bottom: 20px;
  font-size: 13px;
}

.auth-tabs {
  gap: 2px;
  margin-bottom: 18px;
}

.auth-tab {
  min-height: 39px;
  border-bottom-width: 2px;
  font-size: 12.5px;
}

.auth-subtabs {
  gap: 18px;
}

.auth-subtab {
  font-size: 12px;
}

.field {
  margin-bottom: 13px;
}

.field label {
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 12px;
}

.field input {
  min-height: 40px;
  padding: 9px 11px;
  background: #141516;
  border-color: #38393a;
  border-radius: 7px;
  font-size: 13px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.field input:focus {
  border-color: #858688;
  background: #171819;
}

.btn-ghost {
  border-color: #414243;
  border-radius: 7px;
}

.btn-ghost:hover {
  border-color: #5a5b5c;
}

.form-error,
.settings-warning {
  border-radius: 7px;
}

.form-error {
  font-size: 12px;
}

.form-notice {
  font-size: 12px;
}

.auth-desc,
.auth-hint {
  font-size: 12.5px;
}

.drawer-scrim {
  display: block;
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.drawer-scrim.show {
  opacity: 1;
  visibility: visible;
}

.settings-drawer {
  background: #18191a;
  border-right-color: #343536;
  box-shadow: 10px 0 36px rgba(0, 0, 0, 0.34);
  transition: transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.settings-head {
  min-height: 58px;
  padding: 13px 18px;
}

.settings-head h2 {
  font-size: 14px;
  letter-spacing: 0;
}

.settings-body {
  padding: 8px 20px 24px;
}

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

.settings-section h3 {
  margin-bottom: 7px;
  font-size: 13px;
  letter-spacing: 0;
}

.settings-desc,
.settings-hint {
  font-size: 11.5px;
}

.mode-card {
  min-height: 66px;
  margin-bottom: 7px;
  padding: 12px;
  border-color: #333435;
  border-radius: 8px;
  transition: background-color 130ms ease, border-color 130ms ease, opacity 130ms ease;
}

.mode-card.active {
  border-color: #696a6b;
  background: #252627;
}

.mode-name {
  font-size: 13px;
  letter-spacing: 0;
}

.mode-desc {
  font-size: 11.5px;
}

.resource-row {
  padding: 9px 0;
  font-size: 13px;
}

.resource-label {
  font-size: 12px;
}

.resource-value {
  font-variant-numeric: tabular-nums;
}

/* Restrained hover and focus states */
.settings-btn,
.icon-btn,
.drawer-close,
.modal-close,
.text-btn,
.link-btn {
  transition: background-color 130ms ease, color 130ms ease, border-color 130ms ease;
}

@media (max-width: 860px) {
  .topbar {
    min-height: 54px;
    padding: 8px 14px;
  }

  .messages {
    padding: 22px 16px 10px;
  }

  .composer-area {
    padding: 9px 14px 16px;
  }

  .sidebar {
    background: #171819;
    transition: transform 200ms cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .notice-banner {
    padding: 8px 14px;
  }
}

@media (max-width: 480px) {
  .modal-panel {
    padding: 22px 18px 18px;
  }

  .auth-tab {
    font-size: 12px;
  }

  .field-inline .btn-ghost {
    padding: 0 9px;
    font-size: 12px;
  }

  .user-area {
    gap: 3px;
  }

  .nickname {
    max-width: 72px;
  }
}

@media (max-width: 860px) {
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.68);
    opacity: 0;
    visibility: hidden;
    transition: opacity 170ms ease, visibility 170ms ease;
  }

  .scrim.show {
    display: block;
    opacity: 1;
    visibility: visible;
  }
}

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


/* ---------- 登录弹窗：邮箱主表单 + 底部第三方入口 ---------- */

.login-back {
  display: inline-flex;
  align-items: center;
  margin: 0 0 12px;
  padding: 4px 8px 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.login-back:hover {
  background: var(--surface-hover);
  color: var(--text-dim);
}

.form-title {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.field-hint {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 11.5px;
}

.field-password {
  position: relative;
}

.field-password input {
  padding-right: 82px;
}

.field-link {
  position: absolute;
  top: 50%;
  right: 11px;
  transform: translateY(-50%);
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.auth-promoter {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.auth-promoter .link-btn {
  margin-left: 3px;
  font-size: 12.5px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 11.5px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.method-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 9px;
  padding: 10px 13px;
  border: 1px solid #3a3b3c;
  border-radius: 8px;
  background: #191a1b;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.method-btn:hover:not(:disabled) {
  background: #212223;
  border-color: #565758;
}

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

.method-btn-strong {
  margin-top: 4px;
}

.method-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #3a3b3c;
  border-radius: 7px;
  color: var(--text-dim);
  background: #202122;
}

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

/* 微软四色标识：唯一允许的彩色装饰，仅用于品牌识别 */
.ms-logo {
  border: 1px solid transparent;
  background: transparent;
  padding: 2px;
}

.ms-logo svg {
  width: 18px;
  height: 18px;
}

.method-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.method-name {
  font-size: 13px;
  font-weight: 500;
}

.method-note {
  color: var(--muted);
  font-size: 11.5px;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 196px;
  height: 196px;
  margin: 6px auto 12px;
  border: 1px solid #3a3b3c;
  border-radius: 10px;
  background: #f4f4f5;
}

.qr-frame img {
  width: 180px;
  height: 180px;
  display: block;
}

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

.qr-status.warn {
  color: var(--danger);
}

.mobile-status-icon {
  width: 44px;
  height: 44px;
  margin: 6px auto 14px;
  display: grid;
  place-items: center;
  border: 1px solid #3a3b3c;
  border-radius: 50%;
  color: var(--text);
  font-size: 18px;
}

.mobile-status-icon.error {
  color: var(--danger);
  border-color: rgba(239, 98, 91, 0.45);
}

.mobile-status-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.mobile-status-title.error {
  color: var(--danger);
}

.mobile-status-msg {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
  text-align: center;
}

/* 扫码落地页：隐藏聊天外壳，仅保留登录面板 */
body.mobile-login-page .app {
  display: block;
  height: auto;
  min-height: 0;
  overflow: visible;
}

body.mobile-login-page .main {
  display: block;
  height: auto;
}

body.mobile-login-page .messages,
body.mobile-login-page .composer-area,
body.mobile-login-page .sidebar,
body.mobile-login-page .notice-banner,
body.mobile-login-page .user-area,
body.mobile-login-page .scrim {
  display: none !important;
}

body.mobile-login-page .topbar {
  min-height: 52px;
  padding: 12px 18px;
  border-bottom-color: #252627;
}

body.mobile-login-page .modal {
  position: static;
  inset: auto;
  display: block;
  place-items: initial;
  min-height: 0;
  padding: 24px 16px 40px;
}

body.mobile-login-page .modal-backdrop,
body.mobile-login-page .modal-close {
  display: none;
}

body.mobile-login-page .modal-panel {
  width: min(420px, 100%);
  margin: 0 auto;
  box-shadow: none;
  animation: none;
}

@media (max-width: 480px) {
  .method-btn {
    padding: 9px 11px;
    gap: 10px;
  }

  .qr-frame {
    width: 100%;
    max-width: 196px;
  }
}

/* 邮箱模式切换：salutation 与 mode 的一致性微调 */
.form-title:empty {
  display: none;
}
