:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --text: #17201a;
  --muted: #667067;
  --line: #d9ded6;
  --accent: #0f766e;
  --alert: #b42318;
  --chip: #e8eee8;
  --shadow: 0 16px 40px rgba(23, 32, 26, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  max-width: 100%;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 44px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 12px;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  margin: 0 0 6px;
}

p {
  margin: 0;
}

#updatedAt {
  color: var(--muted);
  font-size: 14px;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

#refreshButton,
#overviewButton,
.tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
}

#refreshButton,
#overviewButton {
  border-radius: 8px;
  padding: 0 14px;
}

#overviewButton[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.view {
  display: block;
}

.feed-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.language-tabs {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  padding: 4px;
}

.language-tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  min-height: 32px;
  padding: 0 10px;
}

.language-tab.active {
  background: var(--accent);
  color: #ffffff;
}

.overview-page {
  display: grid;
  gap: 14px;
}

.controls {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.tabs {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tab {
  border-radius: 8px;
  padding: 0 10px;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

#searchInput {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  width: 100%;
}

.result-summary {
  color: var(--muted);
  font-size: 14px;
}

.summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.summary > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.summary span {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.summary label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
  text-transform: uppercase;
}

.feed {
  display: grid;
  gap: 12px;
}

.incoming {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

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

.incoming h2 {
  font-size: 16px;
  line-height: 1.2;
  margin: 0 0 4px;
}

#incomingUpdatedAt {
  color: var(--muted);
  font-size: 13px;
}

#incomingToggle {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
}

.incoming-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.incoming-post {
  background: #f9faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

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

.incoming-meta strong {
  color: var(--text);
}

.incoming-post p,
.incoming-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.media-pill {
  background: #edf4f2;
  border: 1px solid #cce2dc;
  border-radius: 999px;
  color: #22584f;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 6px 8px;
}

.story {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  padding: 18px;
}

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

.unread-dot {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 999px;
  flex: 0 0 auto;
  height: 10px;
  width: 10px;
}

.story.unread .unread-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.story-text {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.5;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: start;
  unicode-bidi: plaintext;
}

.story-headline {
  font-size: 18px;
  font-weight: 700;
  line-height: inherit;
  unicode-bidi: plaintext;
}

.summary-text {
  unicode-bidi: plaintext;
}

.story-text a {
  color: var(--accent);
  font: inherit;
  overflow-wrap: anywhere;
}

.feed-media {
  background: #f2f5f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  margin: 8px 0 12px;
  overflow: hidden;
  position: relative;
}

.feed-media img,
.feed-media video {
  display: block;
  max-height: 430px;
  object-fit: contain;
  width: 100%;
}

.feed-media video {
  background: #000000;
}

.video-download-card {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 12px;
}

.video-download-card div {
  display: grid;
  gap: 3px;
  min-width: 180px;
}

.video-download-card strong {
  font-size: 14px;
}

.video-download-card span {
  color: var(--muted);
  font-size: 12px;
}

.video-download-card a {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  min-height: 34px;
  padding: 8px 10px;
  text-decoration: none;
}

.video-thumb {
  color: inherit;
  text-decoration: none;
}

.video-thumb-fallback {
  align-items: center;
  aspect-ratio: 16 / 9;
  display: grid;
  justify-items: center;
  min-height: 180px;
}

.video-placeholder {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 6px;
  justify-items: center;
  max-width: 80%;
  text-align: center;
}

.video-placeholder strong {
  color: var(--text);
  font-size: 20px;
}

.video-placeholder span {
  font-size: 13px;
}

.video-badge {
  background: rgba(15, 118, 110, 0.92);
  border-radius: 999px;
  bottom: 10px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  left: 10px;
  padding: 6px 10px;
  position: absolute;
}

.video-download-overlay {
  background: rgba(23, 32, 26, 0.78);
  border-radius: 8px;
  bottom: 10px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  position: absolute;
  right: 10px;
}

.meta,
.chips {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.chip {
  background: var(--chip);
  border-radius: 999px;
  color: #314036;
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
}

.score {
  color: var(--accent);
  font-weight: 700;
}

.summary-text {
  font-size: 18px;
  font-weight: 400;
  line-height: inherit;
  margin: 0;
}

.why {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.more {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 10px;
}

.more summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  min-height: 32px;
}

.story-tags,
.story-media,
.story-links {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
}

.more > section + section {
  border-top: 1px solid var(--line);
}

.story-tags h3,
.story-media h3,
.story-links h3 {
  font-size: 14px;
  line-height: 1.2;
  margin: 0;
}

.story-media-list {
  display: grid;
  gap: 8px;
}

.story-media-item {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-media-item .media-pill {
  margin-bottom: 0;
}

.story-media-item span {
  color: var(--muted);
  font-size: 13px;
}

.story-media-item a {
  color: var(--accent);
  font-size: 13px;
}

.detail-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px;
}

.source-links {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.detail-row a,
.source-links a {
  color: var(--accent);
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

@media (max-width: 760px) {
  body {
    -webkit-text-size-adjust: 100%;
  }

  .controls {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .shell {
    padding: 8px 8px 32px;
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  #updatedAt {
    font-size: 12px;
    line-height: 1.35;
  }

  .topbar-actions {
    gap: 6px;
    width: 100%;
  }

  #refreshButton,
  #overviewButton {
    min-height: 34px;
    padding: 0 10px;
  }

  .tabs,
  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feed {
    gap: 8px;
  }

  .feed-toolbar {
    justify-content: stretch;
  }

  .language-tabs {
    width: 100%;
  }

  .story {
    border-radius: 8px;
    box-shadow: none;
    min-width: 0;
    padding: 14px 12px;
  }

  .story-stamp {
    font-size: 13px;
    gap: 7px;
    margin-bottom: 7px;
  }

  .unread-dot {
    height: 9px;
    width: 9px;
  }

  .story-headline {
    font-size: 18px;
  }

  .summary-text {
    font-size: 18px;
  }

  .feed-media img,
  .feed-media video {
    max-height: 320px;
  }

  .video-download-card {
    align-items: stretch;
    display: grid;
  }

  .more summary {
    font-size: 15px;
    min-height: 38px;
  }
}
