/* GBPRO 스타일 — 다크 기본, 라이트 토글. 상승=빨강 / 하락=파랑 (한국 관례) */
:root {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface2: #232321; --border: rgba(255, 255, 255, .10);
  --text: #f0efec; --text2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --up: #e66767; --down: #3987e5; --up-fill: #e66767; --down-fill: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  /* 공포(파랑) ← 중립(회색) → 탐욕(빨강) 5단계 */
  --b0: #3987e5; --b1: #1c5cab; --b2: #4a4a46; --b3: #a34545; --b4: #e66767;
  --warn: #fab219;
  --radius: 12px;
  --chat-l: 70%; /* 채팅 닉네임 색의 밝기 (라이트 테마에서는 어둡게) */
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f9f9f7; --surface: #fcfcfb; --surface2: #f0efec; --border: rgba(11, 11, 11, .10);
  --text: #0b0b0b; --text2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7;
  --up: #d03b3b; --down: #1c5cab; --up-fill: #e34948; --down-fill: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --b0: #2a78d6; --b1: #86b6ef; --b2: #c3c2b7; --b3: #ef9a99; --b4: #e34948;
  --chat-l: 36%;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.muted { color: var(--muted); } .t2 { color: var(--text2); } .small { font-size: 12px; }

/* ── 헤더 ── */
header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.bar { max-width: 1320px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; height: 52px; }
.logo { font-weight: 800; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.logo span { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav::-webkit-scrollbar { display: none; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--text2); white-space: nowrap; font-weight: 500; }
nav a:hover { background: var(--surface2); }
nav a.on { color: var(--text); background: var(--surface2); font-weight: 700; }
.hdr-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.iconbtn { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--text2); }
.iconbtn:hover { background: var(--surface2); }
.kakao-btn { background: #fee500; color: #191919; font-weight: 700; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
.kakao-btn:hover { filter: brightness(.95); }
.kakao-btn[hidden] { display: none; }
.tape { border-top: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tape::-webkit-scrollbar { display: none; }
.tape-in { max-width: 1320px; margin: 0 auto; padding: 0 16px; display: flex; gap: 22px; height: 34px; align-items: center; font-size: 12.5px; white-space: nowrap; }
.tape-in b { font-weight: 600; margin-right: 6px; }
.tape-in .muted { margin-right: 6px; }

main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 60px; min-height: 70vh; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { color: var(--text2); margin: 4px 0 18px; max-width: 760px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g57 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mt { margin-top: 14px; } .mt2 { margin-top: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { font-size: 13px; font-weight: 700; color: var(--text2); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 a, .more { font-weight: 500; color: var(--muted); font-size: 12px; }
.card h3 a:hover, .more:hover { color: var(--text); }
.sec-title { font-size: 16px; font-weight: 800; margin: 30px 0 4px; }
.sec-sub { color: var(--text2); margin-bottom: 12px; font-size: 13px; max-width: 820px; }

/* ── 게이지 / 지수 ── */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; }
.gauge { width: 100%; max-width: 300px; }
.gauge .score { font-size: 44px; font-weight: 800; fill: var(--text); letter-spacing: -.03em; }
.gauge .lbl { font-size: 11px; fill: var(--muted); }
.band-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-weight: 700; font-size: 13px; background: var(--surface2); }
.band-pill i { width: 8px; height: 8px; border-radius: 50%; }
.cmp { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; margin-top: 12px; }
.cmp div { background: var(--surface2); border-radius: 8px; padding: 6px 8px; text-align: center; }
.cmp small { display: block; color: var(--muted); font-size: 11px; }
.cmp b { font-size: 15px; }
.regime { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--surface2); width: 100%; }
.regime b { font-size: 15px; }
.regime p { color: var(--text2); font-size: 13px; margin-top: 2px; }
.meter { display: grid; grid-template-columns: 96px 1fr 38px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.meter .track { height: 8px; border-radius: 4px; background: var(--surface2); position: relative; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.meter .mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.meter b { text-align: right; }

/* ── 타일 / 표 ── */
.tile { display: flex; flex-direction: column; gap: 2px; }
.tile .nm { color: var(--text2); font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .px { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.tile svg { margin-top: 6px; width: 100%; height: 36px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.tbl-wrap { overflow-x: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 11px; border-radius: 99px; background: var(--surface2); color: var(--text2); font-size: 12.5px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.chip:hover { color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); font-weight: 700; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--surface2); color: var(--text2); font-size: 11px; margin-right: 4px; white-space: nowrap; }
.tag.major { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--text); font-weight: 700; }
.stars { color: var(--warn); letter-spacing: -1px; font-size: 11px; white-space: nowrap; }
.stars .muted { color: var(--axis); }
.sbar { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--surface2); position: relative; vertical-align: middle; margin-right: 6px; }
.sbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }

/* ── 히트맵 ── */
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 2px; border-radius: 10px; overflow: hidden; }
.heat .cell { padding: 10px 10px 9px; min-height: 62px; display: flex; flex-direction: column; justify-content: space-between; }
.heat .cell b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat .cell span { font-size: 15px; font-weight: 700; }

/* ── 뉴스 ── */
.news-item { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.news-item:last-child { border-bottom: 0; }
.news-item time { color: var(--muted); font-size: 12px; padding-top: 2px; }
.news-item a.ttl { font-weight: 600; line-height: 1.45; display: block; }
.news-item a.ttl:hover { text-decoration: underline; }
.news-item .ko { color: var(--text2); font-size: 13px; margin-top: 2px; }
.news-item .meta { margin-top: 4px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.search { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; color: var(--text); font: inherit; width: 100%; max-width: 280px; }
.trend-row { display: grid; grid-template-columns: 84px 1fr 34px; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; cursor: pointer; }
.trend-row .track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.trend-row .track i { display: block; height: 100%; background: var(--s1); border-radius: 4px; }

/* ── 브리핑 ── */
.brief h2 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; line-height: 1.35; }
.brief .sum { font-size: 15px; line-height: 1.7; margin-top: 10px; color: var(--text); }
.brief .pt { margin-top: 14px; }
.brief .pt b { display: block; font-size: 14px; }
.brief .pt p { color: var(--text2); margin-top: 2px; }
.brief ul { margin: 6px 0 0; padding-left: 18px; }
.brief li { margin: 3px 0; color: var(--text2); }
.brief .sec { margin-top: 22px; }
.brief .sec > h4 { font-size: 13px; color: var(--muted); font-weight: 700; margin: 0 0 6px; }
.brief-list a { display: block; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; }
.brief-list a:hover { background: var(--surface2); }
.brief-list a.on { background: var(--surface2); border-color: var(--border); }
.brief-list b { display: block; font-size: 13px; }
.brief-list small { color: var(--muted); }
.watch { background: var(--surface2); border-radius: 10px; padding: 12px 14px; margin-top: 16px; }

/* ── 캘린더 ── */
.day { border-top: 1px solid var(--border); padding: 14px 0; display: grid; grid-template-columns: 92px 1fr; gap: 12px; }
.day:first-child { border-top: 0; }
.day .d b { font-size: 15px; display: block; }
.day.today .d b::after { content: "오늘"; font-size: 11px; background: var(--text); color: var(--bg); border-radius: 5px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.ev { display: grid; grid-template-columns: 46px 44px 1fr auto; gap: 8px; padding: 5px 0; align-items: baseline; font-size: 13px; }
.ev .vals { color: var(--text2); font-size: 12.5px; text-align: right; white-space: nowrap; }
.ev.past { opacity: .62; }
.holiday { background: color-mix(in srgb, var(--warn) 16%, transparent); border-radius: 8px; padding: 6px 10px; font-weight: 600; font-size: 13px; margin-bottom: 6px; }

/* ── 차트 ── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12px; white-space: nowrap; z-index: 5; display: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.chart .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.axis-t { font-size: 10.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.seg { display: inline-flex; background: var(--surface2); border-radius: 8px; padding: 2px; }
.seg button { padding: 3px 10px; border-radius: 6px; font-size: 12px; color: var(--text2); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 0 0 1px var(--border); }

.st-bar { position: sticky; top: 96px; z-index: 10; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
.st-clock { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.st-clock .muted { font-size: 15px; font-weight: 500; }
.st-step.live { outline: 2px solid var(--warn); }
.st-script { font-size: 16px; line-height: 1.85; white-space: pre-wrap; }
.st-points { margin: 10px 0 0; padding-left: 18px; }
.st-points li { margin: 3px 0; color: var(--text2); }
.st-day { display: flex; align-items: center; gap: 6px; padding: 4px 12px; font-size: 12.5px; white-space: nowrap; }
.st-day .tag { max-width: 84px; overflow: hidden; text-overflow: ellipsis; margin-right: 0; }
.st-day .num { flex: none; }
.st-copy { margin-top: 10px; }
.st-copy pre { margin: 4px 0 0; padding: 10px 12px; background: var(--surface2); border-radius: 8px; white-space: pre-wrap; font: inherit; font-size: 13px; color: var(--text2); }
.st-title { font-size: 17px; font-weight: 700; padding: 4px 0; }
details { border-top: 1px solid var(--border); padding: 12px 0; }
details summary { cursor: pointer; font-weight: 700; }
details p, details li { color: var(--text2); margin-top: 6px; }
footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 20px 16px 40px; max-width: 1320px; margin: 0 auto; line-height: 1.7; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.rmap text { font-size: 10.5px; fill: var(--muted); }
.rmap .cur { font-weight: 700; fill: var(--text); font-size: 11px; }

/* ── 게시판 ── */
.bd-list { padding: 4px 18px; }
.bd-row { display: block; padding: 15px 0; border-bottom: 1px solid var(--grid); }
.bd-row:last-child { border-bottom: 0; }
.bd-row b { font-size: 15.5px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.bd-row:hover b { text-decoration: underline; }
.bd-row p { color: var(--text2); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.bd-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.bd-meta .tag { margin-right: 0; }
.bd-post { padding: 26px; max-width: 860px; }
.bd-post h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.35; overflow-wrap: anywhere; }
.bd-body { margin-top: 20px; font-size: 15px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.bd-body a { color: var(--s1); text-decoration: underline; }
.bd-ops { display: flex; gap: 8px; align-items: center; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--grid); }
.bd-form { display: grid; gap: 10px; max-width: 860px; }
.bd-form .search { max-width: none; }
.bd-form textarea { min-height: 340px; resize: vertical; line-height: 1.7; font-size: 14.5px; }
.bd-pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 14px; }

/* ── 익명 채팅 팝업 (모든 화면 오른쪽 아래) ── */
.chat-fab { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 52px; height: 52px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); transition: transform .15s; }
.chat-fab:hover { transform: scale(1.06); }
.chat-fab .dot { position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--up); border: 2px solid var(--bg); }
.chat-fab .dot[hidden] { display: none; }
.chat-pop { position: fixed; right: 18px; bottom: 82px; z-index: 40; width: 360px; max-width: calc(100vw - 24px); height: min(560px, calc(100vh - 150px)); height: min(560px, calc(100dvh - 150px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 44px rgba(0, 0, 0, .45); overflow: hidden; }
.chat-pop[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface2); }
.chat-head > div { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-note { padding: 7px 14px; font-size: 11.5px; line-height: 1.5; color: var(--muted); border-bottom: 1px solid var(--grid); }
.chat-link { color: var(--text2); text-decoration: underline; font-size: 11.5px; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.chat-msg { max-width: 88%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; }
.chat-msg .who { display: flex; gap: 6px; align-items: center; font-size: 12px; flex-wrap: wrap; }
.chat-msg.mine .who { justify-content: flex-end; }
.chat-msg .who b { color: hsl(var(--h, 210) 60% var(--chat-l)); }
.chat-msg .who b.adm { color: var(--text); }
.chat-msg .who .tag { margin: 0; }
.chat-msg time { color: var(--muted); font-size: 11px; }
.chat-msg .txt { margin-top: 3px; padding: 7px 11px; border-radius: 4px 12px 12px 12px; background: var(--surface2); font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; width: fit-content; }
.chat-msg.mine .txt { border-radius: 12px 4px 12px 12px; margin-left: auto; background: color-mix(in srgb, var(--s1) 28%, var(--surface2)); }
.chat-msg .ops button { font-size: 11px; color: var(--muted); text-decoration: underline; padding: 0 2px; }
.chat-msg .ops button:hover { color: var(--up); }
.chat-new { position: absolute; left: 50%; transform: translateX(-50%); bottom: 66px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 99px; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.chat-new[hidden] { display: none; }
#chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
#chat-form input { flex: 1; min-width: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; color: var(--text); font: inherit; }
#chat-form .chip { padding: 6px 14px; }
.chat-err { padding: 0 12px 8px; color: var(--up); }
.chat-err[hidden] { display: none; }

@media (max-width: 980px) {
  #newsgrid, #briefgrid { grid-template-columns: minmax(0, 1fr) !important; }
  .g57, .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hdr-right .upd { display: none; }
  .kakao-btn { padding: 5px 9px; font-size: 12px; }
  .logo span { display: none; }
  .bar { gap: 10px; }
}
@media (max-width: 560px) {
  .day { grid-template-columns: 1fr; gap: 4px; }
  .ev { grid-template-columns: 42px 1fr; }
  .ev .ctry { display: none; }
  .ev .vals { grid-column: 2; text-align: left; }
  .page-title { font-size: 19px; }
  .bd-post { padding: 18px; }
  .chat-fab { right: 12px; bottom: 12px; }
  .chat-pop { left: 8px; right: 8px; bottom: 74px; width: auto; max-width: none; height: min(560px, calc(100vh - 150px)); height: min(560px, calc(100dvh - 150px)); }
  #chat-form input { font-size: 16px; } /* iOS 는 16px 미만 입력창에 초점이 가면 화면을 확대한다 */
}
