:root {
  --bg: #f7f6f2;
  --ink: #22231f;
  --muted: #777970;
  --line: #dcded6;
  --paper: #fff;
  --accent: #f02d32;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}
button, input {
  font: inherit;
}

button, select, summary {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .5;
}

[hidden] {
  display: none !important;
}

a:focus-visible, button:focus-visible, input:focus-visible, .card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* One phone-style layout at every screen size. */
.shell {
  width: 100%;
  max-width: 900px;
  margin-inline: auto;
  padding-inline: 20px;
}
.reader-header {
  min-height: 108px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 24px;
}
.brand, #pageTitle, .article-page h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.035em;
}

.header-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}
.brand, #pageTitle {
  line-height: 1.05;
}
#pageTitle {
  color: var(--accent);
  margin: 0;
  overflow-wrap: anywhere;
}
#pageTitle:focus { outline: none; }
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
.brand span { color: var(--accent); }
.home-collections {
  padding: 0;
  margin: 0;
  list-style: none;
}
.home-collections a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding-block: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.home-collections a:hover { color: var(--accent); }
.home-collections .library-start { margin-top: 28px; }
.row-chevron { flex-shrink: 0; color: var(--muted); font-size: 26px; font-weight: 400; }
.home-empty { color: var(--muted); font-size: 14px; line-height: 1.5; }
.home-view .article-list {
  margin-bottom: 0;
}
.home-details {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 40px;
}
.today {
  color: var(--muted);
  font-size: 12px;
}

.manage-link {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.manage-link:hover, .manage-link[aria-current="page"] {
  color: var(--accent);
}

/* Article list */
.article-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 60px;
}

.date-group {
  margin: 28px 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}
.date-group:first-child {
  margin-top: 0;
}

.date-count {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 400;
}

.card {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
  padding: 22px 0 26px;
  border-bottom: 1px solid #e7e8e1;
  cursor: pointer;
}
.card-body {
  flex: 1;
  min-width: 0;
}

.card-publication {
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.card .eyebrow {
  color: #b95650;
}

.headline {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  margin: 5px 0 7px;
  font-size: 21px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.card:hover .headline {
  color: var(--accent);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.read-check {
  font-size: 11px;
  line-height: 1;
}

.card-thumbnail {
  position: relative;
  flex: 0 0 auto;
  width: 96px;
  aspect-ratio: 1.91 / 1;
  overflow: hidden;
  border-radius: 4px;
  margin-top: 4px;
  background: #424440;
}
.card-thumbnail:not(:has(img)) {
  display: none;
}

.card-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty {
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}

.empty h2 {
  color: var(--ink);
  font-size: 30px;
  font-weight: 400;
}

/* Article reading */
.article-page {
  width: 100%;
  margin-inline: auto;
  padding: 0 0 60px;
}
.article-page:focus {
  outline: none;
}

.article-main, .reader-content {
  min-width: 0;
  overflow-wrap: anywhere;
}

.article-publication {
  display: inline-block;
  margin-bottom: 14px;
  line-height: 1.5;
}

.article-page h1 {
  margin: 0 0 24px;
}

.article-page a {
  color: var(--accent);
  text-decoration: none;
}

.article-page h1, .article-page h1 a {
  color: var(--ink);
}

.article-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding-block: 12px;
  border-block: 1px solid var(--line);
  margin-bottom: 32px;
  font-size: 12px;
  line-height: 1.5;
}
.article-author {
  font-weight: 500;
}

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

.article-save {
  margin-left: auto;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: inherit;
}

.article-save:hover, .article-save[aria-pressed="true"] {
  color: var(--accent);
}

.reader-content {
  color: #34362f;
  font-size: 20px;
  line-height: 1.55;
}

.reader-content p {
  margin: 0 0 22px;
}

.reader-content img {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin-bottom: 36px;
}

.reader-content figure {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 24px;
}

.reader-content figure img {
  margin-bottom: 0;
}

.reader-content figure:not(:has(figcaption, .wp-caption-text, .caption, .image-caption)) {
  margin-bottom: 36px;
}

.reader-content img:has(+ :is(figcaption, .wp-caption-text, .caption, .image-caption)),
.reader-content :is(a, p):has(+ :is(figcaption, .wp-caption-text, .caption, .image-caption)) img {
  margin-bottom: 0;
}

.reader-content p:has(> img:only-child),
.reader-content p:has(> a:only-child > img:only-child) {
  margin-bottom: 0;
}

.reader-content video, .reader-content iframe {
  max-width: 100%;
}

.reader-content pre, .reader-content table {
  max-width: 100%;
  overflow-x: auto;
}

.reader-content figcaption, .reader-content .wp-caption-text, .reader-content .caption, .reader-content .image-caption {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 8px 0 20px;
}

.reader-content :is(figcaption, .wp-caption-text, .caption, .image-caption) p {
  margin: 0;
  font: inherit;
}

.reader-content blockquote {
  margin: 28px 0;
  padding-left: 24px;
  color: #686b62;
}

.reader-content blockquote p:last-child {
  margin-bottom: 0;
}

.reader-content hr {
  height: 0;
  margin: 28px 0;
  border: 0;
  border-top: 1px solid #e7e8e1;
}

.reader-status {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 24px;
}

/* Manage collections and feeds */
.manage-page {
  min-width: 0;
  padding-bottom: 60px;
}

.manage-tabs {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--line);
}

.manage-tabs button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.manage-tabs button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.manage-tabs button span {
  font-size: 12px;
  font-weight: 400;
}

.manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 18px;
}

.manage-actions button {
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: none;
  color: var(--ink);
  font-size: 13px;
}

#newFeed, #newCollection {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
}

.collection-settings {
  padding-bottom: 16px;
  color: var(--muted);
}

.collection-settings > summary {
  display: none;
}

.collection-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.collection-info {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.collection-title {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}

.collection-title:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.collection-count {
  font-size: 12px;
  line-height: 1.5;
}

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

.collection-tools button, .collection-edit button, .collection-confirm button {
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--muted);
  padding: 7px 8px;
  font-size: 12px;
}

.collection-tools button {
  min-width: 40px;
  min-height: 44px;
  padding: 6px 10px;
  font-size: 17px;
  line-height: 1;
}

.collection-tools button:hover, .collection-edit button:hover, .collection-confirm button:hover {
  background: #e5e5de;
  color: var(--ink);
}

.collection-tools button:disabled {
  opacity: .25;
}

.collection-tools .collection-remove, .collection-confirm .collection-remove {
  color: #b4232c;
}

.collection-edit, .collection-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-size: 12px;
}

.collection-confirm > span {
  flex: 1 1 150px;
}

.collection-edit input {
  flex: 1 1 100px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-size: 13px;
}

.collection-edit button[type="submit"] {
  background: var(--ink);
  color: var(--paper);
}

.collection-edit p, .collection-confirm p {
  flex-basis: 100%;
  margin: 0;
  color: #b4232c;
  font-size: 11px;
}

.collection-edit p:empty, .collection-confirm p:empty, .collection-form p:empty {
  display: none;
}

.collection-form {
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.collection-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
}

.collection-form > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.collection-form input {
  flex: 1 1 120px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.collection-form button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-size: 12px;
}

.collection-form button[type="submit"] {
  background: var(--ink);
  color: var(--paper);
}

.import-message:empty {
  display: none;
}

.collection-form p, .import-message {
  color: var(--muted);
  font-size: 12px;
}

.feed-row {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.feed-row-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.feed-row-heading strong {
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

.feed-title-link:hover {
  color: var(--accent);
}

.feed-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.feed-mode-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.feed-mode-label select {
  max-width: 145px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.feed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.collection-tag {
  position: relative;
  cursor: pointer;
}

.collection-tag input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.collection-tag span {
  display: block;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  font-size: 12px;
}

.collection-tag input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.collection-tag input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.collection-tag input:disabled + span {
  opacity: .5;
}

.feed-options {
  position: relative;
}

.feed-options summary {
  padding: 4px 8px;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.feed-options summary::-webkit-details-marker {
  display: none;
}

.feed-options > div {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 3;
  min-width: 130px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 5px 20px #0001;
}

.feed-options button {
  display: block;
  width: 100%;
  padding: 9px;
  border: 0;
  background: none;
  font-size: 12px;
  text-align: left;
}

.feed-options button:hover {
  background: var(--bg);
}

.feed-options button[data-remove-feed] {
  color: #b4232c;
}

/* Add and rename dialogs */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #0007;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 20px;
  border-radius: 16px;
  background: var(--paper);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 400;
}

.modal p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.modal label {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
}

.modal input, #feedChoice {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  background: var(--paper);
}

#discoveredFeeds {
  margin-block: 12px;
}

#feedChoice {
  border-radius: 8px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.modal-actions button {
  padding: 11px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.modal-actions .primary {
  background: var(--ink);
  color: var(--paper);
}
