:root {
  --ink: #101d25;
  --muted: #65727b;
  --line: #dce4e7;
  --soft: #f2f6f7;
  --panel: #ffffff;
  --aqua: #bdeaf0;
  --aqua-strong: #18bfe2;
  --aqua-dark: #087b91;
  --navy: #15303b;
  --focus: #095f70;
  --shadow: 0 24px 60px rgba(28, 64, 74, 0.1);
  font-family: "DengXian", "等线", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #edf4f5;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

.portfolio-return {
  position: fixed;
  left: 24px;
  bottom: 22px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid rgba(18, 50, 59, 0.16);
  border-radius: 999px;
  color: #12323b;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(18, 50, 59, 0.12);
  backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease;
}

.portfolio-return:hover {
  transform: translateY(-2px);
  background: #b9edf1;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 7% 3%, rgba(24, 191, 226, 0.14), transparent 28rem),
    linear-gradient(180deg, #f7fbfb 0%, #edf4f5 100%);
}

button,
textarea,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(24, 191, 226, 0.32);
  outline-offset: 3px;
}

.app-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 24px auto;
  overflow: hidden;
  border: 1px solid rgba(16, 29, 37, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 94px;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(7, 79, 94, 0.12);
  background: var(--aqua);
}

.brand-lockup,
.demo-badge,
.input-row,
.panel-heading,
.panel-meta,
.doi-bar,
.doi-bar > div {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 2px solid var(--navy);
  border-radius: 16px 16px 16px 4px;
  color: var(--navy);
  font-size: 23px;
  font-weight: 700;
  transform: rotate(-4deg);
}

.brand-lockup h1,
.brand-lockup p,
.profile-copy strong,
.profile-copy span,
.search-heading h2,
.search-heading p,
.panel-heading h2,
.doi-bar p {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.brand-lockup p {
  margin-top: 4px;
  color: var(--aqua-dark);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.demo-badge {
  gap: 10px;
  padding: 6px 8px 6px 6px;
  border: 1px solid rgba(21, 48, 59, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
}

.demo-badge img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
}

.demo-badge span {
  color: var(--aqua-dark);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.demo-badge strong {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--navy);
  color: white;
  font-size: 10px;
}

main {
  padding: 24px;
}

.search-card {
  padding: 30px;
  border-radius: 22px;
  background: var(--navy);
  color: white;
}

.search-heading {
  max-width: 780px;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--aqua-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.search-card .eyebrow {
  color: #72ddef;
}

.search-heading h2 {
  font-size: clamp(25px, 3vw, 38px);
  letter-spacing: -1px;
}

.search-heading p {
  margin-top: 8px;
  color: #b9c8ce;
  font-size: 14px;
}

.search-form {
  margin-top: 24px;
}

.search-form > label {
  display: block;
  margin-bottom: 9px;
  color: #d7e4e7;
  font-size: 13px;
  font-weight: 600;
}

.input-row {
  align-items: stretch;
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: #fbfefe;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.6;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea::placeholder {
  color: #92a0a6;
}

textarea:focus {
  border-color: var(--aqua-strong);
  box-shadow: 0 0 0 4px rgba(24, 191, 226, 0.13);
  outline: none;
}

.generate-button {
  display: flex;
  flex: 0 0 176px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 16px;
  background: var(--aqua);
  color: var(--navy);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.generate-button:hover {
  background: #a5e4ec;
  transform: translateY(-2px);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.button-orbit {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
}

.button-orbit img {
  display: block;
  width: 100%;
  height: 100%;
}

.button-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.button-copy strong {
  font-size: 15px;
}

.button-copy small {
  margin-top: 2px;
  color: #4b6d75;
  font-size: 10px;
}

.agent-status {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(114, 221, 239, 0.24);
  border-radius: 12px;
  background: rgba(5, 18, 23, 0.32);
  color: #c9e5ea;
  font-size: 12px;
}

.agent-trace summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.agent-trace summary::-webkit-details-marker {
  display: none;
}

.agent-trace summary::after {
  content: "+";
  color: #72ddef;
  font-size: 18px;
  line-height: 1;
}

.agent-trace[open] summary::after {
  content: "−";
}

.agent-trace summary small {
  margin-left: auto;
  color: #87a1a9;
  font-size: 10px;
}

.agent-trace ol {
  display: grid;
  gap: 8px;
  margin: 14px 0 2px;
  padding: 14px 14px 14px 32px;
  border-top: 1px solid rgba(114, 221, 239, 0.16);
  color: #bdd7dc;
  line-height: 1.55;
}

.agent-trace li::marker {
  color: #72ddef;
  font-weight: 700;
}

.status-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.status-steps span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-steps span:not(:last-child)::after {
  content: "→";
  color: #6b8790;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(300px, 0.85fr);
  gap: 18px;
  margin-top: 18px;
}

.paper-panel,
.insight-panel {
  min-height: 548px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--soft);
}

.panel-heading {
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 22px;
  letter-spacing: -0.4px;
}

.panel-meta {
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.panel-meta strong {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 9px;
  background: #dcebee;
  color: var(--aqua-dark);
}

.table-wrap,
.paper-detail {
  min-height: 440px;
  overflow: hidden;
  border: 1px solid rgba(16, 29, 37, 0.06);
  border-radius: 16px;
  background: var(--panel);
}

.paper-table-head,
.paper-row {
  display: grid;
  grid-template-columns: 52px minmax(240px, 1fr) 118px 104px;
  align-items: center;
  gap: 12px;
}

.paper-table-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.paper-row {
  width: 100%;
  min-height: 75px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid #edf1f2;
  background: white;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}

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

.paper-row:hover {
  background: #f5fbfc;
}

.paper-row.is-selected {
  position: relative;
  z-index: 1;
  background: #ebf9fb;
  box-shadow: inset 4px 0 0 var(--aqua-strong);
}

.paper-index {
  color: #829097;
  font-size: 12px;
  font-weight: 700;
}

.paper-name {
  min-width: 0;
}

.paper-name strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.paper-name small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: #849198;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paper-date {
  color: #5c6a71;
  font-size: 12px;
}

.level-pill,
.detail-tag {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
}

.level-pill {
  padding: 6px 9px;
  font-size: 10px;
}

.level-key {
  background: #d8f6ee;
  color: #08745d;
}

.level-recommended {
  background: #e1f4fa;
  color: #096a84;
}

.level-normal {
  background: #edf0f1;
  color: #66747b;
}

.paper-detail {
  padding: 22px;
}

.detail-empty,
.empty-state {
  display: flex;
  min-height: 380px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #829097;
  text-align: center;
}

.detail-empty span {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
  place-items: center;
  border: 1px solid #cbd7da;
  border-radius: 50%;
  font-size: 21px;
}

.detail-empty p,
.empty-state p {
  max-width: 250px;
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
}

.detail-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  letter-spacing: -0.2px;
}

.detail-meta {
  margin: 9px 0 18px;
  color: #76848a;
  font-size: 11px;
  line-height: 1.6;
}

.detail-block {
  padding: 16px 0;
  border-top: 1px solid #edf1f2;
}

.detail-block h3 {
  margin: 0 0 7px;
  color: var(--aqua-dark);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-block p {
  margin: 0;
  color: #3b4b52;
  font-size: 13px;
  line-height: 1.75;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.detail-tag {
  padding: 5px 8px;
  background: #edf6f7;
  color: #557178;
  font-size: 9px;
}

.doi-bar {
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 16px 28px;
  border-top: 1px solid rgba(7, 79, 94, 0.12);
  background: var(--aqua);
}

.doi-bar > div {
  min-width: 0;
  gap: 12px;
}

.doi-label {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--navy);
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.doi-bar a {
  overflow: hidden;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  text-decoration-thickness: 1px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doi-bar a[aria-disabled="true"] {
  color: #6f8990;
  pointer-events: none;
  text-decoration: none;
}

.doi-bar p {
  color: #4e737c;
  font-size: 10px;
  text-align: right;
}

.empty-state {
  min-height: 390px;
  padding: 24px;
}

.empty-state h3 {
  margin: 16px 0 7px;
  color: #56666d;
  font-size: 15px;
}

.empty-radar {
  position: relative;
  width: 72px;
  height: 72px;
  border: 1px solid #b8c9cd;
  border-radius: 50%;
}

.empty-radar::before,
.empty-radar::after,
.empty-radar span {
  position: absolute;
  content: "";
}

.empty-radar::before {
  inset: 11px;
  border: 1px solid #d1dcde;
  border-radius: 50%;
}

.empty-radar::after {
  left: 35px;
  top: 8px;
  width: 1px;
  height: 28px;
  background: var(--aqua-strong);
  transform: rotate(38deg);
  transform-origin: bottom;
}

.empty-radar span {
  right: 15px;
  top: 19px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--aqua-strong);
}

.loading-list {
  padding: 10px 16px;
}

.loading-row {
  display: grid;
  grid-template-columns: 52px 1fr 118px 104px;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid #edf1f2;
}

.skeleton {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edef;
}

.skeleton::after {
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
  content: "";
  animation: shimmer 1.25s infinite;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(380px, calc(100% - 48px));
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--navy);
  box-shadow: 0 14px 38px rgba(12, 39, 49, 0.24);
  color: white;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes shimmer {
  from { transform: translateX(-120%); }
  to { transform: translateX(280%); }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    margin: 12px auto;
    border-radius: 20px;
  }

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

  .insight-panel,
  .paper-panel {
    min-height: auto;
  }

  .doi-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .doi-bar p {
    text-align: left;
  }
}

@media (max-width: 680px) {
  .topbar,
  main,
  .doi-bar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand-lockup h1 {
    font-size: 20px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .demo-badge span {
    display: none;
  }

  .agent-trace summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-trace summary small {
    margin-left: 0;
  }

  .search-card,
  .paper-panel,
  .insight-panel {
    padding: 18px;
    border-radius: 17px;
  }

  .input-row {
    align-items: stretch;
    flex-direction: column;
  }

  .generate-button {
    min-height: 68px;
    flex-basis: auto;
  }

  .paper-table-head,
  .paper-row {
    grid-template-columns: 34px minmax(0, 1fr) 82px;
    gap: 8px;
  }

  .paper-table-head span:nth-child(3),
  .paper-date {
    display: none;
  }

  .paper-table-head {
    font-size: 9px;
  }

  .paper-row {
    min-height: 82px;
    padding-inline: 12px;
  }

  .panel-meta span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
