/* ===== AI 美术教室 · 仿 DeepSeek 风格 ===== */
:root {
  --accent: #4d6bfe;
  --accent-soft: #eef1ff;
  --bg: #ffffff;
  --sidebar-bg: #f4f5f7;
  --border: #e6e8eb;
  --text: #1f2329;
  --text-2: #51565f;
  --text-3: #8a919f;
  --hover: #eceef2;
  --danger: #f4544c;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.65;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea, input { font-family: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none; }

/* ===== 密码门 ===== */
.gate {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef1ff 0%, #fdf6ee 55%, #e9f7f0 100%);
}
.gate-card {
  background: #fff; border-radius: 20px; padding: 44px 40px 32px;
  width: 400px; max-width: 92vw; text-align: center;
  box-shadow: 0 12px 40px rgba(31, 35, 41, .08);
}
.gate-logo { font-size: 52px; line-height: 1; margin-bottom: 14px; }
.gate-card h1 { font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.gate-sub { color: var(--text-3); margin-top: 8px; font-size: 14px; }
.gate-form { margin-top: 26px; display: flex; gap: 10px; }
.gate-form input {
  flex: 1; padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 15px; outline: none;
  transition: border-color .15s;
}
.gate-form input:focus { border-color: var(--accent); }
.gate-form button {
  padding: 12px 20px; background: var(--accent); color: #fff;
  border-radius: var(--radius); font-size: 15px; font-weight: 600;
  transition: opacity .15s; white-space: nowrap;
}
.gate-form button:hover { opacity: .88; }
.gate-form button:disabled { opacity: .5; cursor: not-allowed; }
.gate-err { color: var(--danger); font-size: 13.5px; margin-top: 12px; min-height: 20px; }
.gate-tip { color: var(--text-3); font-size: 12.5px; margin-top: 14px; }

/* ===== 布局 ===== */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 260px; min-width: 260px; background: var(--sidebar-bg);
  display: flex; flex-direction: column; border-right: 1px solid var(--border);
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.logo-icon { font-size: 20px; }
.new-chat-btn {
  margin: 6px 12px 10px; padding: 10px 14px; text-align: left;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 8px; transition: all .15s;
}
.new-chat-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.plus { font-size: 16px; }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.conv-item {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
  transition: background .12s;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: #e8ebff; }
.conv-item .conv-title {
  flex: 1; font-size: 13.5px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item.active .conv-title { color: var(--accent); font-weight: 600; }
.conv-item .conv-del {
  visibility: hidden; color: var(--text-3); font-size: 13px;
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
}
.conv-item:hover .conv-del { visibility: visible; }
.conv-item .conv-del:hover { background: #dde0e6; color: var(--danger); }

.sidebar-foot {
  border-top: 1px solid var(--border); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.user-badge { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.user-avatar { font-size: 18px; }
.logout-btn { font-size: 13px; color: var(--text-3); padding: 4px 8px; border-radius: 6px; }
.logout-btn:hover { color: var(--danger); background: #fdeceb; }

/* ===== 主区域 ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 10px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { flex: 1; font-weight: 600; font-size: 14.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-switch {
  display: flex; background: var(--sidebar-bg); border-radius: 10px; padding: 3px; gap: 2px;
}
.mode-btn {
  padding: 6px 14px; border-radius: 8px; font-size: 13.5px; color: var(--text-2);
  transition: all .15s;
}
.mode-btn.active { background: #fff; color: var(--accent); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.icon-btn { font-size: 16px; padding: 6px 10px; border-radius: 8px; color: var(--text-2); }
.icon-btn:hover { background: var(--hover); }

.chat-area { flex: 1; overflow-y: auto; }

.welcome {
  max-width: 720px; margin: 0 auto; padding: 12vh 24px 40px; text-align: center;
}
.welcome-logo { font-size: 56px; line-height: 1; margin-bottom: 16px; }
.welcome h2 { font-size: 24px; font-weight: 700; }
.welcome-sub { color: var(--text-3); margin-top: 10px; font-size: 14.5px; }
.welcome-chips { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 13.5px; color: var(--text-2); background: #fff; transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ===== 消息 ===== */
.messages { max-width: 780px; margin: 0 auto; padding: 24px 24px 10px; }
.msg { display: flex; gap: 12px; margin-bottom: 28px; }
.msg .avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--sidebar-bg);
}
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: var(--accent-soft); }
.msg .bubble {
  max-width: calc(100% - 60px); min-width: 0;
  padding: 10px 16px; border-radius: 16px;
  background: var(--sidebar-bg); overflow-wrap: break-word;
}
.msg.user .bubble { background: var(--accent-soft); border-top-right-radius: 6px; }
.msg.assistant .bubble { background: transparent; padding-left: 0; padding-right: 0; }
.msg .bubble .plain { white-space: pre-wrap; }

/* markdown 样式 */
.md { font-size: 15px; }
.md p { margin: 0 0 12px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 10px; line-height: 1.4; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; }
.md ul, .md ol { padding-left: 24px; margin: 0 0 12px; }
.md li { margin: 4px 0; }
.md code {
  background: #f1f2f5; padding: 2px 6px; border-radius: 5px;
  font-size: 13px; font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
.md pre {
  background: #1e2430; color: #d6dce6; padding: 14px 16px; border-radius: 10px;
  overflow-x: auto; margin: 0 0 14px;
}
.md pre code { background: none; padding: 0; font-size: 13px; line-height: 1.6; }
.md blockquote { border-left: 3px solid var(--border); padding-left: 14px; color: var(--text-3); margin: 0 0 12px; }
.md table { border-collapse: collapse; margin: 0 0 12px; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 12px; }
.md th { background: var(--sidebar-bg); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md a { color: var(--accent); }
.md img { max-width: 100%; border-radius: 10px; }

/* 深度思考块 */
.think-box {
  border-left: 3px solid #c9cede; margin-bottom: 12px; padding: 8px 14px;
  background: #f7f8fa; border-radius: 0 8px 8px 0; font-size: 13.5px;
}
.think-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  color: var(--text-3); font-size: 13px; user-select: none; font-weight: 500;
}
.think-head .think-arrow { transition: transform .2s; font-size: 11px; }
.think-box.open .think-arrow { transform: rotate(90deg); }
.think-body { display: none; margin-top: 10px; color: var(--text-3); white-space: pre-wrap; font-size: 13px; line-height: 1.7; }
.think-box.open .think-body { display: block; }

/* 图片消息 */
.img-result { position: relative; display: inline-block; }
.img-result img {
  max-width: min(480px, 100%); border-radius: 14px; display: block;
  border: 1px solid var(--border); cursor: zoom-in;
}
.img-actions { display: flex; gap: 8px; margin-top: 10px; }
.img-action-btn {
  font-size: 13px; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-2); transition: all .15s;
}
.img-action-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 打字光标 */
.cursor { display: inline-block; width: 8px; height: 17px; background: var(--accent); vertical-align: -3px; border-radius: 2px; animation: blink 1s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.loading-dots { display: inline-flex; gap: 4px; }
.loading-dots i { width: 6px; height: 6px; background: var(--text-3); border-radius: 50%; animation: bounce 1.2s infinite; }
.loading-dots i:nth-child(2) { animation-delay: .15s; }
.loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.msg-error { color: var(--danger); font-size: 14px; background: #fdeceb; padding: 10px 14px; border-radius: 10px; }
.stop-btn {
  margin-top: 10px; font-size: 13px; padding: 5px 16px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-2); transition: all .15s;
}
.stop-btn:hover { color: var(--danger); border-color: #f5b8b4; }

/* ===== 输入区 ===== */
.composer-wrap { padding: 8px 16px 12px; background: linear-gradient(transparent, #fff 30%); }
.composer {
  max-width: 780px; margin: 0 auto;
  border: 1.5px solid var(--border); border-radius: 18px; background: #fff;
  padding: 12px 14px 10px; transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,107,254,.1); }
.mode-hint { font-size: 12.5px; color: var(--accent); margin-bottom: 6px; display: none; }
.composer textarea {
  width: 100%; border: none; outline: none; resize: none;
  font-size: 15px; line-height: 1.6; max-height: 180px; background: transparent;
}
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

.model-select-wrap { position: relative; }
.model-select {
  display: flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-2);
  background: var(--sidebar-bg); transition: background .12s; user-select: none;
}
.model-select:hover { background: var(--hover); }
.caret { font-size: 10px; color: var(--text-3); }
.model-dropdown {
  position: absolute; bottom: 40px; left: 0; min-width: 260px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12); padding: 6px; z-index: 20;
}
.model-option { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.model-option:hover { background: var(--sidebar-bg); }
.model-option.selected { background: var(--accent-soft); }
.mo-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.model-option.selected .mo-name { color: var(--accent); }
.mo-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.send-wrap { display: flex; align-items: center; gap: 8px; }
.send-btn {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.send-btn:hover { opacity: .85; }
.send-btn:disabled { background: #c3cdfd; cursor: not-allowed; }
.composer-note { text-align: center; font-size: 11.5px; color: #b6bcc6; margin-top: 8px; }

/* ===== 图片弹窗 ===== */
.img-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.img-modal-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 92vw; }
.img-modal-inner img { max-width: min(80vw, 900px); max-height: 78vh; border-radius: 14px; }
.img-modal-actions { display: flex; gap: 12px; }
.img-dl-btn, .img-close-btn {
  padding: 9px 20px; border-radius: 10px; font-size: 14px; text-decoration: none;
}
.img-dl-btn { background: #fff; color: var(--text); font-weight: 600; }
.img-close-btn { background: rgba(255,255,255,.15); color: #fff; }
.img-dl-btn:hover { background: #eef0f3; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d5d8de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bdc2ca; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 移动端 ===== */
@media (max-width: 760px) {
  .mobile-only { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform .25s;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
  .messages { padding: 16px 14px 8px; }
  .msg .bubble { max-width: calc(100% - 52px); }
  .welcome { padding-top: 8vh; }
  .mode-switch { display: none; }
  .composer-wrap { padding: 8px 10px 10px; }
  .model-dropdown { left: auto; right: -4px; }
}
