/* ============================================================
   몰래스탁 — 본체 사이트 스타일 (핀테크 라이트)
   ============================================================ */

* { box-sizing: border-box; }

:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --fg: #191f28;
  --sub: #6b7684;
  --line: #e5e8eb;
  --brand: #1b64da;
  --sel: #eef4ff;
  --head: #f9fafb;
  --radius: 14px;
  --shadow: 0 1px 4px rgba(25, 31, 40, .06);
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

[hidden] { display: none !important; }

body[data-color="kr"] { --up: #f04452; --down: #3182f6; }
body[data-color="us"] { --up: #16a34a; --down: #dc2626; }

/* ---------- 다크 테마 (마진킹/토스풍 — 기본값) ---------- */
body[data-theme="dark"] {
  --bg: #0d0e12;
  --surface: #16171c;
  --fg: #e8eaf0;
  --sub: #8a91a0;
  --line: #24262c;
  --brand: #4593fc;
  --sel: #1e222b;
  --head: #1a1c22;
  --shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
body[data-theme="dark"][data-color="kr"] { --up: #f2565f; --down: #4593fc; }
body[data-theme="dark"] .modal-card { background: var(--surface); color: var(--fg); }
body[data-theme="dark"] #office-picker button,
body[data-theme="dark"] #set-color button { background: var(--surface); color: var(--fg); }
body[data-theme="dark"] .brief-p, body[data-theme="dark"] .notice-body { color: #c3cad4; }
body[data-theme="dark"] .skel {
  background: linear-gradient(90deg, #1d222b 25%, #242a35 50%, #1d222b 75%);
  background-size: 200% 100%;
}
body[data-theme="dark"] #office-btn { background: #2a313c; }
body[data-theme="dark"] .slogo img { background: #fff; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--sub); }
.num { font-variant-numeric: tabular-nums; }

a { color: inherit; }

/* ---------- 상단바 ---------- */
#site { min-height: 100vh; display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  /* 와이드 화면에서 콘텐츠 컬럼(1200px)에 맞춰 중앙 정렬 */
  padding: 10px max(18px, calc((100% - 1200px) / 2));
  position: sticky; top: 0; z-index: 50;
}
.logo { font-size: 20px; font-weight: 900; letter-spacing: -0.5px; text-decoration: none; white-space: nowrap; }
.logo em { font-style: normal; color: var(--brand); }

#search-wrap { position: relative; flex: 1; max-width: 440px; }
#search-input {
  width: 100%; padding: 9px 14px; font-size: 13.5px; color: var(--fg);
  background: var(--bg); border: 1px solid transparent; border-radius: 22px; outline: none;
  font-family: inherit;
}
#search-input:focus { border-color: var(--brand); background: var(--surface); }
#search-drop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(25, 31, 40, .12); overflow: hidden;
}
.s-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; cursor: pointer; }
.s-item span { color: var(--sub); font-size: 12px; }
.s-item.sel, .s-item:hover { background: var(--sel); }

.mkt-chip {
  font-size: 12px; color: var(--sub); white-space: nowrap;
  background: var(--bg); border-radius: 14px; padding: 6px 12px;
  margin-left: auto; /* 우측 컨트롤 그룹(칩~설정)을 컬럼 오른쪽 끝에 정렬 */
}
.mkt-chip b { font-variant-numeric: tabular-nums; }
.mkt-chip.up { color: var(--up); background: color-mix(in srgb, var(--up) 10%, transparent); }
.mkt-chip.down { color: var(--down); background: color-mix(in srgb, var(--down) 10%, transparent); }

#theme-btn {
  border: none; background: none; color: var(--sub); font-size: 16px; cursor: pointer; padding: 4px 4px;
}
#theme-btn:hover { color: var(--fg); }

#office-btn {
  border: none; background: #191f28; color: #fff; font-size: 12.5px; font-family: inherit;
  border-radius: 18px; padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
#office-btn:hover { background: #333d4b; }
#settings-btn {
  border: none; background: none; color: var(--sub); font-size: 17px; cursor: pointer; padding: 4px 6px;
}
#settings-btn:hover { color: var(--fg); }

/* ---------- 내비게이션 ---------- */
#gnav {
  display: flex; gap: 2px; background: var(--surface);
  border-bottom: 1px solid var(--line); overflow-x: auto;
  padding: 0 max(14px, calc((100% - 1200px) / 2)); /* 상단바와 동일 컬럼 정렬 */
  position: sticky; top: 53px; z-index: 40;
}
#gnav button {
  border: none; background: none; font-family: inherit; font-size: 14px; color: var(--sub);
  padding: 11px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
#gnav button.on { color: var(--fg); font-weight: bold; border-bottom-color: var(--fg); }
#gnav button:hover { color: var(--fg); }

/* ---------- 메인 ---------- */
#view { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 16px 14px 30px; }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 14px;
}
.card.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.card h3 { margin: 0 0 12px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.h-sub { font-size: 11.5px; color: var(--sub); font-weight: normal; }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.home-grid .card { margin-bottom: 0; min-width: 0; } /* 내부 콘텐츠가 열 폭을 밀어내지 못하게 (태블릿 폭 잘림 방지) */
.home-grid .card:first-child { grid-column: 1 / -1; }

.mini-loading, .empty-note { color: var(--sub); font-size: 13px; padding: 6px 0; }
.empty-note a { color: var(--brand); }
.more-link {
  display: inline-block; margin-top: 10px; font-size: 12.5px; color: var(--brand); text-decoration: none;
}
.more-link:hover { text-decoration: underline; }

/* ---------- 지수 카드 ---------- */
.idx-row { display: flex; gap: 12px; }
.idx-card {
  flex: 1; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px 8px; overflow: hidden; background: var(--surface);
}
.idx-top { display: flex; justify-content: space-between; align-items: baseline; }
.idx-name { font-weight: bold; font-size: 13.5px; }
.idx-status { font-size: 11px; color: var(--sub); }
.idx-value { font-size: 24px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.idx-change { font-size: 12.5px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.idx-card.up .idx-value, .idx-card.up .idx-change { color: var(--up); }
.idx-card.down .idx-value, .idx-card.down .idx-change { color: var(--down); }
.idx-card .spark { width: 100%; height: 36px; display: block; }
.idx-row.slim .idx-value { font-size: 19px; }
.idx-row.slim .spark { height: 26px; }
.spark polyline { stroke: var(--sub); }
.spark.up polyline { stroke: var(--up); }
.spark.down polyline { stroke: var(--down); }

/* ---------- 급등락/관심 미니 행 ---------- */
.movers-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.movers-cols > div { min-width: 0; }
.m-head { font-size: 11.5px; font-weight: bold; padding: 4px 0 6px; }
.m-head.up { color: var(--up); }
.m-head.down { color: var(--down); }
.mover-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
}
.mover-row:hover { background: var(--sel); }
.m-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-price { color: var(--sub); }
.m-rate {
  min-width: 66px; text-align: center; border-radius: 8px; padding: 3px 8px; font-size: 12.5px;
}
.m-rate.up { background: color-mix(in srgb, var(--up) 12%, transparent); }
.m-rate.down { background: color-mix(in srgb, var(--down) 12%, transparent); }

/* ---------- 뉴스 ---------- */
.news-mini-row {
  display: block; padding: 7px 4px; border-radius: 8px; text-decoration: none;
}
.news-mini-row:hover { background: var(--sel); }
.nm-title { display: block; font-size: 13px; line-height: 1.45; }
.nm-meta { display: block; font-size: 11px; color: var(--sub); margin-top: 2px; }

.news-list { display: flex; flex-direction: column; }
.news-row {
  display: flex; flex-direction: row-reverse; gap: 14px; padding: 13px 4px;
  border-bottom: 1px solid var(--line); text-decoration: none;
}
.news-row:last-child { border-bottom: none; }
.news-row:hover .news-title { color: var(--brand); }
.news-thumb { width: 92px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.news-body { flex: 1; min-width: 0; }
.news-title { font-size: 14.5px; font-weight: bold; line-height: 1.45; }
.news-sub {
  font-size: 12.5px; color: var(--sub); margin-top: 4px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.news-meta { font-size: 11.5px; color: var(--sub); margin-top: 5px; }

/* ---------- 시세 테이블 ---------- */
.q-card { padding-top: 14px; }
.q-tabs {
  display: flex; gap: 2px; align-items: center; border-bottom: 1px solid var(--line);
  margin: 12px 0 0; flex-wrap: wrap;
}
.q-tabs > button {
  border: none; background: none; color: var(--sub); font-size: 13.5px; cursor: pointer;
  padding: 9px 12px; border-bottom: 2px solid transparent; font-family: inherit;
}
.q-tabs > button.on { color: var(--fg); border-bottom-color: var(--fg); font-weight: bold; }
.q-market { margin-left: auto; display: flex; gap: 4px; }
.q-market button {
  font-size: 12px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); cursor: pointer; font-family: inherit; color: var(--sub);
}
.q-market button.on { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.q-refresh { font-size: 11.5px; color: var(--sub); margin-left: 10px; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; font-weight: normal; color: var(--sub); font-size: 12px;
  background: var(--head); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid th.r, table.grid td.r { text-align: right; }
table.grid tr.rowlink { cursor: pointer; }
table.grid tr.rowlink:hover td, table.grid tr.sel td { background: var(--sel); }
table.grid .name { font-weight: bold; }
table.grid .name .code { font-weight: normal; color: var(--sub); font-size: 11px; margin-left: 6px; }
table.grid .empty { color: var(--sub); padding: 20px 8px; }
table.grid .rn { width: 30px; color: var(--sub); font-size: 11px; text-align: center; }
table.grid .x { width: 34px; text-align: center; }
table.grid button.del, table.grid button.add {
  border: none; background: none; color: var(--sub); cursor: pointer;
  font-size: 14px; padding: 2px 7px; border-radius: 6px;
}
table.grid button.del:hover { color: #fff; background: #f04452; }
table.grid button.add:hover { color: #fff; background: var(--brand); }
table.grid tr.total td { font-weight: bold; background: var(--head); border-top: 2px solid var(--line); }
.cell-in {
  width: 88px; padding: 5px 7px; font-size: 12.5px; text-align: right;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--fg);
  font-family: inherit;
}
.cell-in:focus { outline: none; border-color: var(--brand); }

/* ---------- 종목 상세 ---------- */
#detail {
  border: 1px solid var(--line); border-radius: 12px; background: var(--head);
  padding: 16px 18px; margin-top: 14px;
}
.d-loading { color: var(--sub); padding: 8px; }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.d-head > div:first-child { min-width: 0; }
.d-name { font-size: 15.5px; font-weight: bold; }
.d-name .code { color: var(--sub); font-size: 11.5px; font-weight: normal; }
.d-price { font-size: 26px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.d-chg { font-size: 13px; font-weight: normal; }
.d-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
#d-close { border: none; background: none; color: var(--sub); font-size: 20px; cursor: pointer; }
#d-close:hover { color: var(--fg); }
.d-chart { margin: 10px 0 4px; }
.d-chart .spark { width: 100%; height: 120px; }
.d-chart-cap { font-size: 11.5px; color: var(--sub); margin-top: 2px; }
.d-ohlc { display: flex; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.d-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 20px; padding-top: 10px; }
.d-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 2px 0; }
.d-kv span { color: var(--sub); }
.d-kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.d-news { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.d-news h4 { margin: 0 0 6px; font-size: 13px; }

/* ---------- 게시판 ---------- */
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chips { display: flex; gap: 6px; margin: 4px 0 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 16px;
  font-size: 12.5px; padding: 6px 13px; cursor: pointer; font-family: inherit; color: var(--sub);
}
.chip.on { background: var(--fg); color: var(--surface); border-color: var(--fg); }

.board-list { display: flex; flex-direction: column; }
.post-row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 13.5px;
}
.post-row:hover { background: var(--sel); }
.p-cat {
  font-size: 11px; color: var(--sub); background: var(--bg); border-radius: 8px;
  padding: 3px 0; text-align: center;
}
.p-cat.big { display: inline-block; padding: 3px 10px; margin-bottom: 8px; }
.p-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-cmt { color: var(--brand); font-size: 12px; }
.p-meta { font-size: 11.5px; color: var(--sub); white-space: nowrap; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding-top: 14px; font-size: 12.5px; color: var(--sub); }
.pager button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 6px 14px; cursor: pointer; font-family: inherit; font-size: 12.5px;
}
.pager button:disabled { opacity: .4; cursor: default; }

.post-view { padding: 6px 0 14px; }
.post-title { margin: 0 0 6px; font-size: 19px; }
.post-meta { font-size: 12px; color: var(--sub); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.post-body { padding: 16px 0; line-height: 1.8; font-size: 14px; min-height: 80px; }
.post-actions { display: flex; gap: 8px; }
.back-link { font-size: 12.5px; color: var(--sub); text-decoration: none; }
.back-link:hover { color: var(--fg); }

.cmt-wrap { border-top: 2px solid var(--line); padding-top: 12px; }
.cmt-wrap h4 { margin: 0 0 8px; font-size: 13.5px; }
.cmt { padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.cmt b { font-size: 12.5px; }
.cmt-time { color: var(--sub); font-size: 11px; margin-left: 8px; }
.cmt-body { margin-top: 4px; line-height: 1.6; }
.cmt-form { margin-top: 12px; }

/* ---------- 폼/버튼 ---------- */
.form { display: flex; flex-direction: column; gap: 10px; }
.form input, .form textarea, .form select, .cmt-form input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--fg);
}
.form input:focus, .form textarea:focus, .cmt-form input:focus { outline: none; border-color: var(--brand); }
.form textarea { resize: vertical; line-height: 1.7; }
.form-row2 { display: flex; gap: 8px; }
.form-row2 > * { flex: 1; min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.btn-primary {
  border: none; background: var(--brand); color: #fff; border-radius: 10px;
  padding: 9px 18px; font-size: 13px; cursor: pointer; font-family: inherit; text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-line {
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 10px;
  padding: 8px 14px; font-size: 12.5px; cursor: pointer; font-family: inherit; text-decoration: none;
  display: inline-block;
}
.btn-line:hover { border-color: var(--sub); }
.btn-line.danger:hover { border-color: #f04452; color: #f04452; }

/* ---------- 공지 ---------- */
.notice {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px;
}
.notice summary { cursor: pointer; font-weight: bold; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.notice-date { margin-left: auto; font-weight: normal; font-size: 11.5px; color: var(--sub); }
.notice-body { padding: 10px 2px 2px; font-size: 13px; line-height: 1.8; color: #333d4b; }

/* ---------- AI 브리핑 ---------- */
.badge-ai {
  font-size: 10.5px; font-weight: bold; color: #fff; letter-spacing: .5px;
  background: linear-gradient(135deg, #6366f1, #a855f7); border-radius: 8px; padding: 2.5px 8px;
}
.brief-stamp { font-size: 11.5px; color: var(--sub); margin-bottom: 10px; }
.brief-headline { font-weight: bold; font-size: 14.5px; margin: 0 0 6px; line-height: 1.5; }
.brief-headline.big { font-size: 19px; margin: 0 0 10px; min-height: 29px; }
.brief-p { font-size: 13.5px; line-height: 1.8; color: #333d4b; margin: 0 0 8px; min-height: 20px; }
.brief-sub { margin: 14px 0 8px; font-size: 13.5px; }
.brief-feats { display: flex; flex-direction: column; gap: 6px; }
.feat-row {
  font-size: 13px; padding: 9px 13px; border-radius: 10px; background: var(--bg); cursor: pointer;
  border-left: 3px solid var(--sub);
}
.feat-row.up { border-left-color: var(--up); }
.feat-row.down { border-left-color: var(--down); }
.feat-row:hover { background: var(--sel); }
.brief-note { font-size: 11.5px; color: var(--sub); margin-top: 14px; }
.typing::after { content: '▍'; color: #a855f7; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .typing::after { animation: none; } }

/* ---------- 배지/푸터 ---------- */
.badge-live, .badge-demo { font-size: 11px; font-weight: normal; border-radius: 8px; padding: 3px 8px; }
.badge-live { color: #0a7d47; background: #e6f4ec; }
.badge-demo { color: #b45309; background: #fdf0e0; }

#site-foot {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
  color: var(--sub); font-size: 11.5px; padding: 14px 16px 20px;
}
#site-foot a { color: var(--brand); text-decoration: none; }
#site-foot .sep { opacity: .5; }
#mode-badge.demo { color: #d97706; font-weight: bold; }
#mode-badge.live { color: #0a7d47; font-weight: bold; }
.hint { opacity: .85; }

/* ---------- 모달/토스트 ---------- */
#settings-modal, #office-modal {
  position: fixed; inset: 0; z-index: 90; background: rgba(25, 31, 40, .5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: #fff; color: #191f28; border-radius: 16px; width: 100%; max-width: 460px;
  padding: 20px 22px; box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head b { font-size: 15px; }
#settings-close, #office-close { border: none; background: none; font-size: 20px; cursor: pointer; color: #6b7684; }
.set-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.set-row > label { width: 92px; color: #6b7684; font-size: 12.5px; flex-shrink: 0; }
.set-row select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; }
#set-color { display: flex; gap: 6px; flex-wrap: wrap; }
#set-color button {
  padding: 7px 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  cursor: pointer; font-size: 12.5px; font-family: inherit;
}
#set-color button.on { background: #191f28; color: #fff; border-color: #191f28; }
.set-note { color: #8b95a1; font-size: 11.5px; line-height: 1.7; margin: 14px 0 0; }

#office-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#office-picker button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: 16px 8px 13px; cursor: pointer; font-family: inherit;
}
#office-picker button:hover { border-color: var(--brand); background: var(--sel); }
#office-picker button.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--sel); }
#office-picker button b { font-size: 13.5px; }
#office-picker button span:last-child { font-size: 11px; color: var(--sub); }
#office-picker .op-none { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 8px; padding: 11px; }
.op-icon {
  width: 34px; height: 34px; border-radius: 9px; color: #fff; font-weight: bold;
  display: flex; align-items: center; justify-content: center; font-size: 15px; margin-bottom: 4px;
}
.op-icon.xl { background: #107C41; }
.op-icon.pp { background: #C43E1C; }
.op-icon.ps { background: #001E36; color: #31A8FF; }
.op-icon.vs { background: #0066B8; font-size: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #191f28; color: #fff; padding: 10px 20px; border-radius: 22px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 120;
}
#toast.show { opacity: .96; transform: translateX(-50%) translateY(0); }

/* ---------- 보스키 오버레이 ---------- */
#boss {
  position: fixed; inset: 0; z-index: 100; background: #ececec;
  display: flex; align-items: flex-start; justify-content: center;
  overflow: auto; padding: 40px 16px;
}
.boss-doc {
  background: #fff; max-width: 760px; width: 100%; min-height: 85vh;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .18); padding: 60px 70px;
  color: #222; line-height: 1.8;
}
.boss-doc h1 { font-size: 21px; text-align: center; margin: 0 0 8px; }
.boss-meta { text-align: center; color: #888; font-size: 12px; margin-bottom: 28px; }
.boss-doc table { width: 100%; border-collapse: collapse; margin: 18px 0 22px; font-size: 13px; }
.boss-doc th, .boss-doc td { border: 1px solid #999; padding: 8px 12px; text-align: left; }
.boss-doc th { background: #f2f2f2; }
.boss-hint { color: #ccc; font-size: 11px; text-align: right; margin-top: 40px; }

/* ---------- 종목 로고 아바타 ---------- */
.slogo {
  position: relative; width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--line); overflow: hidden;
  vertical-align: middle; margin-right: 8px;
}
.slogo i { font-style: normal; font-size: 11px; font-weight: 700; color: var(--sub); }
.slogo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
table.grid .name .slogo { width: 26px; height: 26px; }
.d-name .slogo { width: 28px; height: 28px; }

/* ---------- 글로벌·코인 티커 스트립 ---------- */
.g-strip {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.g-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px;
  background: var(--bg); border-radius: 18px; padding: 7px 13px; white-space: nowrap;
}
.g-chip .g-name { color: var(--sub); font-size: 12px; }
.g-chip b { font-weight: 700; }

/* ---------- 스켈레톤 로딩 ---------- */
.skel {
  display: inline-block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, #eef1f4 25%, #f7f9fa 50%, #eef1f4 75%);
  background-size: 200% 100%; animation: skel-wave 1.4s ease infinite;
}
.skel-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 4px; }
@keyframes skel-wave { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---------- 가격 변동 플래시 ---------- */
td.fl-up { animation: cell-fl-up 1.1s ease-out; }
td.fl-down { animation: cell-fl-down 1.1s ease-out; }
@keyframes cell-fl-up { 0% { background: color-mix(in srgb, var(--up) 22%, #fff); } 100% { background: transparent; } }
@keyframes cell-fl-down { 0% { background: color-mix(in srgb, var(--down) 22%, #fff); } 100% { background: transparent; } }

/* ---------- 하단 실시간 티커 바 ---------- */
#ticker {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; overflow: hidden;
  background: var(--surface); border-top: 1px solid var(--line);
  height: 34px; display: flex; align-items: center; white-space: nowrap;
}
.tk-track {
  display: inline-flex; gap: 30px; padding-left: 18px;
  animation: tk-scroll 55s linear infinite; will-change: transform;
}
#ticker:hover .tk-track { animation-play-state: paused; }
@keyframes tk-scroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .tk-track { animation: none; } }
.tk-item { font-size: 12px; color: var(--sub); display: inline-flex; gap: 6px; align-items: center; }
.tk-item b { color: var(--fg); font-weight: 600; }
.tk-item i { font-style: normal; }
#site-foot { padding-bottom: 48px; }
body:not([data-office="none"]) #ticker { display: none; }

/* ---------- 종목 상세: 왜 움직였을까 ---------- */
.d-why {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: var(--sel); border-radius: 10px; padding: 10px 14px; margin: 8px 0 2px;
  border-left: 3px solid var(--brand); font-size: 13px;
}
.d-why-tag { font-weight: 700; color: var(--brand); font-size: 12px; white-space: nowrap; }
.d-why a { text-decoration: none; flex: 1; min-width: 200px; }
.d-why a:hover { text-decoration: underline; }
.d-why-meta { font-size: 11px; color: var(--sub); white-space: nowrap; }

/* ---------- 글로벌 칩: HL 야간 ---------- */
.g-chip.hl { outline: 1px solid #0e9b6f55; }
.g-chip.hl .g-name::after { content: ' HL'; font-size: 9px; color: #0e9b6f; font-weight: bold; }

/* ---------- 마진킹 스타일 홈 상단 ---------- */
.mk-strip {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.mks-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 8px 12px; border-right: 1px solid var(--line); min-width: 0;
}
.mks-item:last-child { border-right: 0; }
.mks-label { font-size: 12px; font-weight: 700; letter-spacing: -.2px; }
.mks-item b { font-size: 16.5px; font-weight: 700; }
.mks-item i { font-style: normal; font-size: 11.5px; }
.mk-red { color: #f2565f; }
.mk-orange { color: #f5a623; }
.mk-blue { color: #4593fc; }
.mk-green { color: #2fbf86; }
.mk-purple { color: #a78bfa; }
.mk-yellow { color: #f7cf4e; }

.mk-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.mkc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 12px; box-shadow: var(--shadow); min-width: 0;
}
.mkc-head { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.mkc-head b { font-size: 13.5px; white-space: nowrap; }
.mkc-head .slogo { margin-right: 0; }
.mkc-tick {
  font-style: normal; font-size: 9.5px; color: var(--sub); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; font-weight: 700;
}
.mkc-logo {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 14px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mkc-logo.btc { background: #f7931a; }
.mkc-logo.eth { background: #627eea; }
.mkc-logo.kr { background: #2c3d90; font-size: 10px; }
.mkc-spark { margin-left: auto; flex: 0 1 170px; min-width: 70px; height: 44px; }
.mkc-spark .spark { width: 100%; height: 100%; }
.mkc-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.mkc-cols > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mkc-cols span { font-size: 10.5px; color: var(--sub); white-space: nowrap; }
.mkc-cols b { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkc-cols i { font-style: normal; font-size: 10.5px; }
.mk-hl { font-style: normal; color: #0e9b6f; font-weight: 800; font-size: 9px; }

@media (max-width: 1000px) { .mk-strip { grid-template-columns: repeat(3, 1fr); } .mks-item { border-bottom: 1px solid var(--line); } }
@media (max-width: 620px) { .mk-cards { grid-template-columns: 1fr; } .mk-strip { grid-template-columns: 1fr 1fr; } }

/* ---------- 투자자별 매매동향 (토스) ---------- */
.iv-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.iv-block { min-width: 0; }
.iv-title { font-size: 12.5px; font-weight: 700; margin-bottom: 7px; }
.iv-row { display: flex; align-items: center; gap: 8px; padding: 3.5px 0; font-size: 12.5px; }
.iv-k { width: 44px; color: var(--sub); flex-shrink: 0; }
.iv-bar { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.iv-bar i { display: block; height: 100%; border-radius: 4px; }
.iv-bar i.up { background: var(--up); }
.iv-bar i.down { background: var(--down); }
.iv-bar i.flat { background: var(--sub); }
.iv-row b { min-width: 64px; text-align: right; font-weight: 600; }
@media (max-width: 760px) { .iv-wrap { grid-template-columns: 1fr; } }

/* ---------- 종목 상세 캔들차트 ---------- */
.d-ranges { display: flex; gap: 4px; margin-bottom: 8px; }
.d-ranges button {
  border: 1px solid var(--line); background: var(--surface); color: var(--sub);
  border-radius: 14px; font-size: 12px; padding: 4px 12px; cursor: pointer; font-family: inherit;
}
.d-ranges button.on { background: var(--fg); color: var(--surface); border-color: var(--fg); font-weight: 600; }
#d-canvas { display: block; width: 100%; height: 240px; }

/* ---------- 반응형 ---------- */
@media (max-width: 760px) {
  #topbar { padding: 9px 10px; gap: 8px; }
  .mkt-chip { display: none; }
  #office-btn { padding: 7px 11px; font-size: 11.5px; }
  #gnav { top: 51px; }
  .home-grid { grid-template-columns: 1fr; }
  .movers-cols { grid-template-columns: 1fr; }
  .idx-row { flex-direction: column; }
  .news-thumb { width: 74px; height: 54px; }
  .post-row { grid-template-columns: 52px 1fr; }
  .p-meta { grid-column: 2; text-align: left; }
  .form-row2 { flex-direction: column; }
  .cmt-form { flex-direction: row; }
  .cmt-form input:first-child { max-width: 90px; }
  .boss-doc { padding: 30px 22px; }
  .d-grid { grid-template-columns: 1fr 1fr; }
  #office-picker { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   실시간 채팅 패널 + 시세판 종목 추가 팝오버
   ============================================================ */

#chat-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font-size: 12.5px; font-family: inherit; border-radius: 18px; padding: 7px 12px;
  cursor: pointer; white-space: nowrap;
}
#chat-btn:hover { border-color: var(--brand); }
#chat-btn b { color: var(--brand); font-variant-numeric: tabular-nums; }

#chat-panel {
  position: fixed; right: 12px; top: 64px; bottom: 12px; width: 302px; z-index: 85;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border-bottom: 1px solid var(--line); font-size: 13.5px;
}
#chat-online2 { color: var(--sub); font-size: 11.5px; }
#chat-close { margin-left: auto; border: none; background: none; font-size: 18px; color: var(--sub); cursor: pointer; }
#chat-close:hover { color: var(--fg); }

.chat-msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 9px; }
.chat-msg { font-size: 12.5px; line-height: 1.5; }
.chat-meta { display: flex; align-items: center; gap: 5px; margin-bottom: 1px; }
.chat-meta b { font-size: 12px; }
.chat-time { color: var(--sub); font-size: 10.5px; margin-left: auto; }
.chat-body { color: var(--fg); word-break: break-word; }
.chat-tag { font-style: normal; color: var(--brand); font-weight: 600; cursor: pointer; }

.chat-rank { font-size: 9.5px; border-radius: 6px; padding: 1px 5px; font-weight: bold; flex-shrink: 0; }
.chat-rank.r1 { background: #e8eaed; color: #5f6672; }
.chat-rank.r2 { background: #e2f3e8; color: #1a7d43; }
.chat-rank.r3 { background: #e3edfd; color: #1b64da; }
.chat-rank.r4 { background: #efe6fb; color: #7c3aed; }
.chat-rank.r5 { background: #fdeae3; color: #c2410c; }
.chat-rank.r6 { background: #1f2430; color: #e9c46a; }
body[data-theme="dark"] .chat-rank.r1, body[data-office="ps"] .chat-rank.r1,
body[data-office="vscode"] .chat-rank.r1 { background: #2a2f3a; color: #9aa3b2; }

.chat-me {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px; font-size: 11.5px;
  color: var(--sub); border-top: 1px solid var(--line);
}
.chat-me b { color: var(--fg); display: inline-flex; align-items: center; gap: 4px; }
#chat-renick { font-style: normal; cursor: pointer; margin-left: auto; opacity: .7; }
#chat-renick:hover { opacity: 1; }

.chat-inputrow { display: flex; gap: 6px; padding: 0 12px 8px; }
#chat-input {
  flex: 1; min-width: 0; padding: 9px 12px; font-size: 12.5px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--fg); outline: none;
}
#chat-input:focus { border-color: var(--brand); }
#chat-send {
  border: none; background: var(--brand); color: #fff; border-radius: 9px;
  padding: 0 14px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.chat-note { padding: 0 14px 10px; font-size: 10px; color: var(--sub); }

@media (max-width: 760px) {
  #chat-panel { left: 8px; right: 8px; width: auto; top: auto; height: 62vh; }
  #chat-btn b { display: none; }
}

/* ---------- 시세판 [＋ 종목 추가] ---------- */
.q-tabs { position: relative; }
.q-addbtn {
  margin-left: auto; border: 1px solid var(--brand); background: var(--surface); color: var(--brand);
  font-size: 12px; font-family: inherit; border-radius: 14px; padding: 5px 12px; cursor: pointer; white-space: nowrap;
}
.q-addbtn:hover { background: var(--sel); }
.q-addbtn + .q-refresh { margin-left: 10px; }
.q-market ~ .q-addbtn { margin-left: auto; }
.q-addpop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 45; width: 300px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2); padding: 10px;
}
#q-add-input {
  width: 100%; box-sizing: border-box; padding: 9px 12px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); outline: none;
}
#q-add-input:focus { border-color: var(--brand); }
.q-add-results { max-height: 240px; overflow-y: auto; margin-top: 6px; }
.q-add-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.q-add-item span { color: var(--sub); font-size: 11.5px; }
.q-add-item:hover { background: var(--sel); }
.q-add-item.has { opacity: .5; cursor: default; }
.q-add-hint { color: var(--sub); font-size: 12px; padding: 8px 4px; }

/* ============================================================
   로그인 / 프로필 (Supabase 소셜 인증)
   ============================================================ */

#login-btn {
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font-size: 12.5px; font-family: inherit; border-radius: 18px; padding: 7px 16px;
  cursor: pointer; white-space: nowrap;
}
#login-btn:hover { filter: brightness(1.08); }

.profile-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 18px; padding: 4px 10px 4px 4px;
  background: var(--surface); font-size: 12.5px; color: var(--fg); white-space: nowrap;
}
.profile-chip:hover { border-color: var(--brand); }
.profile-chip img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.pf-initial {
  width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold;
}
.profile-chip i { font-style: normal; color: var(--sub); font-size: 9px; }

.profile-menu {
  position: fixed; top: 52px; right: 130px; z-index: 95;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2); padding: 6px; min-width: 170px;
  display: flex; flex-direction: column;
}
.profile-menu button {
  border: none; background: none; text-align: left; font-family: inherit; font-size: 12.5px;
  color: var(--fg); padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
.profile-menu button:hover { background: var(--sel); }
#pf-logout { color: #d9534f; }

#login-modal {
  position: fixed; inset: 0; z-index: 96; background: rgba(25, 31, 40, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-card { max-width: 360px; }
.login-sub { font-size: 13px; color: var(--sub); line-height: 1.7; margin: 0 0 16px; }
.login-sub b { color: var(--fg); }
.login-provider {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 12px; border-radius: 10px; font-size: 14px; font-family: inherit;
  cursor: pointer; margin-bottom: 9px; font-weight: 600;
}
.login-provider.google { border: 1px solid #dadce0; background: #fff; color: #3c4043; }
.login-provider.google:hover { background: #f8f9fa; border-color: #c6c9cc; }
.login-provider.kakao { border: none; background: #FEE500; color: #191919; }
.login-provider.kakao:hover { filter: brightness(.97); }

/* 채팅 인증 뱃지 */
.chat-rank.rv { background: #e3edfd; color: #1b64da; }
.chat-rank.rv::before { content: '✓ '; }
body[data-theme="dark"] .chat-rank.rv, body[data-office="ps"] .chat-rank.rv,
body[data-office="vscode"] .chat-rank.rv { background: #14304f; color: #7fb3ff; }

@media (max-width: 760px) {
  .profile-chip b { display: none; }
  .profile-menu { right: 60px; }
}

/* ============================================================
   참여 기능 — 예측 투표 / 모의투자 / 수익률 카드
   ============================================================ */

/* 예측 투표 카드 */
.pd-btns { display: flex; gap: 8px; margin-bottom: 10px; }
.pd-btn {
  flex: 1; padding: 12px 8px; border-radius: 12px; font-size: 14px; font-weight: bold;
  font-family: inherit; cursor: pointer; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--fg); transition: all .12s;
}
.pd-btn.up:hover, .pd-btn.up.on { border-color: var(--up); color: var(--up); background: color-mix(in srgb, var(--up) 8%, var(--surface)); }
.pd-btn.down:hover, .pd-btn.down.on { border-color: var(--down); color: var(--down); background: color-mix(in srgb, var(--down) 8%, var(--surface)); }
.pd-btn.on { box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent); }
.pd-bar { height: 8px; border-radius: 4px; background: var(--down); overflow: hidden; display: flex; }
.pd-bar i { display: block; height: 100%; background: var(--up); }
.pd-meta { display: flex; gap: 12px; font-size: 11.5px; margin-top: 6px; color: var(--sub); }
.pd-meta span:last-child { margin-left: auto; }
.pd-last { font-size: 12px; color: var(--sub); margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.pd-hit { color: #e9a13b; }
.pd-foot { display: flex; gap: 10px; font-size: 11.5px; color: var(--sub); margin-top: 6px; }
.pd-streak { margin-left: auto; }

/* 모의투자 */
.paper-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.paper-grid .card { margin-bottom: 0; }
.pt-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 18px; }
.pt-summary div { display: flex; flex-direction: column; gap: 2px; }
.pt-summary span { font-size: 11.5px; color: var(--sub); }
.pt-summary b { font-size: 17px; }
.pt-order { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pt-searchwrap { position: relative; flex: 1; min-width: 180px; max-width: 300px; }
#pt-search, #pt-qty {
  width: 100%; box-sizing: border-box; padding: 9px 12px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--fg); outline: none;
}
#pt-search:focus, #pt-qty:focus { border-color: var(--brand); }
#pt-qty { width: 110px; }
.pt-searchwrap .q-add-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.pt-picked { font-size: 12.5px; color: var(--sub); min-width: 150px; }
.pt-buy, .pt-sell {
  border: none; border-radius: 9px; padding: 10px 20px; font-size: 13px; font-weight: bold;
  font-family: inherit; color: #fff; cursor: pointer;
}
.pt-buy { background: var(--up); }
.pt-sell { background: var(--down); }
.pt-buy:hover, .pt-sell:hover { filter: brightness(1.08); }
.pt-rankrow {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.pt-rankrow:last-child { border-bottom: none; }
.pt-rankno {
  width: 22px; height: 22px; border-radius: 50%; background: var(--bg); color: var(--sub);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0;
}
.pt-rankno.top { background: #f5c518; color: #4a3a00; }
.pt-rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 가격·수익률을 고정 폭 우측 정렬 열로 — 수익률 텍스트 폭에 따라 가격 끝이 흔들리지 않게 */
.pt-rankrow > span.num { min-width: 96px; text-align: right; }
.pt-rankrow > b.num { min-width: 58px; text-align: right; }
.pt-close { padding: 4px 9px; font-size: 11px; }

@media (max-width: 760px) {
  .paper-grid { grid-template-columns: 1fr; }
  .pt-summary b { font-size: 15px; }
}

/* ============================================================
   종목 상세 심화 (컨센서스/투자자동향/재무/리포트/동종업계)
   ============================================================ */

.d-consensus {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 11px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--line));
  font-size: 13px;
}
.d-sec-tag {
  font-size: 10.5px; font-weight: bold; letter-spacing: .5px; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent); border-radius: 7px; padding: 2.5px 8px;
}
.d-consensus b { font-size: 14px; }
.d-cons-op { color: var(--sub); font-size: 12px; margin-left: auto; }

.d-sec { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.d-sec h4 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: baseline; gap: 8px; }
.d-sec h4 small { font-size: 11px; color: var(--sub); font-weight: normal; }

.d-mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.d-mini-table th {
  text-align: left; font-weight: normal; color: var(--sub); font-size: 11.5px;
  padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.d-mini-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.d-mini-table th.r, .d-mini-table td.r { text-align: right; }
.d-mini-table tr:last-child td { border-bottom: none; }
.d-est { font-style: normal; color: var(--brand); font-size: 9.5px; margin-left: 2px; font-weight: bold; }

.d-report { padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.d-report:last-child { border-bottom: none; }
.d-report b { display: block; font-weight: 600; line-height: 1.45; }
.d-report span { color: var(--sub); font-size: 11.5px; }

.d-peers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.d-peer {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12px;
}
.d-peer:hover { border-color: var(--brand); background: var(--sel); }
.d-peer span { color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-peer b { font-size: 13.5px; }
.d-peer i { font-style: normal; font-size: 11.5px; }

/* ============================================================
   모바일 하단 탭바 + 모바일 전면 최적화
   ============================================================ */

#tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 88;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
#tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  border: none; background: none; font-family: inherit; font-size: 10px; color: var(--sub);
  padding: 5px 0 3px; cursor: pointer; border-radius: 10px;
}
#tabbar button i { font-style: normal; font-size: 17px; line-height: 1.15; }
#tabbar button.on { color: var(--brand); font-weight: bold; }
body:not([data-office="none"]) #tabbar { display: none !important; }

@media (max-width: 760px) {
  /* 하단 탭바 표시, 상단 gnav·하단 티커 숨김 */
  #tabbar { display: flex; }
  #gnav { display: none; }
  #ticker { display: none; }
  #site { padding-bottom: 64px; }

  /* 상단바 압축 */
  #topbar { padding: 8px 10px; gap: 7px; }
  .logo { font-size: 17px; }
  #office-btn { padding: 7px 10px; font-size: 11px; }
  #chat-btn { padding: 6px 10px; font-size: 12px; }
  #login-btn { padding: 6px 12px; font-size: 11.5px; }
  #view { padding: 12px 10px 20px; }

  /* 채팅: 풀시트 */
  #chat-panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 72vh; border-radius: 16px 16px 0 0; }

  /* 종목 상세 심화 모바일 */
  .d-peers { grid-template-columns: 1fr 1fr; }
  .d-consensus { gap: 8px; font-size: 12px; }
  .d-cons-op { margin-left: 0; width: 100%; }

  /* 터치 타깃 확대 */
  table.grid td { padding: 11px 8px; }
  .q-tabs > button { padding: 11px 10px; }
  .pd-btn { padding: 14px 8px; }
  .pt-buy, .pt-sell { padding: 12px 22px; }
}

/* ============================================================
   v5.6 — LLM 브리핑 / 종목 토론 / 모바일 정렬 픽스
   ============================================================ */

/* ---------- LLM 브리핑 ---------- */
.brief-src { color: #a855f7; }
.brief-fb { color: var(--sub); font-weight: normal; }
.brief-sectors { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 4px; }
.sector-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface);
}
.sector-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sector-head b { font-size: 13.5px; }
.sector-stance { font-size: 10.5px; font-weight: bold; border-radius: 8px; padding: 2.5px 9px; }
.sector-stance.up { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.sector-stance.down { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.sector-stance.flat { color: var(--sub); background: var(--bg); }
.sector-card p { margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--sub); }
.brief-risk { padding: 10px 13px; border-radius: 10px; background: color-mix(in srgb, #e9a13b 9%, var(--surface)); border: 1px solid color-mix(in srgb, #e9a13b 30%, var(--line)); }
.brief-tmr { margin-top: 8px; }

/* ---------- 종목 토론 ---------- */
.p-stock {
  font-style: normal; font-weight: bold; color: var(--brand); font-size: 12px; cursor: pointer;
}
.p-stock:hover { text-decoration: underline; }
.chip.stock { border-color: var(--brand); color: var(--brand); background: var(--sel); display: inline-flex; gap: 5px; align-items: center; }
.chip.stock.on { background: var(--brand); color: #fff; }
.chip.stock i { font-style: normal; opacity: .8; }
.w-stocktag {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-bottom: 12px;
  padding: 9px 13px; border-radius: 10px; background: var(--sel);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
}
.w-stocktag b { color: var(--brand); }
.w-stocktag i { font-style: normal; margin-left: auto; cursor: pointer; color: var(--sub); padding: 0 4px; }
.w-stocktag i:hover { color: var(--fg); }
.d-talk-btns { margin-left: auto; display: inline-flex; gap: 6px; }
.d-talk-btns .btn-line, .d-talk-btns .btn-primary { padding: 5px 11px; font-size: 11.5px; }
.d-talk-row {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 4px;
  border-bottom: 1px solid var(--line); text-decoration: none; font-size: 12.5px;
}
.d-talk-row:last-child { border-bottom: none; }
.d-talk-row:hover b { color: var(--brand); }
.d-talk-row b { font-weight: 600; }
.d-talk-row span { color: var(--sub); font-size: 11px; }
.d-talk-row .p-cmt { font-style: normal; }

/* ---------- 공통 픽스 ---------- */
.pager button { color: var(--fg); background: var(--surface); }   /* 다크에서 글자 안 보이던 버그 */

/* ---------- 모바일 정렬 픽스 ---------- */
@media (pointer: coarse) {
  body { touch-action: manipulation; }  /* 더블 탭 줌 방지 → 더블 탭 위장과 충돌 제거 */
}

@media (max-width: 760px) {
  /* 상단바: 오피스(PC 전용)·테마 버튼 숨겨 검색창 공간 확보 */
  #office-btn, #theme-btn { display: none !important; }
  #search-wrap { max-width: none; min-width: 0; }
  #search-input { padding: 8px 12px; font-size: 13px; }

  /* 시세판: 지수 카드 2열 컴팩트 */
  .idx-row, .idx-row.slim { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .idx-card { min-width: 0; padding: 10px 12px 6px; }
  .idx-value { font-size: 20px; }
  .idx-row.slim .idx-value { font-size: 18px; }

  /* 시세 탭: 한 줄 스크롤 (두 줄 꺾임 제거) */
  .q-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .q-tabs::-webkit-scrollbar { display: none; }
  .q-tabs > button { flex-shrink: 0; }
  .q-market { flex-shrink: 0; }
  .q-addbtn { flex-shrink: 0; margin-left: 8px; }
  .q-refresh { display: none; }
  .q-addpop { right: 8px; left: 8px; width: auto; }

  /* 시세 테이블: 종목명 말줄임으로 등락률까지 확보 */
  table.grid { font-size: 12.5px; }
  table.grid td { padding: 10px 6px; }
  table.grid th { padding: 6px; }
  table.grid .name { max-width: 118px; overflow: hidden; text-overflow: ellipsis; }
  table.grid .name .code { display: none; }
  table.grid .rn { width: 22px; }

  /* 카드/푸터 여백 균일 + 중앙 정렬 */
  .card { padding: 14px; border-radius: 12px; }
  .card.narrow { max-width: none; }
  #site-foot { text-align: center; font-size: 10.5px; padding: 10px 14px 16px; }
  .board-head { flex-wrap: wrap; gap: 8px; }
  .brief-sectors { grid-template-columns: 1fr; }
  .d-talk-btns { width: 100%; margin: 6px 0 0; }

  /* 홈 지표 스트립: 3열 균등 */
  .mk-strip { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ============================================================
   v5.7 — 등급 진행바 / 시스템 메시지 / 모의투자 보강
   ============================================================ */

.chat-progress {
  padding: 0 14px 8px; font-size: 11px; color: var(--sub);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.chat-progress b { color: var(--fg); }
.chat-pgbar {
  flex-basis: 100%; height: 5px; border-radius: 3px; background: var(--bg); overflow: hidden;
}
.chat-pgbar i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #a855f7); }

.chat-msg.sys .chat-body {
  background: color-mix(in srgb, #a855f7 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #a855f7 28%, var(--line));
  border-radius: 9px; padding: 7px 10px; font-size: 12px;
}
.chat-rank.rs { background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }

.pt-hint { font-style: normal; display: block; font-size: 11px; color: var(--sub); margin-top: 2px; }
/* 하이라이트는 좌우로 4px 번지되, 내용 x좌표는 다른 행과 동일하게 (margin으로 폭 보정) */
.pt-rankrow.me { background: var(--sel); border-radius: 9px; margin: 0 -4px; padding-left: 8px; padding-right: 8px; }
.pt-me {
  font-style: normal; font-size: 9.5px; font-weight: bold; color: #fff; background: var(--brand);
  border-radius: 6px; padding: 1.5px 6px; margin-left: 4px; vertical-align: 1px;
}
#pt-hist .name { font-weight: 600; }
#pt-max { flex-shrink: 0; }

/* ============================================================
   v5.8 — 채팅 채널 / 등급 모달 / 시즌·명예의 전당 / 포춘쿠키
   ============================================================ */

/* 채팅 채널 탭 */
.chat-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.chat-tabs button {
  border: none; background: none; font-family: inherit; font-size: 12px; color: var(--sub);
  padding: 8px 10px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.chat-tabs button.on { color: var(--fg); font-weight: bold; border-bottom-color: var(--brand); }
#chat-input:disabled { opacity: .55; cursor: not-allowed; }
.chat-progress { cursor: pointer; }
.chat-progress:hover b { color: var(--brand); }
#chat-nick { cursor: pointer; }

/* 등급 안내 모달 */
#rank-modal {
  position: fixed; inset: 0; z-index: 97; background: rgba(25, 31, 40, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#rank-modal .modal-card { max-width: 400px; max-height: 86vh; overflow-y: auto; }
.rk-intro { font-size: 13px; margin: 0 0 12px; }
.rk-ladder { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.rk-step {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--line); font-size: 12.5px; opacity: .55;
}
.rk-step.ok { opacity: 1; }
.rk-step.cur { border-color: var(--brand); background: var(--sel); opacity: 1; }
.rk-step b { margin-left: auto; font-variant-numeric: tabular-nums; }
.rk-step i { font-style: normal; font-size: 10.5px; color: var(--brand); font-weight: bold; }
.rk-h { margin: 14px 0 6px; font-size: 13px; }
.rk-table { display: flex; flex-direction: column; }
.rk-row {
  display: flex; justify-content: space-between; padding: 6px 4px;
  border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.rk-row:last-child { border-bottom: none; }
.rk-row span { color: var(--sub); }

/* 시즌 리더보드 + 명예의 전당 */
.rk-periods { margin: 0; }
.rk-periods .chip { padding: 4px 10px; font-size: 11.5px; }
.hall-h { margin: 14px 0 6px; font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.hall-h small { font-size: 11px; color: var(--sub); font-weight: normal; }
.hall-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.hall-row:last-child { border-bottom: none; }
.hall-badge {
  font-size: 10px; font-weight: bold; color: #b7791f; background: #fdf3d8;
  border-radius: 7px; padding: 2px 7px;
}
body[data-theme="dark"] .hall-badge { background: #3a2f14; color: #e9c46a; }
.hall-nick { flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hall-row > .num { min-width: 58px; text-align: right; }

/* 포춘쿠키 */
.ft-cookie {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 22px 10px; cursor: pointer; border: 1px dashed var(--line); border-radius: 12px;
}
.ft-cookie:hover { border-color: var(--brand); background: var(--sel); }
.ft-cookie i { font-style: normal; font-size: 40px; }
.ft-cookie span { font-size: 12px; color: var(--sub); }
.ft-open { display: flex; gap: 12px; align-items: flex-start; }
.ft-open i { font-style: normal; font-size: 30px; }
.ft-msg { margin: 2px 0 10px; font-size: 13.5px; line-height: 1.7; font-weight: 600; }
.ft-meta { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--sub); flex-wrap: wrap; }
.ft-meta b { color: var(--brand); }
.ft-meta .btn-line { margin-left: auto; padding: 5px 12px; font-size: 11.5px; }
.ft-note { font-size: 10.5px; color: var(--sub); margin: 10px 0 0; }

.rk-cap { font-size: 11.5px; color: var(--sub); background: var(--bg); border-radius: 8px; padding: 8px 11px; margin: 0 0 12px; }
.rk-cap b { color: var(--fg); }

/* ============================================================
   긴급 위장 문서 — KPI/차트/진행바 (boss.js)
   ============================================================ */

.boss-doc h2.boss-h2 {
  font-size: 14px; margin: 22px 0 10px; color: #333;
  border-left: 3px solid #4472C4; padding-left: 9px;
}
.boss-h2 small { font-weight: normal; color: #999; font-size: 11px; }

.boss-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0 6px; }
.boss-kpis > div {
  border: 1px solid #e1e4e8; border-radius: 6px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px; background: #fafbfc;
}
.boss-kpis span { font-size: 10.5px; color: #888; }
.boss-kpis b { font-size: 19px; color: #222; font-variant-numeric: tabular-nums; }
.boss-kpis i { font-style: normal; font-size: 10.5px; color: #999; }
.boss-kpis i.g { color: #1a7d43; }

.boss-cv { width: 100%; height: 210px; display: block; margin: 4px 0 8px; }
.boss-cv.sq { height: 180px; }

.boss-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px; align-items: start; }

.bpb-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; font-size: 12.5px; color: #444; }
.bpb-row > span { width: 72px; flex-shrink: 0; }
.bpb { flex: 1; height: 11px; background: #edf0f3; border-radius: 2px; overflow: hidden; }
.bpb i { display: block; height: 100%; background: #4472C4; }
.bpb-row em { font-style: normal; font-size: 11.5px; color: #666; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.boss-doc b.ok { color: #1a7d43; font-weight: 600; }
.boss-doc b.warn { color: #c2410c; font-weight: 600; }

@media (max-width: 760px) {
  .boss-kpis { grid-template-columns: 1fr 1fr; }
  .boss-2col { grid-template-columns: 1fr; }
  .boss-cv { height: 170px; }
}

/* ---------- 리서치 리포트 ---------- */
.rs-list { display: flex; flex-direction: column; }
.rs-row {
  display: block; padding: 13px 4px; border-bottom: 1px solid var(--line); text-decoration: none;
}
.rs-row:last-child { border-bottom: none; }
.rs-row:hover .rs-title { color: var(--brand); }
.rs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.rs-broker {
  font-size: 10.5px; font-weight: bold; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent); border-radius: 7px; padding: 2.5px 8px;
}
.rs-meta { font-size: 11px; color: var(--sub); margin-left: auto; }
.rs-title { display: block; font-size: 14px; line-height: 1.5; }
.rs-preview {
  margin: 4px 0 0; font-size: 12.5px; color: var(--sub); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rs-note { font-size: 10.5px; color: var(--sub); margin: 12px 0 0; }
.d-report.link { display: block; text-decoration: none; }
.d-report.link:hover b { color: var(--brand); }

/* ---------- 온보딩 플로팅 가이드 (코치마크 투어) ---------- */
#tour-root { position: fixed; inset: 0; z-index: 300; }
#tour-root[hidden] { display: none !important; }
.tour-dim { position: absolute; inset: 0; }
.tour-spot {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(8, 10, 14, .62), 0 0 0 2px var(--brand);
  transition: all .28s cubic-bezier(.4, 0, .2, 1);
}
.tour-spot[hidden] { display: none !important; }
/* 스포트라이트가 있으면 그 box-shadow가 딤을 담당, 없는(중앙 카드) 스텝은 dim 레이어가 담당 */
#tour-root:has(.tour-spot[hidden]) .tour-dim { background: rgba(8, 10, 14, .62); }
.tour-card {
  position: fixed; background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35); width: 400px; max-width: calc(100vw - 24px);
  transition: top .28s cubic-bezier(.4, 0, .2, 1), left .28s cubic-bezier(.4, 0, .2, 1);
}
.tour-emoji { font-size: 26px; margin-bottom: 6px; }
.tour-title { display: block; font-size: 16px; margin-bottom: 6px; }
.tour-body { margin: 0 0 14px; font-size: 13px; line-height: 1.65; color: var(--sub); }
.tour-body b { color: var(--fg); }
.tour-foot { display: flex; align-items: center; justify-content: space-between; }
.tour-step { font-size: 11.5px; color: var(--sub); font-variant-numeric: tabular-nums; }
.tour-btns { display: flex; gap: 6px; }
.tour-btns button { border-radius: 9px; padding: 7px 13px; font-size: 12.5px; cursor: pointer; }
.tour-ghost { background: transparent; border: 1px solid var(--line); color: var(--sub); }
.tour-ghost:hover { color: var(--fg); border-color: var(--sub); }
.tour-cta { background: var(--brand); border: 1px solid var(--brand); color: #fff; font-weight: 700; }
.tour-cta:hover { filter: brightness(1.08); }
body.touring { overflow: hidden; }

/* ---------- 이사 라운지 이벤트 배너 ---------- */
.chat-vipbanner {
  margin: 8px 10px 0; padding: 9px 12px; border-radius: 10px; font-size: 12px; line-height: 1.55;
  background: linear-gradient(135deg, rgba(245, 197, 24, .14), rgba(245, 197, 24, .05));
  border: 1px solid rgba(245, 197, 24, .35); color: var(--fg);
}
.chat-vipbanner .vip-sub { display: block; font-size: 10.5px; color: var(--sub); margin-top: 2px; }

/* ---------- 설정: 긴급 위장 문서 (직군 프리셋 + 개별 토글) ---------- */
.set-boss { align-items: flex-start; }
.set-boss label small { color: var(--sub); font-weight: normal; font-size: 10.5px; }
#set-bossdocs { flex: 1; min-width: 0; }
.bs-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.bs-docs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.bs-doc {
  display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer;
  padding: 3px 2px; border-radius: 6px; white-space: nowrap; overflow: hidden;
}
.bs-doc:hover { background: var(--sel); }
.bs-doc input { accent-color: var(--brand); }
#set-bossdocs .set-note { margin: 6px 0 0; }
@media (max-width: 760px) {
  .set-boss { flex-direction: column; }
  .bs-docs { grid-template-columns: 1fr; }
}
#settings-modal .modal-card { max-height: 86vh; overflow-y: auto; }

/* 종목 상세: 최근 공시 */
.d-disc-row { display: block; padding: 7px 4px; border-radius: 8px; text-decoration: none; }
.d-disc-row:hover { background: var(--sel); }
.d-disc-row .dd-title { display: block; font-size: 13px; }
.d-disc-row .dd-meta { font-size: 11px; color: var(--sub); }

/* ETF 스크리너 컨트롤 */
.etf-ctrl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.etf-ctrl input {
  flex: 1; min-width: 140px; max-width: 220px; padding: 6px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); font-size: 12.5px; font-family: inherit;
}

/* 모의투자: 지정가·미체결·자산 곡선 */
.pt-order #pt-price { width: 110px; }
.pt-curve { width: 100%; height: 130px; margin-top: 4px; }
.pt-curve-h { margin: 14px 0 4px; font-size: 13px; }
.pt-curve-h small { color: var(--sub); font-weight: normal; }
.pt-ord-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 4px;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.pt-ord-row:last-child { border-bottom: none; }
.pt-ord-row .po-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-ord-row .po-name .code { font-style: normal; color: var(--sub); font-size: 11px; margin-left: 4px; }
.pt-ord-row .num { min-width: 70px; text-align: right; }
.po-cancel { padding: 4px 10px; font-size: 11.5px; }
