:root {
  --ink: #171914;
  --paper: #f5f1e8;
  --paper-deep: #e9e2d4;
  --acid: #d9f66b;
  --moss: #354530;
  --sage: #dce4ce;
  --coral: #ef7458;
  --line: rgba(23, 25, 20, 0.24);
  --muted: #696b63;
  --display: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}

@media (min-width: 761px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

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

.masthead {
  min-height: 132px;
  display: grid;
  grid-template-columns: minmax(205px, 0.72fr) minmax(420px, 1.75fr) minmax(175px, 0.55fr);
  gap: clamp(18px, 3vw, 46px);
  align-items: center;
  padding: 13px clamp(20px, 3vw, 48px);
  color: var(--paper);
  background:
    radial-gradient(circle at 77% 25%, rgba(217, 246, 107, 0.13), transparent 22%),
    linear-gradient(116deg, #151713, #20251d 72%, #171914);
  border-bottom: 1px solid #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 62px;
  height: 62px;
  object-fit: cover;
  border: 2px solid var(--paper);
  border-radius: 50%;
  filter: contrast(1.05);
}

.brand-copy {
  display: grid;
  gap: 5px;
}

.eyebrow,
.section-number,
.taste-kicker,
.count-badge,
.engine-status {
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--acid);
}

.wordmark {
  font-family: var(--display);
  font-size: 1.17rem;
  font-weight: 700;
  line-height: 0.9;
}

.masthead-intro {
  max-width: 760px;
}

.issue-line {
  display: flex;
  gap: 18px;
  margin: 0 0 7px;
  color: #c4c8bb;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.issue-line span + span::before {
  content: "•";
  margin-right: 18px;
  color: var(--coral);
}

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.9rem, 3vw, 3.15rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.88;
}

.masthead h1 em {
  color: var(--acid);
  font-weight: 400;
}

.masthead-intro > p:last-child {
  max-width: 610px;
  margin: 8px 0 0;
  color: #cfd2c8;
  font-size: 0.72rem;
  line-height: 1.35;
}

.source-stamp {
  justify-self: end;
  min-width: 175px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--acid);
  border: 1px solid #000;
  box-shadow: 4px 4px 0 var(--coral);
  text-decoration: none;
  transform: rotate(1.5deg);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.source-stamp:hover {
  box-shadow: 3px 3px 0 var(--coral);
  transform: rotate(0deg) translate(3px, 3px);
}

.source-stamp span,
.source-stamp small,
.source-stamp strong {
  display: block;
}

.source-stamp span {
  font-size: 0.59rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.source-stamp strong {
  margin: 3px 0 6px;
  font-family: var(--display);
  font-size: 1.03rem;
}

.source-stamp small {
  padding-top: 5px;
  border-top: 1px solid rgba(23, 25, 20, 0.45);
  font-size: 0.61rem;
}

.license-ribbon {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 29px;
  padding: 5px 20px;
  background: var(--coral);
  border-bottom: 1px solid var(--ink);
  font-size: 0.61rem;
  line-height: 1.25;
  text-align: center;
}

.license-ribbon p {
  margin: 0;
}

.license-ribbon a,
.site-footer a {
  font-weight: 750;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  min-height: 0;
  overflow: hidden;
}

.story-browser,
.recommendation-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 12px clamp(16px, 2.3vw, 34px) 10px;
}

.story-browser {
  background:
    linear-gradient(rgba(23, 25, 20, 0.028) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
  border-right: 1px solid var(--ink);
}

.recommendation-panel {
  background:
    radial-gradient(circle at 85% 9%, rgba(255, 255, 255, 0.55), transparent 22%),
    var(--sage);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 2px solid var(--ink);
}

.section-number {
  margin: 0 0 3px;
  color: var(--moss);
}

.section-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.93;
}

.count-badge,
.engine-status {
  padding: 4px 6px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.engine-status {
  color: var(--moss);
}

.story-search {
  flex: none;
  margin-bottom: 8px;
}

.story-search > label {
  display: block;
  margin-bottom: 3px;
  color: var(--moss);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.search-input-row {
  display: flex;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.75);
}

.search-input-row:focus-within {
  outline: 2px solid var(--coral);
  outline-offset: 1px;
}

.search-input-row input {
  min-width: 0;
  flex: 1;
  padding: 7px 9px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.72rem;
}

.search-input-row button {
  padding: 0 9px;
  border: 0;
  border-left: 1px solid var(--ink);
  color: var(--ink);
  background: var(--acid);
  cursor: pointer;
  font-size: 0.57rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-input-row button[hidden] {
  display: none;
}

.story-search p {
  min-height: 0.75rem;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.57rem;
}

.article-list {
  display: grid;
  gap: 7px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding: 1px 5px 5px 1px;
  scrollbar-color: var(--moss) transparent;
  scrollbar-width: thin;
}

.article-card {
  position: relative;
  padding: 9px 11px 10px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(23, 25, 20, 0.13);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.article-card:hover {
  background: #fffef9;
  box-shadow: 6px 6px 0 rgba(23, 25, 20, 0.18);
  transform: translate(-2px, -2px);
}

.article-card.is-liked {
  background: #fff7f1;
  box-shadow: 5px 5px 0 var(--coral);
}

.card-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.article-index {
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.like-button,
.page-button,
.text-button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.like-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: 1px solid var(--ink);
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.like-button span {
  color: var(--coral);
  font-size: 0.82rem;
  line-height: 0.7;
}

.like-button:hover,
.like-button[aria-pressed="true"] {
  color: #fff;
  background: var(--ink);
}

.article-card h3 {
  max-width: 92%;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(0.92rem, 1.2vw, 1.12rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.12;
}

.article-title {
  text-decoration: none;
}

.article-title:hover {
  text-decoration: underline;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
}

.article-attribution {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 5px 0 0;
  color: #4d5048;
  font-size: 0.54rem;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
}

.article-attribution a {
  text-underline-offset: 2px;
}

.original-link {
  color: #9c3c2d;
}

.article-excerpt {
  display: -webkit-box;
  overflow: hidden;
  margin: 5px 0 0;
  color: #3e403a;
  font-family: var(--display);
  font-size: 0.72rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.byline-warning {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.6rem;
  font-style: italic;
}

.loading-card {
  height: 90px;
  border: 1px solid var(--line);
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.25) 25%, rgba(255, 255, 255, 0.8) 40%, rgba(255, 255, 255, 0.25) 55%) 0 0 / 300% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  to { background-position: -150% 0; }
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--ink);
}

.pagination span {
  font-size: 0.66rem;
  font-family: var(--display);
  font-style: italic;
}

.page-button {
  padding: 5px 8px;
  border: 1px solid var(--ink);
  font-size: 0.59rem;
  font-weight: 800;
  text-transform: uppercase;
}

.page-button:last-child {
  justify-self: end;
}

.page-button:hover:not(:disabled) {
  background: var(--acid);
}

.page-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.taste-box {
  margin-bottom: 7px;
  padding: 8px 10px;
  color: var(--paper);
  background: var(--moss);
  border: 1px solid var(--ink);
}

.taste-title-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.taste-title-row > div {
  display: grid;
  gap: 2px;
}

.taste-kicker {
  color: var(--acid);
}

#like-count {
  font-family: var(--display);
  font-size: 0.95rem;
}

.text-button {
  padding: 4px 0;
  color: #dce1d7;
  border-bottom: 1px solid currentColor;
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
}

.liked-stories {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.liked-placeholder {
  margin: 0;
  color: #cbd0c5;
  font-size: 0.65rem;
}

.liked-placeholder span {
  color: var(--acid);
  font-weight: 750;
}

.liked-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 5px;
  padding: 3px 6px;
  color: var(--ink);
  background: var(--acid);
  border: 1px solid #0d0e0b;
  font-size: 0.6rem;
  font-weight: 700;
}

.liked-chip span {
  overflow: hidden;
  max-width: 250px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.liked-chip button {
  width: 17px;
  height: 17px;
  padding: 0;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.68rem;
  line-height: 1;
}

.tuning-panel {
  flex: none;
  margin-bottom: 7px;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid var(--ink);
}

.tuning-panel summary {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.61rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tuning-panel summary::marker,
.tuning-panel summary::-webkit-details-marker {
  display: none;
}

.summary-hint {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 650;
}

.tuning-panel[open] summary {
  border-bottom: 1px solid var(--ink);
}

.tuning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 8px 10px;
}

.tuning-grid label > span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.59rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tuning-grid output {
  color: #9c3c2d;
}

.tuning-grid input {
  width: 100%;
  margin: 5px 0 3px;
  accent-color: var(--coral);
}

.tuning-grid small {
  display: block;
  color: var(--muted);
  font-size: 0.56rem;
  line-height: 1.35;
}

.recommendation-status {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 100px;
  padding: 10px;
  background: rgba(245, 241, 232, 0.57);
  border: 1px dashed var(--ink);
}

.recommendation-status[hidden] {
  display: none;
}

.recommendation-status img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 50%;
  mix-blend-mode: multiply;
}

.recommendation-status strong {
  font-family: var(--display);
  font-size: 1rem;
}

.recommendation-status p {
  max-width: 430px;
  margin: 4px 0 0;
  color: #555b50;
  font-size: 0.66rem;
  line-height: 1.35;
}

.recommendation-list .article-card:nth-child(3n + 2) {
  background: rgba(255, 251, 235, 0.8);
}

.recommendation-list .article-card:nth-child(3n) {
  background: rgba(247, 255, 221, 0.72);
}

.site-footer {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 24px;
  align-items: center;
  padding: 6px clamp(20px, 3vw, 48px);
  color: #d9dbd4;
  background: var(--ink);
  border-top: 3px solid var(--coral);
}

.site-footer strong {
  color: var(--acid);
  font-family: var(--display);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 2px 0 0;
  font-size: 0.56rem;
  line-height: 1.3;
}

.footer-attribution {
  max-width: 760px;
}

.error-card {
  padding: 24px;
  color: #6c2018;
  background: #ffe6df;
  border: 1px solid #6c2018;
  font-size: 0.82rem;
  line-height: 1.5;
}

@media (max-width: 1040px) {
  .masthead {
    grid-template-columns: 0.8fr 1.4fr;
  }

  .source-stamp {
    display: none;
  }

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

  .story-browser,
  .recommendation-panel {
    padding-inline: 28px;
  }

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

@media (max-width: 760px) {
  .masthead {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 13px;
    padding: 14px 16px;
  }

  .brand img {
    width: 52px;
    height: 52px;
  }

  .masthead h1 {
    font-size: clamp(1.85rem, 9vw, 2.8rem);
  }

  .masthead-intro > p:last-child {
    max-width: 520px;
    font-size: 0.68rem;
  }

  .license-ribbon > span {
    display: none;
  }

  .workspace {
    display: block;
  }

  .story-browser {
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  .story-browser,
  .recommendation-panel {
    overflow: visible;
    padding: 18px 14px 24px;
  }

  .section-heading {
    align-items: start;
  }

  .section-heading h2 {
    font-size: 1.7rem;
  }

  .count-badge,
  .engine-status {
    max-width: 115px;
    white-space: normal;
    text-align: right;
  }

  .article-card {
    padding: 11px;
  }

  .article-card h3 {
    max-width: 100%;
    font-size: 1.08rem;
  }

  .recommendation-status {
    display: block;
    text-align: center;
  }

  .site-footer {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 12px 16px;
  }
}

@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;
  }
}
