:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1c1f;
  --muted: #5f5f68;
  --line: #e4e2db;
  --chip: #efede6;
  --accent: #0f5fc4;
  --on-accent: #ffffff;
  --warn: #a64b00;
  --new: #0f7b4f;
  --blog: #0f5fc4;
  --youtube: #c4261d;
  --reddit: #c8430a;
  --x: #1c1c1f;
  --header-height: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1b1c20;
    --text: #ececef;
    --muted: #a0a0aa;
    --line: #2d2e33;
    --chip: #26272c;
    --accent: #8db4ff;
    --on-accent: #10131a;
    --warn: #f0a35c;
    --new: #55cf9b;
    --blog: #8db4ff;
    --youtube: #ff7b72;
    --reddit: #ff9255;
    --x: #ececef;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.status-link {
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.status-link.warn { color: var(--warn); }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.types {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.types::-webkit-scrollbar { display: none; }

.types button {
  flex: none;
  min-height: 34px;
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.types button:hover { color: var(--text); }

.types button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

.search {
  flex: 0 1 170px;
  min-width: 90px;
  height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
}

.topics-filter {
  position: relative;
  margin-top: 8px;
}

.topics-toggle { display: none; }

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  flex: none;
  min-height: 28px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.chip:hover { color: var(--text); }

/* Everything starts selected, so a full-strength fill would turn the whole header into one block of colour. */
.chip[aria-pressed="true"] {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

/* Feed */
.summary {
  margin: 14px 0 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.summary strong { color: var(--new); font-weight: 600; }

.day-heading {
  position: sticky;
  top: var(--header-height);
  z-index: 5;
  margin: 0;
  padding: 18px 0 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.item {
  position: relative;
  display: flow-root;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.day:last-child .item:last-child { border-bottom: 0; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.kind {
  font-weight: 600;
}

.kind-blog { color: var(--blog); }
.kind-youtube { color: var(--youtube); }
.kind-reddit { color: var(--reddit); }
.kind-x { color: var(--x); }

.new-tag {
  color: var(--new);
  font-weight: 600;
}

.item h3 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.item-link {
  color: inherit;
  text-decoration: none;
}

/* The whole row opens the post. Topic buttons sit above this layer. */
.item-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.item:hover h3 .item-link, .item:hover .post-text .item-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.post-text {
  margin: 0;
  font-size: 16px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 10px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--chip);
}

.thumb {
  float: right;
  width: 96px;
  height: 72px;
  margin: 2px 0 6px 14px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--chip);
}

.tags {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 8px;
}

.tag {
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.tag:hover {
  color: var(--accent);
  text-decoration: underline;
}

#sentinel { height: 1px; }

.end, .empty {
  margin: 32px 0 48px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.empty button {
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* Sources dialog */
dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

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

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-head h2 { margin: 0; font-size: 18px; }

.dialog-head button {
  min-height: 32px;
  padding: 2px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.dialog-note {
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

code {
  font-family: Consolas, ui-monospace, monospace;
  font-size: 0.95em;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 7px 8px 7px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th { color: var(--muted); font-size: 12px; font-weight: 600; }

.source-state { white-space: nowrap; }
.source-state.warn { color: var(--warn); }
.source-group { padding-top: 16px; font-weight: 600; }

@media (max-width: 560px) {
  /* The full header would take a fifth of a phone screen, so only the day heading sticks. */
  .top { position: static; }
  .day-heading { top: 0; }
  .topics-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
  }

  .topics-toggle::after {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    margin: -4px 2px 0;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
  }

  .topics-toggle[aria-expanded="true"]::after {
    margin-top: 4px;
    transform: rotate(-135deg);
  }

  .topics {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    max-height: 60vh;
    padding: 4px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
  }

  .topics-filter.open .topics { display: flex; }

  .chip,
  .chip[aria-pressed="true"] {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 4px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font-size: 15px;
    text-align: left;
  }

  .chip::before {
    content: "";
    flex: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--muted);
    border-radius: 4px;
    color: var(--on-accent);
    font-size: 13px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
  }

  .chip[aria-pressed="true"]::before {
    content: "✓";
    border-color: var(--accent);
    background: var(--accent);
  }

  .controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .search { flex: none; width: 100%; font-size: 16px; }
  .media { border-radius: 4px; }
  .thumb { width: 76px; height: 58px; margin-left: 10px; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
