:root {
  --navy: #000000;
  --navy-soft: #2E2E2E;
  --white: #FFFFFF;
  --gray-text: #4B4B4B;
  --gray-bg: #F5F5F5;
  --border: #E0E0E0;
  --gold: #C9A227;
  --danger: #C0392B;
  --party-blue: #003B96;
  --radius: 14px;
  --max-width: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--gray-bg);
  color: #1A1A1A;
}

body {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 64px;
  background: var(--white);
  transition: max-width 0.2s ease;
}

/* 반응형: 화면이 넓어질수록 카드 폭도 함께 넓어진다 */
@media (min-width: 768px) {
  :root { --max-width: 720px; }
  main { padding: 24px 32px; }
}
@media (min-width: 1024px) {
  :root { --max-width: 1040px; }
  main { padding: 32px 44px; }
  .section-title { font-size: 17px; }
  .link-row .link-name { font-size: 15px; }
  .chip-avatar { width: 60px; height: 60px; font-size: 17px; }
}

/* 상단바 */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  color: var(--white);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 1px;
}
.topbar .brand .brand-accent { color: var(--party-blue); }

/* 하단 탭바 */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #9B9B9B;
  font-size: 11px;
  cursor: pointer;
}
.tab-btn .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 20px;
  line-height: 1;
}
.tab-btn.active { color: var(--navy); font-weight: 700; }

/* 공통 섹션 */
main { flex: 1; padding: 16px; }
section { margin-bottom: 24px; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* HOME - 배너 */
.keyword-banner {
  background: var(--navy);
  color: var(--white);
  padding: 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  overflow: hidden;
}
.keyword-banner .label {
  display: inline-block;
  font-size: 11px;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.keyword-slider {
  overflow: hidden;
  height: 94px; /* 3줄(26px) + gap 2개(8px) */
}
.keyword-slide-track {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.keyword-slide-item {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.keyword-slide-item .keyword-rank {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  font-size: 11px;
}
.keyword-slide-item .keyword-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.keyword-slide-item--active {
  color: var(--white);
  font-size: 17px;
  font-weight: 800;
}
.keyword-slide-item--active .keyword-rank {
  background: var(--white);
  color: var(--navy);
}
.keyword-slide-item:hover { color: var(--white); }

/* 주간베스트 슬라이더 (3개씩 노출, 2.5초마다 한 칸씩 가로로 슬라이드) */
.best-slider {
  overflow: hidden;
}
.best-track {
  display: flex;
  gap: 10px;
  touch-action: pan-y; /* 가로 스와이프는 JS가 처리, 세로 스크롤은 그대로 둔다 */
  cursor: grab;
  user-select: none;
}
.best-track:active { cursor: grabbing; }
.best-card {
  flex: 0 0 calc((100% - 20px) / 3);
  min-width: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.best-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--navy-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 16px;
  overflow: hidden;
}
.best-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.best-thumb .play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.best-info { min-width: 0; padding: 8px; }
.best-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.best-channel {
  font-size: 12px;
  color: var(--gray-text);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.best-channel .badge-todo { margin-left: 4px; }

/* 그리드 (인기채널, 숏컷) */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.chip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}
.chip-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  position: relative;
  overflow: hidden;
}
.chip-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chip-label {
  font-size: 11px;
  text-align: center;
  line-height: 1.3;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortcut-row {
  display: flex;
  gap: 8px;
}
.shortcut-btn {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  background: var(--gray-bg);
}

/* 광고 배너 */
.ad-banner {
  display: block;
  background: var(--gray-bg);
  border: 1px dashed #D0D0D0;
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: inherit;
}
.ad-banner .ad-title { font-size: 13px; font-weight: 700; color: var(--navy); }
.ad-banner .ad-sub { font-size: 11.5px; color: var(--gray-text); margin-top: 4px; }
.ad-slot-wrap {
  width: 100%;
  overflow: hidden;
  margin-top: 8px;
}
.ad-slot-wrap--fixed {
  display: flex;
  justify-content: center;
}
.ad-slot {
  transform-origin: top left;
  margin-left: 8px;
}
.ad-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--white);
  background: var(--gold);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.ad-disclosure { font-size: 10.5px; color: #9B9B9B; margin-top: 6px; }

/* HOME - 지금 알아야 할 토막 경제 */
.econ-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.econ-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--white);
  cursor: pointer;
}
.econ-label { font-size: 11px; color: var(--gray-text); font-weight: 600; }
.econ-value { font-size: 18px; font-weight: 700; color: var(--navy); margin: 4px 0 6px; }
.econ-note { font-size: 11px; line-height: 1.4; color: var(--gray-text); }

/* HOME - 더불어민주당 주요 일정 (주간 달력) */
.mj-schedule {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
}
.mj-week-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.mj-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--gray-text);
  font-size: 11px;
}
.mj-tab-date {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 13px;
  font-weight: 700;
  color: #1A1A1A;
  border-radius: 50%;
}
.mj-tab.active { background: var(--gray-bg); }
.mj-tab.active .mj-tab-date { background: var(--navy); color: var(--white); }
.mj-day-detail { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.mj-person-name { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.mj-event { font-size: 12px; line-height: 1.5; color: #333333; margin-bottom: 6px; }
.mj-event:last-child { margin-bottom: 0; }
.mj-event-time { font-weight: 700; color: var(--party-blue); margin-right: 6px; }
.mj-event-place { font-size: 11px; color: var(--gray-text); }
.mj-source {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border);
  text-align: right;
  font-size: 10px;
  color: #9B9B9B;
}
.mj-source a { color: #9B9B9B; }

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title-row .section-title { margin: 0; }
.mj-month-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--navy);
  background: var(--gray-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
}

/* 월별일정보기 팝업 (이슈브리핑 팝업 껍데기 재사용) */
.mj-month-card { position: relative; }
.mj-month-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg);
  color: var(--gray-text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mj-month-weekdays,
.mj-month-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.mj-month-weekdays {
  margin-top: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--gray-text);
  text-align: center;
}
.mj-month-day {
  position: relative;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  color: #1A1A1A;
  border: none;
  background: none;
  cursor: pointer;
}
.mj-month-day.empty { cursor: default; }
.mj-month-day-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.mj-month-day .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--party-blue); }
.mj-month-day.active .mj-month-day-num { background: var(--navy); color: var(--white); }
.mj-month-day.active .dot { background: var(--party-blue); }
.mj-month-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  max-height: 260px;
  overflow-y: auto;
}

/* 리스트형 아이템 (유튜브/커뮤니티) */
.category-block { margin-bottom: 18px; }
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  text-decoration: none;
  color: inherit;
}
.link-row .link-name { font-size: 14px; font-weight: 600; }
.link-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.link-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.link-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.link-grid { display: block; }
@media (min-width: 768px) {
  .link-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 12px; }
  .link-grid .link-row { margin-bottom: 0; }
}
@media (min-width: 1024px) {
  .link-grid { grid-template-columns: repeat(3, 1fr); }
}
.link-row .link-note { font-size: 11px; color: #B0472C; margin-top: 2px; }

/* 유튜브 - 채널 카드 (헤더 + 최신 영상 3개) */
.channel-list { display: flex; flex-direction: column; gap: 10px; }
.channel-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}
.channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
}
.channel-header .link-note { font-size: 11px; color: #B0472C; margin-top: 2px; }
.channel-videos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
}
.channel-videos--empty {
  display: block;
  padding: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: #9B9B9B;
  font-size: 12px;
}
.video-item { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.video-thumb {
  position: relative;
  width: 120px;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  background: var(--navy-soft);
  border-radius: 6px;
  overflow: hidden;
}
.video-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-thumb svg { position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; }
.video-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: #1A1A1A;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 768px) {
  .channel-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (min-width: 1024px) {
  .channel-list { grid-template-columns: repeat(3, 1fr); }
}
.star-btn {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: #DDDDDD;
  padding: 4px;
}
.star-btn.active { color: var(--gold); }

.badge-todo {
  font-size: 10px;
  color: var(--white);
  background: #B0472C;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.empty-state {
  text-align: center;
  color: #9B9B9B;
  font-size: 13px;
  padding: 30px 0;
}

/* 이슈브리핑 - 홈 화면 제목 리스트 */
.issue-title-list { display: block; }
.issue-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  text-decoration: none;
  color: inherit;
}
.issue-title-text {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 정당 히스토리 - 목록 항목의 시기 배지 */
.party-history-period {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  background: var(--gray-bg);
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.issue-more-btn {
  display: block;
  text-align: center;
  padding: 10px 0;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  background: var(--gray-bg);
}

/* 이슈브리핑 - 기사 카드 */
.issue-article {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.issue-article-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 6px;
  line-height: 1.35;
}
.issue-article-date { font-size: 12px; color: var(--gray-text); margin-bottom: 10px; }
.issue-article-content { font-size: 14px; line-height: 1.6; color: #333333; white-space: pre-line; }

/* 이슈브리핑 - 풀팝업 (탭하면 열리고, 다시 탭하면 닫힘) */
.issue-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  padding: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.issue-popup-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: var(--max-width);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}
.issue-popup-card::-webkit-scrollbar { width: 8px; }
.issue-popup-card::-webkit-scrollbar-track { background: transparent; }
.issue-popup-card::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}
.issue-popup-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 8px;
  line-height: 1.35;
}
.issue-popup-date { font-size: 12px; color: var(--gray-text); margin-bottom: 12px; }
.issue-popup-content { font-size: 14px; line-height: 1.7; color: #333333; white-space: pre-line; }
/* 꾹 누르면 전체 복사되므로, 네이티브 텍스트선택/컨텍스트메뉴가 끼어들지 않게 막는다 */
.issue-popup-title,
.issue-popup-date,
.issue-popup-content {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.issue-copy-toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 200;
  pointer-events: none;
  animation: issueCopyToastFade 1.5s ease forwards;
}
@keyframes issueCopyToastFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(6px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.issue-popup-references {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.issue-popup-ref-heading { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.issue-popup-ref-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.issue-popup-ref-item a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--gray-bg);
}
.issue-popup-ref-source { font-size: 11px; font-weight: 700; color: var(--party-blue); }
.issue-popup-ref-title { font-size: 13px; color: #333333; line-height: 1.4; }

/* MORE 탭 */
.more-item {
  display: block;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  font-size: 14px;
}
.disclaimer-box {
  background: var(--gray-bg);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--gray-text);
  margin-bottom: 16px;
}
.disclaimer-box .disclaimer-list {
  margin: 0;
  padding-left: 18px;
}
.disclaimer-box .disclaimer-list li { margin-bottom: 6px; }
.disclaimer-box .disclaimer-list li:last-child { margin-bottom: 0; }
.version-info {
  text-align: center;
  font-size: 11px;
  color: #B8B8B8;
  padding: 16px 0 4px;
}

/* MORE 탭 - 설정 */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--white);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.setting-label { font-size: 14px; font-weight: 700; color: var(--navy); }
.setting-desc { font-size: 12px; color: var(--gray-text); margin-top: 3px; }

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 13px;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.switch.on { background: var(--navy); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }
.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch.on .switch-knob { transform: translateX(20px); }
