:root {
  --black: #000;
  --surface: #0b0d0d;
  --surface-soft: #101313;
  --text: #f7faf6;
  --reading: #e9ede7;
  --support: #d7dcd5;
  --meta: #92988f;
  --line: #242826;
  --connector: #3b4240;
  --accent: #b8ff5e;
  --font: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--black);
  color: var(--text);
  font-family: var(--font);
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.thread-header {
  position: sticky;
  z-index: 20;
  top: 0;
  background: rgba(0, 0, 0, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  width: min(100%, 840px);
  height: 62px;
  margin: 0 auto;
  padding: 0 18px;
}

.back-link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  text-decoration: none;
  transition: background 150ms ease;
}

.back-link:hover {
  background: var(--surface-soft);
}

.header-inner > div {
  display: grid;
  gap: 2px;
}

.header-inner strong {
  font-size: 15px;
}

.header-inner span {
  color: var(--meta);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.header-action {
  min-height: 40px;
  padding: 0 10px;
  background: transparent;
  color: var(--meta);
  cursor: pointer;
  font-size: 10px;
}

.progress-track {
  height: 2px;
  background: transparent;
}

.progress-track i {
  display: block;
  width: var(--thread-progress, 0%);
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.timeline {
  width: min(100%, 840px);
  margin: 0 auto;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.post {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 23px 22px 5px 18px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 70px;
}

.root-post {
  padding-top: 32px;
}

.avatar-column {
  position: relative;
  display: flex;
  justify-content: center;
}

.avatar {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(184, 255, 94, 0.42);
  border-radius: 50%;
  background: #0f140c;
  color: var(--accent);
  font-size: 12px;
  font-style: italic;
  font-weight: 800;
}

.avatar-large {
  width: 43px;
  height: 43px;
}

.thread-line {
  position: absolute;
  top: 48px;
  bottom: -6px;
  left: 50%;
  width: 2px;
  background: var(--connector);
  transform: translateX(-50%);
}

/* 그룹 = 부모 트윗 + 답글 묶음. X처럼 묶음 안은 경계선 없이 연결선만 잇고,
   묶음 사이는 두꺼운 구분대로 대화 단위를 끊는다. */
.group-thread {
  border-bottom: 10px solid var(--surface-soft);
}

.group-thread .post {
  border-bottom: 0;
}

.group-parent {
  padding-bottom: 2px;
}

.group-parent .thread-line {
  top: 44px;
  bottom: 0;
}

.group-title {
  margin: 12px 0 4px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.group-sub {
  margin: 0 0 8px;
  color: var(--meta);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.group-thread .thread-post {
  padding-top: 12px;
}

/* 답글 위쪽 연결선: 셀 사이 여백을 넘어 이전 셀의 아래 연결선과 겹치도록
   넉넉히 위로 뻗는다(같은 위치·색이라 겹침은 보이지 않음). */
.group-thread .thread-post .avatar-column::before {
  position: absolute;
  top: -32px;
  left: 50%;
  width: 2px;
  height: 32px;
  background: var(--connector);
  content: "";
  transform: translateX(-50%);
}

.group-thread .thread-post:not(:last-child) .avatar-column::after {
  position: absolute;
  top: 44px;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--connector);
  content: "";
  transform: translateX(-50%);
}

.post-content {
  min-width: 0;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
  color: var(--meta);
  font-size: 12px;
}

.post-meta strong {
  color: var(--text);
  font-size: 13px;
}

.verified {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  color: #10150d;
  font-size: 9px;
  font-weight: 900;
}

.post-kicker,
.reply-context {
  margin: 12px 0 0;
  color: var(--reading);
  font-size: 13px;
}

.root-post h1 {
  margin: 15px 0 18px;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.05em;
  text-wrap: balance;
}

.root-post h1 em {
  color: var(--accent);
  font-style: normal;
  font-weight: 300;
}

.root-summary {
  max-width: 690px;
  margin: 0 0 24px;
}

.root-summary p {
  margin: 0;
  color: var(--reading);
  font-size: 18px;
  line-height: 1.65;
  letter-spacing: -0.015em;
  text-wrap: pretty;
}

.root-summary p + p {
  margin-top: 16px;
}

.root-brief {
  margin: 27px 0 26px;
  padding: 24px 0 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.root-brief h2 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: -0.025em;
}

.root-brief ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.root-brief li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  padding: 15px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.root-brief li > span {
  padding-top: 2px;
  color: var(--accent);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.root-brief li p {
  display: grid;
  gap: 4px;
  margin: 0;
  color: var(--support);
  font-size: 13px;
  line-height: 1.62;
  text-wrap: pretty;
}

.root-brief li strong {
  color: var(--text);
  font-size: 14px;
}

.root-brief li button {
  display: grid;
  gap: 4px;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.root-brief li button:hover strong {
  color: var(--accent);
}

.video-card {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.map-card {
  display: block;
  padding: 20px 20px 64px;
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(184, 255, 94, 0.09), transparent 60%),
    var(--surface);
  color: var(--support);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", ui-monospace, Menlo, monospace;
}

.video-caption {
  position: absolute;
  right: 20px;
  bottom: 15px;
  left: 20px;
  display: grid;
  gap: 3px;
}

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

.video-caption small {
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
}

.post-actions {
  display: flex;
  justify-content: space-between;
  max-width: 520px;
  margin-top: 12px;
  padding: 4px 0 10px;
}

.post-actions button,
.post-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 8px;
  gap: 7px;
  border-radius: 999px;
  background: transparent;
  color: var(--meta);
  cursor: pointer;
  font-size: 10px;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease, transform 100ms ease;
}

.post-actions button:hover,
.post-actions a:hover {
  background: rgba(184, 255, 94, 0.08);
  color: var(--accent);
}

.post-actions button:active,
.post-actions a:active {
  transform: scale(0.96);
}

.root-actions {
  max-width: 100%;
}

.thread-post {
  position: relative;
}

.reply-context {
  color: var(--meta);
  font-size: 11px;
}

.reply-context span {
  color: var(--accent);
}

.closing-post h2 {
  margin: 11px 0 13px;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.thread-post h3 {
  margin: 10px 0 10px;
  font-size: 17px;
  line-height: 1.4;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.thread-summary {
  max-width: 700px;
}

.thread-summary > p {
  margin: 0;
  color: var(--reading);
  font-size: 16px;
  line-height: 1.78;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.thread-summary > p + p {
  margin-top: 17px;
}

/* 근거 뱃지와 출처 링크를 한 줄에 컴팩트하게 담는다. */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.tag-row .signal,
.tag-row a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  text-decoration: none;
}

.tag-row .signal {
  color: var(--meta);
}

.tag-row .signal.primary {
  border-color: rgba(184, 255, 94, 0.28);
  color: var(--accent);
}

.tag-row a {
  color: var(--support);
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.tag-row a:hover {
  border-color: rgba(184, 255, 94, 0.4);
  background: rgba(184, 255, 94, 0.06);
  color: var(--accent);
}

.tag-row a span {
  color: var(--meta);
  font-size: 9px;
}

.tag-row a:hover span {
  color: var(--accent);
}

.context-panel {
  margin-top: 20px;
  padding: 18px 18px 6px;
  border-left: 2px solid var(--accent);
  background: rgba(184, 255, 94, 0.035);
}

.context-panel h3 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: -0.01em;
}

.context-panel p {
  margin: 0 0 12px;
  color: var(--reading);
  font-size: 15px;
  line-height: 1.72;
}

.watch-list {
  margin: 19px 0;
  padding: 0;
  list-style: none;
}

.watch-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 11px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.watch-list li > span {
  color: var(--accent);
  font-size: 11px;
}

.watch-list p {
  margin: 0;
  color: var(--support);
  font-size: 14px;
  line-height: 1.62;
}

.closing-copy {
  color: var(--reading);
  font-size: 16px;
  line-height: 1.75;
}

dialog {
  width: min(600px, calc(100vw - 32px));
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #080a09;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: absolute;
  top: 19px;
  right: 19px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 19px;
}

.dialog-kicker {
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

dialog h2 {
  margin: 13px 0 24px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.scope-rows {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.scope-rows div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.scope-rows dt,
.scope-rows strong {
  color: var(--meta);
  font-size: 11px;
}

.scope-rows p {
  margin: 0;
  color: var(--reading);
  font-size: 13px;
  line-height: 1.55;
}

.glossary-block {
  margin-top: 22px;
}

.glossary-block > strong {
  display: block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 11px;
}

.glossary-block dl {
  margin: 0;
}

.glossary-block dt {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.glossary-block dd {
  margin: 3px 0 12px;
  color: var(--support);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 700px) {
  .header-inner {
    padding: 0 10px;
  }

  .timeline {
    border-right: 0;
    border-left: 0;
  }

  .post {
    grid-template-columns: 43px 1fr;
    gap: 8px;
    padding: 18px 14px 4px 8px;
  }

  .root-post {
    padding-top: 24px;
  }

  .avatar,
  .avatar-large {
    width: 35px;
    height: 35px;
    font-size: 10px;
  }

  .root-post h1 {
    font-size: 32px;
  }

  .root-summary p {
    font-size: 16px;
  }

  .closing-post h2 {
    font-size: 20px;
  }

  .group-title {
    font-size: 19px;
  }

  .thread-post h3 {
    font-size: 16px;
  }

  .thread-summary > p {
    font-size: 15px;
  }

  .scope-rows div {
    grid-template-columns: 110px 1fr;
  }

  dialog {
    padding: 30px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- header actions: 지난 호 / 범위 확인 --- */
.header-inner .header-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.header-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  transition:
    border-color 150ms ease,
    color 150ms ease;
}

.header-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- data load error banner (shown when opened without a server) --- */
.load-error {
  width: min(100%, 840px);
  margin: 16px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.load-error code {
  padding: 1px 6px;
  border-radius: 5px;
  background: #000;
  color: var(--accent);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}

/* --- archive (지난 호) list --- */
.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  max-height: min(60vh, 520px);
  overflow-y: auto;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  transition: background 150ms ease;
}

.archive-item:hover {
  background: var(--surface-soft);
}

.archive-date {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.archive-tag {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--meta);
  font-size: 11px;
}

.archive-counts {
  margin-left: auto;
  color: var(--meta);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.archive-item[aria-current="true"] {
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.archive-item[aria-current="true"] .archive-date {
  color: var(--accent);
}
