:root {
  color-scheme: light dark;
  --page-bg: #fbf9f6;
  --bg: #fdeee7;
  --panel: #fdeee7;
  --callout-bg: #eef1f4;
  --border: #f0ddd3;
  --text: #143a3c;
  --muted: #7c9490;
  --accent: #1e441e;
  --accent-hover: #143014;
  --card-shadow: 0 1px 2px rgba(20, 58, 60, 0.06), 0 10px 28px rgba(20, 58, 60, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #051718;
    --bg: #0b3f41;
    --panel: #0b3f41;
    --callout-bg: #0d3234;
    --border: #145154;
    --text: #fff2ee;
    --muted: #9fb3af;
    --accent: #4f8f52;
    --accent-hover: #6aab6d;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

a { color: var(--accent); }

.card {
  background: var(--bg);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}

.topbar {
  max-width: 640px;
  margin: 24px auto 0;
  padding: 32px 20px 22px;
  text-align: center;
}

.topbar.card { margin-bottom: 24px; }

.hero-card .topbar {
  margin: 0;
  padding: 12px 0 8px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
}

.brand-caption {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 16px;
  color: var(--accent);
}

.brand-block {
  font-family: 'Anton', 'Arial Black', Impact, sans-serif;
  font-size: 44px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.1;
  margin-top: 4px;
}

.brand-italic {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 32px;
  color: var(--accent);
  line-height: 1.2;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 20px 60px;
}

body.home main {
  max-width: 1100px;
}

body.home .topbar,
body.home .about-section-top,
body.home .about-section,
body.home .sort-bar {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

.sort-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}

.sort-bar label {
  color: var(--muted);
}

.sort-bar select {
  width: auto;
  flex: none;
}

.article-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-flow: dense;
  grid-auto-rows: 8px;
  gap: 16px;
}

.article-list > li {
  display: contents;
}

@media (min-width: 640px) {
  .article-list { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
  .article-list { grid-template-columns: repeat(3, 1fr); }
}

.article-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
}

.article-card:hover {
  outline: 2px solid var(--accent);
}

/* Box size roughly follows article length — bigger stories get bigger boxes. */
@media (min-width: 640px) {
  .article-card.size-large { grid-column: span 2; padding: 24px 26px; }
}

.article-card.size-large .article-card-title { font-size: 26px; }
.article-card.size-medium .article-card-title { font-size: 19px; }
.article-card.size-small .article-card-title { font-size: 16px; }

.article-card.size-small { padding: 14px 16px; }
.article-card.size-small .article-card-thumb { display: none; }
.article-card.size-small .article-card-excerpt {
  font-size: 13px;
  line-height: 1.4;
}

.article-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  margin: -2px -2px 12px;
  display: block;
}

.article-card.size-large .article-card-thumb {
  aspect-ratio: 16 / 8;
}

.article-card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 21px;
  margin: 0 0 6px;
  color: var(--text);
}

.article-card-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
}

.article-card-excerpt {
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  color: var(--text);
}

.article-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-pill {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  border: none;
  font-family: inherit;
}

.tag-pill:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.tag-pill:active {
  transform: scale(0.94);
}

.tag-pill.active {
  background: var(--accent);
  color: #fff;
}

/* Fills leftover mosaic gaps left by the masonry packing — only ever
   created when real article cards don't perfectly tile the grid. */
.filler-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  min-height: 90px;
  background: var(--callout-bg);
  border: 2px dashed var(--accent);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.filler-card:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--callout-bg));
  outline: none;
}

.filler-icon {
  font-size: 22px;
  line-height: 1;
}

.hero-card {
  padding: 8px 24px 32px;
  margin-bottom: 20px;
}

.article-header {
  text-align: center;
  padding-top: 12px;
}

.back-link {
  display: inline-block;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  margin: 0 0 4px 20px;
}

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

.article-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 10px;
}

.article-excerpt {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 18px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 16px;
}

.article-meta {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  margin: 0;
}

.article-header-tags {
  justify-content: center;
  margin-top: 14px;
}

.article-meta sup {
  font-variant: normal;
  text-transform: lowercase;
}

.article-cover {
  width: 100%;
  border-radius: 12px;
  margin-bottom: 24px;
  display: block;
  box-shadow: var(--card-shadow);
}

.body-card {
  padding: 28px 24px;
  margin-bottom: 20px;
}

.body-card:last-child {
  margin-bottom: 0;
}

.section-label {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
  margin: 0 0 14px;
}

.article-body {
  font-size: 17px;
  line-height: 1.7;
  font-family: 'EB Garamond', Georgia, serif;
}

.article-body h3 {
  font-family: 'Playfair Display', Georgia, serif;
  margin-top: 1.6em;
}

.article-body p { margin: 0 0 1em; }

.article-body img {
  max-width: 100%;
  border-radius: 12px;
  display: block;
  margin: 1.2em 0;
  box-shadow: var(--card-shadow);
}

.article-body ul,
.article-body ol {
  margin: 0 0 1em;
  padding-left: 1.3em;
}

/* A paragraph that's just a bold section label, e.g. "**What happened:**" */
.article-body p:has(> strong:only-child) {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 19px;
  color: var(--accent);
  margin-top: 1.4em;
}

.article-body blockquote {
  background: var(--callout-bg);
  border-radius: 4px 14px 14px 4px;
  border-left: 5px solid var(--accent);
  padding: 18px 20px;
  margin: 0 0 1.2em;
  color: var(--text);
}

.article-body blockquote p:last-child { margin-bottom: 0; }

.article-sources {
  margin-top: 2.2em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border);
}

.sources-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.sources-list {
  margin: 0;
  padding-left: 1.3em;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.sources-list li {
  margin-bottom: 7px;
}

.sources-list a {
  color: var(--accent);
  word-break: break-word;
}

.sources-list li.source-no-link {
  font-style: italic;
}

.collapsible-heading {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  user-select: none;
}

.collapsible-heading::after {
  content: '\25BE';
  font-size: 0.75em;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.body-card.collapsed .collapsible-heading::after {
  transform: rotate(-90deg);
}

.body-card.collapsed .section-label,
.body-card.collapsed .sources-heading {
  margin-bottom: 0;
}

.body-card.collapsed > .article-body,
.body-card.collapsed > .sources-list {
  display: none;
}


.about-section {
  margin-top: 24px;
  padding: 28px 24px;
}

.about-section-top {
  margin-bottom: 24px;
  padding: 28px 24px;
}

.section-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 12px;
}

.about-text {
  font-size: 16px;
  line-height: 1.6;
  margin: 0 0 18px;
  max-width: 56ch;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.team-card {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 16px 18px;
}

.team-card-filterable {
  cursor: pointer;
}

.team-card-filterable:hover,
.team-card-filterable:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.team-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  margin: 0 0 6px;
}

.team-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: 12px;
}

.team-photo-placeholder {
  background: var(--muted);
  opacity: 0.35;
}

.team-role {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.5;
}

.footer {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 20px 20px 40px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

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

/* Shared editor styles */
.issue-bar {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.issue-select {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
}

.danger-link { color: #b5432f; }

.save-status {
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
  white-space: nowrap;
}

.editor {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.field input[type="text"],
.field input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}

.field textarea {
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.5;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}

.field textarea:focus,
.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-label-row label { margin: 0; }

.field-hint {
  font-size: 13px;
  color: var(--muted);
  margin: -4px 0 0;
}

.split-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.split-row .field { flex: 1; min-width: 200px; }

.preview-pane {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 15px;
  line-height: 1.6;
  max-height: 400px;
  overflow: auto;
}

.image-drop {
  border: 2px dashed var(--border);
  border-radius: 8px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  position: relative;
}

.image-drop:focus {
  outline: none;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.image-placeholder { font-size: 14px; color: var(--muted); }

.image-preview {
  max-width: 100%;
  max-height: 320px;
  border-radius: 6px;
  display: block;
}

.remove-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  padding: 0;
}

.generate-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 30px;
}

.primary-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.primary-btn:hover { background: var(--accent-hover); color: #fff; }

.secondary-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px;
  cursor: pointer;
}

.secondary-btn:hover { border-color: var(--accent); }

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.status-badge.published { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.status-badge.draft { background: color-mix(in srgb, var(--muted) 20%, transparent); color: var(--muted); }

.password-gate {
  max-width: 360px;
  margin: 80px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.password-gate input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  background: var(--panel);
  color: var(--text);
}

.error-text { color: #b5432f; font-size: 13px; }

.author-picker {
  display: flex;
  gap: 18px;
  margin-bottom: 4px;
}

.author-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
}

.author-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Newsletter issue editor (modal export view) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal {
  background: var(--panel);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 17px;
  margin: 0;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
}

.tab-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 13px;
  border-bottom: none;
}

.tab-btn.active {
  color: var(--text);
  background: var(--bg);
  font-weight: 600;
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
  min-height: 300px;
}

.preview-frame {
  width: 100%;
  height: 50vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.source-view {
  width: 100%;
  height: 50vh;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--page-bg);
  color: var(--text);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal-toast {
  margin: 0 20px 14px;
  font-size: 13px;
  color: var(--accent);
  min-height: 16px;
}

.issue-title-row {
  max-width: 720px;
  margin: 10px auto 0;
  padding: 0 20px;
}

.issue-title-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  padding: 6px 2px;
  font-family: inherit;
}

.issue-title-input:focus {
  outline: none;
  border-color: var(--accent);
}
