:root {
  --bg: #f6f6ef;
  --fg: #222;
  --link: #000;
  --muted: #828282;
  --accent: #ff781f;
  --search-bg: #fff;
  --search-fg: #000;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --fg: #ddd;
  --link: #e1e1e1;
  --muted: #999;
  --accent: #c12a4c;
  --search-bg: #333;
  --search-fg: #eee;
}

body {
  background: var(--bg);
  color: #7f7f7f; 
  font-family: Verdana, Geneva, sans-serif;
  line-height: 1.4;
}

header {
  background: var(--accent);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  /* padding: 8px 12px; */
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.1rem;
  margin: 0;
  flex-shrink: 0;
  padding-right: 32px;
  padding-top: 6px;
  padding-bottom: 6px;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

[data-theme="dark"] header {
  background: #532e00;
}

.topbar-nav {
  display: flex;
  gap: 0;
  align-items: center;
  margin-right: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

.topbar-nav .nav-link {
  background: none;
  border: none;
  color: #000;
  padding: 0 10px;
  cursor: pointer;
  font: inherit;
  outline: none;
  transition: color 0.18s;
  text-decoration: none;
  box-shadow: none;
  user-select: none;
}

.topbar-nav .nav-link.active {
  text-decoration: underline;
  color: var(--accent);
  background: none !important;
  border-radius: 0 !important;
}

[data-theme="dark"] .topbar-nav .nav-link {
  color: #fff;
}

[data-theme="light"] .topbar-nav .nav-link {
  color: #000;
}

.topbar-nav .nav-link.active {
  text-decoration: underline;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
}

.topbar-nav .divider {
  color: var(--muted);
  padding: 0 4px;
  user-select: none;
}

/* Hide old header-controls */
.header-controls {
  display: none !important;
}

/* Footer controls */
.footer-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-top: 10px;
  font-size: 1rem;
  gap: 8px;
}
.footer-controls .footer-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 18px;
  justify-content: flex-end;
  width: 100%;
}

input#filter {
  display: none;
  margin-bottom: 8px;
  width: 320px;
  max-width: 100%;
  align-self: flex-end;
}

.footer-controls .footer-link {
  color: var(--fg);
  cursor: pointer;
  font: inherit;
  outline: none;
  padding: 5px;
  transition: color 0.18s;
}

[data-theme="dark"] .footer-controls .footer-link {
  color: #e1e1e1;
}

[data-theme="light"] .footer-controls .footer-link {
  color: #000;
}

.footer-controls .footer-link:hover {
  color: var(--accent);
}

main {
  max-width: 730px;
  margin: 0.6em auto;
  padding: 0 12px;
  background: var(--bg);
}

article {
  padding: 4px 0;
  font-size: 1.1rem;
}

article a {
  color: #000; /* match story-title a for light theme */
}

[data-theme="dark"] article a {
  color: #e1e1e1; /* match story-title a for dark theme */
}

a {
  color: var(--link);
  text-decoration: none;
  word-break: break-word;
}

a:hover {
  text-decoration: underline;
}

a:visited {
  color: #888 !important;
  filter: grayscale(1);
}

small {
  display: inline;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.comments-link {
  color: var(--muted) !important;
}

nav.pagination {
  text-align: center;
  margin: 1.5em 0;
}

nav.pagination a {
  text-decoration: none;
  margin: 0 6px;
  display: inline-block;
}

/* Make only story title links less white (muted) */
.story-title a {
  color: #000; /* pure black for light theme */
}

[data-theme="dark"] .story-title a {
  color: #e1e1e1; /* muted for dark theme */
}

.story-title {
  color: #000;
}
[data-theme="dark"] .story-title {
  color: #e1e1e1;
}

/* Mobile tweaks */
@media (max-width: 750px) {
  header {
    align-items: flex-start;
    padding: 8px 10px;
  }

  .header-controls {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }

  .footer-controls {
    align-items: stretch;
    gap: 8px;
  }
  .footer-controls .footer-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 10px;
  }
  input#filter {
    width: 100%;
    max-width: 100vw;
    margin-bottom: 8px;
    align-self: stretch;
  }

  nav.pagination a {
    padding: 10px 18px;
    font-size: 1.2rem;
    margin: 8px 12px;
  }

  header h1 {
    margin: 0 0 12px 0;
    padding-right: 0;
    padding-bottom: 0;
    padding-top: 6px;
  }
  .topbar-nav {
    margin-bottom: 8px;
    padding-top: 0;
    padding-bottom: 6px;
  }
}
footer {
    text-align: right;
    padding: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.story-title a,
.topbar-nav .nav-link {
  color: #000 !important;
}
[data-theme="dark"] .story-title a,
[data-theme="dark"] .topbar-nav .nav-link {
  color: #e1e1e1 !important;
}
