:root {
  --bg: #101113;
  --bg-deep: #0b0c0e;
  --surface: #17191d;
  --surface-2: #1e2126;
  --surface-3: #262a31;
  --paper: #f1e6d4;
  --paper-muted: #c9bca8;
  --ink: #171514;
  --text: #f2eee8;
  --muted: #a8a8a6;
  --faint: #73767c;
  --line: #30343b;
  --line-soft: #24272d;
  --blue: #4d75ff;
  --blue-soft: #89a4ff;
  --orange: #f5a33b;
  --orange-soft: #ffc070;
  --green: #6fcf97;
  --red: #ef7d7d;
  --yellow: #e8c76a;
  --shadow: 0 30px 80px rgb(0 0 0 / 34%);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --content: min(1180px, calc(100vw - 40px));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgb(77 117 255 / 13%), transparent 31rem),
    radial-gradient(circle at 92% 18%, rgb(245 163 59 / 8%), transparent 28rem),
    var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

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

a {
  color: inherit;
}

button {
  color: inherit;
}

::selection {
  color: #0c0d0f;
  background: var(--orange-soft);
}

:focus-visible {
  outline: 3px solid var(--blue-soft);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--paper);
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  overflow: clip;
}

.topbar {
  position: sticky;
  z-index: 100;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  width: var(--content);
  min-height: 76px;
  margin: 0 auto;
  border-bottom: 1px solid rgb(255 255 255 / 7%);
  background: rgb(16 17 19 / 82%);
  backdrop-filter: blur(18px) saturate(130%);
}

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

.brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
}

.brand-mark img {
  display: block;
  width: 38px;
  height: 38px;
}

.brand-copy {
  display: grid;
  line-height: 1.18;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.topnav a {
  position: relative;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.topnav a::after {
  position: absolute;
  right: 0;
  bottom: -8px;
  left: 0;
  height: 2px;
  content: "";
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 160ms ease;
}

.topnav a:hover {
  color: var(--text);
}

.topnav a:hover::after {
  transform: scaleX(1);
}

.locale-switch {
  display: flex;
  justify-self: end;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.locale-switch button {
  min-width: 38px;
  min-height: 31px;
  padding: 4px 9px;
  color: var(--faint);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.locale-switch button[aria-pressed="true"] {
  color: white;
  background: var(--blue);
  box-shadow: 0 4px 12px rgb(77 117 255 / 25%);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
  align-items: center;
  gap: clamp(48px, 8vw, 110px);
  width: var(--content);
  min-height: 620px;
  margin: 0 auto;
  padding: 78px 0 92px;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 16px;
  color: var(--orange-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.terminal-caret {
  color: var(--blue-soft);
  font-size: 16px;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(48px, 7.2vw, 86px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero h1 span,
.hero h1 em {
  display: block;
}

.hero h1 em {
  color: var(--paper);
  font-style: italic;
  font-weight: 400;
}

.hero-lede {
  max-width: 660px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.82;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

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

.button-primary {
  color: white;
  background: var(--blue);
  box-shadow: 0 12px 30px rgb(77 117 255 / 25%);
}

.button-primary:hover {
  background: #5b80ff;
}

.button-quiet {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.button-quiet:hover {
  border-color: #494e58;
  background: var(--surface-2);
}

.stats-terminal {
  position: relative;
  overflow: hidden;
  border: 1px solid #373b43;
  border-radius: var(--radius-md);
  background: #0d0e10;
  box-shadow: var(--shadow), 0 0 0 1px rgb(255 255 255 / 2%) inset;
  transform: rotate(1.2deg);
}

.stats-terminal::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  background: repeating-linear-gradient(0deg, rgb(255 255 255 / 1.6%) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}

.terminal-titlebar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid #2d3036;
  background: #181a1e;
}

.terminal-titlebar > span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4b4e55;
}

.terminal-titlebar > span:nth-child(1) { background: #ef6a65; }
.terminal-titlebar > span:nth-child(2) { background: #e9b748; }
.terminal-titlebar > span:nth-child(3) { background: #64c173; }

.terminal-titlebar code {
  margin-left: 8px;
  color: #81858e;
  font-family: var(--mono);
  font-size: 10px;
}

.terminal-body {
  position: relative;
  z-index: 1;
  padding: 26px 24px 24px;
  font-family: var(--mono);
  font-size: 13px;
}

.terminal-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 14px;
  color: #a4a6aa;
}

.terminal-row strong {
  color: var(--orange);
  font-size: 16px;
}

.terminal-rule {
  height: 1px;
  margin: 21px 0 18px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.terminal-body p {
  margin: 0;
  color: #777a80;
  font-size: 11px;
}

.prompt {
  color: var(--blue-soft);
}

.comparison-panel {
  width: var(--content);
  margin: 0 auto 120px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(120deg, rgb(77 117 255 / 8%), transparent 40%),
    var(--surface);
  box-shadow: 0 18px 60px rgb(0 0 0 / 15%);
}

.comparison-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 26px;
}

.comparison-heading h2,
.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.comparison-heading > p {
  max-width: 410px;
  margin: 0;
  color: var(--faint);
  font-size: 13px;
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(240px, 1fr) minmax(260px, 1.15fr);
  gap: 14px;
  align-items: stretch;
}

.field,
.select-field {
  display: grid;
  gap: 8px;
}

.field > span,
.select-field > span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field input,
.field select,
.select-field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-deep);
}

.field select,
.select-field select {
  cursor: pointer;
}

.comparison-output {
  display: flex;
  align-items: center;
  min-height: 78px;
  padding: 16px 20px;
  color: var(--paper);
  border: 1px solid rgb(245 163 59 / 28%);
  border-radius: 10px;
  background: rgb(245 163 59 / 6%);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.3;
}

.comparison-output strong {
  margin: 0 6px;
  color: var(--orange-soft);
  font-family: var(--mono);
  font-size: 28px;
}

.catalog-section,
.roadmap-section {
  width: var(--content);
  margin: 0 auto;
  padding-bottom: 120px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 34px;
}

.section-heading h2 {
  max-width: 760px;
}

.result-summary {
  flex: 0 0 auto;
  margin: 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.7fr) repeat(3, minmax(150px, 0.65fr)) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgb(23 25 29 / 80%);
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field svg {
  position: absolute;
  left: 15px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--faint);
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-field input {
  width: 100%;
  min-height: 50px;
  padding: 0 48px 0 44px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-deep);
}

.search-field input::placeholder {
  color: #666970;
}

.search-field kbd {
  position: absolute;
  right: 14px;
  min-width: 24px;
  padding: 2px 6px;
  color: #767981;
  border: 1px solid #3a3e46;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #202329;
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.reset-button {
  min-height: 50px;
  padding: 0 15px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.reset-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.active-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 25px;
  margin: 0 0 20px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 10px;
}

.filter-chip button {
  display: grid;
  width: 17px;
  height: 17px;
  padding: 0;
  place-items: center;
  color: var(--faint);
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  cursor: pointer;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px 18px;
}

.book-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 34px rgb(0 0 0 / 12%);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.book-card:hover {
  border-color: #444954;
  box-shadow: 0 20px 50px rgb(0 0 0 / 28%);
  transform: translateY(-5px);
}

.book-card:focus-visible {
  outline-offset: 5px;
}

.book-cover {
  --cover-a: #3458cf;
  --cover-b: #16235a;
  position: relative;
  display: grid;
  min-height: 245px;
  padding: 18px;
  align-content: space-between;
  overflow: hidden;
  color: white;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 12%), transparent 38%),
    linear-gradient(145deg, var(--cover-a), var(--cover-b));
  isolation: isolate;
}

.book-card[data-tone="1"] .book-cover { --cover-a: #3c63e5; --cover-b: #17224d; }
.book-card[data-tone="2"] .book-cover { --cover-a: #bf6a38; --cover-b: #4e251b; }
.book-card[data-tone="3"] .book-cover { --cover-a: #7f4442; --cover-b: #33191b; }
.book-card[data-tone="4"] .book-cover { --cover-a: #2e756d; --cover-b: #133a39; }
.book-card[data-tone="5"] .book-cover { --cover-a: #876b2f; --cover-b: #3f3014; }
.book-card[data-tone="6"] .book-cover { --cover-a: #6d4d8a; --cover-b: #2e203b; }
.book-card[data-tone="7"] .book-cover { --cover-a: #496176; --cover-b: #202d39; }
.book-card[data-tone="8"] .book-cover { --cover-a: #9b4a65; --cover-b: #3e1e2c; }

.book-cover::before {
  position: absolute;
  z-index: -1;
  top: -25%;
  right: -25%;
  width: 86%;
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 50%;
  box-shadow:
    0 0 0 24px rgb(255 255 255 / 3%),
    0 0 0 52px rgb(255 255 255 / 2%);
}

.book-cover::after {
  position: absolute;
  z-index: -1;
  right: 12px;
  bottom: 12px;
  width: 54px;
  height: 54px;
  content: attr(data-rank);
  color: rgb(255 255 255 / 12%);
  font-family: var(--serif);
  font-size: 54px;
  font-style: italic;
  line-height: 1;
}

.cover-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.cover-rank {
  color: rgb(255 255 255 / 68%);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.cover-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  color: rgb(255 255 255 / 83%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 999px;
  background: rgb(0 0 0 / 13%);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
}

.cover-title {
  max-width: 92%;
  margin: 42px 0 8px;
  font-family: var(--serif);
  font-size: clamp(24px, 2.2vw, 33px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.cover-author {
  margin: 0;
  color: rgb(255 255 255 / 67%);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.book-meta {
  display: grid;
  align-content: start;
  padding: 17px 17px 15px;
}

.book-english-title {
  min-height: 36px;
  margin: 0;
  color: var(--paper-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.book-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  margin-top: 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

.book-facts span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.book-facts span::before {
  width: 4px;
  height: 4px;
  content: "";
  border-radius: 50%;
  background: #5f636b;
}

.token-meter {
  height: 3px;
  margin: 16px 0 11px;
  overflow: hidden;
  border-radius: 2px;
  background: #292d33;
}

.token-meter span {
  display: block;
  width: var(--token-width);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--orange));
}

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.source-icons {
  display: flex;
  gap: 5px;
}

.source-icon {
  display: grid;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
}

.open-label {
  color: var(--blue-soft);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
}

.empty-state {
  padding: 70px 20px;
  color: var(--faint);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  text-align: center;
}

.empty-state > span {
  display: block;
  color: #4a4d54;
  font-family: var(--mono);
  font-size: 42px;
}

.empty-state h3 {
  margin: 10px 0 4px;
  color: var(--text);
}

.empty-state p {
  margin: 0;
}

.registry-section {
  width: var(--content);
  margin: 0 auto;
  padding: 0 0 120px;
}

.registry-intro {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.registry-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line);
}

.registry-metrics article {
  min-height: 164px;
  padding: 22px;
  background:
    linear-gradient(145deg, rgb(77 117 255 / 7%), transparent 58%),
    var(--surface);
}

.registry-metrics span,
.registry-metrics small {
  display: block;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

.registry-metrics span {
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.registry-metrics strong {
  display: block;
  margin: 15px 0 10px;
  color: var(--orange-soft);
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 500;
  line-height: 1;
}

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

.registry-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgb(23 25 29 / 82%);
}

.registry-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.registry-panel-heading h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
}

.registry-panel-heading span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.registry-rows {
  display: grid;
}

.registry-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 59px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
}

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

.registry-row-index {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

.registry-row-copy {
  min-width: 0;
}

.registry-row-copy strong,
.registry-row-copy small {
  display: block;
}

.registry-row-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-row-copy small {
  margin-top: 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
}

.registry-row-count {
  color: var(--blue-soft);
  font-family: var(--mono);
  font-size: 14px;
}

.registry-policy {
  margin: 18px 0 0;
  padding: 13px 16px;
  color: var(--muted);
  border: 1px solid rgb(245 163 59 / 24%);
  border-radius: 9px;
  background: rgb(245 163 59 / 5%);
  font-family: var(--mono);
  font-size: 10px;
}

.registry-policy > span:first-child {
  margin-right: 7px;
  color: var(--orange-soft);
}

.rights-section {
  margin: 0;
  padding: 104px max(20px, calc((100vw - 1180px) / 2));
  color: var(--ink);
  background:
    linear-gradient(90deg, rgb(255 255 255 / 26%) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(rgb(255 255 255 / 22%) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--paper);
}

.section-heading-light .section-kicker {
  color: #8a5a20;
}

.section-heading-light h2 {
  max-width: 970px;
}

.principles-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 48px;
  border: 1px solid rgb(23 21 20 / 18%);
  background: rgb(23 21 20 / 18%);
}

.principles-grid article {
  min-height: 270px;
  padding: 28px;
  background: rgb(241 230 212 / 95%);
}

.principle-number {
  display: block;
  margin-bottom: 56px;
  color: #9a8468;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.principles-grid h3 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
}

.principles-grid p {
  margin: 0;
  color: #5f574f;
  font-size: 13px;
  line-height: 1.75;
}

.rights-legend {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.rights-legend > div {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: center;
  padding: 15px 18px;
  border: 1px solid rgb(23 21 20 / 16%);
  border-radius: 10px;
  background: rgb(255 255 255 / 28%);
}

.rights-legend strong {
  font-size: 12px;
}

.rights-legend small {
  grid-column: 2;
  color: #736b62;
  font-size: 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.status-pd { background: #318653; }
.status-review { background: #b47722; }
.status-protected { background: #86545a; }

.roadmap-section {
  padding-top: 116px;
}

.roadmap-list {
  margin: 46px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.roadmap-list li {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: start;
  gap: 22px;
  padding: 28px 6px;
  border-bottom: 1px solid var(--line);
}

.roadmap-list > li > span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
}

.roadmap-list strong {
  display: block;
  margin-bottom: 5px;
  font-family: var(--serif);
  font-size: 22px;
}

.roadmap-list p {
  max-width: 740px;
  margin: 0;
  color: var(--faint);
  font-size: 13px;
}

.roadmap-list small {
  padding: 4px 8px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
}

.roadmap-list li.is-current {
  background: linear-gradient(90deg, rgb(77 117 255 / 10%), transparent 55%);
}

.roadmap-list li.is-current > span,
.roadmap-list li.is-current small {
  color: var(--blue-soft);
}

.roadmap-list li.is-complete > span,
.roadmap-list li.is-complete small {
  color: var(--green);
}

.footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  width: var(--content);
  margin: 0 auto;
  padding: 42px 0 52px;
  border-top: 1px solid var(--line);
}

.footer strong {
  font-family: var(--serif);
  font-size: 20px;
}

.footer p {
  max-width: 600px;
  margin: 7px 0 0;
  color: var(--faint);
  font-size: 11px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 18px;
}

.footer-links a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-underline-offset: 4px;
}

.book-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  padding: 0;
  overflow: hidden auto;
  color: var(--text);
  border: 1px solid #454a54;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 40px 110px rgb(0 0 0 / 60%);
}

.book-dialog::backdrop {
  background: rgb(3 4 5 / 76%);
  backdrop-filter: blur(10px);
}

.dialog-close-form {
  position: sticky;
  z-index: 3;
  top: 0;
  height: 0;
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgb(16 17 19 / 90%);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.dialog-hero {
  --cover-a: #3458cf;
  --cover-b: #16235a;
  position: relative;
  min-height: 270px;
  padding: 42px clamp(24px, 6vw, 64px) 34px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgb(255 255 255 / 9%), transparent 45%),
    linear-gradient(145deg, var(--cover-a), var(--cover-b));
}

.dialog-hero[data-tone="1"] { --cover-a: #3c63e5; --cover-b: #17224d; }
.dialog-hero[data-tone="2"] { --cover-a: #bf6a38; --cover-b: #4e251b; }
.dialog-hero[data-tone="3"] { --cover-a: #7f4442; --cover-b: #33191b; }
.dialog-hero[data-tone="4"] { --cover-a: #2e756d; --cover-b: #133a39; }
.dialog-hero[data-tone="5"] { --cover-a: #876b2f; --cover-b: #3f3014; }
.dialog-hero[data-tone="6"] { --cover-a: #6d4d8a; --cover-b: #2e203b; }
.dialog-hero[data-tone="7"] { --cover-a: #496176; --cover-b: #202d39; }
.dialog-hero[data-tone="8"] { --cover-a: #9b4a65; --cover-b: #3e1e2c; }

.dialog-hero::after {
  position: absolute;
  right: 7%;
  bottom: -45%;
  width: 330px;
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgb(255 255 255 / 15%);
  border-radius: 50%;
  box-shadow: 0 0 0 40px rgb(255 255 255 / 3%), 0 0 0 92px rgb(255 255 255 / 2%);
}

.dialog-rank {
  position: relative;
  z-index: 1;
  color: rgb(255 255 255 / 68%);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.dialog-hero h2 {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 38px 0 10px;
  font-family: var(--serif);
  font-size: clamp(38px, 7vw, 68px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.dialog-hero p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: rgb(255 255 255 / 70%);
  font-family: var(--mono);
  font-size: 11px;
}

.dialog-body {
  display: grid;
  gap: 32px;
  padding: 34px clamp(24px, 6vw, 64px) 50px;
}

.dialog-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.dialog-fact {
  min-width: 0;
  padding: 14px;
  background: var(--surface-2);
}

.dialog-fact small {
  display: block;
  margin-bottom: 7px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dialog-fact strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.dialog-section h3 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 23px;
}

.title-variants {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.title-variant {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}

.title-variant small {
  display: block;
  margin-bottom: 5px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  text-transform: uppercase;
}

.title-variant strong {
  display: block;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rights-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 16px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-deep);
  font-size: 12px;
}

.rights-note .status-dot {
  margin-top: 5px;
}

.source-list {
  display: grid;
  gap: 9px;
}

.edition-list {
  display: grid;
  gap: 11px;
}

.edition-record {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}

.edition-record.is-discovery {
  border-style: dashed;
}

.edition-record-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 14px;
}

.edition-record-title {
  min-width: 0;
}

.edition-record-title a {
  display: inline;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration-color: rgb(137 164 255 / 45%);
  text-underline-offset: 3px;
}

.edition-record-title a:hover {
  color: var(--blue-soft);
}

.edition-record-title small {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-size: 9px;
}

.edition-metadata {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-deep);
}

.edition-metadata > div {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line-soft);
}

.edition-metadata > div:last-child {
  border-right: 0;
}

.edition-metadata dt {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.edition-metadata dd {
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edition-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 11px 14px 0;
}

.edition-formats span {
  padding: 3px 6px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 7px;
  text-transform: uppercase;
}

.edition-review {
  padding: 10px 14px 13px;
  color: var(--faint);
  font-size: 10px;
}

.edition-review summary {
  color: var(--blue-soft);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.edition-review p {
  margin: 9px 0 0;
}

.edition-rights-statement {
  padding-left: 10px;
  border-left: 2px solid var(--orange);
}

.source-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 13px;
  align-items: center;
  padding: 13px;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

.source-link:hover {
  border-color: #4a505b;
  transform: translateX(3px);
}

.source-media {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  color: var(--blue-soft);
  border-radius: 8px;
  background: var(--surface-3);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.source-copy {
  min-width: 0;
}

.source-copy strong {
  display: block;
  font-size: 12px;
}

.source-copy small {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-arrow {
  color: var(--blue-soft);
}

.discovery-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.discovery-list a {
  padding: 7px 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 10px;
  text-decoration: none;
}

.discovery-list a:hover {
  color: var(--text);
  border-color: #4a505b;
}

.no-sources {
  padding: 18px;
  color: var(--faint);
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 12px;
}

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

.copy-link {
  min-height: 40px;
  padding: 8px 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.copy-link:hover {
  color: var(--text);
}

.toast {
  position: fixed;
  z-index: 1100;
  right: 22px;
  bottom: 22px;
  padding: 11px 15px;
  color: var(--ink);
  border-radius: 9px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
}

.noscript {
  position: fixed;
  z-index: 1000;
  right: 12px;
  bottom: 12px;
  left: 12px;
  padding: 16px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 10px;
  text-align: center;
}

.skeleton-card {
  min-height: 390px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background:
    linear-gradient(90deg, transparent, rgb(255 255 255 / 4%), transparent) 0 0 / 240px 100% no-repeat,
    var(--surface);
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  to { background-position: calc(100% + 240px) 0; }
}

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

@media (max-width: 1080px) {
  .filters {
    grid-template-columns: minmax(260px, 1.5fr) repeat(2, minmax(150px, 0.7fr));
  }

  .filters .select-field:nth-of-type(4) {
    grid-column: 1 / 2;
  }

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

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

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

@media (max-width: 860px) {
  :root {
    --content: min(100% - 28px, 720px);
  }

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

  .topnav {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 70px 0 86px;
  }

  .stats-terminal {
    max-width: 540px;
    transform: none;
  }

  .comparison-heading,
  .section-heading {
    align-items: start;
    flex-direction: column;
  }

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

  .comparison-output {
    grid-column: 1 / -1;
  }

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

  .search-field {
    grid-column: 1 / -1;
  }

  .filters .select-field:nth-of-type(4) {
    grid-column: auto;
  }

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

  .rights-legend {
    grid-template-columns: 1fr;
  }

  .registry-ledger {
    grid-template-columns: 1fr;
  }

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

  .footer-links {
    justify-content: start;
  }
}

@media (max-width: 580px) {
  :root {
    --content: calc(100% - 24px);
  }

  .topbar {
    min-height: 68px;
  }

  .brand-copy small {
    display: none;
  }

  .locale-switch button {
    min-width: 34px;
  }

  .hero {
    padding-top: 54px;
  }

  .hero h1 {
    font-size: clamp(43px, 14vw, 66px);
  }

  .hero-actions {
    display: grid;
  }

  .comparison-panel {
    margin-bottom: 90px;
    padding: 23px;
  }

  .calculator-grid,
  .filters,
  .book-grid,
  .principles-grid,
  .registry-metrics,
  .dialog-facts,
  .title-variants {
    grid-template-columns: 1fr;
  }

  .filters .select-field:nth-of-type(4),
  .search-field,
  .comparison-output {
    grid-column: auto;
  }

  .book-cover {
    min-height: 300px;
  }

  .cover-title {
    font-size: 38px;
  }

  .rights-section {
    padding-top: 78px;
    padding-bottom: 78px;
  }

  .principles-grid article {
    min-height: auto;
  }

  .principle-number {
    margin-bottom: 30px;
  }

  .roadmap-list li {
    grid-template-columns: 42px 1fr;
  }

  .roadmap-list small {
    display: none;
  }

  .source-link {
    grid-template-columns: auto 1fr;
  }

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

  .edition-metadata > div:nth-child(2) {
    border-right: 0;
  }

  .edition-metadata > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line-soft);
  }

  .source-arrow {
    display: none;
  }
}

@media print {
  .topbar,
  .hero-actions,
  .comparison-panel,
  .reader-section,
  .filters,
  .rights-section,
  .roadmap-section,
  .footer,
  .dialog-close-form {
    display: none !important;
  }

  body {
    color: #111;
    background: white;
  }

  .hero {
    min-height: auto;
    padding: 20px 0;
  }

  .stats-terminal {
    color: #111;
    border: 1px solid #bbb;
    background: white;
    box-shadow: none;
  }

  .book-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .book-card {
    break-inside: avoid;
    border-color: #bbb;
    box-shadow: none;
  }
}

.book-card[type="button"] {
  width: 100%;
  padding: 0;
  appearance: none;
  font: inherit;
  text-align: left;
}

.book-card > span,
.book-cover > span,
.book-meta > span {
  display: block;
}

.cover-topline,
.source-row,
.source-icons,
.book-facts span,
.cover-status {
  display: flex;
}

.doc-page {
  width: min(820px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 64px 0 100px;
}

.doc-back {
  display: inline-block;
  margin-bottom: 54px;
  color: var(--blue-soft);
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
}

.doc-page h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(46px, 8vw, 76px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.doc-lede {
  margin: 30px 0 66px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.85;
}

.doc-page section {
  padding: 34px 0;
  border-top: 1px solid var(--line);
}

.doc-page h2 {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 29px;
}

.doc-page p,
.doc-page li,
.doc-page dd {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.doc-page code {
  padding: 2px 5px;
  color: var(--orange-soft);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
}

.doc-definition-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.doc-definition-list > div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.doc-definition-list dt {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.doc-definition-list dd {
  margin: 0;
}

.doc-disclaimer {
  margin-top: 48px;
  padding: 18px;
  border: 1px solid rgb(245 163 59 / 30%);
  border-radius: 10px;
  background: rgb(245 163 59 / 6%);
}

@media (max-width: 580px) {
  .doc-definition-list > div {
    grid-template-columns: 1fr;
  }
}

.doc-body {
  background:
    radial-gradient(circle at 20% -10%, rgb(77 117 255 / 14%), transparent 35rem),
    var(--bg);
}

.doc-page {
  width: min(820px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 72px 0 110px;
}

.doc-back {
  display: inline-flex;
  margin-bottom: 70px;
  color: var(--blue-soft);
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
}

.doc-page h1 {
  max-width: 720px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(48px, 9vw, 82px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.doc-lede {
  margin: 32px 0 70px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.doc-page section {
  padding: 30px 0;
  border-top: 1px solid var(--line);
}

.doc-page h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
}

.doc-page section p,
.doc-page dd {
  color: var(--muted);
  line-height: 1.8;
}

.doc-page dl {
  display: grid;
  gap: 10px;
  margin: 20px 0 0;
}

.doc-page dl > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.doc-page dt,
.doc-page dd {
  margin: 0;
}

.doc-page code {
  color: var(--orange-soft);
  font-family: var(--mono);
}

.doc-end {
  margin-top: 50px;
  color: var(--faint);
  font-size: 12px;
}

@media (max-width: 580px) {
  .doc-page {
    padding-top: 42px;
  }

  .doc-back {
    margin-bottom: 48px;
  }

  .doc-page dl > div {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

/* Parallel reader */

.reader-section {
  width: var(--content);
  margin: 0 auto;
  padding: 118px 0 104px;
}

.reader-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.6fr);
  gap: clamp(30px, 7vw, 96px);
  align-items: end;
}

.reader-heading h2 {
  max-width: 850px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(42px, 6.2vw, 78px);
  font-weight: 580;
  line-height: 0.98;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.reader-heading > p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.reader-assurances {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 48px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--surface);
}

.reader-assurances > span {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 15px 18px;
  border-right: 1px solid var(--line);
}

.reader-assurances > span:last-child {
  border-right: 0;
}

.reader-assurances strong {
  color: var(--green);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.reader-assurances small {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg-deep);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.reader-workbench {
  min-width: 0;
  padding: 22px;
}

.reader-work-switch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding-bottom: 20px;
}

.reader-work-switch > span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-work-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.reader-work-tabs button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.reader-work-tabs button:hover {
  border-color: var(--faint);
  background: var(--surface-2);
}

.reader-work-tabs button[aria-selected="true"] {
  color: var(--ink);
  border-color: var(--orange-soft);
  background: var(--paper);
}

.reader-work-tabs button span {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-work-tabs button small {
  flex: 0 0 auto;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.02em;
}

.reader-work-tabs button[aria-selected="true"] small {
  color: #5f594f;
}

.reader-work-context {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  padding: 24px 2px 18px;
  border-top: 1px solid var(--line-soft);
}

.reader-context-label {
  margin: 0 0 8px;
  color: var(--blue-soft);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-work-context h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.reader-work-context > div > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.reader-work-context > code {
  flex: 0 0 auto;
  padding: 7px 9px;
  color: var(--orange-soft);
  border: 1px solid rgb(245 163 59 / 20%);
  border-radius: 6px;
  background: rgb(245 163 59 / 6%);
  font-family: var(--mono);
  font-size: 9px;
}

.reader-toolbar {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto 120px auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.reader-toolbar button,
.reader-alignment-tools button,
.reader-file-meta button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
}

.reader-toolbar button {
  min-height: 40px;
  padding: 8px 11px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.reader-toolbar button:hover:not(:disabled),
.reader-alignment-tools button:hover:not(:disabled),
.reader-file-meta button:hover {
  color: var(--text);
  border-color: var(--blue-soft);
}

.reader-toolbar button:disabled,
.reader-alignment-tools button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.reader-position-control,
.reader-font-control {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.reader-position-control > span:first-child,
.reader-font-control > span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.reader-position-control > span:last-child {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.reader-position-control output {
  min-width: 52px;
  color: var(--paper-muted);
  font-family: var(--mono);
  font-size: 9px;
  text-align: right;
}

.reader-toolbar input[type="range"] {
  width: 100%;
  accent-color: var(--orange);
}

.reader-lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.reader-lane,
.reader-lane-skeleton {
  min-width: 0;
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  overflow: hidden;
}

.reader-lane:nth-child(1) {
  --lane-accent: var(--blue-soft);
}

.reader-lane:nth-child(2) {
  --lane-accent: var(--orange-soft);
}

.reader-lane:nth-child(3) {
  --lane-accent: var(--green);
}

.reader-lane-skeleton {
  background: linear-gradient(110deg, var(--surface) 25%, var(--surface-2) 42%, var(--surface) 58%);
  background-size: 250% 100%;
  animation: reader-skeleton 1.4s linear infinite;
}

@keyframes reader-skeleton {
  to { background-position-x: -250%; }
}

.reader-lane-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 11px 12px;
  border-top: 3px solid var(--lane-accent);
  border-bottom: 1px solid var(--line-soft);
}

.reader-language-code {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--lane-accent);
  border: 1px solid color-mix(in srgb, var(--lane-accent), transparent 55%);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
}

.reader-lane-header > span:last-child {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}

.reader-lane-header strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-lane-header small {
  margin-top: 4px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.reader-lane-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.reader-lane-tools > label:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.reader-lane-tools > label:first-child span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  text-transform: uppercase;
}

.reader-lane-tools select {
  min-width: 0;
  height: 31px;
  padding: 4px 7px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-deep);
  font-family: var(--mono);
  font-size: 8px;
}

.reader-file-button {
  align-self: end;
  padding: 7px 9px;
  color: var(--ink);
  border: 1px solid var(--lane-accent);
  border-radius: 6px;
  background: var(--lane-accent);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
}

.reader-file-button:hover {
  filter: brightness(1.08);
}

.reader-file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.reader-lane-empty {
  display: grid;
  place-content: center;
  min-height: 312px;
  padding: 38px 22px;
  text-align: center;
}

.reader-lane-empty > span {
  color: var(--lane-accent);
  font-family: var(--mono);
  font-size: 34px;
}

.reader-lane-empty strong {
  margin-top: 9px;
  font-family: var(--serif);
  font-size: 18px;
}

.reader-lane-empty p {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.75;
}

.reader-file-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.reader-file-meta > span {
  display: grid;
  min-width: 0;
}

.reader-file-meta strong {
  overflow: hidden;
  color: var(--paper-muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-file-meta small,
.reader-file-meta p,
.reader-file-meta code {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
}

.reader-file-meta p {
  grid-column: 1 / -1;
  margin: 0;
}

.reader-file-meta code {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-file-meta button {
  align-self: start;
  padding: 4px 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
}

.reader-segment {
  min-height: 280px;
  max-height: 520px;
  padding: 16px 15px 20px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgb(23 21 20 / 5%) 1px, transparent 1px) 30px 0 / 30px 100%,
    var(--paper);
  overflow: auto;
  scrollbar-color: #a79985 transparent;
}

.reader-segment small {
  color: #817767;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.03em;
}

.reader-segment p {
  margin: 17px 0 0;
  font-family: var(--serif);
  font-size: var(--reader-font-size, 20px);
  line-height: 1.75;
  text-wrap: pretty;
}

.reader-segment-gap {
  color: #746c60;
  font-family: var(--sans) !important;
  font-size: 12px !important;
  font-style: italic;
}

.reader-alignment-tools {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 6px;
  padding: 8px;
}

.reader-alignment-tools button {
  height: 30px;
  color: var(--lane-accent);
  font-family: var(--mono);
  font-size: 17px;
}

.reader-alignment-tools output {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  text-align: center;
}

.reader-alignment-note {
  display: flex;
  gap: 9px;
  margin: 12px 3px 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
}

.reader-alignment-note > span:first-child {
  color: var(--orange-soft);
}

.reader-rights-console {
  min-width: 0;
  padding: 24px 18px;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(rgb(255 255 255 / 1%) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--surface);
}

.reader-rights-heading h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.reader-rights-heading > p:last-child {
  margin: 12px 0 21px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.reader-rights-matrix {
  display: grid;
  gap: 8px;
}

.reader-rights-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  border-radius: 8px;
  background: rgb(11 12 14 / 78%);
}

.reader-rights-card.is-blocked {
  border-left-color: var(--red);
}

.reader-rights-card header {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: start;
  gap: 8px;
}

.reader-rights-card header strong {
  color: var(--paper);
  font-family: var(--mono);
  font-size: 10px;
}

.reader-rights-card header span {
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 7px;
  line-height: 1.45;
  text-transform: uppercase;
}

.reader-rights-card.is-blocked header span {
  color: var(--red);
}

.reader-rights-card p {
  margin: 9px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

.reader-rights-card > div {
  display: grid;
  gap: 3px;
}

.reader-rights-card a {
  color: var(--blue-soft);
  font-family: var(--mono);
  font-size: 7px;
  text-decoration: none;
}

.reader-rights-card a:hover {
  text-decoration: underline;
}

.reader-status {
  position: sticky;
  z-index: 5;
  bottom: 18px;
  width: fit-content;
  max-width: min(620px, calc(100vw - 40px));
  margin: 18px auto 0;
  padding: 10px 14px;
  color: var(--ink);
  border-radius: 8px;
  background: var(--orange-soft);
  box-shadow: 0 12px 35px rgb(0 0 0 / 35%);
  font-family: var(--mono);
  font-size: 9px;
}

.reader-section.is-loading .reader-workbench {
  opacity: 0.72;
}

.reader-section.has-error .reader-layout {
  border-color: rgb(239 125 125 / 55%);
}

@media (max-width: 1100px) {
  .topnav {
    gap: 18px;
  }

  .reader-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .reader-toolbar {
    grid-template-columns: auto minmax(160px, 1fr) auto;
  }

  .reader-font-control,
  .reader-toolbar > button:last-child {
    grid-column: span 1;
  }
}

@media (max-width: 900px) {
  .reader-heading {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .reader-heading > p {
    max-width: 650px;
  }

  .reader-layout {
    grid-template-columns: 1fr;
  }

  .reader-rights-console {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

@media (max-width: 760px) {
  .reader-assurances {
    grid-template-columns: 1fr;
  }

  .reader-assurances > span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .reader-assurances > span:last-child {
    border-bottom: 0;
  }

  .reader-work-switch {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .reader-toolbar {
    grid-template-columns: auto 1fr auto;
  }

  .reader-toolbar .reader-font-control {
    grid-column: 1 / 3;
  }

  .reader-toolbar > button:last-child {
    grid-column: 3;
  }

  .reader-lanes {
    grid-template-columns: 1fr;
  }

  .reader-lane,
  .reader-lane-skeleton {
    min-height: 400px;
  }
}

@media (max-width: 580px) {
  .reader-section {
    width: min(100% - 24px, 1180px);
    padding: 82px 0 72px;
  }

  .reader-heading h2 {
    font-size: clamp(40px, 14vw, 61px);
  }

  .reader-workbench {
    padding: 12px;
  }

  .reader-work-tabs {
    grid-template-columns: 1fr;
  }

  .reader-work-context {
    align-items: start;
    flex-direction: column;
    gap: 14px;
  }

  .reader-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .reader-toolbar .reader-position-control {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .reader-toolbar #reader-previous,
  .reader-toolbar #reader-next {
    grid-row: 2;
  }

  .reader-toolbar .reader-font-control {
    grid-column: 1 / -1;
  }

  .reader-toolbar > button:last-child {
    grid-column: 1 / -1;
  }

  .reader-rights-matrix {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-lane-skeleton {
    animation: none;
  }
}
