.messages { scroll-behavior: smooth; }
.scroll-bottom {
  position: absolute;
  right: 26px;
  bottom: 124px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-color: var(--line);
  background: #171c23;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  font-size: 17px;
}
.overview { width: min(980px, 100%); margin: 0 auto; padding: 14px 4px 26px; }
.overview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px; }
.overview-head h1 { margin: 0; font-size: 30px; letter-spacing: -.045em; }
.overview-head p { max-width: 600px; color: var(--muted); margin: 8px 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 24px 0 14px; }
.stat-card {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .015));
}
.stat-card strong { display: block; font-size: 24px; letter-spacing: -.04em; }
.stat-card span { display: block; color: var(--muted-2); font-size: 11px; margin-top: 3px; }
.overview-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; }
.overview-service { color: var(--muted-2); font-size: 11px; margin-left: auto; }
.recent-block { border-top: 1px solid var(--line-soft); padding-top: 18px; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.recent-head h2 { margin: 0; font-size: 14px; }
.recent-head span { color: var(--muted-2); font-size: 11px; }
.recent-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: transparent;
  padding: 10px 12px;
  color: var(--text);
}
.recent-item:hover { background: rgba(255, 255, 255, .035); }
.recent-item .dot { flex: none; }
.recent-main { min-width: 0; }
.recent-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.recent-meta { display: block; color: var(--muted-2); font-size: 10px; margin-top: 2px; }
.msg { display: flex; gap: 11px; margin-bottom: 20px; }
.msg.user { justify-content: flex-end; }
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  flex: none;
  display: grid;
  place-items: center;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 750;
  color: #0a0c10;
  background: linear-gradient(145deg, #a9bdff, #5b7dff);
}
.msg-body { min-width: 0; max-width: min(860px, 100%); }
.msg.user .msg-body {
  max-width: min(720px, 92%);
  padding: 10px 14px;
  border: 1px solid rgba(124, 156, 255, .24);
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(180deg, rgba(124, 156, 255, .16), rgba(124, 156, 255, .08));
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; color: var(--muted-2); font-size: 11px; }
.msg-head strong { color: var(--muted); font-size: 11px; font-weight: 600; }
.msg.assistant .msg-body { width: 100%; }
.part-text { color: #dfe7f0; overflow-wrap: anywhere; }
.part-text p { margin: 0 0 10px; }
.part-text p:last-child { margin-bottom: 0; }
.part-text h1, .part-text h2, .part-text h3 { margin: 18px 0 8px; line-height: 1.25; letter-spacing: -.02em; }
.part-text h1 { font-size: 20px; }
.part-text h2 { font-size: 17px; }
.part-text h3 { font-size: 15px; }
.part-text ul, .part-text ol { margin: 6px 0 10px; padding-left: 22px; }
.part-text li { margin: 3px 0; }
.part-text blockquote { margin: 10px 0; padding: 6px 12px; border-left: 3px solid var(--accent); color: var(--muted); background: rgba(255,255,255,.02); }
.part-text code {
  font-family: var(--mono);
  font-size: .9em;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .07);
  color: #cfe0ff;
}
.part-text pre {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0d11;
  overflow: auto;
  font-size: 12px;
  line-height: 1.55;
}
.part-text pre { position: relative; }
.part-text pre code { padding: 0; background: transparent; color: #cfd9e6; }
.code-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 7px;
  border-color: var(--line);
  background: rgba(17, 21, 26, .9);
  color: var(--muted);
  font-size: 10px;
  opacity: 0;
  transition: opacity .15s;
}
.part-text pre:hover .code-copy { opacity: 1; }
.part-text a { color: var(--accent); text-decoration: none; }
.part-text a:hover { text-decoration: underline; }
.part-text hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

details.reasoning, details.tool {
  margin: 8px 0;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: rgba(255, 255, 255, .018);
  padding: 0 12px;
}
details.reasoning summary, details.tool summary {
  cursor: pointer;
  padding: 8px 0;
  color: var(--muted-2);
  font-size: 11px;
  user-select: none;
}
details[open].reasoning, details[open].tool { background: rgba(255, 255, 255, .03); }
details.reasoning pre, details.tool pre {
  margin: 0 0 10px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.tool-status { color: var(--orange); }
.tool-status.completed { color: var(--green); }
.tool-status.error { color: var(--red); }
.msg-time { color: var(--muted-2); font-size: 10px; margin-top: 7px; }
.typing { display: inline-flex; gap: 4px; align-items: center; color: var(--muted-2); font-size: 12px; padding: 4px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.msg-error { color: var(--red); font-size: 12px; margin-top: 6px; }
.msg-note { color: var(--muted-2); font-size: 12px; margin: 10px 0; }
.chat-state {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 28px auto;
  max-width: 420px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
  color: var(--muted);
  font-size: 12px;
}
.chat-state strong { display: block; color: var(--text); font-size: 13px; margin-bottom: 3px; }
.chat-state span { display: block; color: var(--muted-2); }
.chat-state button { margin-left: auto; }
.chat-state.error-state { border-color: rgba(255, 111, 120, .3); background: rgba(255, 111, 120, .05); }
.chat-state.error-state strong { color: #ffc2c6; }
.state-spinner {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(124, 156, 255, .2);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.forms { padding: 0 clamp(12px, 3vw, 34px); }
.form-card {
  margin-bottom: 12px;
  border: 1px solid rgba(245, 166, 91, .3);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(245, 166, 91, .09), rgba(245, 166, 91, .03));
  padding: 14px;
}
.form-card h3 { margin: 0 0 3px; font-size: 14px; }
.form-card .form-sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.form-field { margin: 12px 0; }
.form-field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.form-field .field-desc { color: var(--muted-2); font-size: 11px; margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea { font-size: 13px; }
.form-field .checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.form-field .checks label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 12px; }
.form-field .checks input { width: auto; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.attach-chip progress { width: 48px; height: 4px; margin-left: 2px; }
.chat.dropping .composer { border-color: rgba(124, 156, 255, .75); box-shadow: 0 0 0 3px rgba(124, 156, 255, .14); }
.chat.dropping .messages { opacity: .55; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 6, 9, .68);
  backdrop-filter: blur(8px);
}
.modal-card {
  width: min(620px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #11151a;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-card.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: 12px; }
.field .hint { color: var(--muted-2); font-size: 11px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-meta { color: var(--muted-2); font-size: 11px; word-break: break-all; margin-top: 4px; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 12px; color: var(--muted-2); font-size: 12px; }
.crumbs button { border: 0; background: transparent; padding: 2px 3px; color: var(--accent); }
.file-list { border: 1px solid var(--line-soft); border-radius: 12px; overflow: hidden; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: rgba(255,255,255,.025); }
.file-icon { width: 22px; text-align: center; opacity: .8; }
.file-main { min-width: 0; flex: 1; }
.file-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-meta { color: var(--muted-2); font-size: 10px; }
.file-actions { display: flex; gap: 5px; }
.file-actions button, .file-actions a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 4px 7px;
  font-size: 11px;
  text-decoration: none;
}
.file-empty { padding: 30px 16px; text-align: center; color: var(--muted-2); font-size: 12px; }
.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.upload-row input[type=file] { flex: 1; padding: 7px; font-size: 11px; }
progress { width: 100%; height: 5px; accent-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #1a2028;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 12px;
}
.toast.bad { border-color: rgba(255, 111, 120, .4); color: #ffc2c6; }
.toast.good { border-color: rgba(89, 214, 166, .35); }

@media (max-width: 760px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .recent-list { grid-template-columns: 1fr; }
  .overview-head h1 { font-size: 24px; }
  .overview-head .empty-mark { display: none; }
  .overview-actions { flex-wrap: wrap; }
  .overview-service { width: 100%; margin-left: 0; }
  .scroll-bottom { right: 16px; bottom: 116px; }
}
@media (max-width: 620px) {
  .row-2 { grid-template-columns: 1fr; }
  .msg-avatar { display: none; }
  .msg.user .msg-body { max-width: 96%; }
  .modal { padding: 8px; }
  .modal-card { max-height: 92vh; }
}
