:root {
  --bg: #eef7ef;
  --bg-soft: #f7fbf6;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --text: #172a1e;
  --muted: #657568;
  --line: rgba(54, 107, 70, 0.12);
  --green-900: #143d25;
  --green-700: #1f7a3e;
  --green-600: #2b9a50;
  --green-500: #48ad66;
  --green-200: #cdebd4;
  --green-100: #e3f4e6;
  --green-50: #f3fbf4;
  --green-25: #f7fcf7;
  --shadow: 0 22px 70px rgba(43, 96, 58, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #fbfdf8 0%, #eff8f1 44%, #e8f3ea 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
textarea,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 251, 246, 0.92)),
    rgba(250, 253, 249, 0.92);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
}

.brand-mark {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border-radius: 18px;
  background: transparent;
  box-shadow: 0 16px 34px rgba(38, 105, 58, 0.1);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.02);
}

.brand strong {
  display: block;
  font-size: 19px;
  font-weight: 620;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

.nav-section {
  display: grid;
  gap: 8px;
}

.nav-title {
  margin: 0 0 9px;
  padding: 0 10px;
  color: #5f7464;
  font-size: 14px;
  font-weight: 620;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 10px;
  border-radius: 8px;
  color: #465749;
  font-size: 15.5px;
  font-weight: 520;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--green-900);
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(47, 116, 68, 0.07);
}

.nav-icon {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  overflow: hidden;
  place-items: center;
  border-radius: 12px;
  background: transparent;
}

.nav-icon img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.02);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  filter: drop-shadow(0 8px 14px rgba(36, 109, 56, 0.08));
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #65b978;
  box-shadow: 0 0 0 5px rgba(72, 161, 91, 0.09);
}

.workspace {
  min-width: 0;
  padding: 40px 56px 56px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(232, 245, 234, 0.18) 100%),
    linear-gradient(135deg, #f8fcf7 0%, #eef8f0 46%, #e7f2e8 100%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar h1,
.hero h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 650;
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

.ghost-button,
.primary-button,
.send-button,
.quick-prompts button,
.tool-chip,
.mode-select-button,
.mode-menu-item {
  border: 0;
  cursor: pointer;
}

.ghost-button,
.primary-button {
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
}

.ghost-button {
  color: var(--green-700);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  box-shadow: 0 14px 32px rgba(31, 122, 62, 0.22);
}

.hero {
  display: grid;
  justify-items: center;
  gap: 26px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 44px 0 40px;
  text-align: center;
}

.hero-copy {
  max-width: 980px;
}

.hero h2 {
  color: var(--green-900);
  font-size: clamp(30px, 3.3vw, 44px);
  font-weight: 500;
  line-height: 1.22;
  white-space: nowrap;
}

.hero-copy p:last-child {
  max-width: 920px;
  margin: 24px auto 0;
  color: #6f7f74;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.75;
}

.query-box {
  width: min(1120px, 100%);
  min-height: 156px;
  padding: 24px 28px 20px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(208, 238, 216, 0.32), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(252, 255, 252, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 26px 78px rgba(44, 92, 57, 0.1);
}

.query-box textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
  line-height: 1.7;
}

.query-box textarea::placeholder {
  color: #9aa79d;
}

.query-tools {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
}

.mode-picker {
  position: relative;
  flex: 0 0 auto;
}

.mode-select-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 156px;
  min-height: 46px;
  padding: 4px 4px 4px 18px;
  border: 1px solid rgba(95, 166, 114, 0.24);
  border-radius: 999px;
  color: var(--green-900);
  background:
    linear-gradient(180deg, rgba(248, 253, 248, 0.98), rgba(240, 250, 242, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    0 10px 24px rgba(54, 114, 70, 0.08);
  font-weight: 620;
  font-size: 14px;
  text-align: center;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.mode-select-button [data-mode-label] {
  line-height: 1;
}

.mode-select-button:hover,
.mode-select-button[aria-expanded="true"] {
  border-color: rgba(63, 136, 82, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 14px 30px rgba(43, 101, 59, 0.12);
  transform: translateY(-1px);
}

.mode-select-button:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 4px rgba(81, 170, 104, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 14px 30px rgba(43, 101, 59, 0.12);
}

.mode-select-caret {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  color: var(--green-900);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(233, 247, 236, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 0 0 1px rgba(102, 168, 120, 0.12),
    0 8px 18px rgba(49, 109, 65, 0.1);
  transition:
    transform 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.mode-select-button:hover .mode-select-caret,
.mode-select-button[aria-expanded="true"] .mode-select-caret {
  transform: translateY(-1px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(226, 244, 231, 1));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    inset 0 0 0 1px rgba(73, 146, 92, 0.16),
    0 10px 20px rgba(46, 105, 62, 0.14);
}

.mode-select-button[aria-expanded="true"] .mode-select-caret svg {
  transform: rotate(180deg);
}

.mode-select-caret svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  fill: none;
  transition: transform 180ms ease;
}

.mode-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 12;
  display: grid;
  width: 172px;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(31, 122, 62, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(28, 74, 40, 0.14);
}

.mode-menu[hidden] {
  display: none;
}

.mode-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: #475f4e;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.mode-menu-item:hover,
.mode-menu-item.active {
  color: var(--green-900);
  background: #eef8ef;
}

.mode-menu-item.active::after {
  content: "✓";
  color: var(--green-700);
  font-weight: 600;
}

.tool-chip {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #dfe9e2;
  border-radius: 999px;
  color: #30463a;
  background: #f4f7f4;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  font-weight: 600;
}

.tool-chip.active {
  color: var(--green-900);
  border-color: var(--green-200);
  background: var(--green-50);
}

.send-button {
  margin-left: auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #b8bab9;
  background: #f1f2f1;
  box-shadow: none;
  font-size: 14px;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease,
    background 180ms ease;
}

.send-button.is-ready {
  color: var(--green-700);
  background: #e4f4e8;
}

.send-button.is-ready:hover:not(:disabled) {
  background: #d9efdf;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(31, 122, 62, 0.12);
}

.send-button:active:not(:disabled) {
  transform: translateY(0);
}

.send-button:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 4px rgba(81, 170, 104, 0.16),
    0 10px 22px rgba(31, 122, 62, 0.12);
}

.send-button-face {
  position: relative;
  display: grid;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
}

.send-button-icon {
  display: grid;
  flex: 0 0 auto;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 999px;
  color: inherit;
  background: transparent;
  transition: color 180ms ease;
}

.send-button-icon svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
}

.send-button.is-loading .send-button-face {
  display: grid;
}

.send-button.is-loading .send-button-icon {
  position: relative;
  background: transparent;
}

.send-button.is-loading .send-button-icon svg {
  display: none;
}

.send-button.is-loading .send-button-icon::before {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(31, 122, 62, 0.2);
  border-top-color: currentColor;
  border-radius: 999px;
  animation: spin 900ms linear infinite;
}

.send-button:disabled {
  cursor: not-allowed;
}

.send-button.is-loading:disabled {
  cursor: wait;
}

.quick-prompts {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  align-items: center;
  width: min(980px, 100%);
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.quick-prompts span {
  color: var(--green-900);
  font-weight: 650;
}

.quick-prompts button {
  min-height: 40px;
  min-width: 0;
  padding: 0 22px;
  border-radius: 999px;
  color: #617268;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.94);
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-prompts button:nth-of-type(n + 4) {
  display: none;
}

.paper-selector {
  display: grid;
  gap: 10px;
  width: min(1120px, 100%);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
}

.paper-selector[hidden] {
  display: none;
}

.paper-selector-head,
.selected-paper,
.paper-option {
  display: grid;
  align-items: center;
  gap: 12px;
}

.paper-selector-head {
  grid-template-columns: minmax(0, 1fr) auto;
}

.paper-option {
  grid-template-columns: minmax(92px, 128px) minmax(0, 1fr);
}

.selected-paper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.selected-paper[hidden] {
  display: none;
}

.paper-selector-head label {
  color: var(--green-900);
  font-weight: 650;
}

.paper-selector-head span,
.selected-paper span,
.paper-option span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  min-width: 0;
}

.paper-selector input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: var(--text);
  background: #fbfefb;
}

.paper-options {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.paper-option {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfefb;
  cursor: pointer;
  text-align: left;
}

.paper-option:hover,
.paper-option.selected {
  border-color: rgba(31, 122, 62, 0.42);
  background: #eef8ef;
}

.paper-option strong,
.selected-paper-chip strong {
  overflow: hidden;
  color: var(--green-900);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-paper {
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid rgba(31, 122, 62, 0.24);
  border-radius: 8px;
  background: #eef8ef;
}

.selected-paper-chip,
.paper-followup {
  border: 0;
  border-radius: 999px;
  color: var(--green-700);
  background: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.selected-paper-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 150px;
  min-height: 30px;
  padding: 5px 9px 5px 11px;
  border: 1px solid rgba(31, 122, 62, 0.18);
  box-shadow: 0 8px 20px rgba(31, 122, 62, 0.06);
}

.selected-paper-remove {
  display: grid;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: var(--green-600);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.selected-paper-title-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: none;
  width: max-content;
  max-width: min(560px, 72vw);
  padding: 8px 10px;
  border: 1px solid rgba(31, 122, 62, 0.2);
  border-radius: 8px;
  color: var(--green-900);
  background: #ffffff;
  box-shadow: 0 16px 38px rgba(29, 84, 43, 0.14);
  font-size: 12px;
  line-height: 1.5;
}

.selected-paper-chip:hover .selected-paper-title-popover,
.selected-paper-chip:focus .selected-paper-title-popover,
.selected-paper-chip:focus-within .selected-paper-title-popover {
  display: block;
}

.result-panel {
  width: min(1120px, 100%);
  margin-top: 6px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(35, 93, 55, 0.075);
  text-align: left;
}

.result-body {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.stream-status {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-900);
  background: #f5fbf6;
  font-size: 13px;
  font-weight: 600;
}

.stream-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stream-metrics span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #526557;
  background: #fbfefb;
  font-size: 12px;
}

.stream-output {
  margin: 0;
  padding: 14px;
  min-height: 140px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #345041;
  background: #fbfefb;
  word-break: break-word;
  line-height: 1.7;
  font-size: 13px;
}

.result-meta,
.result-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-meta-details {
  color: #6b7f71;
  font-size: 12px;
}

.result-meta-details summary {
  width: fit-content;
  cursor: pointer;
  color: #6b7f71;
}

.result-meta-details[open] summary {
  margin-bottom: 8px;
}

.result-meta span,
.result-list span {
  padding: 7px 10px;
  border-radius: 999px;
  color: #45614c;
  background: #f3faf4;
  font-size: 12px;
}

.result-list b {
  width: 100%;
  color: var(--green-900);
  font-size: 13px;
}

.live-answer {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefb;
}

.live-answer strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green-900);
  font-size: 13px;
}

.live-answer-content {
  margin: 0;
  color: #345041;
  word-break: break-word;
  line-height: 1.7;
  font-size: 13px;
}

.live-answer-content p {
  margin: 0 0 10px;
}

.live-answer-content h3,
.live-answer-content h4,
.live-answer-content h5,
.live-answer-content h6 {
  margin: 14px 0 7px;
  color: var(--green-900);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.live-answer-content h3:first-child,
.live-answer-content h4:first-child,
.live-answer-content h5:first-child,
.live-answer-content h6:first-child {
  margin-top: 0;
}

.live-answer-content p:last-child,
.live-answer-content ul:last-child,
.live-answer-content h3:last-child,
.live-answer-content h4:last-child,
.live-answer-content h5:last-child,
.live-answer-content h6:last-child,
.live-answer-content hr:last-child {
  margin-bottom: 0;
}

.live-answer-content h6 {
  color: #3b5b49;
  font-size: 12.5px;
}

.live-answer-content .markdown-hr {
  height: 1px;
  margin: 16px 0;
  border: 0;
  background: linear-gradient(90deg, transparent, rgba(35, 83, 55, 0.24), transparent);
}

.live-answer-content ul {
  display: grid;
  gap: 7px;
  margin: 0 0 10px;
  padding-left: 19px;
}

.live-answer-content li {
  padding-left: 2px;
}

.live-answer-content strong {
  display: inline;
  margin: 0;
  font-size: inherit;
  font-weight: 600;
}

.live-answer-content em {
  color: #526557;
  font-style: italic;
}

.live-answer-content code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--green-900);
  background: #f3faf4;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 12px;
}

.markdown-table-wrap {
  width: 100%;
  margin: 12px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.markdown-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  color: #263f31;
  font-size: 12.5px;
  line-height: 1.6;
}

.markdown-table th,
.markdown-table td {
  padding: 9px 11px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.markdown-table th:last-child,
.markdown-table td:last-child {
  border-right: 0;
}

.markdown-table tr:last-child td {
  border-bottom: 0;
}

.markdown-table th {
  color: var(--green-900);
  background: #eef8ef;
  font-weight: 650;
  white-space: nowrap;
}

.markdown-table td {
  background: #fffefd;
}

.inline-citation {
  color: var(--green-700);
  font-weight: 650;
  text-decoration: none;
}

.inline-citation:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.citation-list {
  align-items: center;
}

.citation-chip,
.reference-title,
.reference-snippet,
.icon-button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.citation-chip {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--green-900);
  background: #e8f6ec;
  font-size: 12px;
  font-weight: 650;
}

.citation-chip:hover,
.reference-title:hover,
.reference-file a:hover,
.pdf-file-link:hover {
  color: var(--green-700);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.result-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
}

.result-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.candidate-summary {
  font-size: 14px;
}

.result-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-card-head strong {
  min-width: 0;
  color: var(--green-900);
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.result-card-head span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--green-700);
  background: var(--green-50);
  font-size: 12px;
  font-weight: 600;
}

.kv-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.kv-list div {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fcf8;
}

.kv-list dt {
  color: var(--green-900);
  font-weight: 600;
}

.kv-list dd {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.result-muted,
.result-error {
  margin: 0;
  color: var(--muted);
}

.result-error {
  color: #a33a36;
}

.reference-section {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.reference-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reference-section-head b {
  color: var(--green-900);
}

.reference-section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.reference-grid {
  display: grid;
  gap: 8px;
}

.reference-card {
  scroll-margin-top: 18px;
  padding: 9px 10px;
  border: 0;
  border-radius: 14px;
  color: #45614c;
  background: #f3faf4;
  font-size: 12px;
}

.reference-card:target {
  box-shadow: inset 0 0 0 1px rgba(31, 122, 62, 0.22);
}

.reference-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.reference-card-head span {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--green-700);
  background: rgba(255, 255, 255, 0.64);
  font-size: 11.5px;
  font-weight: 600;
}

.reference-title {
  min-width: 0;
  padding: 0;
  color: #345041;
  background: transparent;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: left;
}

.reference-snippet {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 0;
  color: #526d59;
  background: transparent;
  line-height: 1.55;
  overflow-wrap: anywhere;
  text-align: left;
}

.reference-file {
  margin: 7px 0 0;
  color: #6d806f;
  font-size: 11.5px;
}

.reference-file a,
.pdf-file-link {
  color: var(--green-900);
  font-weight: 650;
}

.paper-followup {
  margin-left: 8px;
  padding: 3px 8px;
  border: 1px solid rgba(31, 122, 62, 0.14);
  background: rgba(255, 255, 255, 0.7);
}

.reference-modal[hidden] {
  display: none;
}

.reference-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
}

.reference-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 42, 24, 0.34);
  backdrop-filter: blur(8px);
}

.reference-modal-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(1080px, 100%);
  max-height: min(82vh, 820px);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 28px 90px rgba(21, 62, 32, 0.24);
}

.reference-modal-header,
.reference-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.reference-modal-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  overflow-wrap: anywhere;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: var(--green-900);
  background: var(--green-50);
  font-size: 22px;
  line-height: 1;
}

.reference-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reference-modal-meta span {
  padding: 7px 10px;
  border-radius: 999px;
  color: #45614c;
  background: #f3faf4;
  font-size: 12px;
  font-weight: 600;
}

.reference-modal-text {
  min-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefb;
}

.reference-modal-text pre {
  margin: 0;
  padding: 18px;
  color: #263f31;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.75;
  font-family: inherit;
  font-size: 14px;
}

.extracted-table-wrap {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.extracted-table-caption {
  margin: 0;
  color: var(--green-900);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
}

.extracted-table {
  width: 100%;
  border-collapse: collapse;
  color: #263f31;
  font-size: 14px;
}

.extracted-table th,
.extracted-table td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.extracted-table th {
  color: var(--green-900);
  background: #eef8ef;
  font-weight: 650;
}

.extracted-table td {
  background: #ffffff;
}

.raw-reference-text {
  color: var(--muted);
  font-size: 13px;
}

.raw-reference-text summary {
  cursor: pointer;
  font-weight: 600;
}

.raw-reference-text pre {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf7;
}

.loading-shell {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(68, 128, 84, 0.12);
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(207, 238, 215, 0.44), transparent 32%),
    linear-gradient(180deg, #fcfffc 0%, #f5fbf6 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 14px 30px rgba(41, 93, 56, 0.06);
}

.loading-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.loading-head strong {
  display: block;
  color: var(--green-900);
  font-size: 14px;
  font-weight: 650;
}

.loading-head p {
  margin: 4px 0 0;
  color: #69806f;
  font-size: 13px;
  line-height: 1.6;
}

.loading-pulse {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #47aa68, #2d7f49);
  box-shadow: 0 0 0 0 rgba(72, 173, 102, 0.38);
  animation: pulseGlow 1.6s ease-out infinite;
}

.loading-steps {
  display: grid;
  gap: 10px;
}

.loading-steps span {
  position: relative;
  padding: 13px 16px 13px 48px;
  border: 1px solid rgba(75, 138, 91, 0.12);
  border-radius: 14px;
  color: #4d6252;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 248, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.loading-steps span::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 16px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.72), transparent 34%),
    linear-gradient(135deg, rgba(58, 160, 84, 0.94), rgba(29, 114, 61, 0.94));
  box-shadow: 0 8px 16px rgba(49, 116, 67, 0.16);
  transform: translateY(-50%);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(72, 173, 102, 0.32);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(72, 173, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(72, 173, 102, 0);
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
}

.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 18px 50px rgba(35, 93, 55, 0.055);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel h3 {
  font-size: 22px;
  font-weight: 650;
}

.panel p {
  color: var(--muted);
  line-height: 1.7;
}

.model-zone {
  grid-row: span 2;
  min-height: 332px;
  border-color: rgba(255, 255, 255, 0.94);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.5), rgba(223, 241, 227, 0.52));
}

.model-zone > p {
  margin: 12px 0 22px;
  font-weight: 500;
}

.module-list {
  display: grid;
  gap: 12px;
}

.module-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.92);
}

.module-icon,
.feature-icon {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  overflow: visible;
  place-items: center;
  background: transparent;
  filter: drop-shadow(0 9px 18px rgba(35, 94, 52, 0.06));
}

.module-icon img,
.feature-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(1.08) contrast(1.02);
}

.module-row strong {
  color: var(--green-900);
  font-size: 15px;
}

.module-row p {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.badge {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--green-700);
  background: var(--green-50);
  font-size: 12px;
  font-weight: 600;
}

.badge.green {
  color: white;
  background: var(--green-700);
}

.feature-panel {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 160px;
  overflow: hidden;
}

.feature-panel::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -34px;
  width: 156px;
  height: 88px;
  border: 1px solid rgba(49, 139, 73, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.34), rgba(87, 178, 108, 0.11)),
    linear-gradient(90deg, transparent 0 42%, rgba(53, 150, 78, 0.08) 42% 46%, transparent 46% 100%);
  transform: skewX(-18deg);
  pointer-events: none;
}

.feature-title {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.feature-title h3 {
  font-size: 20px;
  line-height: 1.35;
}

.feature-panel a {
  position: relative;
  z-index: 1;
  justify-self: end;
  margin-top: 18px;
  color: var(--green-700);
  font-weight: 600;
}

.pill-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.pill-row span {
  padding: 9px 12px;
  border-radius: 8px;
  color: #66806d;
  background: rgba(246, 251, 247, 0.7);
  font-size: 12px;
  font-weight: 500;
}

.wide-panel {
  grid-column: span 2;
}

.status-panel {
  min-height: 168px;
  background:
    radial-gradient(circle at 100% 30%, rgba(65, 177, 92, 0.16) 0 2px, transparent 2px 8px),
    rgba(255, 255, 255, 0.7);
  background-size: auto, auto;
}

.status-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.status-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 96px minmax(92px, auto);
  align-items: center;
  gap: 14px;
  min-height: 34px;
}

.status-row span {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  border: 1px solid rgba(31, 122, 62, 0.34);
  border-radius: 8px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 600;
}

.status-row strong {
  min-width: 0;
  overflow: hidden;
  color: #2f4436;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-row em {
  color: #8a998d;
  font-style: normal;
  text-align: right;
}

.status-row b {
  color: var(--green-700);
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-weight: 650;
  text-align: right;
}

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

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

  .workspace {
    padding: 26px 22px 42px;
  }

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

  .model-zone,
  .wide-panel {
    grid-column: span 2;
  }

  .quick-prompts {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

@media (max-width: 720px) {
  .topbar,
  .query-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .ghost-button,
  .primary-button,
  .mode-picker,
  .mode-select-button {
    width: 100%;
  }

  .send-button {
    width: 48px;
    height: 48px;
    align-self: flex-end;
  }

  .mode-picker {
    display: grid;
  }

  .mode-menu {
    position: static;
    width: 100%;
    margin-top: 8px;
  }

  .kv-list div {
    grid-template-columns: 1fr;
  }

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

  .model-zone,
  .wide-panel {
    grid-column: auto;
  }

  .hero {
    padding-top: 22px;
  }

  .hero h2 {
    white-space: normal;
  }

  .query-box {
    min-height: 0;
    padding: 18px;
    border-radius: 18px;
  }

  .query-box textarea {
    min-height: 120px;
  }

  .quick-prompts button {
    white-space: normal;
  }

  .status-row {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .status-row:last-child {
    border-bottom: 0;
  }

  .status-row span,
  .status-row em,
  .status-row b {
    justify-self: start;
    text-align: left;
  }

  .reference-modal {
    padding: 14px;
  }

  .reference-modal-dialog {
    max-height: 90vh;
    padding: 16px;
  }

  .reference-modal-header,
  .reference-modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .paper-selector-head,
  .paper-option,
  .selected-paper {
    grid-template-columns: 1fr;
  }

  .selected-paper button {
    width: fit-content;
  }
}
