:root {
  --bg: #f4efe6;
  --ink: #1f1e1b;
  --muted: #645f57;
  --panel: #fffaf1;
  --line: #dbcbb3;
  --primary: #145f68;
  --accent: #bf5b32;
  --chip: #f1e4d2;
  --shadow-soft: 0 16px 34px rgba(49, 34, 14, 0.12);
  --shadow-hard: 0 28px 56px rgba(24, 16, 7, 0.2);
  --radius-xl: 24px;
  --radius-lg: 18px;
}

:root[data-theme="dark"] {
  --bg: #0d141a;
  --ink: #e8edf2;
  --muted: #9ca9b5;
  --panel: #121d26;
  --line: #2a3a48;
  --primary: #2c9eb4;
  --accent: #e17f4a;
  --chip: #1a2731;
  --shadow-soft: 0 16px 34px rgba(0, 0, 0, 0.35);
  --shadow-hard: 0 28px 56px rgba(0, 0, 0, 0.46);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(90rem 48rem at -8% -10%, #fff1d7 0%, transparent 54%),
    radial-gradient(72rem 38rem at 104% -12%, #dceff1 0%, transparent 51%),
    var(--bg);
  min-height: 100vh;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(90rem 48rem at -8% -10%, rgba(39, 67, 92, 0.5) 0%, transparent 54%),
    radial-gradient(72rem 38rem at 104% -12%, rgba(25, 94, 97, 0.42) 0%, transparent 51%),
    var(--bg);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.08;
  background-image: radial-gradient(#000 0.6px, transparent 0.6px);
  background-size: 3px 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(14px, 2.8vw, 34px);
  border-bottom: 1px solid rgba(219, 203, 179, 0.7);
  backdrop-filter: blur(8px);
  background: rgba(255, 249, 239, 0.72);
}

:root[data-theme="dark"] .topbar {
  border-bottom-color: rgba(65, 90, 112, 0.7);
  background: rgba(9, 16, 24, 0.78);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(140deg, var(--primary), #0e3e45);
  box-shadow: var(--shadow-soft);
}

.brand-text {
  font-family: "Fraunces", serif;
  font-size: 1.16rem;
}

.menu {
  display: flex;
  gap: 16px;
}

.menu a {
  text-decoration: none;
  color: #3d3933;
  font-weight: 600;
  font-size: 0.95rem;
}

:root[data-theme="dark"] .menu a {
  color: #c6d3de;
}

.theme-toggle {
  border: 1px solid #ccb99e;
  background: rgba(255, 252, 246, 0.88);
  color: #2a2520;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

:root[data-theme="dark"] .theme-toggle {
  border-color: #48647a;
  background: rgba(24, 36, 48, 0.92);
  color: #d7e4ee;
}

main {
  width: min(1180px, 100% - 28px);
  margin-inline: auto;
  display: grid;
  gap: 30px;
  padding: 22px 0 44px;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: clamp(24px, 5vw, 46px);
  background:
    linear-gradient(128deg, rgba(255, 252, 245, 0.95), rgba(244, 255, 255, 0.92)),
    var(--panel);
  box-shadow: var(--shadow-hard);
}

:root[data-theme="dark"] .hero {
  background:
    linear-gradient(128deg, rgba(23, 36, 47, 0.96), rgba(13, 25, 34, 0.92)),
    var(--panel);
}

.hero::after {
  content: "";
  position: absolute;
  right: -90px;
  top: -70px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 95, 104, 0.24), rgba(20, 95, 104, 0));
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  font-weight: 700;
  color: #4f6472;
}

:root[data-theme="dark"] .eyebrow {
  color: #88a9bd;
}

h1, h2, h3 {
  font-family: "Fraunces", serif;
  line-height: 1.15;
  margin: 0;
}

.hero h1 {
  margin-top: 10px;
  max-width: 16ch;
  font-size: clamp(2rem, 4.7vw, 3.5rem);
}

.lead {
  margin: 14px 0 0;
  max-width: 66ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.62;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 700;
  transition: transform 0.24s ease, box-shadow 0.24s ease;
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(130deg, var(--primary), #0b4651);
  box-shadow: 0 10px 20px rgba(11, 70, 81, 0.28);
}

.btn-ghost {
  color: #2f2b25;
  border: 1px solid #bfae97;
  background: rgba(255, 252, 245, 0.8);
}

:root[data-theme="dark"] .btn-ghost {
  color: #d7e1ea;
  border-color: #51687c;
  background: rgba(27, 40, 51, 0.78);
}

.hero-ribbons {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-ribbons span {
  padding: 8px 10px;
  border-radius: 999px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  border: 1px dashed rgba(20, 95, 104, 0.4);
  background: rgba(20, 95, 104, 0.08);
}

:root[data-theme="dark"] .hero-ribbons span {
  border-color: rgba(84, 168, 180, 0.46);
  background: rgba(41, 102, 118, 0.22);
  color: #d6eaf2;
}

.catalog,
.about,
.publish {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3.4vw, 30px);
  background: rgba(255, 250, 241, 0.86);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .catalog,
:root[data-theme="dark"] .about,
:root[data-theme="dark"] .publish {
  background: rgba(19, 30, 39, 0.86);
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.toolbar {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.search-wrap {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #524b43;
}

:root[data-theme="dark"] .search-wrap {
  color: #adc0cf;
}

.search-wrap input {
  border: 1px solid #ccb99e;
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  color: #2a2622;
  font-size: 15px;
}

:root[data-theme="dark"] .search-wrap input {
  border-color: #4d677b;
  background: #14202a;
  color: #d9e4ed;
}

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

.chip {
  border: 1px solid #ccb99e;
  background: var(--chip);
  color: #42392f;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

:root[data-theme="dark"] .chip {
  border-color: #4e687a;
  color: #c8d7e2;
}

.chip.active {
  border-color: #0f4d56;
  background: #d8ecef;
  color: #13363b;
}

:root[data-theme="dark"] .chip.active {
  border-color: #63bfd0;
  background: #1d3b48;
  color: #ddf4fb;
}

.grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.book {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid #ddcdb8;
  border-radius: 14px;
  background: #fffdf9;
  transition: transform 0.24s ease, box-shadow 0.24s ease;
}

:root[data-theme="dark"] .book {
  border-color: #334757;
  background: #16232d;
}

.book:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 26px rgba(54, 37, 14, 0.16);
}

.book img {
  width: 100%;
  height: 144px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #d8c4aa;
}

:root[data-theme="dark"] .book img {
  border-color: #456075;
}

.book h3 {
  margin: 0;
  font-size: 1.05rem;
}

.book p {
  margin: 6px 0 0;
  color: #6a645b;
  font-size: 0.92rem;
  line-height: 1.42;
}

:root[data-theme="dark"] .book p {
  color: #9dafbd;
}

.meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta span {
  border-radius: 999px;
  border: 1px solid #d8c9b5;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #4a443d;
}

:root[data-theme="dark"] .meta span {
  border-color: #3e5567;
  color: #b7c9d8;
}

.book-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  color: #0e4a54;
  border: 1px solid #aac7cc;
  background: #ebf5f6;
  border-radius: 999px;
  padding: 6px 10px;
}

:root[data-theme="dark"] .link-btn {
  color: #d6f2f7;
  border-color: #4a7c85;
  background: #1f3f49;
}

.read-btn {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: #fff;
  border-color: #0f4c55;
  background: linear-gradient(130deg, #14616a, #0d434b);
  box-shadow: 0 10px 18px rgba(15, 67, 75, 0.26);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.read-btn::after {
  content: "→";
  margin-left: 8px;
}

.read-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(15, 67, 75, 0.34);
}

.link-btn.alt {
  color: #563621;
  border-color: #d8c3ae;
  background: #f8efe2;
}

:root[data-theme="dark"] .link-btn.alt {
  color: #f7d2bf;
  border-color: #875f48;
  background: #3c2a21;
}

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

.about-card {
  border: 1px solid #decfb9;
  border-radius: 14px;
  padding: 14px;
  background: #fffdf8;
}

:root[data-theme="dark"] .about-card {
  border-color: #324555;
  background: #16222c;
}

.about-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #555047;
  line-height: 1.55;
}

:root[data-theme="dark"] .about-card ul {
  color: #aab8c4;
}

.about-card.accent {
  background: linear-gradient(140deg, #fef8ef, #e9f5f6);
}

:root[data-theme="dark"] .about-card.accent {
  background: linear-gradient(140deg, #1a2a34, #17323c);
}

.publish p {
  margin: 10px 0 0;
  color: #59534c;
}

:root[data-theme="dark"] .publish p {
  color: #a8b8c6;
}

.inline-code {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f0e3d0;
  border: 1px solid #ddc7ac;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

:root[data-theme="dark"] .inline-code {
  background: #1d2b36;
  border-color: #3c5568;
  color: #cfe1ee;
}

.footer {
  text-align: center;
  padding: 20px 12px 30px;
  color: #6b6358;
  font-size: 14px;
}

:root[data-theme="dark"] .footer {
  color: #95a8b8;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.72s ease forwards;
  animation-play-state: paused;
}

.reveal.visible {
  animation-play-state: running;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 880px) {
  .menu { display: none; }
  .about { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding: 10px 12px; }
  main { width: calc(100% - 16px); gap: 16px; }
  .hero,
  .catalog,
  .about,
  .publish { padding: 14px; }
  .book { grid-template-columns: 80px 1fr; }
  .book img { height: 124px; }
}
