:root {
  color-scheme: light;
  --paper: #f5f1e8;
  --paper-soft: #fbf8f1;
  --ink: #20251f;
  --ink-soft: #62685f;
  --line: rgba(32, 37, 31, 0.14);
  --line-strong: rgba(32, 37, 31, 0.24);
  --surface: rgba(255, 253, 248, 0.76);
  --surface-solid: #fffdf8;
  --moss: #3f5b48;
  --moss-dark: #2f4537;
  --shadow: 0 18px 55px rgba(50, 45, 33, 0.09);
  --serif: Iowan Old Style, Baskerville, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171a17;
  --paper-soft: #1c201c;
  --ink: #edf0e9;
  --ink-soft: #aeb6aa;
  --line: rgba(235, 240, 232, 0.12);
  --line-strong: rgba(235, 240, 232, 0.23);
  --surface: rgba(34, 39, 34, 0.78);
  --surface-solid: #222722;
  --moss: #a9c7ae;
  --moss-dark: #c3d9c6;
  --shadow: 0 22px 65px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 78% 4%, rgba(190, 150, 107, 0.13), transparent 29rem),
    radial-gradient(circle at 10% 18%, rgba(93, 125, 101, 0.1), transparent 31rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 180ms ease, color 180ms ease;
}

body.reader-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: inherit;
}

.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: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

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

.site-header {
  width: calc(100% - 2rem);
  max-width: 1240px;
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  color: var(--ink);
  font-size: 0.79rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.wordmark-mark {
  position: relative;
  width: 24px;
  height: 24px;
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.wordmark-mark::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  top: 8px;
  left: 8px;
  border-radius: 50%;
  background: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, border 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  transform: translateY(-1px);
}

.icon-button svg,
.saved-button svg,
.save-card svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.sun-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: block;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

main {
  width: calc(100% - 2rem);
  max-width: 1240px;
  margin: 0 auto;
}

.hero {
  min-height: 680px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 5rem 0 4rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 1.25rem;
  color: var(--moss);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1 {
  max-width: 980px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.4rem, 7.2vw, 7rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.94;
}

.hero-copy {
  max-width: 620px;
  margin: 2.2rem 0 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(1.16rem, 2.2vw, 1.45rem);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 1.4rem;
  border-radius: 999px;
  background: var(--moss-dark);
  color: var(--paper-soft);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  transition: transform 160ms ease, opacity 160ms ease;
}

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

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: none;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
}

.text-button span {
  transition: transform 160ms ease;
}

.text-button:hover span {
  transform: translate(2px, -2px);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 4rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-meta span {
  padding: 0 1.1rem;
  border-left: 1px solid var(--line-strong);
}

.hero-meta span:first-child {
  padding-left: 0;
  border-left: 0;
}

.hero-meta strong {
  color: var(--ink);
  font-weight: 700;
}

.library {
  padding: 6.5rem 0 7rem;
}

.library-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.25rem;
}

.library-heading .eyebrow {
  margin-bottom: 0.7rem;
}

.library-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 4.5vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.04em;
}

.result-count {
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
}

.search-box {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border 160ms ease, background 160ms ease;
}

.search-box:focus-within {
  border-color: var(--moss);
  background: var(--surface-solid);
}

.search-box svg {
  width: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--ink-soft);
  stroke-linecap: round;
  stroke-width: 1.7;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.93rem;
}

.search-box input::placeholder {
  color: var(--ink-soft);
  opacity: 0.8;
}

kbd {
  padding: 0.22rem 0.42rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.68rem;
}

.saved-button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}

.saved-button span {
  min-width: 1.4rem;
  padding: 0.15rem 0.38rem;
  border-radius: 999px;
  background: var(--line);
  font-size: 0.68rem;
}

.saved-button[aria-pressed="true"] {
  border-color: var(--moss);
  color: var(--moss-dark);
  background: rgba(83, 112, 91, 0.1);
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 2rem;
  padding-bottom: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.filter-button {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 150ms ease;
}

.filter-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.filter-button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-soft);
}

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

.reflection-card {
  --accent: #708c78;
  position: relative;
  min-width: 0;
  min-height: 365px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 46%),
    var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.reflection-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-4px);
}

.reflection-card::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -52px;
  width: 120px;
  height: 120px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-category {
  margin: 0;
  color: var(--accent, var(--moss));
  font-size: 0.67rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.save-card {
  position: relative;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.save-card:hover {
  background: var(--line);
  color: var(--ink);
}

.save-card.is-saved,
#readerSave.is-saved {
  color: var(--accent, var(--moss-dark));
}

.save-card.is-saved svg,
#readerSave.is-saved svg {
  fill: currentColor;
}

.card-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.card-open h3 {
  margin: 1.35rem 0 0.9rem;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.4vw, 1.85rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.card-body {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 1.5rem;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
}

.read-more span {
  transition: transform 160ms ease;
}

.reflection-card:hover .read-more span {
  transform: translateX(3px);
}

.empty-state {
  padding: 6rem 1rem;
  text-align: center;
}

.empty-state > span {
  color: var(--moss);
  font-family: var(--serif);
  font-size: 3.5rem;
}

.empty-state h3 {
  margin: 0.4rem 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
}

.empty-state p {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
}

footer {
  width: calc(100% - 2rem);
  max-width: 1240px;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.72rem;
}

footer p {
  margin: 0;
}

.library-link {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 650;
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}

.library-link:hover {
  color: var(--ink);
}

.single-main {
  min-height: calc(100svh - 76px - 90px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
}

.single-card {
  --accent: #708c78;
  max-width: 700px;
  padding: 0 1rem;
}

.single-card .card-category {
  font-size: 0.72rem;
}

.single-card h1 {
  margin: 1.1rem 0 1.6rem;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 5.5vw, 3.75rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 1.02;
}

.single-card .reader-body {
  max-width: none;
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
}

@media (max-width: 640px) {
  .single-main {
    min-height: calc(100svh - 66px - 110px);
    padding: 2.5rem 0;
  }
}

.reader {
  width: min(92vw, 760px);
  max-width: none;
  max-height: min(88vh, 820px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.reader::backdrop {
  background: rgba(20, 23, 20, 0.58);
  backdrop-filter: blur(6px);
}

.reader[open] {
  animation: reader-in 180ms ease-out;
}

@keyframes reader-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
}

.reader-shell {
  max-height: min(88vh, 820px);
  display: flex;
  flex-direction: column;
}

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.reader-position {
  color: var(--ink-soft);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-actions {
  display: flex;
  gap: 0.45rem;
}

.reader-actions .icon-button {
  width: 38px;
  height: 38px;
}

.reader-content {
  flex: 1;
  padding: clamp(2rem, 6vw, 4.75rem);
  overflow-y: auto;
}

.reader-content h2 {
  max-width: 620px;
  margin: 1.1rem 0 1.6rem;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 5.5vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.reader-body {
  max-width: 610px;
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.5vw, 1.35rem);
  line-height: 1.7;
}

.reader-nav {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.reader-nav button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.8rem;
  border: 0;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}

.reader-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 3px;
}

@media (max-width: 960px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .site-header,
  main,
  footer {
    width: calc(100% - 1.25rem);
  }

  .site-header {
    height: 66px;
  }

  .hero {
    min-height: calc(100svh - 66px);
    padding: 4.5rem 0 2.5rem;
  }

  h1 {
    max-width: 100%;
    font-size: clamp(2.7rem, 11.4vw, 3.25rem);
    line-height: 0.93;
    overflow-wrap: anywhere;
  }

  h1 br {
    display: none;
  }

  .hero-copy {
    margin-top: 1.75rem;
    font-size: 1.12rem;
  }

  .hero-actions {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
  }

  .primary-button {
    width: 100%;
  }

  .hero-meta {
    gap: 0.55rem 0;
    margin-top: auto;
    padding-top: 3rem;
    font-size: 0.65rem;
  }

  .hero-meta span {
    padding: 0 0.65rem;
  }

  .library {
    padding: 5rem 0;
  }

  .library-heading {
    display: block;
  }

  .result-count {
    margin-top: 0.8rem;
  }

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

  .saved-button {
    width: 54px;
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .saved-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  kbd {
    display: none;
  }

  .filter-row {
    width: calc(100% + 0.625rem);
    margin-right: -0.625rem;
  }

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

  .reflection-card {
    min-height: 340px;
    padding: 1.3rem;
  }

  .reflection-card:hover {
    transform: none;
  }

  .card-open h3 {
    font-size: 1.72rem;
  }

  footer {
    flex-direction: column;
    line-height: 1.5;
  }

  .reader {
    width: 100%;
    max-height: 92svh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }

  .reader-shell {
    max-height: 92svh;
  }

  .reader-content {
    padding: 2.7rem 1.35rem 3rem;
  }

  .reader-content h2 {
    font-size: clamp(2.4rem, 12vw, 3.5rem);
  }

  .reader-body {
    font-size: 1.18rem;
    line-height: 1.65;
  }
}

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