/* claude-webui 样式 */
:root {
  --bg: #0f1117;
  --bg-panel: #171a23;
  --bg-hover: #1e2230;
  --border: #2a2f3f;
  --text: #e6e8ee;
  --text-dim: #9aa1b5;
  --accent: #d97757;
  --accent-dim: #b85c3e;
  --user-bubble: #2b3a52;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px;
}

/* 登录页 Tab */
.auth-tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg); border-radius: 8px; padding: 4px; }
.auth-tab {
  flex: 1; padding: 8px; border: none; border-radius: 6px; background: transparent;
  color: var(--text-dim); font-size: 14px; cursor: pointer;
}
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-tab:disabled { opacity: .4; cursor: not-allowed; }

/* 用户信息区 */
.user-info {
  padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px;
  color: var(--text-dim); display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap;
}
.user-info .u-name { color: var(--text); font-weight: 600; }
.user-info a.admin-link { color: #79b8ff; text-decoration: none; }
.user-info a.admin-link:hover { text-decoration: underline; }

/* ---- 登录页 ---- */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 44px; width: 360px; text-align: center;
}
.login-logo { font-size: 40px; color: var(--accent); margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 28px; }
.login-card input {
  width: 100%; padding: 11px 14px; margin-bottom: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.login-card button:hover { background: var(--accent-dim); }
.login-card button:disabled { opacity: .6; cursor: wait; }
.login-error { color: #ff7b72; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---- 聊天页布局 ---- */
.chat-wrap { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 280px; flex-shrink: 0; background: var(--bg-panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.side-head { padding: 16px 16px 8px; display: flex; align-items: center; justify-content: space-between; }
.side-head .brand { font-weight: 600; font-size: 15px; }
.side-head .brand span { color: var(--accent); }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }
.new-chat-btn {
  margin: 8px 16px; padding: 9px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; font-size: 14px;
}
.new-chat-btn:hover { background: var(--accent-dim); }
.session-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.session-item {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--text-dim);
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-item:hover { background: var(--bg-hover); color: var(--text); }
.session-item.active { background: var(--bg-hover); color: var(--text); border-left: 2px solid var(--accent); }

/* 文件面板 */
.files-panel { border-top: 1px solid var(--border); max-height: 40%; display: flex; flex-direction: column; }
.files-head {
  padding: 10px 16px; display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-dim); font-weight: 600;
}
.files-head .actions { display: flex; gap: 6px; }
.file-list { overflow-y: auto; padding: 0 8px 8px; }
.file-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  font-size: 13px;
}
.file-item:hover { background: var(--bg-hover); }
.file-item .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .f-size { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.file-item .f-icon { flex-shrink: 0; }
.file-item a.dl, .file-item button.del {
  color: var(--text-dim); text-decoration: none; cursor: pointer; background: none;
  border: none; font-size: 13px; padding: 2px 4px;
}
.file-item a.dl:hover { color: #7ee787; }
.file-item button.del:hover { color: #ff7b72; }
.file-item a.dl {
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 8px; font-size: 12px;
}
.file-item button.del { border: none; font-size: 12px; }

/* 聊天流里的文件下载卡片 */
.file-card {
  display: inline-flex; align-items: center; gap: 8px;
  background: #16281f; border: 1px solid #2e5c42; border-radius: 8px;
  padding: 8px 12px; margin: 4px 0 8px; max-width: 100%;
}
.file-card .fc-icon { font-size: 18px; }
.file-card .fc-name {
  font-size: 13px; color: #d9f2e5; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-card .fc-size { font-size: 11px; color: #6f9e85; flex-shrink: 0; }
.file-card .fc-btn {
  background: var(--accent); color: #fff; text-decoration: none;
  border-radius: 6px; padding: 5px 12px; font-size: 13px; flex-shrink: 0;
}
.file-card .fc-btn:hover { background: var(--accent-dim); }
.files-empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 12px; }
.upload-label {
  margin: 0 16px 12px; padding: 8px; text-align: center; border: 1px dashed var(--border);
  border-radius: 8px; color: var(--text-dim); font-size: 12px; cursor: pointer; display: block;
}
.upload-label:hover { border-color: var(--accent); color: var(--accent); }
.upload-label input { display: none; }

/* 主聊天区 */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 24px 0; }
.msg-row { max-width: 760px; margin: 0 auto; padding: 0 20px; display: flex; margin-bottom: 18px; }
.msg-row .avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; margin-right: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 15px; margin-top: 2px;
}
.msg-row.assistant .avatar { background: var(--accent); color: #fff; }
.msg-row.user { justify-content: flex-end; }
.msg-row.user .avatar { order: 2; margin-right: 0; margin-left: 12px; background: var(--user-bubble); }
.msg-bubble {
  max-width: 82%; padding: 12px 16px; border-radius: var(--radius); line-height: 1.65;
  overflow-wrap: break-word; min-width: 0;
}
.msg-row.assistant .msg-bubble { background: var(--bg-panel); border: 1px solid var(--border); }
.msg-row.user .msg-bubble { background: var(--user-bubble); }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 8px 0 8px 22px; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 12px 0 8px; font-size: 1.05em; }
.msg-bubble code {
  background: #0b0d12; border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-size: .9em; font-family: "SF Mono", Consolas, monospace;
}
.msg-bubble pre {
  background: #0b0d12; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow-x: auto; margin: 8px 0;
}
.msg-bubble pre code { background: none; border: none; padding: 0; }
.msg-bubble a { color: #79b8ff; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #1a2233;
  border: 1px solid #2c3a55; color: #8ab4ff; border-radius: 6px;
  padding: 3px 10px; font-size: 12px; margin: 4px 0;
}
.typing-cursor { display: inline-block; width: 8px; height: 16px; background: var(--accent);
  vertical-align: text-bottom; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.empty-hint { text-align: center; color: var(--text-dim); margin-top: 18vh; }
.empty-hint .big { font-size: 44px; color: var(--accent); margin-bottom: 12px; }
.empty-hint .tips { font-size: 13px; line-height: 2; }

/* 输入区 */
.input-bar { border-top: 1px solid var(--border); background: var(--bg-panel); padding: 14px 20px; }
.input-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.input-inner textarea {
  flex: 1; resize: none; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px;
  font-size: 14px; font-family: inherit; line-height: 1.5; max-height: 160px; outline: none;
}
.input-inner textarea:focus { border-color: var(--accent); }
.send-btn {
  background: var(--accent); border: none; color: #fff; border-radius: 10px;
  padding: 11px 20px; font-size: 14px; cursor: pointer; flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-dim); }
.send-btn:disabled { opacity: .5; cursor: wait; }
.status-line { max-width: 760px; margin: 6px auto 0; font-size: 12px; color: var(--text-dim); min-height: 16px; padding: 0 2px; }

/* 移动端 */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -300px; top: 0; bottom: 0; z-index: 10; transition: left .25s; }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.5); }
  .mobile-toggle { display: block !important; }
  .msg-bubble { max-width: 92%; }
  .chat-main { width: 100%; }
}
.mobile-toggle { display: none; }
.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 9; }
.sidebar-mask.show { display: block; }
