/* 赛博大V — light theme + compact layout (target: 20+ visible chat lines) */

:root {
  --pico-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                      "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --pico-font-size: 14px;
  --pico-line-height: 1.5;
  --pico-spacing: 0.6rem;

  /* Match zhihu's soft gray bg */
  --pico-background-color: #f3f4f6;
  --pico-card-background-color: #ffffff;
  --pico-color: #1f2937;
  --pico-h2-color: #111827;
  --pico-primary: #3b82f6;
  --pico-primary-hover: #2563eb;
  --pico-primary-background: #3b82f6;
}

body { padding-bottom: 0; background: var(--pico-background-color); }

/* --- compact top nav --- */
.topnav {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  margin: 0 0 0.4rem 0;
  padding: 0.25rem 1rem;
  min-height: 0;
}
.topnav ul { margin: 0; padding: 0.15rem 0; }
.topnav li { padding: 0.15rem 0.5rem; }
.topnav strong a { font-size: 0.95rem; }

/* Full-width main: small 1rem gutter on each side; no max-width cap. */
main.container { padding: 0.4rem 1rem 0.6rem; max-width: none; width: 100%; }

.muted { color: #6b7280; font-size: 0.82rem; }

/* --- breadcrumb (blogger tabs) — compact --- */
nav[aria-label="breadcrumb"] {
  background: transparent;
  margin: 0 0 0.4rem 0;
}
nav[aria-label="breadcrumb"] ul {
  padding-left: 0;
  flex-wrap: wrap;
  margin: 0;
  gap: 0.15rem;
}
nav[aria-label="breadcrumb"] li { padding: 0; }
nav[aria-label="breadcrumb"] a {
  text-decoration: none;
  color: #4b5563;
  padding: 0.2rem 0.65rem;
  border-radius: 5px;
  font-size: 0.85rem;
}
nav[aria-label="breadcrumb"] a:hover { background: #e5e7eb; }
nav[aria-label="breadcrumb"] a[aria-current="page"] {
  background: var(--pico-primary);
  color: #ffffff;
  font-weight: 600;
}

/* --- bloggers landing grid: fixed 3 cols on desktop, 2 on tablet, 1 on phone --- */

.bloggers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}
@media (max-width: 768px) {
  .bloggers-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .bloggers-grid { grid-template-columns: 1fr; }
}

/* --- chat layout — reclaim every pixel for messages --- */

.chat-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.5rem;
  height: calc(100vh - 100px);
  min-height: 460px;
}

.chat-sidebar {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  overflow-y: auto;
  font-size: 0.85rem;
}
.chat-sidebar form button { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.chat-sidebar ul { padding-left: 0; list-style: none; margin: 0.4rem 0; }
.chat-sidebar li { margin: 0.25rem 0; }
.chat-sidebar a { color: #374151; text-decoration: none; }
.chat-sidebar a:hover { color: var(--pico-primary); }
.chat-sidebar a.active { color: var(--pico-primary); font-weight: 600; }
.chat-sidebar small { font-size: 0.72rem; }

.chat-main {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-main > header {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  font-size: 0.9rem;
}
.chat-main > header button { padding: 0.15rem 0.6rem !important; font-size: 0.78rem !important; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.8rem;
  background: #f9fafb;
}

.chat-bubble {
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  margin: 0.35rem 0;
  max-width: 88%;
  line-height: 1.55;
  word-wrap: break-word;
  font-size: 0.88rem;
}
.chat-bubble.user {
  background: var(--pico-primary);
  color: #ffffff;
  margin-left: auto;
  white-space: pre-wrap;
}
.chat-bubble.assistant {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
}

/* --- markdown styles inside assistant bubbles (compact) --- */
.chat-bubble.assistant > *:first-child { margin-top: 0; }
.chat-bubble.assistant > *:last-child { margin-bottom: 0; }
.chat-bubble.assistant h1,
.chat-bubble.assistant h2,
.chat-bubble.assistant h3,
.chat-bubble.assistant h4 {
  margin: 0.6rem 0 0.25rem;
  line-height: 1.3;
}
.chat-bubble.assistant h1 { font-size: 1.1rem; }
.chat-bubble.assistant h2 { font-size: 1.02rem; }
.chat-bubble.assistant h3 { font-size: 0.96rem; }
.chat-bubble.assistant h4 { font-size: 0.92rem; }
.chat-bubble.assistant p { margin: 0.3rem 0; }
.chat-bubble.assistant ul,
.chat-bubble.assistant ol { padding-left: 1.3rem; margin: 0.3rem 0; }
.chat-bubble.assistant li { margin: 0.15rem 0; }
.chat-bubble.assistant code {
  background: #f3f4f6;
  padding: 0.06rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.chat-bubble.assistant pre {
  background: #f3f4f6;
  padding: 0.6rem;
  border-radius: 5px;
  overflow-x: auto;
  margin: 0.45rem 0;
  font-size: 0.82rem;
  line-height: 1.4;
}
.chat-bubble.assistant pre code { background: transparent; padding: 0; }
.chat-bubble.assistant blockquote {
  border-left: 3px solid #e5e7eb;
  padding-left: 0.7rem;
  margin: 0.35rem 0;
  color: #4b5563;
}
.chat-bubble.assistant a {
  color: var(--pico-primary);
  text-decoration: underline;
}
.chat-bubble.assistant a:hover { color: var(--pico-primary-hover); }
.chat-bubble.assistant table {
  border-collapse: collapse;
  margin: 0.45rem 0;
  font-size: 0.82rem;
}
.chat-bubble.assistant th,
.chat-bubble.assistant td {
  border: 1px solid #e5e7eb;
  padding: 0.25rem 0.55rem;
}
.chat-bubble.assistant th { background: #f9fafb; font-weight: 600; }
.chat-bubble.assistant hr { border: none; border-top: 1px solid #e5e7eb; margin: 0.5rem 0; }

/* --- input bar at the bottom ---
   Pico's `form > button { width: 100% }` would squash the textarea;
   we force textarea-wide / button-narrow via flex + width:auto.
*/
.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  align-items: stretch;
}
.chat-input textarea {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 110px;       /* ~5 lines of Chinese */
  max-height: 240px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0.5rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  margin: 0;
  background: #ffffff;
  color: #111827;
  box-sizing: border-box;
}
.chat-input textarea:focus {
  border-color: var(--pico-primary);
  outline: 2px solid rgba(59, 130, 246, 0.15);
}
.chat-input button {
  flex: 0 0 auto;
  width: auto !important;
  min-width: 78px;
  max-width: 110px;
  padding: 0.5rem 1.1rem;
  font-size: 0.88rem;
  margin: 0;
  align-self: stretch;
  box-sizing: border-box;
}

/* --- responsive: phones / narrow screens --- */
@media (max-width: 700px) {
  :root { --pico-font-size: 13.5px; }
  main.container { padding: 0.3rem 0.6rem; }

  .chat-layout {
    grid-template-columns: 1fr;        /* stack vertically */
    grid-template-rows: auto 1fr;
    height: calc(100vh - 80px);
    gap: 0.4rem;
  }
  .chat-sidebar {
    max-height: 110px;                 /* collapsed; scroll inside */
    padding: 0.4rem 0.5rem;
    font-size: 0.82rem;
  }
  .chat-sidebar ul { display: flex; flex-wrap: wrap; gap: 0.3rem; }
  .chat-sidebar li { margin: 0; }
  .chat-sidebar li small { display: none; }   /* hide timestamps to save space */

  .chat-bubble { max-width: 95%; font-size: 0.86rem; }
  .chat-input { padding: 0.4rem 0.5rem; gap: 0.4rem; }
  .chat-input textarea { min-height: 80px; font-size: 0.88rem; }
  .chat-input button { min-width: 64px; padding: 0.45rem 0.8rem; font-size: 0.85rem; }

  nav[aria-label="breadcrumb"] a { padding: 0.15rem 0.5rem; font-size: 0.8rem; }
  .topnav { padding: 0.15rem 0.6rem; }
}

/* --- multi-blogger conversation cards (问所有人) --- */

.multi-cards {
  display: grid;
  /* Always cap at 3 columns regardless of participant count — 5 / 10 people
     just wrap into 2 / 4 rows. Avoids cramped horizontal stacking. */
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0.6rem 0;
}
@media (max-width: 1000px) {
  .multi-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .multi-cards { grid-template-columns: 1fr; }
}

.multi-card {
  margin: 0;
  padding: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 0.86rem;
}
.multi-card-blogger { border-left: 4px solid #6b7280; }
.multi-card-master  { border-left: 4px solid #b45309; }
.multi-card-advisor { border-left: 4px solid #7c3aed; }

.multi-card-head {
  padding: 0.4rem 0.6rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}
.multi-card-head strong { flex: 1; }
.multi-card-status { font-size: 0.78rem; color: #6b7280; }

.multi-card-body {
  padding: 0.6rem 0.8rem;
  line-height: 1.55;
  overflow-x: auto;
  flex: 1;
}
.multi-card-body p { margin: 0.4rem 0; }
.multi-card-body p:first-child { margin-top: 0; }
.multi-card-body p:last-child { margin-bottom: 0; }
.multi-card-body h1, .multi-card-body h2, .multi-card-body h3, .multi-card-body h4 {
  margin: 0.6rem 0 0.3rem;
  font-size: 0.95rem;
}
.multi-card-body ul, .multi-card-body ol { margin: 0.3rem 0 0.3rem 1.4rem; }
.multi-card-body code { background: #f3f4f6; padding: 0.05rem 0.25rem; border-radius: 3px; }
.multi-card-body table { font-size: 0.82rem; border-collapse: collapse; margin: 0.4rem 0; }
.multi-card-body th, .multi-card-body td { border: 1px solid #e5e7eb; padding: 0.25rem 0.4rem; }
.multi-card-body blockquote { border-left: 3px solid #d1d5db; padding-left: 0.6rem; color: #4b5563; margin: 0.4rem 0; }

.multi-summary {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
  line-height: 1.6;
  font-size: 0.88rem;
}
.multi-summary::before {
  content: "📊 综合对比";
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #78350f;
}
.multi-summary table { border-collapse: collapse; margin: 0.4rem 0; font-size: 0.84rem; }
.multi-summary th, .multi-summary td { border: 1px solid #fcd34d; padding: 0.3rem 0.5rem; background: rgba(255,255,255,0.6); }
