:root {
  color-scheme: dark;
  --switcher-height: 50px;
  --ink: #f4fff9;
  --text: #c2ded4;
  --muted: #7f9c92;
  --paper: #06100f;
  --panel: rgba(10, 31, 29, 0.86);
  --panel-strong: #0d211f;
  --line: rgba(111, 255, 214, 0.2);
  --hot: #ff5f8f;
  --cyan: #55f0cf;
  --acid: #f7d154;
  --amber: #7dd3fc;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.38);
}

:root[data-scheme="mono"] {
  --ink: #f7fbff;
  --text: #d5e3ed;
  --muted: #8fa1ad;
  --paper: #090c10;
  --panel: rgba(20, 25, 31, 0.9);
  --panel-strong: #121821;
  --line: rgba(214, 231, 242, 0.18);
  --hot: #dbe7ef;
  --cyan: #9db2c1;
  --acid: #f2c66d;
  --amber: #d99380;
}

:root[data-scheme="paper"] {
  color-scheme: light;
  --ink: #161914;
  --text: #394039;
  --muted: #6f776d;
  --paper: #f6f1e5;
  --panel: rgba(255, 252, 244, 0.9);
  --panel-strong: #fffaf0;
  --line: rgba(67, 76, 65, 0.18);
  --hot: #b3485d;
  --cyan: #216b78;
  --acid: #586f1f;
  --amber: #b86d2f;
  --shadow: 0 20px 54px rgba(63, 54, 39, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(85, 240, 207, 0.1) 1px, transparent 1px),
    linear-gradient(0deg, rgba(85, 240, 207, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 84% 8%, rgba(247, 209, 84, 0.2), transparent 28rem),
    var(--paper);
  background-size: 44px 44px, 44px 44px, auto, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

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

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) 88%, 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(--text);
  font-size: 0.82rem;
  font-weight: 950;
  white-space: nowrap;
}

.prototype-bar a.is-active,
.prototype-themes button.is-active {
  border-color: var(--cyan);
  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, 680px) max-content;
  gap: 18px;
  align-items: center;
  padding: 16px clamp(14px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(18px);
}

.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,
.label,
.eyebrow,
.context-line,
.byline {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--acid));
  color: #06100f;
  font-weight: 950;
  box-shadow: 0 0 28px rgba(52, 215, 255, 0.24);
}

.search-box {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 9px 13px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  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 rgba(185, 255, 73, 0.58);
  border-radius: 8px;
  background: var(--acid);
  color: #090b10;
  padding: 10px 14px;
  font-weight: 950;
  box-shadow: 0 0 24px rgba(185, 255, 73, 0.2);
}

.layout {
  display: grid;
  grid-template-columns: minmax(170px, 210px) minmax(0, 1fr);
  gap: clamp(14px, 2.6vw, 30px);
  align-items: start;
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 38px);
}

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

.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);
  box-shadow: var(--shadow);
}

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

.rail-nav a {
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  font-weight: 950;
}

.rail-nav a.is-active {
  background: var(--cyan);
  color: #06100f;
}

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

.label,
.eyebrow,
.context-line,
.byline {
  margin: 0;
}

.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: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  padding: 7px 10px;
  font-weight: 900;
}

.control-grid button.is-active,
.chip-list button.is-active {
  border-color: var(--cyan);
  background: rgba(85, 240, 207, 0.16);
  color: var(--ink);
}

.theme-options button.is-active {
  border-color: var(--cyan);
  background: rgba(52, 215, 255, 0.18);
}

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

[hidden] {
  display: none !important;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 410px);
  gap: 24px;
  align-items: end;
  min-height: clamp(300px, 40vh, 480px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(85, 240, 207, 0.1), transparent 42%), var(--panel);
  padding: clamp(18px, 4vw, 42px);
  box-shadow: var(--shadow);
}

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

h1 {
  max-width: 930px;
  margin-bottom: 14px;
  color: var(--ink);
  font-size: clamp(2.9rem, 7vw, 7.4rem);
  font-weight: 950;
  line-height: 0.82;
  letter-spacing: 0;
  text-transform: none;
}

h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 1.06rem;
}

h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1rem;
}

.hero-copy {
  max-width: 680px;
  color: var(--text);
  font-size: 1.12rem;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.stats-panel div {
  display: grid;
  gap: 4px;
  min-height: 124px;
  border: 1px solid var(--line);
  padding: 18px;
}

.stats-panel strong {
  color: var(--acid);
  font-size: 2.4rem;
  line-height: 1;
}

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

.shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 330px);
  gap: 14px;
  overflow-x: auto;
  padding: 4px 4px 18px;
  scroll-snap-type: x proximity;
}

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

.book-tile:nth-child(even) {
  transform: translateY(12px);
}

.cover-link {
  background: #141426;
}

.book-tile img,
.book-detail > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.25) contrast(1.08);
}

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

.score {
  justify-self: start;
  margin-bottom: 2px;
  border-radius: 8px;
  background: var(--acid);
  color: #211805;
  padding: 3px 9px;
  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, 0.95fr) minmax(320px, 1.05fr);
  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:hover,
.reader-card:hover,
.book-tile:hover {
  border-color: rgba(185, 255, 73, 0.74);
}

.profile-link {
  color: var(--hot);
  font-weight: 950;
}

.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: 42px minmax(0, 1fr);
  gap: 12px;
}

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

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

.back-link {
  justify-self: start;
}

.book-detail {
  display: grid;
  grid-template-columns: minmax(220px, 380px) minmax(0, 1fr);
  overflow: hidden;
}

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

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

.article-page {
  max-width: 960px;
}

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

.lede {
  max-width: 780px;
  color: var(--text);
  font-size: 1.22rem;
  font-weight: 760;
}

.stat-strip span {
  border-left: 4px solid var(--cyan);
  padding-left: 8px;
  color: var(--acid);
  font-weight: 950;
}

.tag-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 900;
}

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

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

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

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

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

dialog::backdrop {
  background: rgba(3, 3, 8, 0.72);
}

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

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

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: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

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

@media (max-width: 980px) {
  .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;
  }
}

@media (max-width: 620px) {
  .filters,
  .rail-nav,
  .stats-panel {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: clamp(3rem, 18vw, 5.2rem);
  }

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

  .book-tile,
  .book-tile:nth-child(even) {
    transform: none;
  }

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