:root {
  color-scheme: light;
  --switcher-height: 50px;
  --ink: #181817;
  --soft-ink: #464941;
  --muted: #72786e;
  --paper: #f6f3eb;
  --panel: #fffdf8;
  --line: #ded8ca;
  --green: #2f6b4f;
  --green-dark: #204934;
  --red: #a5483d;
  --blue: #315d85;
  --gold: #d5a233;
  --shadow: 0 18px 45px rgba(50, 45, 35, 0.12);
}

:root[data-scheme="forest"] {
  --ink: #102119;
  --soft-ink: #304a3d;
  --muted: #66786d;
  --paper: #eef4ec;
  --panel: #fbfff9;
  --line: #c9d8c8;
  --green: #28724d;
  --green-dark: #155238;
  --red: #9d4f42;
  --blue: #2e6471;
  --gold: #b7982f;
}

:root[data-scheme="ink"] {
  color-scheme: dark;
  --ink: #f8f3e8;
  --soft-ink: #d8ceb9;
  --muted: #b3a78f;
  --paper: #12100c;
  --panel: #252116;
  --line: #5a4d37;
  --green: #97c985;
  --green-dark: #d4efc4;
  --red: #f09b87;
  --blue: #a8d1e8;
  --gold: #f0c95e;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

:root[data-scheme="ink"] .brand-mark,
:root[data-scheme="ink"] .avatar,
:root[data-scheme="ink"] .primary-action,
:root[data-scheme="ink"] menu button:last-child {
  color: #10140e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(222, 216, 202, 0.36) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--green-dark);
  text-decoration: none;
}

a:hover {
  color: var(--red);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.prototype-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  min-height: var(--switcher-height);
  padding: 8px clamp(14px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(18px);
  overflow-x: auto;
}

.prototype-title {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.prototype-links,
.prototype-themes {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.prototype-divider {
  color: var(--muted);
  font-weight: 950;
}

.prototype-bar a,
.prototype-themes button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  padding: 7px 10px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 950;
  white-space: nowrap;
}

.prototype-bar a.is-active,
.prototype-themes button.is-active {
  border-color: var(--green-dark);
  background: var(--ink);
  color: var(--paper);
}

.shell {
  min-height: 100vh;
}

.masthead {
  position: sticky;
  top: var(--switcher-height);
  z-index: 10;
  display: grid;
  grid-template-columns: max-content minmax(180px, 620px) max-content;
  gap: 18px;
  align-items: center;
  padding: 14px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(16px);
}

.brand,
.person-strip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.brand span:last-child,
.person-strip span:last-child {
  display: grid;
}

.brand small,
.person-strip small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #17382a;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.search-box {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  text-transform: none;
}

.primary-action,
menu button:last-child {
  border: 1px solid var(--green-dark);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  padding: 10px 14px;
  font-weight: 900;
}

.layout {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 34px);
  align-items: start;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 34px);
}

.rail {
  position: sticky;
  top: calc(var(--switcher-height) + 84px);
  align-self: start;
  display: grid;
  gap: 22px;
}

.rail-nav,
.filters,
.stats-panel,
.line-card,
.reader-card,
.empty-state,
.article-page,
.profile-detail,
.book-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.rail-nav {
  display: grid;
  padding: 8px;
}

.rail-nav a {
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--soft-ink);
  font-weight: 900;
}

.rail-nav a.is-active {
  background: var(--ink);
  color: var(--paper);
}

.filters {
  display: grid;
  gap: 22px;
  padding: 14px;
}

.label,
.eyebrow,
.context-line,
.byline {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.control-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  margin-top: 10px;
}

.chip-list button {
  width: 100%;
}

.control-grid button,
.chip-list button,
menu button,
.back-link {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 7px 10px;
  font-weight: 850;
}

.control-grid button.is-active,
.chip-list button.is-active {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 22%, var(--panel));
  color: var(--ink);
}

.main,
.home-view,
.route-view {
  display: grid;
  gap: 28px;
  align-content: start;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 380px);
  gap: 22px;
  align-items: end;
  padding-top: clamp(8px, 2vw, 26px);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 880px;
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 5.6vw, 6.2rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.hero-copy {
  max-width: 620px;
  color: var(--soft-ink);
  font-size: 1.1rem;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  box-shadow: var(--shadow);
}

.stats-panel div {
  display: grid;
  gap: 3px;
  background: var(--panel);
  padding: 16px;
}

.stats-panel strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
}

.stats-panel span,
.mini-meta,
.card-footer {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 285px);
  gap: 14px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scroll-snap-type: x proximity;
}

.book-tile {
  scroll-snap-align: start;
  display: grid;
  grid-template-rows: 250px minmax(170px, auto);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.cover-link,
.book-detail > img {
  background: #d8d2c5;
}

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

.book-tile > div {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
}

.score {
  justify-self: start;
  margin-bottom: 2px;
  border-radius: 8px;
  background: var(--gold);
  color: #2a210c;
  padding: 3px 8px;
  font-weight: 950;
}

.mini-meta,
.card-footer,
.stat-strip,
.tag-row,
.section-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 12px;
}

.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
}

.stack,
.index-list,
.essay-grid {
  display: grid;
  gap: 12px;
}

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

.line-card,
.reader-card,
.empty-state {
  padding: 16px;
}

.line-card {
  display: grid;
  gap: 9px;
}

.line-card p:last-child,
.reader-card p:last-child {
  margin-bottom: 0;
}

.line-card:hover,
.reader-card:hover,
.book-tile:hover {
  border-color: #b7a36b;
}

.profile-link {
  color: var(--red);
  font-weight: 900;
}

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

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

.reader-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
}

.route-heading {
  max-width: 880px;
}

.route-heading p:last-child {
  max-width: 680px;
  color: var(--soft-ink);
  font-size: 1.08rem;
}

.back-link {
  justify-self: start;
  color: var(--ink);
}

.book-detail {
  display: grid;
  grid-template-columns: minmax(210px, 340px) minmax(0, 1fr);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.book-detail > img {
  min-height: 420px;
}

.book-detail > div,
.article-page,
.profile-detail {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: clamp(20px, 4vw, 44px);
}

.article-page {
  max-width: 940px;
  box-shadow: var(--shadow);
}

.reading-page p:not(.context-line):not(.lede) {
  max-width: 720px;
  font-size: 1.05rem;
}

.lede {
  max-width: 760px;
  color: var(--soft-ink);
  font-size: 1.2rem;
  font-weight: 720;
}

.stat-strip span {
  border-left: 4px solid var(--gold);
  padding-left: 8px;
  color: var(--green-dark);
  font-weight: 900;
}

.tag-row span {
  border: 1px solid #cfc3ad;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--soft-ink);
  font-size: 0.84rem;
  font-weight: 800;
}

.profile-detail {
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: start;
  box-shadow: var(--shadow);
}

.large-avatar {
  width: 86px;
  height: 86px;
  font-size: 1.5rem;
}

.route-section {
  margin-top: 0;
}

.empty-state {
  color: var(--muted);
  font-weight: 850;
}

dialog {
  width: min(560px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(24, 24, 23, 0.38);
}

.dialog-panel {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.dialog-header button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

menu {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

@media (max-width: 960px) {
  .masthead,
  .layout,
  .hero-grid,
  .desk-grid,
  .book-detail {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
  }

  .rail-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .rail-nav a {
    text-align: center;
  }

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

  .reader-grid,
  .reader-grid.wide,
  .essay-grid {
    grid-template-columns: 1fr;
  }

  .book-detail > img {
    max-height: 360px;
  }
}

@media (max-width: 620px) {
  .masthead {
    gap: 12px;
  }

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

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

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

  .hero-grid {
    padding-top: 0;
  }

  .stats-panel {
    grid-template-columns: 1fr;
  }

  .shelf {
    grid-auto-columns: minmax(220px, 82vw);
  }

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