:root {
  --bg: #0d1017;
  --panel: #151a24;
  --panel-2: #1b2230;
  --line: #283142;
  --text: #e8edf7;
  --muted: #8f9bb3;
  --accent: #7c9cff;
  --accent-2: #56d6c4;
  --warn: #e6b566;
  --danger: #ff7b86;
  --shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(86, 214, 196, .14), transparent 60%),
    radial-gradient(700px 460px at 15% 0%, rgba(124, 156, 255, .18), transparent 65%),
    var(--bg);
  font: 14px/1.65 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.app { display: flex; min-height: 100%; }

.sidebar {
  width: 280px;
  min-width: 280px;
  padding: 28px 20px 20px;
  background: linear-gradient(180deg, rgba(21, 26, 36, .96), rgba(15, 19, 27, .96));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #7c9cff, #56d6c4);
  color: #0b1020; font-weight: 800; font-size: 20px;
  box-shadow: 0 8px 24px rgba(124, 156, 255, .35);
}
.brand strong { display: block; font-size: 17px; letter-spacing: .5px; }
.brand span { display: block; color: var(--muted); font-size: 12px; }
.tagline { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 0 2px 12px; }

.section-label {
  color: var(--muted); font-size: 11px; letter-spacing: 1.2px;
  margin: 10px 2px 2px;
}
.modes { display: flex; flex-direction: column; gap: 7px; }
.mode {
  text-align: left; border: 1px solid transparent; border-radius: 12px;
  padding: 9px 11px; background: rgba(255, 255, 255, .025); color: var(--text);
  display: flex; flex-direction: column; gap: 1px;
  transition: .18s border-color, .18s background, .18s transform;
}
.mode span { font-weight: 650; }
.mode small { color: var(--muted); font-size: 11.5px; }
.mode:hover { border-color: #39445a; background: rgba(255, 255, 255, .045); }
.mode.active {
  border-color: rgba(124, 156, 255, .7);
  background: linear-gradient(135deg, rgba(124, 156, 255, .16), rgba(86, 214, 196, .08));
  transform: translateX(2px);
}

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; color: var(--text); padding: 7px 2px;
}
.switch-row input { display: none; }
.switch {
  width: 42px; height: 23px; border-radius: 20px; background: #2a3445;
  position: relative; transition: .18s background; flex: none;
}
.switch::after {
  content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%;
  top: 3px; left: 3px; background: #9aa7bd; transition: .18s transform, .18s background;
}
.switch-row input:checked + .switch { background: rgba(86, 214, 196, .36); }
.switch-row input:checked + .switch::after { transform: translateX(19px); background: var(--accent-2); }
.hint { color: var(--muted); font-size: 11.5px; margin: 0 2px 6px; }
.health {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--line);
  padding-top: 14px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 10px currentColor; }
.health.ok .dot { background: var(--accent-2); }
.health.bad .dot { background: var(--danger); }
.sidebar-foot { color: #6f7c95; font-size: 10.5px; line-height: 1.6; padding-top: 6px; }
.sidebar-foot a { color: #9fb3e8; text-decoration: none; }
.sidebar-foot a:hover { text-decoration: underline; }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding: 26px clamp(16px, 4vw, 56px) 18px;
  max-width: 1080px; margin: 0 auto; width: 100%;
}
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.topbar h1 { margin: 0 0 3px; font-size: 24px; letter-spacing: .4px; }
.topbar p { margin: 0; color: var(--muted); font-size: 12.5px; }
.ghost {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03);
  color: var(--muted); border-radius: 9px; padding: 7px 12px;
}
.ghost:hover { color: var(--text); border-color: #43506a; }
.banner {
  margin: 18px 0 0; border: 1px solid rgba(230, 181, 102, .32);
  background: rgba(230, 181, 102, .08); color: #e9c88c;
  padding: 9px 13px; border-radius: 10px; font-size: 12px;
}

.messages {
  flex: 1; overflow: auto; padding: 26px 2px 12px;
  display: flex; flex-direction: column; gap: 16px;
  scrollbar-width: thin;
}
.empty { margin: auto 0; text-align: center; color: var(--muted); padding: 12vh 0 8vh; }
.empty-icon {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 15px;
  display: grid; place-items: center; font-size: 22px; color: #cfe0ff;
  background: linear-gradient(135deg, rgba(124, 156, 255, .22), rgba(86, 214, 196, .12));
  border: 1px solid #33405a;
}
.empty h2 { margin: 0 0 5px; color: #dce6f8; font-size: 19px; }
.empty p { margin: 0 auto 18px; max-width: 440px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chip {
  border: 1px solid #303b50; border-radius: 999px; padding: 6px 11px;
  background: rgba(255, 255, 255, .035); color: #b9c5dc; font-size: 12px;
}
.chip:hover { border-color: #4d5f82; color: #e2eaff; }

.msg { display: flex; gap: 10px; max-width: 84%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar {
  width: 30px; height: 30px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: #222c3d; color: #b9c8e8; border: 1px solid #303d54;
}
.msg.assistant .avatar { background: linear-gradient(135deg, #31477e, #236b64); color: #e9f7ff; }
.bubble-wrap { min-width: 0; }
.bubble {
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(21, 26, 36, .82); padding: 11px 14px;
  white-space: pre-wrap; word-break: break-word; color: #e5ecf9;
}
.msg.user .bubble { background: linear-gradient(135deg, #2d3f6f, #243451); border-color: #3b4f7d; }
.msg.assistant .bubble { border-top-left-radius: 4px; }
.msg.user .bubble { border-top-right-radius: 4px; }
.meta { color: #738096; font-size: 10.5px; margin: 4px 3px 0; }
.msg.user .meta { text-align: right; }
.citations { margin: 7px 3px 0; display: flex; flex-direction: column; gap: 3px; }
.citations a { color: #9db6f0; font-size: 11.5px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citations a:hover { text-decoration: underline; }
.feedback { display: flex; gap: 6px; margin: 6px 3px 0; align-items: center; }
.fb {
  border: 1px solid #303c52; background: rgba(255, 255, 255, .025);
  color: #9eabc2; border-radius: 7px; padding: 3px 7px; font-size: 11px;
}
.fb:hover { border-color: #4a5b78; color: #d8e3f8; }
.fb.on-up { border-color: rgba(86, 214, 196, .55); color: #9cebdd; }
.fb.on-down { border-color: rgba(255, 123, 134, .55); color: #ffadb4; }
.copy { border: 0; background: transparent; color: #7f8da6; font-size: 11px; padding: 3px 4px; }
.copy:hover { color: #d6e1f4; }
.fb-reason { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 7px 3px 0; padding: 8px; border: 1px solid #303c52; border-radius: 9px; background: rgba(21, 26, 36, .7); }
.fb-reason select, .fb-reason input {
  border: 1px solid #303c52; background: #10151e; color: #dfe8f7;
  border-radius: 6px; padding: 5px 8px; font-size: 11.5px; outline: none;
}
.fb-reason input { flex: 1; min-width: 160px; }
.fb-reason select:focus, .fb-reason input:focus { border-color: #607fc9; }
.fb-submit {
  border: 1px solid #3d527c; background: #22304c; color: #cfe0ff;
  border-radius: 6px; padding: 5px 10px; font-size: 11.5px;
}
.fb-submit:hover { border-color: #607fc9; background: #2a3d61; }

.typing { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; padding: 2px 4px 10px; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: #6e8ed8; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
.typing em { font-style: normal; margin-left: 4px; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.composer {
  border: 1px solid #2d3850; border-radius: 16px;
  background: rgba(20, 25, 36, .9); box-shadow: var(--shadow);
  padding: 9px 11px 8px;
}
.composer:focus-within { border-color: rgba(124, 156, 255, .6); }
.composer textarea {
  width: 100%; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--text); padding: 3px 3px 7px; line-height: 1.55;
  min-height: 42px; max-height: 160px;
}
.composer textarea::placeholder { color: #65728a; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 3px 4px 6px; padding: 4px 8px; border-radius: 8px;
  background: rgba(86, 214, 196, .1); border: 1px solid rgba(86, 214, 196, .28);
  color: #b9eee7; font-size: 11.5px; max-width: 100%;
}
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button { border: 0; background: transparent; color: #9fe1d8; font-size: 14px; padding: 0 2px; }
.tools { display: flex; align-items: center; gap: 10px; border-top: 1px solid #273247; padding-top: 7px; }
.tool { color: #9eabc2; font-size: 12px; padding: 3px 4px; border-radius: 6px; }
.tool:hover { color: #d9e4f8; background: rgba(255, 255, 255, .04); }
.tool-note { color: #68758c; font-size: 11px; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send {
  border: 1px solid #4c63a0; border-radius: 9px; padding: 6px 18px;
  background: linear-gradient(135deg, #5d7ee8, #3e62c7); color: #fff;
  font-weight: 650; box-shadow: 0 6px 18px rgba(62, 98, 199, .3);
}
.send:hover { filter: brightness(1.08); }
.send:disabled { opacity: .5; cursor: default; }
.footnote { color: #66738a; font-size: 10.5px; text-align: center; margin: 10px 0 0; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; min-width: 0; height: auto; position: relative;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 18px 16px 14px;
  }
  .modes { display: grid; grid-template-columns: 1fr 1fr; }
  .health { margin-top: 6px; }
  .main { padding: 18px 14px 12px; }
  .topbar h1 { font-size: 20px; }
  .msg { max-width: 94%; }
  .empty { padding: 8vh 0 6vh; }
  .tool-note { display: none; }
}
