:root {
  color-scheme: light;
  --switcher-height: 50px;
  --ink: #18201d;
  --text: #43504a;
  --muted: #74807a;
  --paper: #f8faf7;
  --panel: rgba(255, 255, 255, 0.82);
  --line: rgba(25, 58, 49, 0.14);
  --mint: #69d7ad;
  --coral: #ff745c;
  --violet: #7568ff;
  --sky: #62b6ff;
  --lime: #d7f36a;
  --shadow: 0 22px 70px rgba(40, 57, 49, 0.12);
}

:root[data-scheme="dusk"] {
  color-scheme: dark;
  --ink: #f7f4ff;
  --text: #d5d0ea;
  --muted: #9a94b5;
  --paper: #14121d;
  --panel: rgba(31, 28, 44, 0.86);
  --line: rgba(211, 203, 255, 0.18);
  --mint: #72e1bd;
  --coral: #ff8b73;
  --violet: #a69cff;
  --sky: #83c9ff;
  --lime: #def282;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

:root[data-scheme="print"] {
  --ink: #1d1c19;
  --text: #46433c;
  --muted: #706b60;
  --paper: #f3efe5;
  --panel: rgba(255, 252, 245, 0.9);
  --line: rgba(64, 59, 49, 0.16);
  --mint: #4b9073;
  --coral: #b15a4a;
  --violet: #625a99;
  --sky: #3976a4;
  --lime: #899c32;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(120deg, rgba(105, 215, 173, 0.18), transparent 34rem),
    linear-gradient(260deg, rgba(117, 104, 255, 0.16), transparent 38rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.ambient {
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  background:
    radial-gradient(circle at 28% 32%, rgba(255, 116, 92, 0.22), transparent 18rem),
    radial-gradient(circle at 68% 18%, rgba(98, 182, 255, 0.24), transparent 19rem),
    radial-gradient(circle at 54% 72%, rgba(215, 243, 106, 0.22), transparent 20rem);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from {
    transform: translate3d(-2%, -1%, 0) rotate(-3deg) scale(1);
  }
  to {
    transform: translate3d(2%, 1%, 0) rotate(4deg) scale(1.06);
  }
}

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

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

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(--violet);
  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) 80%, 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;
  text-transform: uppercase;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: conic-gradient(from 140deg, var(--mint), var(--sky), var(--violet), var(--coral), var(--mint));
  color: #101711;
  font-weight: 950;
}

.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: rgba(255, 255, 255, 0.74);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(40, 57, 49, 0.08);
}

.search-box:focus-within {
  border-color: rgba(117, 104, 255, 0.52);
  box-shadow: 0 0 0 4px rgba(117, 104, 255, 0.12);
}

.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(34, 92, 72, 0.26);
  border-radius: 8px;
  background: #18201d;
  color: #fff;
  padding: 10px 14px;
  font-weight: 950;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.primary-action:hover,
menu button:last-child:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(24, 32, 29, 0.18);
}

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

.rail {
  position: sticky;
  top: calc(var(--switcher-height) + 84px);
  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);
  backdrop-filter: blur(18px);
}

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

.rail-nav a {
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 900;
  transition: background 180ms ease, transform 180ms ease;
}

.rail-nav a:hover {
  transform: translateX(3px);
}

.rail-nav a.is-active {
  background: linear-gradient(135deg, rgba(105, 215, 173, 0.52), rgba(98, 182, 255, 0.36));
  color: var(--ink);
}

.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: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  padding: 7px 11px;
  font-weight: 850;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.control-grid button:hover,
.chip-list button:hover,
.back-link:hover {
  transform: translateY(-1px);
}

.control-grid button.is-active,
.chip-list button.is-active {
  border-color: rgba(255, 116, 92, 0.58);
  background: rgba(255, 116, 92, 0.16);
}

.main,
.home-view,
.route-view {
  display: grid;
  gap: clamp(22px, 4vw, 42px);
  align-content: start;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 400px);
  gap: clamp(18px, 4vw, 42px);
  align-items: end;
  min-height: clamp(360px, 54vh, 620px);
  animation: rise-in 520ms ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

h1 {
  max-width: 940px;
  margin-bottom: 14px;
  font-size: clamp(2.7rem, 7vw, 7.8rem);
  font-weight: 920;
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1rem, 1.8vw, 1.25rem);
}

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

.hero-copy {
  max-width: 650px;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.stats-panel div {
  display: grid;
  gap: 4px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  transition: transform 220ms ease;
}

.stats-panel div:hover {
  transform: translateY(-4px) rotate(-1deg);
}

.stats-panel strong {
  font-size: clamp(2rem, 5vw, 3.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-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: clamp(12px, 2vw, 18px);
}

.book-tile {
  display: grid;
  grid-template-rows: minmax(210px, 34vw) minmax(160px, auto);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform-origin: center;
  transition: transform 220ms ease, box-shadow 220ms ease;
  animation: rise-in 520ms ease both;
}

.book-tile:nth-child(2n) {
  animation-delay: 50ms;
}

.book-tile:nth-child(3n) {
  animation-delay: 100ms;
}

.book-tile:hover {
  transform: translateY(-8px) scale(1.015);
  box-shadow: 0 28px 80px rgba(40, 57, 49, 0.18);
}

.cover-link {
  background: rgba(34, 92, 72, 0.12);
}

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

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

.score {
  justify-self: start;
  margin-bottom: 2px;
  border-radius: 999px;
  background: rgba(215, 243, 106, 0.72);
  color: var(--ink);
  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: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: clamp(14px, 3vw, 24px);
}

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

.essay-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

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

.line-card {
  display: grid;
  gap: 9px;
  transition: transform 180ms ease, border-color 180ms ease;
}

.line-card:hover,
.reader-card:hover {
  border-color: rgba(117, 104, 255, 0.36);
  transform: translateY(-3px);
}

.profile-link {
  color: #b13f30;
  font-weight: 900;
}

.reader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}

.reader-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  transition: transform 180ms ease, border-color 180ms ease;
}

.route-heading {
  max-width: 900px;
  animation: rise-in 420ms ease both;
}

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

.back-link {
  justify-self: start;
  border-radius: 8px;
}

.book-detail {
  display: grid;
  grid-template-columns: minmax(220px, 380px) minmax(0, 1fr);
  overflow: hidden;
  animation: rise-in 480ms ease both;
}

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

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

.article-page {
  max-width: 960px;
  animation: rise-in 480ms ease both;
}

.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.2rem;
  font-weight: 720;
}

.stat-strip span {
  border-left: 4px solid var(--mint);
  padding-left: 8px;
  color: #225c48;
  font-weight: 900;
}

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

.profile-detail {
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: start;
  animation: rise-in 480ms ease both;
}

.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, 32, 29, 0.36);
  backdrop-filter: blur(5px);
}

.dialog-panel {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: pop-in 220ms ease both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.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.72);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

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

@media (min-width: 1320px) {
  .book-tile {
    grid-template-rows: 330px minmax(160px, auto);
  }
}

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

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

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

  .search-box,
  .filters,
  .stats-panel,
  .rail-nav {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    min-height: auto;
  }

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

  menu {
    display: grid;
  }
}

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

:root {
  --tabbar-height: 74px;
}

body {
  padding-bottom: calc(var(--tabbar-height) + 22px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 22rem),
    var(--paper);
}

.masthead {
  grid-template-columns: max-content minmax(180px, 1fr) max-content;
}

.layout {
  display: block;
  width: min(1180px, 100%);
}

.main,
.home-view,
.route-view {
  gap: 24px;
}

.rail {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 40;
  display: block;
  max-width: 620px;
  margin: 0 auto;
}

.rail-nav {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  border-radius: 8px;
}

.rail-nav a {
  min-height: 56px;
  display: grid;
  place-items: center;
  padding: 7px 6px;
  text-align: center;
  font-size: 0.82rem;
}

.filters {
  display: none;
}

.hero-grid {
  min-height: auto;
  align-items: start;
  padding-top: clamp(18px, 4vw, 42px);
}

h1 {
  max-width: 760px;
  font-size: clamp(2.5rem, 6vw, 5.8rem);
}

.stats-panel {
  align-self: start;
}

.shelf {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
}

.book-tile {
  grid-template-rows: minmax(190px, 28vw) minmax(150px, auto);
}

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

@media (max-width: 700px) {
  .prototype-title,
  .prototype-divider {
    display: none;
  }

  .masthead {
    position: static;
    grid-template-columns: 1fr;
  }

  .primary-action {
    width: 100%;
  }

  .hero-grid,
  .book-detail {
    grid-template-columns: 1fr;
  }

  .rail-nav a {
    min-height: 52px;
    font-size: 0.78rem;
  }
}
