:root {
  --navy: #0f2a4a;
  --navy-2: #17395f;
  --ink: #1c2430;
  --muted: #6b7684;
  --line: #e4e8ee;
  --bg: #f7f8fb;
  --card: #ffffff;
  --gold: #c98a12;
  --gold-soft: #fdf4e3;
  --user-bubble: #17395f;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 32, 56, 0.06), 0 12px 32px rgba(16, 32, 56, 0.07);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---------- 侧边栏 ---------- */

.sidebar {
  background: linear-gradient(180deg, var(--navy) 0%, #0b2039 100%);
  color: #e8eef6;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  background: linear-gradient(160deg, #f6c667, #d9931c);
  color: #10243d;
  font-weight: 800;
  display: grid; place-items: center;
  font-size: 20px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 17px; letter-spacing: 0.5px; }
.brand-text span { font-size: 12px; color: #9db2cd; }

.side-title {
  font-size: 12px;
  color: #9db2cd;
  letter-spacing: 1px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

.persona-list { display: flex; flex-direction: column; gap: 8px; }

.persona-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  font-family: inherit;
}

.persona-item:hover { background: rgba(255, 255, 255, 0.09); }
.persona-item.active {
  background: rgba(246, 198, 103, 0.16);
  border-color: rgba(246, 198, 103, 0.55);
}

.persona-emoji { font-size: 19px; line-height: 1.2; }
.persona-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.persona-meta strong { font-size: 13.5px; }
.persona-meta em { font-style: normal; font-size: 11px; color: #9db2cd; }

.profile-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.7;
}

.profile-card .muted { color: #93a7c1; margin: 0; }
.profile-row { display: flex; gap: 6px; }
.profile-row b { color: #9db2cd; font-weight: 500; flex: none; }

/* 官方入口查询：给家长一条不依赖 AI 也能自己核实的路径 */
.source-hint { margin: 0; }
.source-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.source-panel[hidden] { display: none; }
.source-group { display: flex; flex-direction: column; gap: 6px; }
.source-group-title { font-size: 11px; color: #9db2cd; letter-spacing: 0.5px; }
.source-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  color: #dce6f2;
  text-decoration: none;
  font-size: 12px;
  transition: background 0.15s;
}
.source-item:hover { background: rgba(255, 255, 255, 0.1); }
.source-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-tag { flex: none; font-size: 10px; padding: 1px 6px; border-radius: 999px; }
.source-tag.ok { background: rgba(133, 214, 160, 0.16); color: #8ed7a8; }
.source-tag.warn { background: rgba(246, 198, 103, 0.16); color: #f0c877; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.ghost-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: #dce6f2;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.ghost-btn:hover { background: rgba(255, 255, 255, 0.08); }

.mini-btn {
  border: none; background: none; color: #f6c667;
  font-size: 11px; cursor: pointer; letter-spacing: 0; font-family: inherit;
}

.tiny { font-size: 11px; color: #8698ae; margin: 0; line-height: 1.6; }
.muted { color: var(--muted); }

/* ---------- 主区域 ---------- */

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

.topbar {
  height: 60px;
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
}

.topbar-title { font-weight: 700; font-size: 15px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #8a5d05;
  border: 1px solid #f0dcb0;
  white-space: nowrap;
}

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  display: grid; place-items: center;
}

.only-mobile { display: none; }

.scroll { flex: 1; overflow-y: auto; padding: 28px 20px 8px; scroll-behavior: smooth; }

.hero { max-width: 780px; margin: 0 auto 26px; }

.hero h1 {
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.32;
  margin: 0 0 12px;
  letter-spacing: -0.3px;
}

.hl { color: var(--gold); }

.hero-sub { color: var(--muted); font-size: 14.5px; line-height: 1.85; margin: 0 0 10px; }
.hero-note {
  font-size: 13px; color: #8a6a1e;
  background: var(--gold-soft);
  border-left: 3px solid #e8bd63;
  padding: 10px 14px; border-radius: 0 10px 10px 0;
  margin: 16px 0 0;
}

.chat { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: 12px; }

.msg { display: flex; gap: 12px; }
.msg.user { flex-direction: row-reverse; }

.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.msg.user .avatar { background: var(--navy); color: #fff; border-color: var(--navy); font-size: 13px; }

.bubble {
  max-width: min(680px, 82%);
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 14.5px;
  line-height: 1.85;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: #eef3f9;
  box-shadow: none;
}

.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3 { font-size: 15px; margin: 16px 0 8px; }
.bubble h4 { font-size: 14px; margin: 14px 0 6px; color: var(--navy-2); }
.bubble ul, .bubble ol { margin: 8px 0 12px; padding-left: 22px; }
.bubble li { margin-bottom: 5px; }
.bubble strong { color: #0d2540; }
.msg.user .bubble strong { color: #fff; }
.bubble code {
  background: #f1f4f8; padding: 1px 5px; border-radius: 5px;
  font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bubble pre {
  background: #0e1d31; color: #e6eefb; padding: 12px 14px;
  border-radius: 10px; overflow-x: auto; font-size: 13px; line-height: 1.65;
}
.bubble pre code { background: none; color: inherit; padding: 0; }
.bubble blockquote {
  margin: 10px 0; padding: 6px 14px;
  border-left: 3px solid #e8bd63; background: #fdfaf3; color: #5c5340;
  border-radius: 0 8px 8px 0;
}
.bubble table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; }
.bubble th { background: #f4f7fb; font-weight: 600; }
.bubble a {
  color: #1a5fb4;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.msg .meta { font-size: 11.5px; color: #9aa5b2; margin-top: 7px; }

/* ---------- 助手侧的气泡列 + 补充检索征询卡片 ---------- */

/* 助手侧用一列包住「正文 + 可选的补充检索征询卡片」 */
.msg-col {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* 「网络信息 · 非官方」标签：让家长一眼分清官网原文和网上说法 */
.search-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #fff4e0;
  border: 1px solid #f0d5a4;
  color: #8a5b06;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
}

.bubble.search { border: 1px solid #f0d5a4; }

.search-card {
  width: 100%;
  max-width: min(680px, 82%);
  background: var(--card);
  border: 1px solid #f0d5a4;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px;
  font-size: 13.5px;
  line-height: 1.8;
}

.search-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #8a5b06;
}

.search-card-dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 50%;
  background: var(--gold);
}

.search-card-body { color: #4a5563; }
.search-card-body p { margin: 0 0 9px; }
.search-card-body p:last-child { margin-bottom: 0; }
.search-card-body ul { margin: 6px 0 10px; padding-left: 20px; }
.search-card-body li { margin-bottom: 4px; }
.search-card-body strong { color: #8a5b06; }

.search-card-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }

.search-btn {
  font: inherit;
  font-size: 13px;
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #55606e;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.search-btn:hover { background: #f4f7fb; border-color: #cfd8e3; }

.search-btn.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 600;
}

.search-btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); }

/* 出错提示气泡：系统提示，不用老师头像的配色 */
.bubble.error {
  background: #fff6f6;
  border: 1px solid #f3d2d2;
  color: #a33a3a;
  box-shadow: none;
}
.bubble.error strong { color: #8f2f2f; }

/* 流式输出中，发送按钮变成「停止」 */
.send-btn.stopping { background: #8c2f2f; }
.send-btn.stopping:hover { background: #a03a3a; }

.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #b9c3d0; display: block;
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

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

.composer {
  flex: none;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 12px 20px 14px;
}

.starters {
  max-width: 780px; margin: 0 auto 10px;
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none;
}
.starters::-webkit-scrollbar { display: none; }

.starter {
  flex: none;
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #45505e;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.starter:hover { border-color: #e0b45c; color: #8a5d05; }

.input-row {
  max-width: 780px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow);
}

.input-row:focus-within { border-color: #cbd6e4; }

#input {
  flex: 1;
  border: none; outline: none; resize: none;
  font-size: 15px; line-height: 1.7;
  font-family: inherit;
  max-height: 160px;
  padding: 6px 0;
  background: transparent;
  color: var(--ink);
}

.send-btn {
  flex: none;
  border: none;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}
.send-btn:hover { background: var(--navy-2); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.center { text-align: center; margin-top: 8px; }

/* ---------- 弹窗 ---------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(12, 24, 40, 0.5);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 18px;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px 24px;
  box-shadow: 0 24px 60px rgba(10, 22, 40, 0.3);
}

.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 18px; margin: 0; }
.modal-sub { font-size: 12.5px; color: var(--muted); line-height: 1.75; margin: 8px 0 18px; }

.profile-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.profile-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: #4a5563;
}

.profile-form input, .profile-form textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  background: #fbfcfe;
}
.profile-form input:focus, .profile-form textarea:focus { border-color: #b9c8da; background: #fff; }

.wide { grid-column: 1 / -1; }

.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-foot .ghost-btn {
  width: auto; border-color: var(--line); color: #55606e; padding: 10px 18px;
}
.modal-foot .ghost-btn:hover { background: #f2f5f9; }

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

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(300px, 84vw);
    z-index: 40;
    transform: translateX(-102%);
    transition: transform 0.24s ease;
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: grid; }
  .scroll { padding: 18px 14px 6px; }
  .composer { padding: 10px 14px 12px; }
  .bubble { max-width: 88%; }
  .search-card { max-width: 88%; }
  .profile-form { grid-template-columns: 1fr; }
}
