:root {
  --ink:    #14202b;   /* petrol ground */
  --raise:  #1b2b38;   /* lifted surface */
  --edge:   #263a4a;
  --paper:  #e8e4da;   /* aged paper, used on plates */
  --text:   #dfe6ea;
  --muted:  #7d8f9c;
  --brass:  #c9a227;
  --brass-d:#8f7318;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: Literata, Georgia, "Times New Roman", serif;

  --gap: 1.5rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0.9rem 1.5rem;
  background: var(--raise);
  border-bottom: 1px solid var(--edge);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  color: var(--paper);
  white-space: nowrap;
}

.searchform {
  display: flex;
  flex: 1 1 22rem;
  max-width: 46rem;
  border: 1px solid var(--edge);
  border-radius: 2px;
  background: var(--ink);
  overflow: hidden;
}
.searchform:focus-within { border-color: var(--brass-d); }

.searchform input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: .55rem .8rem;
  font: inherit;
}
.searchform input::placeholder { color: var(--muted); }
.searchform input:focus { outline: none; }

.searchform button {
  border: 0;
  background: var(--brass);
  color: #211a04;
  font: inherit;
  font-weight: 600;
  padding: 0 1.1rem;
  cursor: pointer;
}
.searchform button:hover { background: #d9b433; }

.topbar-end {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-left: auto;
  color: var(--muted);
  font-size: .875rem;
}
.plain { text-decoration: none; }
.plain:hover { color: var(--brass); }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
  padding: var(--gap);
  gap: var(--gap);
}
.shell--detail { grid-template-columns: minmax(0, 1fr); }

/* ---------- A–Z rail ---------- */

.rail {
  position: sticky;
  top: 5.2rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  font-size: .8rem;
}

.rail-item {
  display: block;
  text-align: center;
  padding: .18rem 0;
  text-decoration: none;
  color: var(--muted);
  border-radius: 2px;
}
.rail-item:hover { color: var(--paper); background: var(--raise); }
.rail-item.is-active { color: #211a04; background: var(--brass); font-weight: 600; }
.rail-item.is-empty { opacity: .28; }
.rail-item.is-digraph { font-size: .68rem; letter-spacing: -.02em; }

/* ---------- content head ---------- */

.content-head { margin-bottom: 1.4rem; }

.content-head h1 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 600;
  margin: 0;
  color: var(--paper);
}

.tally { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }

.facets {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .9rem;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .22rem .6rem;
  border: 1px solid var(--edge);
  border-radius: 2px;
  font-size: .82rem;
  text-decoration: none;
  color: var(--muted);
}
.chip span { font-size: .72rem; opacity: .6; }
.chip:hover { border-color: var(--brass-d); color: var(--paper); }
.chip.is-on { background: var(--brass); border-color: var(--brass); color: #211a04; font-weight: 600; }
.chip.is-on span { opacity: .75; }
.chip.is-clear { border-style: dashed; }

/* ---------- plate grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 1.4rem 1.1rem;
}

.plate-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.plate-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--raise);
  border-radius: 1px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .5), 0 8px 18px -12px rgba(0, 0, 0, .9);
  transition: transform .12s ease;
}
.plate-link:hover .plate-img,
.plate-link:focus-visible .plate-img { transform: translateY(-3px); }

.plate-meta { display: block; margin-top: .5rem; }

.plate-title {
  display: block;
  font-family: var(--serif);
  font-size: .94rem;
  line-height: 1.3;
  color: var(--paper);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.plate-author {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-top: .1rem;
}

/* ---------- pager ---------- */

.pager {
  display: flex;
  justify-content: center;
  gap: .3rem;
  margin: 2.5rem 0 1rem;
  font-size: .9rem;
}
.pager a, .pager span {
  min-width: 2.1rem;
  text-align: center;
  padding: .35rem .5rem;
  border: 1px solid var(--edge);
  border-radius: 2px;
  text-decoration: none;
  color: var(--muted);
}
.pager a:hover { border-color: var(--brass-d); color: var(--paper); }
.pager .is-current { background: var(--brass); border-color: var(--brass); color: #211a04; font-weight: 600; }
.pager .gap { border: 0; }

/* ---------- empty ---------- */

.empty { padding: 4rem 0; color: var(--muted); }
.empty p { margin: 0 0 .4rem; }
.empty .hint { font-size: .9rem; }

/* ---------- detail ---------- */

.back { display: inline-block; margin-bottom: 1.2rem; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--brass); }

.detail {
  display: grid;
  grid-template-columns: minmax(200px, 300px) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

.detail-cover img {
  width: 100%;
  height: auto;
  border-radius: 1px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .5), 0 20px 40px -24px rgba(0, 0, 0, 1);
}

.detail-body h1 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .4rem;
  color: var(--paper);
}

.byline { margin: 0; font-size: 1.1rem; }
.byline a { color: var(--brass); text-decoration: none; }
.byline a:hover { text-decoration: underline; }

.seriesline { margin: .2rem 0 0; color: var(--muted); }
.seriesline a { color: var(--muted); }

.blurb { max-width: 62ch; margin-top: 1.4rem; font-family: var(--serif); line-height: 1.7; }
.pending { margin-top: 1.4rem; color: var(--muted); font-style: italic; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .2rem 1.2rem;
  margin: 1.6rem 0 0;
  font-size: .92rem;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* ---------- files ---------- */

.files { margin-top: 2.4rem; }
.files h2, .related h2 {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 .7rem;
  color: var(--paper);
}
.files h2 span { color: var(--muted); font-weight: 400; font-size: .9rem; }

.rootpick { display: block; margin-bottom: .8rem; font-size: .88rem; color: var(--muted); }
.rootpick select {
  margin-left: .5rem;
  background: var(--raise);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: .25rem .4rem;
  font: inherit;
  font-size: .88rem;
}

.filelist { list-style: none; margin: 0; padding: 0; }
.filelist li {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .45rem 0;
  border-top: 1px solid var(--edge);
}
.filelist li:last-child { border-bottom: 1px solid var(--edge); }

.ext {
  flex: 0 0 3.2rem;
  font-size: .72rem;
  color: var(--brass);
  border: 1px solid var(--brass-d);
  border-radius: 2px;
  text-align: center;
  padding: .05rem 0;
}

.path {
  flex: 1;
  min-width: 0;
  font-size: .82rem;
  color: var(--muted);
  overflow-x: auto;
  white-space: nowrap;
}

.copy {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: 2px;
  color: var(--muted);
  font: inherit;
  font-size: .78rem;
  padding: .2rem .55rem;
  cursor: pointer;
}
.copy:hover { border-color: var(--brass-d); color: var(--paper); }

.drive {
  flex: 0 0 auto;
  border: 1px solid var(--brass-d);
  border-radius: 2px;
  color: var(--brass);
  font-size: .78rem;
  padding: .2rem .55rem;
  text-decoration: none;
}
.drive:hover { background: var(--brass); color: #211a04; }
.copy.is-done { border-color: var(--brass); color: var(--brass); }

/* ---------- related ---------- */

.related { margin-top: 2.2rem; }
.related ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 2rem; }
.related li { break-inside: avoid; padding: .18rem 0; }
.related a { color: var(--text); text-decoration: none; font-size: .92rem; }
.related a:hover { color: var(--brass); }
.related b { color: var(--muted); font-weight: 400; }

/* ---------- login ---------- */

.loginpage {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.loginbox {
  width: min(22rem, 90vw);
  background: var(--raise);
  border: 1px solid var(--edge);
  border-radius: 2px;
  padding: 2rem;
}
.loginbox h1 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.4rem;
  color: var(--paper);
}
.loginbox label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .9rem; }
.loginbox input {
  display: block;
  width: 100%;
  margin-top: .25rem;
  background: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 2px;
  color: var(--text);
  font: inherit;
  padding: .5rem .6rem;
}
.loginbox button {
  width: 100%;
  margin-top: .4rem;
  border: 0;
  border-radius: 2px;
  background: var(--brass);
  color: #211a04;
  font: inherit;
  font-weight: 600;
  padding: .55rem;
  cursor: pointer;
}
.loginerror { color: #e8a0a0; font-size: .88rem; margin: -.6rem 0 1rem; }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .rail-item { padding: .18rem .45rem; }
  .rail-item.is-empty { display: none; }
  .detail { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .detail-cover { max-width: 220px; }
  .related ul { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
