:root {
  color-scheme: light;
  --bg: #fef9f0;
  --bg-header-start: #fbbf24;
  --bg-header-end: #f59e0b;
  --bg-filter: #fef3c7;
  --card: #ffffff;
  --card-border-new: #fde68a;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-source: #92400e;
  --accent: #f59e0b;
  --accent-strong: #78350f;
  --divider: #e5e7eb;
  --shadow-unread: 0 2px 10px rgba(0, 0, 0, 0.08);
  --shadow-read: 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 8px 40px rgba(0, 0, 0, 0.18);
  --radius-card: 14px;
  --radius-thumb: 10px;
  --radius-pill: 999px;
  --radius-modal: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top center, rgba(251, 191, 36, 0.2), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0)),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

img {
  display: block;
  max-width: 100%;
}

.page-shell {
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  background: linear-gradient(135deg, var(--bg-header-start), var(--bg-header-end));
  color: var(--accent-strong);
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.9;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 3.9rem);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.count-pill,
.new-pill,
.status-badge,
.source-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.count-pill {
  margin: 0;
  padding: 0.5rem 0.82rem;
  background: rgba(255, 255, 255, 0.52);
  color: var(--accent-strong);
}

.icon-button,
.ghost-button,
.text-button {
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.icon-button {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font-size: 1.2rem;
}

.icon-button:hover:enabled,
.ghost-button:hover:enabled,
.text-button:hover:enabled,
.article-card:hover {
  transform: translateY(-1px);
}

.icon-button.subtle {
  background: rgba(245, 158, 11, 0.12);
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  background: var(--bg-filter);
  border-bottom: 1px solid rgba(146, 64, 14, 0.12);
}

.filter-label {
  margin: 0;
  color: var(--text-source);
  font-size: 0.95rem;
  font-weight: 700;
}

.status-text {
  margin: 0.18rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.filter-actions,
.modal-actions,
.reader-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ghost-button,
.text-button {
  border-radius: var(--radius-pill);
  padding: 0.72rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-strong);
  border: 1px solid rgba(146, 64, 14, 0.14);
}

.ghost-button.strong {
  background: var(--accent);
  color: #fff8eb;
  border-color: transparent;
}

.text-button {
  background: transparent;
  color: var(--accent-strong);
  padding-inline: 0;
}

.app-main {
  padding: 1rem 1rem 2rem;
}

.shelf-view,
.reader-view {
  width: 100%;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.article-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 0.85rem;
  width: 100%;
  padding: 0.92rem;
  border-radius: var(--radius-card);
  background: var(--card);
  border: 1px solid transparent;
  box-shadow: var(--shadow-unread);
  text-align: left;
  color: var(--text);
}

.article-card.read {
  opacity: 0.5;
  box-shadow: var(--shadow-read);
}

.article-card.new {
  border-color: var(--card-border-new);
}

.card-copy {
  min-width: 0;
}

.card-kicker,
.card-meta,
.reader-meta,
.reader-badges {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.card-kicker {
  margin-bottom: 0.45rem;
}

.new-pill {
  padding: 0.28rem 0.58rem;
  background: var(--bg-filter);
  color: var(--accent-strong);
}

.source-pill,
.status-badge {
  padding: 0.22rem 0.5rem;
}

.source-pill {
  background: rgba(245, 158, 11, 0.11);
  color: var(--text-source);
}

.status-badge {
  background: rgba(120, 113, 108, 0.11);
  color: var(--text-muted);
}

.status-badge.partial {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-strong);
}

.status-badge.failed {
  background: rgba(190, 24, 93, 0.12);
  color: #9d174d;
}

.article-card h3 {
  margin-bottom: 0.35rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.card-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.card-thumb,
.thumb-placeholder {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-thumb);
}

.card-thumb {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fff4cf, #fde68a);
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.thumb-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 0.15rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-divider::before,
.article-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.empty-state,
.reader-empty {
  display: grid;
  place-items: center;
  min-height: 42vh;
  padding: 2rem;
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.68);
  color: var(--text-muted);
  text-align: center;
  box-shadow: var(--shadow-read);
}

.reader-view {
  display: block;
}

.reader-topbar {
  justify-content: space-between;
  padding: 0.1rem 0.15rem 1rem;
}

.reader {
  min-height: calc(100vh - 12rem);
  padding: 0 0 2rem;
}

.reader-article {
  max-width: 70ch;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  padding: 1.4rem clamp(1rem, 3vw, 2rem) 2rem;
  box-shadow: 0 10px 36px rgba(28, 25, 23, 0.08);
}

.reader-badges {
  margin-bottom: 0.75rem;
}

.reader-title {
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.reader-meta {
  margin: 0.7rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.reader-hero {
  margin: 0 0 1.2rem;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff2bd, #fcd34d);
}

.reader-hero img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}

.reader-body {
  font-size: 0.98rem;
  line-height: 1.8;
  color: var(--text);
}

.reader-body > * + * {
  margin-top: 1em;
}

.reader-body a {
  color: var(--accent-strong);
}

.reader-body img {
  border-radius: 12px;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.36);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(460px, 100%);
  display: grid;
  gap: 0.7rem;
  padding: 1.2rem;
  border-radius: var(--radius-modal);
  background: #fffdf8;
  box-shadow: var(--shadow-modal);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.2rem;
}

.modal-panel label {
  color: var(--text-source);
  font-size: 0.88rem;
  font-weight: 700;
}

.modal-panel input {
  width: 100%;
  border: 1px solid rgba(146, 64, 14, 0.14);
  border-radius: 16px;
  padding: 0.92rem 1rem;
  background: #fff;
  color: var(--text);
}

#api-base-url {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .app-header,
  .filter-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .filter-actions,
  .modal-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .article-card {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .card-thumb,
  .thumb-placeholder {
    width: 48px;
    height: 48px;
  }

  .reader-article {
    padding-inline: 1rem;
  }
}
