:root {
  --bg: #f3f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #141618;
  --muted: #666a70;
  --line: #dfddd6;
  --line-strong: #cac7be;
  --accent: #8b1e24;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Archivo", sans-serif;
}

.app-shell {
  width: min(1100px, calc(100% - 20px));
  margin: 10px auto 28px;
}

.topbar,
.headline-panel,
.warning-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.topbar {
  padding: 18px;
}

.topbar__brand {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.98rem;
}

.topbar__controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.control-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.scope-toggle {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #f7f5ef;
}

.scope-button,
.refresh-button,
.source-pill {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.scope-button,
.refresh-button {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.scope-button {
  position: relative;
}

.scope-button.is-active {
  background: var(--ink);
  color: white;
}

.scope-button.is-loading {
  padding-right: 36px;
}

.scope-button.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.refresh-button {
  border: 1px solid var(--line-strong);
  background: white;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.status-row strong {
  color: var(--ink);
}

.source-filters,
.source-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-filters {
  margin-top: 14px;
}

.source-summary {
  margin-top: 10px;
}

.source-pill,
.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.source-pill {
  border: 1px solid var(--line-strong);
  background: white;
}

.source-pill.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.summary-chip {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fbfaf6;
}

.summary-chip__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.content {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.headline-panel {
  padding: 14px 0 0;
  overflow: hidden;
}

.headline-panel__header {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--line);
}

.headline-panel__header h2 {
  font-size: 1.2rem;
}

.headline-list {
  display: grid;
  transition: opacity 160ms ease;
}

.headline-list.is-loading-sort {
  opacity: 0.58;
}

.headline-item {
  border-bottom: 1px solid var(--line);
}

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

.headline-item__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
}

.headline-item__content {
  display: block;
  padding: 4px 6px;
  margin: -4px -6px;
  color: inherit;
  cursor: pointer;
  transition: background-color 160ms ease;
  border-radius: 12px;
}

.headline-item__content:hover,
.headline-item__content.is-open {
  background: #faf8f1;
}

.headline-item__content:focus-visible {
  outline: 2px solid var(--item-accent, var(--accent));
  outline-offset: 2px;
}

.headline-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.headline-item__rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--item-accent, var(--accent)) 14%, white);
  color: var(--item-accent, var(--accent));
  font-weight: 700;
}

.headline-item__source {
  text-decoration: none;
}

.headline-item__source:hover {
  text-decoration: underline;
}

.headline-item__section,
.headline-item__time {
  color: var(--muted);
}

.headline-item__title {
  font-size: 1.03rem;
  line-height: 1.38;
  font-weight: 600;
}

.headline-item__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.headline-item__action {
  align-self: center;
  min-width: 118px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.headline-item__action:hover:not(:disabled),
.headline-item__action.is-open {
  border-color: var(--item-accent, var(--accent));
  background: color-mix(in srgb, var(--item-accent, var(--accent)) 8%, white);
}

.headline-item__action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.headline-item__summary-toggle {
  min-width: 42px;
  width: 42px;
  padding: 10px 0;
  font-size: 1rem;
  line-height: 1;
}

.headline-item__summary {
  margin: 0 16px 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--item-accent, var(--accent));
  border-radius: 0 12px 12px 0;
  background: #fbfaf6;
}

.headline-item__summary-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.headline-item__summary-body {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.55;
}

.headline-item__summary-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.headline-item__summary-list li {
  padding-left: 2px;
}

.headline-item__summary-note {
  color: var(--ink);
}

.headline-item__summary-actions {
  margin-top: 12px;
}

.headline-item__summary-comments-toggle {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--item-accent, var(--accent));
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.headline-item__summary-comments-toggle:hover,
.headline-item__summary-comments-toggle.is-open {
  text-decoration: underline;
}

.headline-item__comments {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.headline-item__comments-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.headline-item__comments-count {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.comment-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.comment-form__name,
.comment-form__text {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.comment-form__text {
  resize: vertical;
}

.comment-form__actions {
  display: flex;
  justify-content: flex-end;
}

.comment-form__submit {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

.comment-form__submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.headline-item__comments-list {
  display: grid;
  gap: 10px;
}

.comment-item,
.comment-empty {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

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

.comment-item__meta strong {
  font-size: 0.9rem;
}

.comment-item__meta time,
.comment-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.comment-item__text {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.5;
}

.headline-empty {
  padding: 18px 16px 20px;
  color: var(--muted);
}

.warning-panel {
  padding: 14px 16px;
}

.warning-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

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

.warning-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 12px, 100%);
    margin-top: 6px;
  }

  .topbar,
  .headline-panel,
  .warning-panel {
    border-radius: 14px;
  }

  .topbar {
    padding: 14px;
  }

  .topbar__controls {
    justify-content: flex-start;
  }

  .control-row {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .headline-item__row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 13px 14px;
  }

  .headline-item__actions {
    justify-content: flex-start;
  }

  .headline-item__action {
    justify-self: start;
    min-width: 0;
  }

  .headline-panel__header {
    padding: 0 14px 12px;
  }

  .headline-item__comments-head,
  .comment-item__meta {
    flex-direction: column;
    align-items: flex-start;
  }
}
