:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6760;
  --border: #e4e1da;
  --accent: #b3261e;
  --title: #1d4f91;
  --new: #1b7a3d;
  --new-bg: #e3f4e8;
  --follow-bg: #e7eefa;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1d1c1a;
    --text: #ecebe7;
    --muted: #a19d95;
    --border: #2f2e2b;
    --accent: #ff8a80;
    --title: #9cc2ff;
    --new: #7fd69a;
    --new-bg: #1d3325;
    --follow-bg: #1f2a3d;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.55 Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.masthead,
.tabs,
main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 16px;
}

.masthead {
  padding-top: 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

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

.masthead-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.masthead-tools p {
  margin-right: 6px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.icon-button:hover,
.icon-button[aria-expanded="true"] {
  color: var(--text);
  background: var(--border);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search {
  max-width: 44rem;
  margin: 10px auto 0;
  padding: 0 16px;
}

.search input,
.topic-add input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.button,
.chip {
  font: inherit;
  cursor: pointer;
}

.button {
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.button.secondary {
  background: none;
  color: var(--text);
  border-color: var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

.chip[aria-pressed="true"] {
  border-color: var(--new);
  color: var(--new);
  background: var(--new-bg);
}

.chip button {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.since {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: 1px;
}

.badge.new {
  background: var(--new-bg);
  color: var(--new);
}

.badge.updated {
  background: var(--border);
  color: var(--text);
}

.badge.follow {
  background: var(--follow-bg);
  color: var(--title);
}

.story-update {
  margin: 0 0 6px;
  padding-left: 10px;
  border-left: 3px solid var(--new);
  font-size: 0.95rem;
}

.story-actions {
  display: flex;
  flex-wrap: wrap;
  column-gap: 20px;
  align-items: flex-start;
}

.story-actions details[open] {
  flex-basis: 100%;
}

.story-framing summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
  user-select: none;
}

.story-framing summary::-webkit-details-marker {
  display: none;
}

.story-framing summary::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.story-framing[open] summary::before {
  transform: rotate(45deg);
}

.story-framing summary:hover {
  color: var(--text);
}

.framing-body {
  margin: 6px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.92rem;
}

.framing-body p {
  margin: 0 0 6px;
}

.story.highlight {
  animation: highlight 2.5s ease-out;
}

@keyframes highlight {
  from {
    background: var(--follow-bg);
  }
}

.settings {
  width: min(32rem, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 8px 20px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
}

.settings::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.settings h2 {
  margin: 16px 0 4px;
  font-size: 1.05rem;
}

.settings-close {
  position: sticky;
  top: 0;
  float: right;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.small {
  font-size: 0.82rem;
  margin: 4px 0 8px;
}

.topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.topic-add {
  display: flex;
  gap: 8px;
}

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

.masthead p {
  margin: 0;
  font-size: 0.8rem;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tabs a {
  padding: 10px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.briefing {
  margin: 20px 0 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}

.briefing h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.briefing p {
  margin: 0 0 8px;
}

.social {
  margin: 20px 0 0;
}

.social h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.social-list {
  margin: 0;
  padding-left: 1.4em;
}

.social-list li {
  margin: 8px 0;
  line-height: 1.35;
}

.social-list a {
  color: var(--text);
  text-decoration-color: var(--border);
}

.social-meta {
  display: block;
  font-size: 0.75rem;
}

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

.trending {
  margin: 20px 0 0;
}

.trending h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.trend-group h3 {
  margin: 8px 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.trend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trend-list a {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.trend-list a:hover {
  border-color: var(--accent);
}

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

.story {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.story-title {
  margin: 0;
  font-weight: 700;
  color: var(--title);
  font-size: 1.2rem;
  line-height: 1.3;
}

.story-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--border);
}

.story-image[hidden] {
  display: none;
}

.story-meta {
  margin: 4px 0 8px;
  font-size: 0.8rem;
}

.story-summary {
  margin: 0 0 10px;
}

.story-sources-toggle summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
  user-select: none;
}

.story-sources-toggle summary::-webkit-details-marker {
  display: none;
}

.story-sources-toggle summary::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.story-sources-toggle[open] summary::before {
  transform: rotate(45deg);
}

.story-sources-toggle summary:hover {
  color: var(--text);
}

.story-sources {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 0.9rem;
}

.story-sources li {
  margin: 8px 0;
  line-height: 1.35;
}

.story-sources a {
  color: var(--text);
  text-decoration-color: var(--border);
}

.story-sources a:hover {
  text-decoration-color: var(--accent);
}

.outlet {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#message {
  margin: 24px 0;
}

@media (max-width: 479px) {
  #updated {
    display: none;
  }
}

/* Larger screens: bigger type, and the picture sits beside the story. */
@media (min-width: 900px) {
  html {
    font-size: 18px;
  }

  .masthead,
  .tabs,
  .search,
  main {
    max-width: 56rem;
  }

  .story.has-image {
    display: grid;
    grid-template-columns: 1fr 15rem;
    column-gap: 24px;
  }

  .story.has-image > :not(.story-image) {
    grid-column: 1;
  }

  .story.has-image .story-image {
    grid-column: 2;
    grid-row: 1 / span 4;
    margin: 4px 0 0;
  }
}

@media (min-width: 1600px) {
  html {
    font-size: 20px;
  }
}
