:root {
  --bg: #f3efe6;
  --paper: #fbfaf5;
  --paper-strong: #fffdf7;
  --ink: #172029;
  --muted: #596576;
  --line: rgba(19, 30, 43, 0.12);
  --accent: #205c4e;
  --accent-soft: #d6ede6;
  --accent-warm: #d96236;
  --shadow: 0 18px 50px rgba(23, 32, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 214, 153, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(85, 151, 130, 0.18), transparent 24%),
    linear-gradient(180deg, #faf7ef 0%, #f1ece0 100%);
  color: var(--ink);
  font-family: "Manrope", "Noto Sans SC", sans-serif;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 245, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand__badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #19433c, #357967);
  color: white;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand h1,
.chat-panel__header h3,
.paper-panel__hero h2 {
  margin: 0;
  font-weight: 800;
}

.brand p,
.muted,
.eyebrow {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
}

.search-card,
.paper-panel,
.chat-panel {
  background: rgba(255, 253, 247, 0.88);
  border: 1px solid rgba(23, 32, 41, 0.08);
  box-shadow: var(--shadow);
}

.search-card {
  padding: 16px;
  border-radius: 20px;
}

.search-card label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.9rem;
  font-weight: 700;
}

input,
textarea,
select,
.ghost-btn,
.primary-btn {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(23, 32, 41, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 108px;
}

.ghost-btn,
.primary-btn,
.paper-card,
.tab {
  cursor: pointer;
}

.ghost-btn,
.tab {
  border: 1px solid rgba(23, 32, 41, 0.10);
  background: rgba(255, 255, 255, 0.75);
}

.ghost-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
}

.primary-btn {
  border: none;
  background: linear-gradient(135deg, #164c40, #25725f);
  color: white;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
}

.paper-list {
  margin-top: 18px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 4px;
}

.paper-card {
  text-align: left;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(23, 32, 41, 0.08);
  background: rgba(255, 255, 255, 0.68);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.paper-card:hover,
.paper-card.is-active {
  transform: translateY(-2px);
  border-color: rgba(32, 92, 78, 0.35);
  box-shadow: 0 12px 22px rgba(22, 76, 64, 0.12);
}

.paper-card__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.paper-card__title {
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
}

.paper-card__doi {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.paper-card__meta {
  font-size: 0.84rem;
  color: #314152;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.9fr);
  gap: 20px;
  padding: 24px;
}

.paper-panel,
.chat-panel {
  border-radius: 28px;
  padding: 24px;
}

.paper-panel__hero,
.chat-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.status-pill,
.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-item {
  border-radius: 18px;
  padding: 14px;
  background: rgba(240, 244, 237, 0.72);
  border: 1px solid rgba(23, 32, 41, 0.06);
}

.summary-item__label {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.summary-item__value {
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

.tabs {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 14px;
  border-radius: 999px;
}

.tab.is-active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.tab.is-disabled,
.tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.doc-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.doc-toolbar {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-btn--inline {
  margin-top: 0;
  width: auto;
  white-space: nowrap;
}

.document-view,
.pdf-view {
  margin-top: 16px;
  min-height: 70vh;
  max-height: 78vh;
  overflow: auto;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(247, 246, 240, 0.95));
  border: 1px solid rgba(23, 32, 41, 0.06);
}

.pdf-view {
  padding: 0;
  overflow: hidden;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  background: white;
}

.empty-state {
  min-height: 70vh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.document-view {
  display: none;
  line-height: 1.75;
}

.doc-heading {
  margin: 26px 0 14px;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.4;
  color: #18312d;
}

.doc-heading--major {
  margin-top: 0;
  font-size: 1.35rem;
}

.doc-block {
  margin: 0 0 14px;
  max-width: 78ch;
}

.doc-block--paragraph {
  font-size: 1rem;
  color: #223240;
}

.doc-block--figure_caption,
.doc-block--table_caption {
  font-size: 0.92rem;
  color: #4c5b69;
  border-left: 3px solid rgba(217, 98, 54, 0.45);
  padding-left: 12px;
  font-style: italic;
}

.doc-block--reference {
  font-size: 0.88rem;
  color: #62707d;
}

.doc-list {
  margin: 0 0 16px 0;
  padding-left: 22px;
  max-width: 78ch;
  color: #223240;
}

.doc-list li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-log {
  margin-top: 18px;
  flex: 1;
  min-height: 300px;
  max-height: calc(100vh - 300px);
  overflow: auto;
  display: grid;
  gap: 12px;
}

.message {
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 10px 24px rgba(23, 32, 41, 0.06);
}

.message--assistant {
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid rgba(23, 32, 41, 0.08);
}

.message--user {
  background: linear-gradient(135deg, #1b5749, #276f5f);
  color: white;
  margin-left: 26px;
}

.message__meta {
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message__body {
  line-height: 1.6;
  white-space: pre-wrap;
}

.message__evidence {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(32, 92, 78, 0.08);
  color: #1f3e37;
  font-size: 0.92rem;
}

.message__trace {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

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

@media (max-width: 1180px) {
  .content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .message--user {
    margin-left: 0;
  }
}
