:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --panel: rgba(255, 252, 247, 0.92);
  --ink: #1d2430;
  --muted: #5f6775;
  --accent: #0e6b61;
  --accent-2: #d96c3f;
  --line: rgba(29, 36, 48, 0.12);
  --shadow: 0 18px 40px rgba(31, 42, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(217, 108, 63, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 107, 97, 0.16), transparent 22%),
    linear-gradient(180deg, #f7f3eb 0%, #efe8db 100%);
}

.page-shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero,
.detail-hero,
.search-panel,
.paper-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 20px;
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1,
.detail-hero h1,
.paper-card h2,
.empty-state h2 {
  margin: 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 700;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 56px);
  line-height: 0.96;
}

.detail-hero h1 {
  font-size: clamp(30px, 4.5vw, 48px);
  line-height: 1.08;
}

.hero-copy {
  max-width: 700px;
  margin: 14px 0 0;
  line-height: 1.7;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  align-items: flex-start;
}

.ghost-link,
.title-link {
  color: inherit;
  text-decoration: none;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(29, 36, 48, 0.14);
}

.hero-stat {
  min-width: 160px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(14, 107, 97, 0.12), rgba(217, 108, 63, 0.12));
  text-align: right;
}

.hero-stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.hero-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 40px;
}

.search-panel {
  padding: 22px;
  margin-bottom: 20px;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.search-grid label,
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

input,
select,
button,
.actions a {
  border-radius: 14px;
  border: 1px solid rgba(29, 36, 48, 0.14);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.78);
}

.actions {
  justify-content: flex-end;
}

button,
.actions a,
.link-row a {
  text-decoration: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

button {
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 22px;
}

.results {
  display: grid;
  gap: 18px;
}

.paper-card {
  padding: 24px;
}

.detail-card + .detail-card {
  margin-top: 18px;
}

.paper-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.title-link:hover,
.ghost-link:hover {
  opacity: 0.86;
}

.meta-line,
.authors,
.path-block,
.detail-grid dt,
.detail-grid dd {
  margin: 0;
}

.meta-line,
.authors,
.detail-grid dt,
.path-block {
  color: var(--muted);
}

.paper-card h2 {
  margin-top: 6px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}

.authors {
  margin-top: 10px;
}

.handle {
  white-space: nowrap;
  color: var(--accent-2);
  font-weight: 600;
}

.abstract {
  margin: 20px 0;
  line-height: 1.8;
}

.abstract-large {
  font-size: 16px;
  line-height: 1.95;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(14, 107, 97, 0.06);
}

.detail-grid dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-grid dd {
  margin-top: 4px;
}

.detail-grid-wide {
  margin-top: 10px;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.link-row a {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(217, 108, 63, 0.12);
  color: #7d3414;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(14, 107, 97, 0.12);
  color: #0b5a52;
  font-size: 14px;
}

.metadata-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.metadata-item {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(29, 36, 48, 0.08);
}

.metadata-item h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.metadata-item ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
}

.hit {
  padding: 0 0.18em;
  border-radius: 0.3em;
  background: rgba(217, 108, 63, 0.26);
  color: inherit;
}

.path-block {
  margin-top: 18px;
  line-height: 1.6;
  word-break: break-all;
}

.empty-state {
  padding: 32px;
  text-align: center;
}

button:hover,
.actions a:hover,
.link-row a:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

@media (max-width: 960px) {
  .search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1100px);
    padding-top: 18px;
  }

  .hero,
  .detail-hero,
  .paper-header {
    flex-direction: column;
  }

  .hero-stat {
    text-align: left;
  }

  .search-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.library-shell {
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: visible;
  background:
    radial-gradient(circle at top left, rgba(159, 146, 255, 0.15), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(122, 100, 255, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f8fe 0%, #f0f3fd 100%);
}

.library-page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  gap: 24px;
  padding: 44px 0 56px;
}

.library-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.8;
  pointer-events: none;
}

.library-orb-a {
  top: 84px;
  left: -80px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(146, 125, 255, 0.3) 0%, rgba(146, 125, 255, 0) 72%);
}

.library-orb-b {
  right: -60px;
  bottom: 100px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(91, 121, 255, 0.22) 0%, rgba(91, 121, 255, 0) 74%);
}

.library-hero {
  display: grid;
  justify-items: center;
  gap: 0;
  padding-top: 8px;
  text-align: center;
}

.library-hero-badge,
.library-brand-mark {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: 0 auto 18px;
  border-radius: 24px;
  background: linear-gradient(135deg, #7467ff 0%, #4f41ea 100%);
  box-shadow: 0 22px 42px rgba(82, 67, 232, 0.28);
}

.library-brand-mark span,
.library-hero-badge span,
.library-hero-icon span {
  display: block;
  width: 26px;
  height: 26px;
  border: 3px solid #fff;
  border-top-left-radius: 8px;
  border-bottom-right-radius: 8px;
  transform: rotate(45deg);
}

.library-eyebrow {
  margin: 0 0 10px;
  color: #6d61eb;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.library-hero h1 {
  margin: 0;
  color: #1a2238;
  font-size: clamp(38px, 6vw, 58px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.library-lead {
  max-width: 720px;
  margin: 14px auto 0;
  color: #77819a;
  font-size: 16px;
  line-height: 1.8;
}

.library-search-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: 32px;
  border: 1px solid rgba(34, 42, 67, 0.08);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 42px rgba(31, 42, 68, 0.08);
  backdrop-filter: blur(10px);
}

.library-search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.library-search-heading p,
.library-search-heading h2 {
  margin: 0;
}

.library-search-heading p {
  color: #6f63e9;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.library-search-heading h2 {
  margin-top: 6px;
  color: #1a2238;
  font-size: 28px;
  line-height: 1;
}

.library-results-header,
.library-card,
.library-idle-state,
.library-empty-state {
  border-radius: 28px;
  border: 1px solid rgba(34, 42, 67, 0.08);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 38px rgba(31, 42, 68, 0.08);
}

.library-search-form {
  display: grid;
  gap: 14px;
}

.library-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.library-field span {
  padding-left: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #8a93ab;
  text-transform: uppercase;
}

.library-field-main input,
.library-field input,
.library-field select {
  min-height: 54px;
  padding: 0 18px;
  border-radius: 18px;
  border: 1px solid rgba(42, 52, 78, 0.1);
  background: #f6f7fd;
  color: #1a2238;
  font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.library-field input:focus,
.library-field select:focus {
  outline: none;
  border-color: rgba(86, 70, 233, 0.4);
  box-shadow:
    0 0 0 4px rgba(107, 88, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.library-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.library-action-row {
  display: flex;
  gap: 12px;
}

.library-primary-action,
.library-secondary-action {
  min-height: 54px;
  border-radius: 18px;
}

.library-primary-action {
  flex: 1 1 auto;
  border: 0;
  background: linear-gradient(135deg, #6a58ff 0%, #493be7 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 18px 34px rgba(83, 65, 233, 0.24);
}

.library-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 92px;
  color: #1a2238;
  text-decoration: none;
  background: #f4f6fb;
  border: 1px solid rgba(34, 42, 67, 0.08);
}

.library-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(246, 247, 253, 0.96);
  scroll-margin-top: 18px;
}

.library-results-header p,
.library-results-header h3 {
  margin: 0;
}

.library-results-header p {
  color: #8d94ac;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.library-results-header h3 {
  margin-top: 4px;
  font-size: 22px;
  color: #1a2238;
}

.library-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.library-card {
  padding: 16px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.library-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 52px rgba(31, 42, 68, 0.12);
}

.library-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.library-card-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f4f6fd;
  color: #8992ab;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-card h4 {
  margin: 0;
  color: #1a2238;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.library-person-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  column-gap: 10px;
  margin-top: 10px;
  align-items: start;
}

.library-person-row span {
  display: inline-flex;
  align-items: flex-start;
  min-height: 28px;
  padding-top: 3px;
  color: #8a93ab;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-person-row p {
  margin: 0;
  min-height: 28px;
  display: flex;
  align-items: flex-start;
  color: #46506a;
  line-height: 1.5;
}

.library-linked-people {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  min-height: 28px;
  padding-top: 1px;
}

.library-linked-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(104, 88, 255, 0.14);
  border-radius: 999px;
  background: rgba(104, 88, 255, 0.08);
  color: #5648e5;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.library-abstract-block {
  margin: 14px 0 12px;
}

.library-abstract {
  max-height: 170px;
  padding-right: 6px;
  color: #4f5873;
  line-height: 1.7;
  overflow: auto;
  scrollbar-width: thin;
}

.library-abstract-block.is-expanded .library-abstract {
  max-height: none;
  overflow: visible;
}

.library-abstract-toggle {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #5a4ce6;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.library-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.library-link-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(104, 88, 255, 0.1);
  border: 1px solid rgba(104, 88, 255, 0.12);
  color: #5648e5;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.library-copy-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(34, 42, 67, 0.08);
  background: #f7f8fd;
  color: #56607b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.copy-chip-strong {
  background: linear-gradient(135deg, #6a58ff 0%, #493be7 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 18px rgba(83, 65, 233, 0.18);
}

.copy-chip:hover,
.library-link-row a:hover,
.library-secondary-action:hover,
.library-primary-action:hover {
  transform: translateY(-1px);
}

.copy-buffer {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

.library-idle-state,
.library-empty-state {
  padding: 30px 24px;
  text-align: center;
}

.library-idle-mark,
.library-empty-mark {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(107, 88, 255, 0.16), rgba(90, 132, 255, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.library-idle-state h3,
.library-empty-state h4 {
  margin: 0;
  color: #1a2238;
  font-size: 26px;
  line-height: 1.15;
}

.library-idle-state p,
.library-empty-state p {
  max-width: 290px;
  margin: 12px auto 0;
  color: #7c859e;
  line-height: 1.75;
}

.copy-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(24, 30, 48, 0.94);
  color: #fff;
  box-shadow: 0 16px 32px rgba(20, 25, 33, 0.24);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

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

@media (max-width: 980px) {
  .library-page {
    width: min(1000px, calc(100% - 24px));
    padding: 28px 0 40px;
  }

  .library-field-grid,
  .library-results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .library-page {
    width: min(100% - 16px, 1220px);
    gap: 18px;
    padding-top: 14px;
  }

  .library-hero h1 {
    font-size: clamp(30px, 11vw, 42px);
  }

  .library-search-panel {
    padding: 18px;
  }

  .library-search-heading h2 {
    font-size: 24px;
  }

  .library-field-grid,
  .library-results-grid {
    grid-template-columns: 1fr;
  }

  .library-action-row {
    flex-direction: column;
  }

  .library-secondary-action {
    flex-basis: auto;
  }

  .library-card h4 {
    font-size: 20px;
  }

  .library-person-row {
    grid-template-columns: 44px 1fr;
    column-gap: 10px;
  }

  .library-abstract {
    max-height: 210px;
  }

  .copy-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    text-align: center;
  }
}
