:root {
  --sidebar-w: 260px;
  --bg: #F5F3EE;
  --bg-main: #FAF9F6;
  --bg-input: #FFFFFF;
  --card: #FFFFFF;
  --card-hover: #F0EDE6;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --text: #2D2B26;
  --text2: #6B6966;
  --text3: #9B9892;
  --border: #E5E2DB;
  --accent: #C96442;
  --accent-hover: #B55A3A;
  --danger: #DC4A38;
  --warning: #D97706;
  --code-bg: #F4F2ED;
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  color: var(--text);
}

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

code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 6px;
}

.hljs { background: transparent !important; color: #383838 !important; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(201, 100, 66, 0.1);
  color: #92400E;
  font-size: 12px;
  margin-bottom: 14px;
}

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  line-height: 1.7;
  font-size: 14px;
}

.notice.info {
  background: rgba(59, 130, 246, 0.08);
  color: #1E40AF;
}

.notice.success {
  background: rgba(34, 197, 94, 0.08);
  color: #166534;
}

.notice.error {
  background: rgba(239, 68, 68, 0.08);
  color: #991B1B;
}

.notice.warning {
  background: rgba(245, 158, 11, 0.08);
  color: #92400E;
}

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

.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text2);
  font-size: 13px;
}

.stack-form input,
.stack-form textarea,
.stack-form select {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.stack-form input:focus,
.stack-form textarea:focus,
.stack-form select:focus {
  border-color: rgba(201, 100, 66, 0.4);
  box-shadow: 0 0 0 4px rgba(201, 100, 66, 0.08);
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

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

.secondary-btn {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.secondary-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.divider {
  margin: 24px 0 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text3);
  font-size: 13px;
}

.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.login-hero,
.login-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}

.login-hero {
  padding: 40px;
}

.login-hero h1 {
  font-size: 40px;
  line-height: 1.15;
  margin-bottom: 14px;
}

.login-hero p {
  color: var(--text2);
  line-height: 1.8;
  max-width: 560px;
}

.tips {
  margin-top: 28px;
  display: grid;
  gap: 14px;
}

.tip-card {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tip-card strong {
  font-size: 14px;
}

.tip-card span {
  color: var(--text2);
  line-height: 1.7;
  font-size: 14px;
}

.login-card {
  padding: 32px;
}

.login-card h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.subtext {
  color: var(--text3);
  margin-bottom: 20px;
}

.chat-page {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
}

.sidebar {
  width: var(--sidebar-w);
  background: #EDEAE3;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.015);
}

.sidebar-top {
  padding: 14px 12px 10px;
}

.btn-new,
.btn-setting,
.btn-icon,
.btn-send,
.btn-search-toggle,
.model-picker-btn,
.modal-close,
.btn-modal {
  border: none;
  cursor: pointer;
}

a.btn-setting,
a.btn-icon,
a.btn-modal {
  text-decoration: none;
}

.btn-new {
  width: 100%;
  background: rgba(0, 0, 0, 0.025);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.025);
}

.btn-new:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.btn-new svg {
  flex-shrink: 0;
}

.btn-setting {
  width: 100%;
  background: rgba(0, 0, 0, 0.02);
  color: var(--text2);
  border: none;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-setting:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.btn-setting .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; display: none; }
.btn-setting .dot.active { display: block; }

.session-count {
  font-size: 12px;
  color: var(--text3);
  background: rgba(0, 0, 0, 0.05);
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 10px;
}

.session-item,
.list-card {
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  margin-bottom: 6px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--text2);
  transition: all 0.18s ease;
}

.session-item {
  align-items: center;
}

.session-item:hover,
.list-card:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
}

.session-item.active,
.list-card.active {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.035);
}

.session-item .s-status,
.list-card .s-status {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex-shrink: 0;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.08);
}

.session-item .s-status {
  margin-top: 0;
  align-self: center;
}

.session-item.generating .s-status {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.s-info,
.list-card .card-main {
  flex: 1;
  min-width: 0;
}

.title-line,
.card-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-line,
.card-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text3);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.del {
  color: var(--text3);
  padding: 2px 4px;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.session-item .del {
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-item:hover .del {
  opacity: 0.8;
}

.del:hover {
  color: var(--danger);
}

.sidebar-bottom {
  padding: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-bottom svg {
  flex-shrink: 0;
}

.user-panel {
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.025);
}

.user-name {
  font-size: 14px;
  font-weight: 600;
}

.user-subline {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text3);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
}

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

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-title strong {
  font-size: 15px;
}

.topbar-title span {
  color: var(--text3);
  font-size: 13px;
}

.topbar-right {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: rgba(0, 0, 0, 0.025);
  color: var(--text2);
  border-radius: 12px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px 28px;
}

.chat-scroll {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 18px;
}

.msg-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.msg-row.user {
  justify-content: flex-end;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, #C96442, #D4845A);
  color: #fff;
}

.msg-content {
  flex: 1;
  max-width: 100%;
  min-width: 0;
}

.msg-row.user .msg-content {
  max-width: 72%;
}

.msg-bubble {
  font-size: 15px;
  line-height: 1.75;
  word-break: break-word;
}

.msg-row.user .msg-bubble {
  background: #EAE7E0;
  color: var(--text);
  padding: 11px 16px;
  border-radius: 20px;
  white-space: pre-wrap;
}

.msg-row.assistant .msg-bubble p {
  margin: 0 0 10px;
}

.msg-row.assistant .msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-row.assistant .stream-preview-plain {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.assistant .msg-bubble blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--text2); margin: 10px 0; }
.msg-row.assistant .msg-bubble a { color: var(--accent); text-decoration: none; }
.msg-row.assistant .msg-bubble a:hover { text-decoration: underline; }

.msg-row.assistant .msg-bubble pre {
  background: var(--code-bg);
  border-radius: 14px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.msg-row.assistant .msg-bubble :not(pre) > code {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 6px;
}

.msg-row.assistant .msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.msg-row.assistant .msg-bubble thead {
  background: rgba(0, 0, 0, 0.04);
}

.msg-row.assistant .msg-bubble th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}

.msg-row.assistant .msg-bubble td {
  padding: 9px 14px;
  color: var(--text2);
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.msg-row.assistant .msg-bubble tr:last-child td {
  border-bottom: none;
}

.msg-row.assistant .msg-bubble tbody tr:hover td {
  background: rgba(0, 0, 0, 0.025);
}

.error-bubble { color: #ef4444; }
.error-actions { display: flex; gap: 6px; margin-top: 8px; }
.error-actions button { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.25); border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; transition: all .15s; }
.error-actions button:hover { background: rgba(239,68,68,0.2); }

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  color: var(--text3);
  font-size: 12px;
}

.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.msg-row:hover .msg-actions {
  opacity: 0.8;
}

.btn-copy {
  border: none;
  background: transparent;
  color: var(--text3);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-copy:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.btn-copy.btn-del:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

.msg-actions:has(.btn-copy-full) {
  opacity: 1;
}

.btn-copy-full {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.03);
  color: var(--text2);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-copy-full:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.12);
}

.btn-copy-full svg {
  flex-shrink: 0;
}

.edit-textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  min-height: 44px;
}

.edit-textarea:focus {
  outline: none;
}

.edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-action {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: none;
}

.btn-action.save {
  background: var(--accent);
  color: #fff;
}

.btn-action.save:hover {
  background: var(--accent-hover);
}

.btn-action.cancel {
  background: transparent;
  color: var(--text3);
}

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

.user-select {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  margin: 0;
}

.user-select:focus {
  outline: none;
  border-color: var(--accent);
}

.sidebar-bottom .user-select {
  margin-bottom: 4px;
}

.btn-send.stopping {
  background: var(--danger);
}

.btn-send.stopping:hover {
  background: #dc2626;
}

.typing-dot {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dot span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  animation: bounce 0.6s infinite alternate;
}

.typing-dot span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  to {
    opacity: 0.3;
    transform: translateY(-4px);
  }
}

.empty-state {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: var(--text3);
}

.empty-state.small {
  min-height: 260px;
}

.empty-state .logo {
  font-size: 48px;
  font-weight: 700;
  color: var(--text);
}

.empty-state .hint {
  font-size: 15px;
  line-height: 1.7;
  max-width: 360px;
}

/* 消息队列 */
.queue-wrap { padding: 0 20px; }
.queue-box { max-width: 768px; margin: 0 auto; }
.queue-box:empty { display: none; }
.queue-item { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.03); border-radius: 12px; padding: 9px 12px; margin-bottom: 8px; border: 1px solid rgba(0,0,0,.04); transition: border-color .15s, background .15s; }
.queue-item.editing { border-color: var(--accent); }
.queue-item.processing { border-color: rgba(201,100,66,.24); background: rgba(201,100,66,.06); }
.queue-item .q-num { color: var(--text3); font-size: 12px; min-width: 18px; text-align: center; flex-shrink: 0; }
.queue-item .q-status { min-width: 54px; height: 24px; padding: 0 10px; border-radius: 999px; background: rgba(201,100,66,.1); color: #92400E; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.queue-item .q-text { flex: 1; color: var(--text); font-size: 14px; line-height: 1.5; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.queue-item.processing .q-text { color: #78350F; }
.queue-item textarea.q-edit { flex: 1; background: transparent; border: none; color: var(--text); font-size: 14px; line-height: 1.5; resize: none; padding: 0; font-family: inherit; min-height: 20px; max-height: 100px; }
.queue-item textarea.q-edit:focus { outline: none; }
.queue-item .q-actions { display: flex; gap: 2px; flex-shrink: 0; }
.queue-item .q-btn { background: transparent; border: none; color: var(--text3); width: 26px; height: 26px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; padding: 0; }
.queue-item .q-btn:hover { color: var(--text); background: var(--bg-hover); }
.queue-item .q-btn.q-save { color: var(--accent); }

.input-wrap {
  padding: 0 20px 22px;
}

.input-box {
  max-width: 820px;
  margin: 0 auto;
  background: #FFFFFF;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: rgba(201, 100, 66, 0.4);
  box-shadow: 0 0 0 4px rgba(201, 100, 66, 0.08), var(--shadow-soft);
}

.input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 13px 12px;
  font-size: 15px;
  line-height: 1.55;
  font-family: inherit;
  resize: none;
  height: 52px;
  max-height: 160px;
  outline: none;
}

.input-box textarea::placeholder {
  color: var(--text3);
}

.model-picker {
  position: relative;
  display: flex;
  flex-shrink: 0;
}

.model-picker-btn {
  background: transparent;
  color: var(--text2);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  padding: 8px 15px;
  min-width: 112px;
  display: flex;
  align-items: center;
}

.model-dropdown {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 220px;
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  padding: 6px;
  display: none;
  z-index: 10;
}

.model-dropdown.open {
  display: block;
}

.model-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text2);
}

.model-item:hover,
.model-item.active {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.btn-search-toggle,
.btn-send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.btn-search-toggle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: transparent;
  color: var(--text3);
}

.btn-search-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.btn-search-toggle.active {
  background: rgba(201, 100, 66, 0.1);
  color: var(--accent);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(201, 100, 66, 0.2);
}

.btn-send:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(201, 100, 66, 0.25);
}

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

.main.empty-mode .chat-area {
  flex: 0 0 auto;
  margin-top: auto;
  overflow: visible;
}

.main.empty-mode .queue-wrap { display: none; }
.main.empty-mode .input-wrap {
  margin-bottom: auto;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  width: min(560px, 92vw);
  max-height: 84vh;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
}

.modal-header,
.modal-footer {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

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

.modal-body textarea {
  width: 100%;
  min-height: 180px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-body textarea:focus {
  outline: none;
  border-color: rgba(201, 100, 66, 0.4);
  box-shadow: 0 0 0 4px rgba(201, 100, 66, 0.08);
}

.modal-body textarea::placeholder {
  color: var(--text3);
}

.modal-body .hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent);
  opacity: 0.85;
}

.modal-close {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text2);
  border-radius: 8px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
}

.btn-modal {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-modal:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-modal.primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-modal.secondary {
  background: rgba(0, 0, 0, 0.04);
}

.admin-page {
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

.admin-layout {
  display: flex;
  height: 100%;
}

.admin-sidebar {
  width: 240px;
  background: #EDEAE3;
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.admin-sidebar-top {
  padding: 20px 16px 12px;
}

.admin-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.admin-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-item {
  width: 100%;
  background: transparent;
  color: var(--text2);
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
  text-align: left;
}

.admin-nav-item:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
}

.admin-nav-item.active {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.admin-sidebar-bottom {
  padding: 10px 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-user-info {
  padding: 12px 14px;
  margin-bottom: 4px;
}

.admin-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.admin-user-role {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.admin-nav-link {
  width: 100%;
  background: transparent;
  color: var(--text2);
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.15s;
  text-decoration: none;
  text-align: left;
}

.admin-nav-link:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  background: var(--bg-main);
}

.admin-content-header {
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.admin-content-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 0;
  width: 100%;
}

.admin-content-header p {
  color: var(--text3);
  font-size: 14px;
  flex: 1;
}

.admin-header-btn {
  flex-shrink: 0;
}

.admin-form-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.admin-tab:not(.admin-split-parent) > .admin-form-card {
  max-width: 480px;
}

#tab-create .admin-form-card {
  max-width: 480px;
}


.admin-form-hint {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.7;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
  padding: 10px 12px;
}

.admin-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text2);
}

.admin-check-row input {
  width: 16px;
  height: 16px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 12px;
}

.toggle-row span {
  font-size: 14px;
  color: var(--text2);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
}

.field-extra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 4px;
}

.field-extra-link {
  background: none;
  border: none;
  color: var(--danger, #dc2626);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.field-extra-link:hover {
  opacity: 1;
}

.admin-table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #FFFFFF;
}

.admin-table {
  min-width: 780px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  padding: 14px 16px;
  color: var(--text3);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  background: rgba(0, 0, 0, 0.015);
  white-space: nowrap;
}

.admin-table td {
  padding: 14px 16px;
  color: var(--text2);
  border-bottom: 1px solid rgba(0, 0, 0, 0.025);
  white-space: nowrap;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

.admin-table strong {
  color: var(--text);
  font-weight: 600;
}

.admin-table th:last-child,
.admin-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #FFFFFF;
}

.admin-table th:last-child {
  background: rgba(249, 250, 251, 1);
}

.admin-table tr:hover td:last-child {
  background: rgba(249, 250, 251, 1);
}

.admin-table td:last-child::before,
.admin-table th:last-child::before {
  content: "";
  position: absolute;
  top: 0;
  left: -6px;
  bottom: 0;
  width: 6px;
  pointer-events: none;
  background: linear-gradient(270deg, rgba(0,0,0,0.04), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.admin-table-wrap.is-scroll-end td:last-child::before,
.admin-table-wrap.is-scroll-end th:last-child::before {
  opacity: 0;
}

.admin-table-wrap.is-scrollable td:last-child::before,
.admin-table-wrap.is-scrollable th:last-child::before {
  opacity: 1;
}

.admin-table-wrap.is-scroll-end td:last-child::before,
.admin-table-wrap.is-scroll-end th:last-child::before {
  opacity: 0;
}

.role-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.role-tag.admin {
  background: rgba(201, 100, 66, 0.1);
  color: #92400E;
}

.role-tag.staff {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text3);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.on {
  background: #22c55e;
}

.status-dot.off {
  background: var(--danger);
}

.table-action {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}

.table-action:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.table-action-btn {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.table-action-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.admin-tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text3);
  font-size: 12px;
}

.admin-tag.muted {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text3);
}

.admin-sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-sub-tab {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text2);
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-sub-tab:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text);
}

.admin-sub-tab.active {
  background: var(--text);
  color: #fff;
}

.admin-sub-tab .sub-tab-count {
  margin-left: 4px;
  opacity: 0.6;
  font-size: 12px;
}

.admin-empty-cell {
  text-align: center;
  color: var(--text3);
  padding: 40px !important;
}

.admin-ellipsis {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.admin-muted {
  color: var(--text3);
}

.session-list::-webkit-scrollbar,
.chat-area::-webkit-scrollbar,
.list-stack::-webkit-scrollbar,
.admin-message-board::-webkit-scrollbar {
  width: 6px;
}

.session-list::-webkit-scrollbar-thumb,
.chat-area::-webkit-scrollbar-thumb,
.list-stack::-webkit-scrollbar-thumb,
.admin-message-board::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
}

/* 骨架屏 */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton-bone {
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-session {
  padding: 10px 12px;
  border-radius: 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.skeleton-session .sk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 8px;
}

.skeleton-session .sk-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-session .sk-title {
  height: 14px;
  width: 70%;
}

.skeleton-session .sk-meta {
  height: 10px;
  width: 50%;
}

.skeleton-msg {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.skeleton-msg.right {
  justify-content: flex-end;
}

.skeleton-msg .sk-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-msg .sk-bubble {
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  max-width: 100%;
}

.skeleton-msg.right .sk-bubble {
  max-width: 50%;
  flex: none;
}

.skeleton-msg .sk-line {
  height: 14px;
  border-radius: 7px;
}

.skeleton-msg.right .sk-line {
  height: 38px;
  border-radius: 19px;
}

.skeleton-table-row {
  display: flex;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.skeleton-table-row .sk-cell {
  height: 14px;
  border-radius: 7px;
}

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

  .chat-page {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
  }

  .admin-sidebar {
    width: 200px;
  }

  .admin-content {
    padding: 24px 20px;
  }

}

/* Toast 轻提示 */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: toastIn 0.25s ease, toastOut 0.25s ease forwards;
  pointer-events: auto;
  max-width: 420px;
  word-break: break-word;
}

.toast.error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.toast.success {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

.toast.info {
  background: #FFFBEB;
  color: #92400E;
  border: 1px solid #FDE68A;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  0%, 75% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* Confirm 确认弹窗 */
.confirm-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirmFadeIn 0.15s ease;
}

.confirm-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  width: min(400px, 88vw);
  padding: 24px;
  animation: confirmSlideIn 0.2s ease;
}

.confirm-box .confirm-msg {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 20px;
}

.confirm-box .confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-box .confirm-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.confirm-box .confirm-cancel {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text2);
}

.confirm-box .confirm-cancel:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}

.confirm-box .confirm-ok {
  background: var(--danger);
  color: #fff;
}

.confirm-box .confirm-ok:hover {
  background: #C4362A;
}

/* Loading 全屏遮罩 */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirmFadeIn 0.15s ease;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: #fff;
  padding: 28px 40px;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-text {
  font-size: 14px;
  color: var(--text2);
}

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

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

@keyframes confirmSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
