:root {
  --bg: #071419;
  --bg-soft: #0d2026;
  --panel: rgba(9, 28, 34, 0.82);
  --panel-strong: rgba(8, 22, 28, 0.96);
  --paper: #f6f0e6;
  --paper-border: rgba(16, 35, 42, 0.08);
  --ink: #112126;
  --ink-soft: #56676b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #c98d3d;
  --accent-soft: rgba(201, 141, 61, 0.16);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #f7f2e9;
  background:
    radial-gradient(circle at 14% 18%, rgba(201, 141, 61, 0.22), transparent 20%),
    radial-gradient(circle at 88% 12%, rgba(85, 132, 145, 0.18), transparent 24%),
    linear-gradient(180deg, #071419 0%, #0a171d 48%, #081218 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.6), transparent 92%);
}

button,
input,
a {
  font: inherit;
}

button,
a {
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 26px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(10, 34, 41, 0.94), rgba(7, 23, 29, 0.98)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.menu-toggle,
.control-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: #f7f2e9;
  text-decoration: none;
}

.menu-toggle:hover,
.control-row button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

.menu-toggle {
  display: none;
}

.brand-kicker,
.paper-specialty-en,
.paper-meta,
.specialty-item small,
.specialty-index,
.position {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-kicker,
.paper-specialty-en,
.specialty-item small,
.specialty-index,
.position {
  font-size: 11px;
  font-weight: 700;
}

.brand-kicker {
  margin: 0 0 10px;
  color: #d5b074;
}

.brand h1,
.paper-head h2,
.sidebar-head h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Songti SC", "STSong", Georgia, serif;
}

.brand h1 {
  font-size: clamp(2rem, 3.2vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand-note {
  margin: 10px 0 0;
  color: rgba(247, 242, 233, 0.72);
  font-size: 15px;
}

.workspace {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  min-height: calc(100vh - 170px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(8, 25, 31, 0.95), rgba(6, 19, 24, 0.98)),
    var(--panel-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar-head {
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-head h2 {
  font-size: 1.8rem;
  color: #fff7eb;
}

.searchbox {
  display: block;
  margin-top: 14px;
}

.searchbox input,
.page-field input {
  width: 100%;
  min-width: 0;
  border-radius: 16px;
  border: 1px solid var(--line);
  outline: none;
}

.searchbox input {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: #f7f2e9;
}

.searchbox input::placeholder {
  color: rgba(247, 242, 233, 0.42);
}

.specialty-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.specialty-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 14px 14px 16px;
  border-radius: 22px;
  text-decoration: none;
  color: #f7f2e9;
  border: 1px solid transparent;
}

.specialty-item + .specialty-item {
  margin-top: 8px;
}

.specialty-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.06);
}

.specialty-item.active {
  background:
    linear-gradient(135deg, rgba(201, 141, 61, 0.2), rgba(201, 141, 61, 0.05)),
    rgba(255, 255, 255, 0.04);
  border-color: rgba(201, 141, 61, 0.4);
  box-shadow: inset 0 0 0 1px rgba(201, 141, 61, 0.14);
}

.specialty-index {
  color: rgba(247, 242, 233, 0.48);
}

.specialty-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.specialty-copy strong {
  font-size: 1.02rem;
  font-weight: 700;
}

.specialty-item small {
  color: rgba(247, 242, 233, 0.5);
}

.reader-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

.paper-bar,
.reader-stage {
  border: 1px solid var(--paper-border);
  border-radius: 28px;
  background: linear-gradient(180deg, #faf5ed 0%, #f4ede2 100%);
  box-shadow: var(--shadow);
}

.paper-bar {
  padding: 28px 30px 24px;
  color: var(--ink);
}

.paper-head {
  display: grid;
  gap: 14px;
  min-width: 0;
}

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

.paper-specialty {
  margin: 0;
  font-size: clamp(1.5rem, 2.2vw, 2.05rem);
  font-weight: 700;
  line-height: 1.1;
}

.paper-specialty-en {
  margin: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(17, 33, 38, 0.14);
  color: #8a6b3c;
}

.paper-head h2 {
  margin: 0;
  width: 100%;
  max-width: none;
  font-size: clamp(1.55rem, 2.1vw, 2.5rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.paper-meta {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid rgba(17, 33, 38, 0.08);
  font-size: 12px;
  color: var(--ink-soft);
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.paper-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(17, 33, 38, 0.12);
  background: rgba(17, 33, 38, 0.04);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.paper-link:hover {
  transform: translateY(-1px);
  background: rgba(17, 33, 38, 0.08);
}

.reader-stage {
  position: relative;
  min-height: 720px;
  overflow: hidden;
}

.pdf-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 720px;
  background: #d9d2c6;
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(17, 33, 38, 0.08);
  background: rgba(250, 245, 237, 0.92);
}

.pdf-page-indicator {
  margin: 0;
  min-width: 88px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
}

.pdf-status {
  margin: 0;
  padding: 14px 18px 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.pdf-status[data-kind="error"] {
  color: #8b3f24;
}

.pdf-canvas-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 12px 24px;
  background-color: #d9d2c6;
  background-position: top center;
  background-repeat: no-repeat;
  background-size: calc(100% - 24px) auto;
}

.pdf-pages {
  display: grid;
  gap: 16px;
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

#pdf-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 720px;
  border: 0;
  background: #d9d2c6;
}

.empty-state,
.fatal-error {
  padding: 24px;
  color: rgba(247, 242, 233, 0.72);
}

.fatal-error {
  max-width: 720px;
  margin: 80px auto;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 1600px);
    padding-top: 10px;
  }

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

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

  .sidebar {
    position: static;
    width: auto;
    max-height: min(46vh, 360px);
    transform: none;
    transition: none;
  }

  .menu-toggle {
    display: none;
  }

  .specialty-list {
    max-height: min(34vh, 280px);
  }
}

@media (max-width: 720px) {
  .topbar,
  .paper-bar {
    padding: 20px 18px;
    border-radius: 24px;
  }

  .paper-taxonomy {
    gap: 6px 10px;
  }

  .paper-specialty-en {
    padding-left: 10px;
  }

  .reader-stage {
    min-height: 560px;
    border-radius: 24px;
  }

  .pdf-viewer {
    min-height: 560px;
  }

  .pdf-toolbar {
    padding: 12px;
  }

  .pdf-page-indicator {
    min-width: 72px;
    font-size: 13px;
  }

  #pdf-frame {
    min-height: 560px;
  }
}
