:root {
  --ink: #16201e;
  --muted: #67716d;
  --paper: #f4f0e7;
  --paper-2: #ebe4d6;
  --white: #fffdf8;
  --green: #173d36;
  --green-2: #24594d;
  --terracotta: #b95c3d;
  --line: rgba(22, 32, 30, .13);
  --shadow: 0 18px 55px rgba(31, 39, 36, .1);
  --sans: "Manrope", system-ui, sans-serif;
  --serif: "Literata", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(185, 92, 61, .08), transparent 27rem),
    linear-gradient(180deg, #f8f5ee 0, var(--paper) 46rem);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

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

.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 14px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(248, 245, 238, .83);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 36px;
  height: 39px;
  padding: 8px 7px;
  border-radius: 6px 6px 10px 4px;
  background: var(--green);
  box-shadow: 3px 4px 0 rgba(185, 92, 61, .22);
}

.brand-mark span {
  width: 5px;
  border-radius: 1px;
  background: #f4eddf;
}

.brand-mark span:nth-child(1) { height: 19px; }
.brand-mark span:nth-child(2) { height: 23px; background: #d89072; }
.brand-mark span:nth-child(3) { height: 16px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions form {
  margin: 0;
}

.user-pill {
  margin-right: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: white;
  background: var(--green);
  box-shadow: 0 8px 24px rgba(23, 61, 54, .18);
}

.button-primary:hover {
  background: var(--green-2);
}

.button-secondary {
  border-color: var(--line);
  background: var(--white);
}

.button-secondary:hover,
.button-quiet:hover {
  border-color: rgba(23, 61, 54, .25);
  background: rgba(255, 255, 255, .75);
}

.button-quiet {
  min-height: 38px;
  padding: 9px 12px;
  border-color: transparent;
  color: var(--green);
  background: transparent;
}

.button-wide {
  width: 100%;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 90px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--terracotta);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
}

.library-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 10px 0 42px;
}

.library-hero h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 70px);
  letter-spacing: -.045em;
  line-height: 1.03;
}

.hero-copy {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.library-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 18px 21px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, .65);
}

.library-stat strong {
  color: var(--green);
  font-family: var(--serif);
  font-size: 34px;
}

.library-stat span {
  color: var(--muted);
  font-size: 12px;
}

.library-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(390px, 100%);
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 253, 248, .78);
}

.search-box span {
  color: var(--green);
  font-family: Georgia, serif;
  font-size: 24px;
}

.search-box input {
  width: 100%;
  height: 46px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 38px 25px;
}

.document-card {
  min-width: 0;
}

.document-card[hidden] {
  display: none;
}

.cover-wrap,
.detail-cover {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 5px 9px 9px 5px;
  background: #dfd7c7;
  box-shadow: 0 14px 30px rgba(28, 35, 32, .14), -5px 0 0 #d4cab8;
}

.cover-wrap {
  aspect-ratio: 2 / 2.85;
  transition: transform .2s ease, box-shadow .2s ease;
}

.cover-wrap::after,
.detail-cover::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 9px;
  content: "";
  background: linear-gradient(90deg, rgba(31, 32, 25, .25), transparent);
  pointer-events: none;
}

.cover-wrap:hover {
  transform: translateY(-5px) rotate(-.3deg);
  box-shadow: 0 23px 40px rgba(28, 35, 32, .18), -5px 0 0 #d4cab8;
}

.cover-wrap img,
.detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 42% 18px 18px;
  color: #f9f4e9;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .08), transparent 45%),
    var(--green);
}

.cover-fallback b {
  font-family: var(--serif);
  font-size: clamp(55px, 7vw, 90px);
  font-weight: 400;
  opacity: .9;
}

.cover-fallback small {
  align-self: flex-end;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
}

.continue-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 7px 9px;
  border-radius: 5px;
  color: white;
  background: rgba(23, 61, 54, .9);
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.document-card-body {
  padding: 18px 2px 0;
}

.document-kicker {
  margin: 0 0 6px;
  color: var(--terracotta);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.document-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.32;
}

.document-card h2 a {
  text-decoration: none;
}

.document-card h2 a:hover {
  color: var(--green-2);
}

.document-author {
  overflow: hidden;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  overflow: hidden;
  height: 3px;
  margin-top: 15px;
  border-radius: 3px;
  background: rgba(23, 61, 54, .1);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--terracotta);
}

.empty-state {
  padding: 85px 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  background: rgba(255, 253, 248, .55);
}

.empty-icon {
  color: var(--green);
  font-size: 48px;
}

.empty-state h2 {
  margin: 16px 0 6px;
  font-size: 30px;
}

.empty-state p,
.empty-search {
  color: var(--muted);
}

.empty-state .button {
  margin-top: 14px;
}

.empty-search {
  padding: 60px 0;
  text-align: center;
}

.back-link {
  display: inline-block;
  margin-bottom: 36px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.document-detail {
  display: grid;
  grid-template-columns: minmax(230px, 340px) minmax(0, 1fr);
  gap: clamp(42px, 7vw, 100px);
  align-items: center;
  padding-bottom: 72px;
}

.detail-cover {
  aspect-ratio: 2 / 2.85;
}

.cover-fallback-large {
  padding-top: 44%;
}

.detail-copy {
  max-width: 710px;
}

.detail-copy h1 {
  margin: 0;
  font-size: clamp(39px, 5vw, 66px);
  letter-spacing: -.045em;
  line-height: 1.08;
}

.detail-byline {
  margin: 18px 0 0;
  color: var(--green);
  font-size: 16px;
  font-weight: 700;
}

.detail-byline span {
  padding: 0 5px;
  color: #afa89b;
}

.detail-description {
  max-width: 650px;
  margin-top: 26px;
  color: #4d5753;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.75;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 34px;
}

.file-meta {
  margin: 15px 0 0;
  color: #8a8f8c;
  font-size: 11px;
}

.reading-memory {
  display: grid;
  grid-template-columns: .65fr 1.35fr;
  gap: 50px;
  padding: 48px 0;
  border-top: 1px solid var(--line);
}

.reading-memory h2 {
  margin: 0;
  font-size: 32px;
}

.memory-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.memory-panel {
  min-height: 155px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, .62);
}

.memory-panel h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 17px;
  color: var(--green);
  font-size: 13px;
  text-transform: uppercase;
}

.memory-panel h3 span {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 10px;
}

.memory-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.page-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.page-chip-list a,
.page-chip-list button {
  padding: 7px 10px;
  border: 1px solid rgba(23, 61, 54, .16);
  border-radius: 999px;
  color: var(--green);
  background: rgba(255, 255, 255, .6);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}

.notes-preview {
  display: grid;
  gap: 8px;
}

.notes-preview a {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.notes-preview b {
  color: var(--green);
  font-size: 10px;
}

.notes-preview span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.login-page {
  overflow-x: hidden;
}

.login-page .site-header {
  background: transparent;
}

.login-page .page-shell {
  width: 100%;
  padding: 0;
}

.login-layout {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  min-height: calc(100vh - 79px);
}

.login-intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  padding: clamp(50px, 8vw, 120px);
  color: white;
  background:
    radial-gradient(circle at 75% 22%, rgba(216, 144, 114, .35), transparent 25%),
    linear-gradient(145deg, #102f2a, #1e4b41);
}

.login-intro::after {
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 360px;
  height: 460px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 7px 20px 20px 7px;
  content: "";
  box-shadow: -24px 0 0 rgba(255, 255, 255, .04), -48px 0 0 rgba(255, 255, 255, .025);
  transform: rotate(-12deg);
}

.login-intro .eyebrow {
  color: #dfa080;
}

.login-intro h1 {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0;
  font-size: clamp(48px, 7vw, 84px);
  letter-spacing: -.055em;
  line-height: 1.04;
}

.login-intro > p:last-child {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 28px 0 0;
  color: rgba(255, 255, 255, .72);
  font-size: 16px;
  line-height: 1.75;
}

.login-card {
  align-self: center;
  width: min(430px, calc(100% - 50px));
  margin: 45px auto;
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, .88);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 31px;
  font-size: 32px;
}

.login-card label {
  display: block;
  margin: 18px 0 7px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.login-card input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: white;
}

.login-card input:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(36, 89, 77, .1);
}

.login-card .button {
  margin-top: 26px;
  min-height: 50px;
}

.login-help {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.form-error {
  margin-bottom: 20px;
  padding: 11px 13px;
  border-radius: 7px;
  color: #8b301d;
  background: #f8ddd4;
  font-size: 12px;
}

.messages {
  position: fixed;
  z-index: 100;
  top: 90px;
  right: 24px;
}

.message {
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  background: var(--green);
  box-shadow: var(--shadow);
}

/* Reader */
.reader-page {
  overflow: hidden;
  background: #252927;
}

.reader-page .site-header {
  display: none;
}

.reader-shell {
  height: 100vh;
}

.reader-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #edf1ee;
  background: #252927;
}

.reader-toolbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  min-height: 66px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  background: #17201e;
  box-shadow: 0 5px 20px rgba(0, 0, 0, .18);
}

.reader-close {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: #e7ece9;
  font-size: 26px;
  text-decoration: none;
}

.reader-close:hover,
.reader-toolbar button:hover {
  background: rgba(255, 255, 255, .1);
}

.reader-title {
  position: absolute;
  left: 64px;
  display: flex;
  flex-direction: column;
  width: min(24vw, 330px);
}

.reader-title strong,
.reader-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title strong {
  font-family: var(--serif);
  font-size: 13px;
}

.reader-title span {
  margin-top: 2px;
  color: rgba(237, 241, 238, .54);
  font-size: 9px;
}

.reader-pager,
.reader-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.reader-pager {
  grid-column: 2;
}

.reader-tools {
  grid-column: 3;
  justify-self: end;
}

.reader-toolbar button {
  display: grid;
  min-width: 38px;
  height: 38px;
  padding: 0 9px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: #edf1ee;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.reader-pager input {
  width: 48px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 6px;
  outline: 0;
  color: white;
  background: rgba(255, 255, 255, .07);
  text-align: center;
}

.reader-pager span {
  margin: 0 5px;
  color: rgba(237, 241, 238, .55);
  font-size: 11px;
}

.reader-pager b {
  color: #edf1ee;
}

.reader-toolbar .bookmark-control.active {
  color: #f2a27e;
  background: rgba(185, 92, 61, .18);
}

.reader-toolbar .notes-toggle {
  width: auto;
  padding: 0 13px;
  font-size: 11px;
}

.reader-workspace {
  display: flex;
  min-height: 0;
  flex: 1;
}

.canvas-stage {
  position: relative;
  display: flex;
  flex: 1;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 34px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, .035), transparent 40rem),
    #292e2c;
}

#pdf-canvas {
  display: block;
  max-width: none;
  background: white;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .4);
}

.reader-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #292e2c;
}

.reader-loading.hidden {
  display: none;
}

.reader-loading span {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, .15);
  border-top-color: #d89072;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.reader-loading p {
  margin-top: 14px;
  color: rgba(255, 255, 255, .6);
  font-size: 11px;
}

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

.notes-panel {
  display: flex;
  width: 0;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  transition: width .22s ease;
}

.notes-panel.open {
  width: min(390px, 36vw);
  border-left: 1px solid rgba(0, 0, 0, .2);
}

.notes-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 320px;
  padding: 27px 25px 18px;
}

.notes-panel-head h2 {
  margin: 0;
  font-size: 23px;
}

.notes-panel-head button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 24px;
}

#page-note {
  min-width: 320px;
  min-height: 260px;
  margin: 0 25px;
  padding: 17px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  color: var(--ink);
  background: var(--white);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.65;
}

#page-note:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(36, 89, 77, .09);
}

.note-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 320px;
  padding: 10px 25px 22px;
}

.note-status span {
  color: var(--muted);
  font-size: 9px;
}

.note-status button {
  border: 0;
  color: var(--terracotta);
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.bookmark-list-block {
  min-width: 320px;
  padding: 22px 25px;
  border-top: 1px solid var(--line);
}

.bookmark-list-block h3 {
  margin: 0 0 13px;
  color: var(--green);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.reader-toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  padding: 11px 15px;
  border-radius: 7px;
  opacity: 0;
  color: white;
  background: var(--green);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  font-size: 11px;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
}

.reader-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1080px) {
  .document-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .reader-title { display: none; }
}

@media (max-width: 820px) {
  .document-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reading-memory { grid-template-columns: 1fr; }
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: 46vh; }
  .reader-toolbar {
    grid-template-columns: 42px 1fr auto;
    min-height: 58px;
    padding: 6px 8px;
  }
  .reader-close { grid-column: 1; }
  .reader-pager { grid-column: 2; justify-self: center; }
  .reader-tools { grid-column: 3; }
  .reader-tools #zoom-out,
  .reader-tools #zoom-in,
  .reader-tools #fit-width { display: none; }
  .reader-toolbar .notes-toggle { font-size: 0; width: 38px; padding: 0; }
  .reader-toolbar .notes-toggle::before { content: "✎"; font-size: 17px; }
  .notes-panel {
    position: absolute;
    z-index: 20;
    top: 58px;
    right: 0;
    bottom: 0;
  }
  .notes-panel.open { width: min(390px, 94vw); }
  .canvas-stage { padding: 18px 10px; }
}

@media (max-width: 620px) {
  .site-header {
    min-height: 68px;
    padding: 11px 18px;
  }
  .brand small,
  .user-pill,
  .header-actions .button-quiet:first-of-type { display: none; }
  .brand-mark { width: 32px; height: 34px; padding: 6px; }
  .page-shell {
    width: min(100% - 28px, 1240px);
    padding: 38px 0 65px;
  }
  .library-hero {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 28px;
  }
  .library-hero h1 { font-size: 43px; }
  .hero-copy { font-size: 14px; }
  .library-stat { padding: 10px 14px; }
  .library-stat strong { font-size: 25px; }
  .library-tools { padding-top: 17px; }
  .document-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px 15px;
  }
  .document-card h2 { font-size: 15px; }
  .document-detail {
    grid-template-columns: 1fr;
    gap: 38px;
  }
  .detail-cover { width: min(72vw, 330px); margin: 0 auto; }
  .detail-copy h1 { font-size: 39px; }
  .memory-columns { grid-template-columns: 1fr; }
  .login-intro { min-height: 45vh; padding: 46px 27px; }
  .login-intro h1 { font-size: 46px; }
  .login-card { padding: 31px 25px; }
  .reader-pager button { display: none; }
  .reader-pager input { width: 41px; }
}
