:root {
  --bg: #ffffff;
  --text: #242424;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --accent: #1a8917;
  --font-serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
}

/* ---- Navbar ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.navbar-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-home {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
}

.navbar-home:hover {
  color: var(--accent);
  text-decoration: none;
}

.navbar-home svg {
  flex-shrink: 0;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.navbar-brand:hover {
  color: var(--text);
  text-decoration: none;
}

/* ---- Layout ---- */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Feed (homepage) ---- */
.feed {
  padding: 32px 0 64px;
}

.feed-item {
  display: block;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.feed-item:first-child {
  padding-top: 0;
}

.feed-item:hover {
  text-decoration: none;
}

.feed-item:hover .feed-title {
  color: var(--text);
  text-decoration: underline;
}

.feed-title {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.feed-excerpt {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-meta {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---- Article page ---- */
.article {
  padding: 40px 0 80px;
}

.article-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 2.625rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.byline {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 32px;
  font-size: 0.875rem;
}

.byline-author {
  color: var(--text);
  font-weight: 500;
}

.byline-date {
  color: var(--muted);
}

.article-body {
  font-family: var(--font-serif);
  font-size: 1.3125rem;
  line-height: 2rem;
  color: var(--text);
}

.article-body p {
  margin-bottom: 1.75rem;
  overflow-wrap: anywhere;
}

.article-body a {
  color: inherit;
  text-decoration: underline;
}

.article-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
}

.article-footer a {
  color: var(--muted);
  text-decoration: none;
}

.article-footer a:hover {
  color: var(--accent);
}

/* ---- Links ---- */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Share buttons ---- */
.article-share {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.article-share-label {
  font-size: 0.875rem;
  color: var(--muted);
  margin-right: 4px;
}

.article-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.article-share-btn:hover {
  color: var(--text);
  border-color: var(--text);
  text-decoration: none;
}

.article-share-copy.copied {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Article navigation ---- */
.article-nav {
  display: flex;
  gap: 24px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.article-nav-item {
  flex: 1;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.article-nav-item:hover {
  text-decoration: none;
}

.article-nav-item:hover .article-nav-title {
  color: var(--accent);
}

.article-nav-next {
  text-align: right;
}

.article-nav-label {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.article-nav-title {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
}

/* ---- Reference popups ---- */
.ref-link {
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8em;
  vertical-align: super;
  line-height: 0;
  font-family: var(--font-sans);
  font-weight: 600;
}

.ref-link:hover {
  text-decoration: underline;
}

.ref-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.ref-popup-overlay.active {
  display: flex;
}

.ref-popup {
  background: var(--bg);
  border-radius: 8px;
  padding: 24px 28px;
  max-width: 520px;
  width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  position: relative;
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}

.ref-popup-num {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.ref-popup-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.ref-popup-close:hover {
  color: var(--text);
}

/* ---- Progress bar ---- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 20;
  transition: width 0.1s linear;
}

/* ---- Summary box ---- */
.article-summary {
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin-bottom: 32px;
  background: #f9faf9;
  border-radius: 0 4px 4px 0;
}

.article-summary-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}

.article-summary p {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--muted);
  margin: 0;
}

/* ---- Drop cap ---- */
.drop-cap > p:first-of-type::first-letter {
  float: left;
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 0.8;
  margin: 6px 8px 0 0;
  color: var(--text);
}

/* ---- Blockquote / pull quote ---- */
.article-body blockquote {
  margin: 2rem 0;
  padding: 0 0 0 30px;
  border-left: 3px solid var(--text);
}

.article-body blockquote p {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.6;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0;
}

/* ---- Section divider ---- */
.article-body hr {
  border: none;
  text-align: center;
  margin: 2.5rem 0;
}

.article-body hr::after {
  content: "···";
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  color: var(--muted);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .container {
    padding: 0 20px;
  }

  .navbar-inner {
    padding: 14px 20px;
  }

  .article-body {
    font-size: 1.1875rem;
    line-height: 1.85rem;
  }

  .feed-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 375px) {
  .article-header h1 {
    font-size: 1.75rem;
  }

  .article-body {
    font-size: 1.0625rem;
    line-height: 1.75rem;
  }

  .drop-cap > p:first-of-type::first-letter {
    font-size: 2.75rem;
  }

  .article-body blockquote p {
    font-size: 1.25rem;
  }
}
