:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --ink: #171a16;
  --muted: #687069;
  --panel: #ffffff;
  --line: #dedbd1;
  --green: #1f6a52;
  --green-dark: #164b3a;
  --gold: #bc7a2c;
  --soft: #eef3ef;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(31, 106, 82, 0.16), transparent 34rem),
    linear-gradient(180deg, #faf8f2 0%, var(--bg) 42%, #edf1ec 100%);
  color: var(--ink);
}

a { color: var(--green); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid rgba(23, 26, 22, 0.08);
  background: rgba(250, 248, 242, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.nav a,
.link-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.nav-cta {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--green);
  color: #fff !important;
}

.main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) 18px;
}

.hero {
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: clamp(28px, 6vw, 68px);
  align-items: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 68px);
  line-height: 1.02;
}

h2 { margin: 0 0 10px; }

.lead {
  max-width: 48rem;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.7;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}

.button.primary {
  background: var(--green);
  color: #fff;
}

.button.primary:hover { background: var(--green-dark); }

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button.full { width: 100%; }

.preview,
.auth-card,
.composer,
.post,
.side-panel,
.person,
.thread,
.chat-shell {
  border: 1px solid rgba(23, 26, 22, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 54px rgba(31, 40, 32, 0.08);
}

.preview {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.mock-post,
.mock-chat {
  min-height: 82px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e9efe9, #fff);
}

.mock-post.strong {
  min-height: 132px;
  background: linear-gradient(135deg, rgba(31, 106, 82, 0.22), #fff);
}

.auth-card {
  width: min(460px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 6vw, 42px);
}

.form {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: #39423b;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  padding: 12px 13px;
}

textarea { resize: vertical; }

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.side-panel,
.composer,
.post,
.person {
  padding: 22px;
}

.content-stack {
  display: grid;
  gap: 18px;
}

.content-stack.narrow {
  width: min(760px, 100%);
  margin: 0 auto;
}

.composer {
  display: grid;
  gap: 12px;
}

.post-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.post p,
.person p,
.side-panel p {
  color: #3d4740;
  line-height: 1.65;
}

.person,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.thread {
  display: grid;
  gap: 6px;
  padding: 18px 20px;
  color: var(--ink);
  text-decoration: none;
}

.thread span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread time,
.post time {
  color: var(--muted);
  font-size: 13px;
}

.chat-shell {
  width: min(840px, 100%);
  margin: 0 auto;
  overflow: hidden;
}

.chat-header,
.message-form {
  padding: 18px 22px;
  background: var(--soft);
}

.messages {
  display: grid;
  gap: 12px;
  min-height: 360px;
  padding: 22px;
}

.message {
  max-width: 74%;
  justify-self: start;
}

.message.mine {
  justify-self: end;
  text-align: right;
}

.message span {
  color: var(--muted);
  font-size: 13px;
}

.message p {
  margin: 5px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--soft);
  line-height: 1.55;
}

.message.mine p {
  background: var(--green);
  color: #fff;
}

.message-form {
  display: grid;
  gap: 12px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.flash,
.empty {
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  color: var(--muted);
}

.flash.success { border: 1px solid rgba(31, 106, 82, 0.22); }
.flash.error { border: 1px solid rgba(176, 58, 46, 0.28); color: #8d2f25; }

.footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .topbar,
  .nav,
  .layout,
  .hero,
  .person,
  .section-title {
    display: grid;
  }

  .topbar {
    gap: 12px;
  }

  .hero {
    min-height: auto;
  }

  .preview {
    display: none;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 88%;
  }
}


.person-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef3ef;
  color: #1f6a52;
  font-size: 13px;
  font-weight: 800;
}

.muted {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.ai-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  border: 1px solid rgba(23, 26, 22, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 54px rgba(31, 40, 32, 0.08);
  padding: 22px;
}

.ai-summary p {
  color: #3d4740;
  line-height: 1.65;
}

.stats {
  display: grid;
  gap: 10px;
  min-width: 160px;
  margin: 0;
}

.stats div {
  border-left: 3px solid var(--green);
  padding-left: 10px;
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stats dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.comment-stack {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.ai-comment {
  border-radius: 8px;
  background: var(--soft);
  padding: 12px 14px;
}

.ai-comment div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
}

.ai-comment span {
  color: var(--muted);
  font-size: 13px;
}

.ai-comment p {
  margin: 6px 0 0;
}

.chat-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .ai-summary,
  .person-actions {
    display: grid;
  }

  .person-actions {
    justify-content: stretch;
  }
}


.message.pending p {
  color: var(--muted);
  font-style: italic;
}

.message.failed p {
  border: 1px solid rgba(176, 58, 46, 0.24);
  background: #fff7f5;
  color: #8d2f25;
}


.messages {
  max-height: min(64vh, 680px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message-form button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.typing-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-width: 54px;
  min-height: 42px;
}


.typing-dots span {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.typing-dots.searching i {
  background: var(--accent);
}

.typing-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-dot 1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.16s; }
.typing-dots i:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.42; }
  40% { transform: translateY(-5px); opacity: 1; }
}


.actions.compact {
  margin-top: 0;
  align-items: center;
  justify-content: flex-end;
}

button:disabled,
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.academic-status {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(31, 106, 82, 0.18);
  border-radius: 8px;
  background: #f7fbf8;
  padding: 14px;
}

.academic-status span {
  color: var(--green);
  overflow-wrap: anywhere;
}

.academic-status p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.error-text {
  color: #8d2f25 !important;
}


.subsection-title {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  text-transform: none;
}

.ai-thread strong::after {
  content: "AI";
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 8px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  vertical-align: middle;
}


.academic-status-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.academic-status-head form {
  margin: 0;
}


.pill.subtle {
  margin-left: 8px;
  background: #f5f1e8;
  color: #7a5524;
}


.academic-preview {
  border: 1px solid rgba(23, 26, 22, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 14px;
}

.academic-preview summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.academic-preview-list {
  display: grid;
  gap: 12px;
  max-height: 520px;
  margin-top: 12px;
  overflow: auto;
}

.academic-preview-item {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.academic-preview-item strong {
  overflow-wrap: anywhere;
}

.academic-preview-item pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #3d4740;
  font: inherit;
  line-height: 1.55;
}


.paper-table {
  display: grid;
  gap: 12px;
  max-height: 620px;
  margin-top: 12px;
  overflow: auto;
}

.paper-row {
  display: grid;
  gap: 10px;
  border-left: 4px solid #b8c7bd;
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.paper-row.verified {
  border-left-color: var(--green);
}

.paper-row.needs_review {
  border-left-color: #bc7a2c;
}

.paper-main,
.paper-meta {
  display: grid;
  gap: 5px;
}

.paper-main span,
.paper-meta span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.paper-evidence summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 800;
}

.paper-evidence pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #3d4740;
  font: inherit;
  line-height: 1.55;
}
