.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-size: 14.5px; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.chat-layout {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 22px 26px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: 18px;
  align-items: start;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.message-list {
  flex: 1;
  padding: 20px 20px 8px;
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(1100px 300px at 50% -10%, #f7f8ff 0%, rgba(255,255,255,0) 70%);
}

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg-user { flex-direction: row-reverse; }

.avatar {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #6d28d9, #4f46e5);
}
.avatar-user { background: linear-gradient(135deg, #334155, #1e293b); }
.avatar-agent { background: linear-gradient(135deg, #0d9488, #0f766e); }

.bubble {
  max-width: 74%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.8px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line-soft);
  background: #fff;
  color: var(--text);
}
.msg-user .bubble {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  color: #fff;
  border-color: transparent;
}
.msg-agent .bubble { background: var(--teal-soft); border-color: #cdeee7; }
.msg-system { justify-content: center; }
.msg-system .sys {
  max-width: 86%;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  text-align: center;
}

.msg-meta {
  margin-top: 5px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-3);
}
.msg-user .msg-meta { justify-content: flex-end; }

.source-box {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #fafbff;
  border: 1px solid var(--line-soft);
  font-size: 12.2px;
  color: var(--text-2);
}
.source-box b { color: var(--primary); font-weight: 600; }

.handoff-card {
  margin-top: 8px;
  padding: 12px 13px;
  border-radius: 11px;
  background: var(--amber-soft);
  border: 1px solid #f6dc9a;
  color: #7c4a03;
  font-size: 12.8px;
}
.handoff-card b { display: block; margin-bottom: 3px; font-size: 13px; }

.typing-row { display: flex; gap: 10px; padding: 0 20px 12px; }
.typing { display: flex; align-items: center; gap: 4px; width: fit-content; }
.typing .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #b9bed1;
  animation: blink 1.2s infinite ease-in-out;
}
.typing .dot:nth-child(2) { animation-delay: .18s; }
.typing .dot:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.quick-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 20px 4px;
  border-top: 1px dashed var(--line);
}
.chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
}
.chip:hover { border-color: #b9bdf3; color: var(--primary); background: var(--primary-soft); }

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px 8px;
  border-top: 1px solid var(--line);
  background: #fcfcfe;
}
.composer textarea {
  min-height: 40px;
  max-height: 132px;
  padding: 10px 12px;
  border-radius: 11px;
}
.composer .btn { height: 40px; padding: 0 20px; }
.composer-hint {
  padding: 0 16px 12px;
  background: #fcfcfe;
  font-size: 11.5px;
  color: var(--text-3);
}

.side-panel { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 78px; }
.side-panel .card { padding: 14px 15px; }
.side-panel h3 { font-size: 13px; margin-bottom: 10px; }
.kv { margin: 0; display: flex; flex-direction: column; gap: 9px; }
.kv > div { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; font-size: 12.5px; font-weight: 550; text-align: right; word-break: break-all; }

.faq-hits { display: flex; flex-direction: column; gap: 8px; }
.faq-hit {
  padding: 8px 10px;
  border-radius: 9px;
  background: #fafbff;
  border: 1px solid var(--line-soft);
}
.faq-hit .t { font-size: 12.5px; font-weight: 550; }
.faq-hit .s { font-size: 11.5px; color: var(--text-3); }

.feature-list { display: flex; flex-direction: column; gap: 8px; font-size: 12.8px; color: var(--text-2); }
.feature-list li { padding-left: 14px; position: relative; }
.feature-list li::before {
  content: "";
  position: absolute; left: 0; top: 8px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
}
.feature-list b { color: var(--text); font-weight: 600; }

.star-row { display: flex; gap: 6px; justify-content: center; margin: 14px 0 10px; }
.star-row button {
  border: none; background: none; cursor: pointer;
  font-size: 30px; line-height: 1;
  color: #d9deea;
  padding: 0 2px;
  transition: color .12s ease, transform .12s ease;
}
.star-row button.on { color: #f59e0b; transform: scale(1.08); }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tag-row label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
}
.tag-row label:has(input:checked) { border-color: #b9bdf3; background: var(--primary-soft); color: var(--primary); }

.pill select {
  max-width: 190px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 500;
}
.pill select:focus { box-shadow: none; }

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .side-panel { position: static; }
  .message-list { max-height: calc(100vh - 430px); }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .bubble { max-width: 84%; }
}
