/* ============================================================
   kospi-night — style.css
   모바일 전용 / 다크 모드 / 미니멀 정보 가독성 우선
   기준 폭 ~390px, 큰 화면에서도 모바일 폭(480px max)로 표시
   ============================================================ */

/* ---------- 1. CSS 변수 (컬러 팔레트) ---------- */
:root {
  --bg-primary: #0f1419;
  --bg-card: #1a1f2e;
  --bg-elevated: #232a3d;
  --border: #2a3144;
  --text-primary: #e6e6e6;
  --text-secondary: #a0a8b8;
  --text-muted: #6b7280;
  --accent: #4a9eff;
  --accent-hover: #7cb8ff;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;

  --radius: 10px;
  --transition: 0.2s ease;

  --max-width: 480px;  /* 모바일 전용 — 큰 화면에서도 모바일 폭으로 표시 */
  --pad-x: 16px;
}

/* ---------- 2. 리셋 / 기본 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "맑은 고딕", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
iframe {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover,
a:focus {
  color: var(--accent-hover);
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0 0 0.4em;
  line-height: 1.25;
  font-weight: 700;
}

p {
  margin: 0 0 1em;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
}

.muted {
  color: var(--text-secondary);
}

.small {
  font-size: 13px;
}

/* ---------- 3. 헤더 ---------- */
.site-header {
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #131826 0%, #0f1419 100%);
}

.site-brand {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-title {
  font-size: 24px;
  letter-spacing: -0.01em;
  margin: 0;
}

.site-subtitle {
  margin: 6px 0 14px;
  color: var(--text-secondary);
  font-size: 14px;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
}

.status-pill.is-open {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.35);
}

.status-pill.is-closed {
  color: var(--text-muted);
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.auto-refresh {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
}

.auto-refresh input {
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- 4. 광고 슬롯 ---------- */
/* AdSense 승인 전까지 빈 광고 영역을 숨김.
   승인 후 노출하려면 아래 `display: none;` 한 줄만 지우면 됨
   (마크업·나머지 스타일은 그대로 유지). */
.ad-slot {
  display: none; /* ← AdSense 승인 후 이 줄 삭제하면 광고 영역 복구 */

  margin: 18px auto;
  max-width: var(--max-width);
  min-height: 90px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.015);
}

.ad-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.ad-slot--top {
  margin-top: 20px;
}

.ad-slot--bottom {
  margin-bottom: 30px;
}

/* ---------- 4-1. 내일 코스피 최대 영향 한 줄 ---------- */
.section--impact {
  margin-top: 4px;
}

.impact-headline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.14), rgba(74, 158, 255, 0.04));
  border: 1px solid rgba(74, 158, 255, 0.35);
  border-left: 4px solid var(--accent);
}

.impact-headline__tag {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-hover);
  text-transform: none;
}

.impact-headline__text {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  word-break: keep-all;
}
.impact-headline__time {
  margin-top: 2px;
  color: var(--text-secondary, #9aa3b2);
}

/* ---------- 5. 섹션 ---------- */
.section {
  margin: 26px 0;
}

.section h2 {
  font-size: 19px;
  margin-bottom: 14px;
  color: var(--text-primary);
}

/* ---------- 6. Hero 카드 (코스피200 야간선물) ---------- */
.section--hero {
  margin-top: 22px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero-card {
  position: relative;
  background: linear-gradient(180deg, #1a1f2e 0%, #151a26 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  overflow: hidden;
  transition: border-color var(--transition);
}

/* 등락 색에 따라 좌측 컬러바 표시 */
.hero-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--text-muted);
  transition: background var(--transition);
}

.hero-card.is-up::before    { background: var(--danger);  } /* 한국 관례: 상승=빨강 */
.hero-card.is-down::before  { background: #4a9eff;        } /* 하락=파랑 */
.hero-card.is-flat::before  { background: var(--text-muted); }
.hero-card.is-error::before { background: var(--warning); }

.hero-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.hero-card__head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.hero-card__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.hero-card__symbol {
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-muted);
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.hero-card__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.hero-card__price {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.hero-card__change {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* 한국 관례: 상승=빨강, 하락=파랑 */
.hero-card.is-up    .hero-card__change { color: var(--danger); }
.hero-card.is-down  .hero-card__change { color: #4a9eff; }
.hero-card.is-flat  .hero-card__change { color: var(--text-secondary); }

.hero-card__change .change-arrow {
  font-size: 14px;
}

.hero-card__change .change-pct {
  font-size: 15px;
  opacity: 0.85;
}

/* ---------- Hero OHLC + 거래량 stats 그리드 ---------- */
.hero-card__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 14px;
  margin: 4px 0 14px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.hero-card__stats .stat {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-card__stats dt {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.hero-card__stats dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.hero-card__foot {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
  line-height: 1.5;
}

.hero-session {
  color: var(--text-secondary);
  font-weight: 600;
}

/* 거래중/마감 배지 — hero footer 안에 인라인으로 강조 */
.session-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  line-height: 1.5;
}

.session-badge--open {
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.4);
}

.session-badge--open::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: session-pulse 2s ease-out infinite;
}

@keyframes session-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.session-badge--closed {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border-color: var(--border);
}

.hero-time-sep {
  color: var(--text-muted);
  opacity: 0.5;
}

.hero-abs,
.hero-rel {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.hero-rel {
  color: var(--accent);
  opacity: 0.85;
}

/* ---------- 6b. 보조 지표 그리드 ---------- */
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.indicator-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--transition);
}

.indicator-card.is-empty {
  opacity: 0.55;
}

.indicator-card__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
  letter-spacing: 0.02em;
}

.indicator-card__price {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1.2;
}

.indicator-card__change {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 4px;
  align-items: baseline;
  color: var(--text-muted);
}

.indicator-card.is-up    .indicator-card__change { color: var(--danger); }
.indicator-card.is-down  .indicator-card__change { color: #4a9eff; }
.indicator-card.is-flat  .indicator-card__change { color: var(--text-secondary); }

.indicator-card .change-arrow {
  font-size: 10px;
}

.indicator-card__time {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 5px;
}

.indicator-card__stale {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* 장중/장마감 배지 */
.indicator-card__session {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.2px;
}
.indicator-card__session.is-open {
  color: #34d399;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.32);
}
.indicator-card__session.is-closed {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.indicator-card__updated {
  margin-right: auto;
}

.indicator-skeleton {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- 7. 뉴스 요약 (주제별 카드) ---------- */
.news-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.news-head h2 {
  margin: 0;
}

.news-head__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.news-meta-line {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- Fetch 상태 배지 (시세·뉴스 공용) ---------- */
.fetch-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.fetch-badge:empty {
  display: none;
}

.fetch-badge__mark {
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
}

.fetch-badge--ok {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.06);
}

.fetch-badge--cached {
  color: var(--text-muted);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.fetch-badge--error {
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.06);
}

.news-topics {
  display: grid;
  gap: 12px;
}

.news-topic {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  transition: border-color var(--transition);
}

.news-topic:hover {
  border-color: rgba(74, 158, 255, 0.35);
}

.news-topic__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.news-topic__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.news-topic__bullets {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  display: grid;
  gap: 6px;
}

.news-topic__bullets li {
  position: relative;
  padding-left: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.news-topic__bullets li::before {
  content: "·";
  position: absolute;
  left: 4px;
  top: -2px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}

.news-topic__sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.news-source {
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.015);
  transition: color var(--transition), border-color var(--transition);
  text-decoration: none;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-source:hover,
.news-source:focus {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.news-skeleton {
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- 8. 푸터 ---------- */
.site-footer {
  margin-top: 40px;
  padding: 24px 0 32px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 14px;
}

.footer-nav a {
  color: var(--text-secondary);
  font-size: 13px;
}

.disclaimer {
  line-height: 1.6;
  margin-bottom: 8px;
}

.copyright {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- 9. 접근성 ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- 10. 콘텐츠 페이지 (about / faq / privacy 등) ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 18px 0 4px;
  font-size: 14px;
  color: var(--text-secondary);
}
.back-link::before {
  content: "←";
  font-size: 15px;
}

.content-article {
  margin: 8px 0 32px;
}
.content-article .lead {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}
.content-article h2 {
  font-size: 20px;
  margin: 32px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.content-article h3 {
  font-size: 16px;
  margin: 22px 0 8px;
  color: var(--accent-hover);
}
.content-article p {
  color: var(--text-primary);
  line-height: 1.75;
}
.content-article ul,
.content-article ol {
  margin: 0 0 1.1em;
  padding-left: 1.3em;
  line-height: 1.7;
}
.content-article li {
  margin-bottom: 6px;
}
.content-article li::marker {
  color: var(--accent);
}
.content-article strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* 간단 표 (거래 시간대 등) */
.content-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 20px;
  font-size: 14px;
}
.content-table th,
.content-table td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.content-table th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
}
.content-table td {
  background: var(--bg-card);
  color: var(--text-secondary);
}

/* FAQ 아코디언풍 (details) */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  margin-bottom: 12px;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-weight: 700;
  color: var(--text-primary);
  position: relative;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  color: var(--accent);
  font-weight: 700;
}
.faq-item[open] summary::after {
  content: "−";
}
.faq-item .faq-body {
  padding: 0 16px 14px;
  color: var(--text-secondary);
  line-height: 1.75;
}
.faq-item .faq-body p:last-child {
  margin-bottom: 0;
}

.content-note {
  margin: 24px 0 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-left: 3px solid var(--warning);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
