:root {
  --orange: #ff6600;
  --background: #ffffff;
  --foreground: #000000;
  --muted: #666666;
  --faint: #e4e4e4;
  --header-background: #ffffff;
  --visited: #777777;
  --focus: #ff6600;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --background: #0b0b0b;
  --foreground: #ffffff;
  --muted: #a0a0a0;
  --faint: #2a2a2a;
  --header-background: #0b0b0b;
  --visited: #888888;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
  scroll-snap-type: y mandatory;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Verdana, Geneva, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

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

a:hover {
  text-decoration: underline;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-background);
  border-bottom: 1px solid var(--faint);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 6px 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-self: start;
  font-weight: 700;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--orange);
  background: var(--orange);
  color: #ffffff;
  font-size: 13px;
  line-height: 1;
}

.feed-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 0;
  justify-self: center;
  overflow-x: auto;
  scrollbar-width: thin;
  white-space: nowrap;
}

.feed-nav a {
  color: var(--muted);
  padding: 5px 0;
  border-bottom: 2px solid transparent;
  font-size: 16px;
  font-weight: 700;
}

.feed-nav a[aria-current="page"] {
  color: var(--orange);
  border-bottom-color: var(--orange);
  text-decoration: none;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--foreground);
  background: var(--faint);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
}

.about-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.about-link:hover {
  color: var(--orange);
}

.page-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 0 18px 32px;
}

.feed-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
  color: var(--muted);
  scroll-snap-align: start;
}

.feed-status h1 {
  margin: 0;
  color: var(--foreground);
  font-size: 14px;
  font-weight: 700;
}

.feed-status p {
  margin: 0;
  flex: 0 0 auto;
  font-size: 12px;
}

.story-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.story {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100svh - 42px);
  padding: 18px 0;
  border-top: 1px solid var(--faint);
  scroll-margin-top: 38px;
  scroll-snap-align: start;
}

.story-main {
  width: min(100%, 860px);
  min-width: 0;
}

.story-title-line {
  min-width: 0;
}

.story-title {
  color: var(--foreground);
  font-size: clamp(34px, 5.8vw, 68px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: 0;
}

.story-title:visited {
  color: var(--visited);
}

.story-domain {
  color: var(--muted);
  display: inline-block;
  margin-top: 10px;
  font-size: 14px;
}

.story-meta {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.story-meta a {
  color: var(--muted);
}

.story-meta a:hover {
  color: var(--orange);
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  font-size: 14px;
  font-weight: 700;
}

.story-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  background: var(--orange);
  color: #ffffff;
  border: 1px solid var(--orange);
  border-radius: 16px;
  text-decoration: none;
}

.story-actions a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.story-preview {
  position: relative;
  height: min(34vh, 280px);
  margin-top: 22px;
  border: 1px solid var(--faint);
  background: var(--background);
  overflow: hidden;
}

.story-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  background: #ffffff;
}

.story-preview p {
  position: absolute;
  left: 8px;
  bottom: 6px;
  margin: 0;
  padding: 2px 4px;
  background: var(--background);
  color: var(--muted);
  font-size: 11px;
}

.loader,
.feed-end,
.error-message {
  margin: 12px 0 0 58px;
  color: var(--muted);
  font-size: 12px;
  scroll-snap-align: start;
}

.error-message {
  color: var(--foreground);
}

.scroll-sentinel {
  height: 1px;
  scroll-snap-align: none;
}

.back-to-top {
  position: fixed;
  left: 14px;
  bottom: 10px;
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--orange);
  color: #ffffff;
  border: 1px solid var(--orange);
  border-radius: 999px;
  font-family: Arial, Helvetica, "Liberation Sans", "Noto Sans Symbols", sans-serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.back-to-top span {
  display: block;
  line-height: 1;
  transform: translateY(-2px);
}

.back-to-top.is-visible {
  display: inline-grid;
}

.top-observer {
  position: absolute;
  top: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .header-inner {
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 5px 8px;
  }

  .brand {
    min-width: 0;
  }

  .feed-nav {
    order: 3;
    grid-column: 1 / -1;
    width: 100%;
    gap: 22px;
  }

  .feed-nav a {
    font-size: 18px;
    padding: 6px 0;
  }

  .theme-toggle {
    justify-self: end;
  }

  .page-shell {
    padding: 0 22px 28px;
  }

  .story {
    min-height: calc(100svh - 74px);
    padding: 12px 0;
    scroll-margin-top: 74px;
  }

  .story-title {
    font-size: clamp(30px, 10vw, 46px);
  }

  .story-domain,
  .story-meta,
  .story-actions {
    font-size: 12px;
  }

  .story-actions {
    gap: 8px;
  }

  .story-actions a {
    flex: 1 1 140px;
    min-height: 44px;
  }

  .story-preview {
    height: 30vh;
    margin-top: 18px;
  }

  .loader,
  .feed-end,
  .error-message {
    margin-left: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
