:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --ink: #171512;
  --muted: #6d665d;
  --hairline: #24211d;
  --rule: #d6cec0;
  --accent: #b91718;
  --accent-soft: #f1d7d2;
  --panel: #fffaf0;
  --shadow: rgba(32, 27, 20, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.masthead {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 24px;
  padding: 20px 0 24px;
  border-bottom: 3px solid var(--hairline);
}

.masthead > div:not(.edition) {
  min-width: 0;
  text-align: center;
}

.edition {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.kicker,
.subtitle {
  margin: 0;
  text-align: center;
}

.kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  text-align: center;
}

.masthead-title-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 8vw, 108px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0;
  white-space: nowrap;
}

.masthead-title-button:hover,
.masthead-title-button:focus-visible {
  color: var(--accent);
}

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

.menu-button {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 48px;
  height: 48px;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  visibility: hidden;
  pointer-events: none;
}

.menu-button span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-button.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-button.is-open span:nth-child(2) {
  opacity: 0;
}

.menu-button.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.menu-panel {
  display: block;
}

.paper-nav {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--hairline);
}

.nav-tab {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.nav-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.controls {
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline);
}

.filter-panel {
  display: grid;
  gap: 14px;
}

.filter-group {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: start;
}

.filter-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 36px;
}

.menu-sort-group {
  display: grid;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.compact-chips {
  gap: 8px;
}

.chip {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  cursor: pointer;
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.mobile-sort-bar {
  display: none;
  gap: 8px;
  align-items: center;
  margin: 12px 0 0;
}

.mobile-sort-bar .chip {
  min-width: 84px;
  min-height: 34px;
  padding: 0 14px;
}

.paper-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  padding-top: 28px;
}

.lead-section,
.articles-section,
.webinar-section,
.fact-note {
  min-width: 0;
}

.loading-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
  padding: 18px 0 20px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.loading-panel[hidden] {
  display: none;
}

.loading-panel-text {
  display: grid;
  gap: 4px;
}

.loading-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loading-panel strong {
  font-size: 18px;
}

.loading-panel span {
  color: var(--muted);
}

.loading-meter {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.4);
}

.loading-meter span {
  display: block;
  width: 8%;
  height: 100%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.loading-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.loading-steps li {
  min-height: 30px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.25);
}

.loading-steps li.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 800;
}

.loading-steps li.done {
  color: var(--ink);
}

.loading-panel.is-complete .loading-meter span {
  background: var(--ink);
}

.loading-panel.is-error .loading-meter span {
  background: var(--accent);
}

.section-label,
.section-row h2,
.source-rail h2,
.webinar-section h2,
.fact-note h2 {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lead-story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 40%);
  gap: 28px;
  min-height: 320px;
  padding: 22px 0 28px;
  border-bottom: 1px solid var(--rule);
}

.lead-story h2 {
  margin: 8px 0 18px;
  font-family: Georgia, "Times New Roman", "Yu Mincho", serif;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: 0;
}

.lead-story p {
  color: var(--muted);
  line-height: 1.8;
}

.lead-image,
.image-placeholder {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--rule);
  background:
    linear-gradient(135deg, rgba(185, 23, 24, 0.18), transparent),
    linear-gradient(45deg, #1e2b32, #0f1113);
  object-fit: cover;
}

.lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 22px;
}

.read-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  background: var(--ink);
  color: white;
  text-decoration: none;
}

.source-rail {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding-left: 28px;
  border-left: 1px solid var(--rule);
}

.source-rail-menu {
  display: none;
}

.rail-header,
.section-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 16px;
}

.lead-heading-row {
  margin-bottom: 0;
}

#statusText,
#webinarStatusText,
#sourceCount {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#sourceCount {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.selected-source-link {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.external-link-icon {
  font-size: 11px;
  line-height: 1;
}

.source-list {
  display: grid;
  gap: 24px;
}

.source-group {
  display: grid;
  gap: 12px;
}

.source-group h3 {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.source-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.source-filter-button {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.source-filter-content {
  display: grid;
  gap: 4px;
}

.source-state-icon {
  margin-top: 4px;
  width: 10px;
  height: 10px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: transparent;
}

.source-filter-button strong {
  font-size: 14px;
}

.source-filter-button strong span {
  color: var(--muted);
  font-weight: 400;
}

.source-url-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.source-filter-button:hover .source-url-text {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.source-item.active strong,
.source-filter-button:hover strong {
  color: var(--accent);
}

.source-item.active .source-state-icon {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--paper);
}

.source-item.active {
  border-bottom-color: var(--accent);
}

.source-item-link .source-filter-button {
  cursor: alias;
}

.source-clear-button {
  min-height: 38px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.articles-section {
  grid-column: 1;
}

.webinar-section {
  grid-column: 1 / -1;
  padding-top: 10px;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
}

.webinar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  border-top: 1px solid var(--rule);
}

.webinar-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.load-more-button {
  display: block;
  width: min(320px, 100%);
  min-height: 44px;
  margin: 24px auto 0;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-weight: 800;
}

.load-more-button:hover,
.load-more-button:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
}

.load-more-button[hidden] {
  display: none;
}

.article-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 228px;
  padding: 20px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.article-card:nth-child(3n) {
  border-right: 0;
}

.webinar-grid .article-card:nth-child(3n) {
  border-right: 1px solid var(--rule);
}

.webinar-grid .article-card:nth-child(4n) {
  border-right: 0;
}

.articles-grid .article-card {
  display: flex;
  min-height: 206px;
  padding: 20px;
}

.articles-grid .article-meta {
  display: flex;
}

.articles-grid .article-source {
  align-self: auto;
}

.articles-grid .save-button {
  margin-left: auto;
}

.articles-grid .article-card h3 {
  max-width: none;
  min-height: calc(22px * 1.28 * 3);
  font-family: Georgia, "Times New Roman", "Yu Mincho", serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.28;
}

.articles-grid .article-card h3 a {
  -webkit-line-clamp: 3;
}

.articles-grid .article-detail {
  max-width: none;
  min-height: calc(14px * 1.65 * 2);
  font-size: 14px;
  line-height: 1.65;
  -webkit-line-clamp: 2;
}

.articles-grid .article-footer {
  justify-content: space-between;
}

.text-lead-story {
  display: block;
  min-height: 0;
  padding-bottom: 24px;
}

.text-lead-story > div {
  max-width: 960px;
}

.text-lead-story h2 {
  font-family: Georgia, "Times New Roman", "Yu Mincho", serif;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.2;
}

.article-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.35);
}

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

.article-meta,
.article-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.article-score {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.save-button {
  min-height: 30px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 10px;
}

.save-button.saved {
  border-color: var(--accent);
  color: var(--accent);
}

.lead-save-button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--ink);
}

.article-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Yu Mincho", serif;
  font-size: 22px;
  line-height: 1.28;
  letter-spacing: 0;
  min-height: calc(22px * 1.28 * 3);
}

.article-card h3 a {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.article-detail {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  min-height: calc(14px * 1.65 * 2);
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.article-footer {
  margin-top: auto;
}

.article-tag {
  color: var(--accent);
}

.fact-note {
  grid-column: 1 / -1;
  margin-top: 24px;
  padding: 18px 0 0;
  border-top: 3px double var(--hairline);
}

.fact-note p {
  max-width: 820px;
  color: var(--muted);
  line-height: 1.7;
}

.fact-note ul {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.fact-note a {
  color: var(--accent);
}

.skeleton {
  display: block;
  height: 14px;
  margin: 0 0 16px;
  background: linear-gradient(90deg, #e7ddce, #f8f1e7, #e7ddce);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton.short {
  width: 26%;
}

.skeleton.title {
  width: 88%;
  height: 56px;
}

.skeleton.line {
  width: 80%;
}

.skeleton.narrow {
  width: 54%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.empty-state {
  padding: 32px 0;
  color: var(--muted);
  line-height: 1.8;
}

@media (max-width: 1040px) {
  .masthead {
    grid-template-columns: 1fr;
  }

  .edition {
    position: static;
    transform: none;
    display: flex;
    grid-column: auto;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    text-align: center;
    white-space: nowrap;
  }

  .edition span + span::before {
    content: "/";
    margin-right: 8px;
    color: var(--rule);
  }

  .controls,
  .paper-grid,
  .lead-story {
    grid-template-columns: 1fr;
  }

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

  .filter-group {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filter-label {
    line-height: 1.4;
  }

  .source-rail,
  .articles-section {
    grid-column: auto;
    grid-row: auto;
  }

  .source-rail {
    padding-left: 0;
    border-left: 0;
  }

  .source-rail-desktop {
    display: none;
  }

  .source-rail-menu {
    display: grid;
    grid-column: auto;
    grid-row: auto;
    gap: 0;
    margin-top: 18px;
    padding: 18px 0 0;
    border-top: 1px solid var(--hairline);
    border-left: 0;
  }

  .menu-button {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 20;
    visibility: visible;
    pointer-events: auto;
    width: 44px;
    height: 44px;
    background: var(--paper);
    opacity: 1;
    appearance: none;
    box-shadow: 0 8px 22px var(--shadow);
  }

  .menu-panel {
    display: none;
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 68px;
    z-index: 19;
    max-height: min(76vh, 680px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    border: 1px solid var(--hairline);
    background: var(--paper);
    box-shadow: 0 14px 36px var(--shadow);
  }

  .menu-panel.is-open {
    display: block;
  }

  .paper-nav {
    display: grid;
    gap: 4px;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    overflow: visible;
    border-bottom: 0;
  }

  .nav-tab {
    justify-content: flex-start;
    width: 100%;
    border: 1px solid var(--rule);
    border-bottom-width: 1px;
    text-align: left;
  }

  .nav-tab.active {
    border-color: var(--accent);
    background: rgba(185, 23, 24, 0.08);
  }

  .controls {
    padding: 14px 0 0;
    border-bottom: 0;
  }

  .menu-sort-group {
    display: none;
  }

  .mobile-sort-bar {
    display: inline-flex;
  }

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

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

  .article-card:nth-child(3n) {
    border-right: 1px solid var(--rule);
  }

  .article-card:nth-child(2n) {
    border-right: 0;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 28px, 1440px);
    padding-top: 6px;
  }

  .masthead {
    display: block;
    padding: 8px 0 14px;
  }

  .edition {
    position: static;
    transform: none;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .masthead > div:not(.edition) {
    padding-right: 0;
  }

  .edition span + span::before {
    content: "/";
    margin-right: 8px;
    color: var(--rule);
  }

  h1 {
    min-width: 0;
  }

  .masthead-title-button {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(30px, 10vw, 42px);
    line-height: 0.9;
    text-overflow: clip;
  }

  .subtitle {
    margin-bottom: 8px;
    font-size: 13px;
  }

  .articles-grid {
    grid-template-columns: 1fr;
  }

  .webinar-grid {
    grid-template-columns: 1fr;
  }

  .article-card,
  .articles-grid .article-card,
  .webinar-grid .article-card,
  .article-card:nth-child(2n),
  .article-card:nth-child(3n) {
    border-right: 0;
    min-height: 0;
    padding: 18px 0;
  }
}
