/* ==========================================================================
   Stock Insight — 서피스 5종
   --------------------------------------------------------------------------
   개편 브리프의 디자인 5안을 전부 채택하되, 서로 다른 사이트가 되지 않도록
   base.css 의 토큰 위에 얹는 "화면 성격별 처리"로 구현한다.
   각 서피스는 자기 클래스 안에서만 스타일을 정의한다(전역 오염 금지).

     A  .s-doc        정밀 문서   → 종목상세 · 재무 · 검색 · 계정
     B  .term         터미널      → 시황/종목상세 안의 시세 보드 모듈(항상 다크)
     C  .s-story      설명 카드   → 홈 · 관심종목
     D  .s-editorial  리서치 지면 → 뉴스 · 정책/소개 문서
     E  .s-board      마켓 보드   → 시황 · 스크리너
   ========================================================================== */


/* ══ A ─ 정밀 문서 ═══════════════════════════════════════════════════════ */

.s-doc .doc-head {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r) var(--r) 0 0;
  border-bottom: 0;
  padding: var(--s5);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s4);
}

.s-doc .doc-ident { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.s-doc .doc-ident h1 {
  font-size: var(--fs-xl);
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  flex-wrap: wrap;
}
.s-doc .doc-ident h1 .ticker {
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--ink-mute);
  letter-spacing: 0;
}
.s-doc .doc-tags { display: flex; flex-wrap: wrap; gap: var(--s2); }

.s-doc .doc-quote { margin-left: auto; text-align: right; }
.s-doc .doc-quote .price {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.1;
  display: block;
}
.s-doc .doc-quote .delta {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.s-doc .doc-quote .asof {
  display: block;
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 2px;
}

.s-doc .doc-body {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 0 0 var(--r) var(--r);
  overflow: hidden;
}

/* 정밀 문서의 지표 격자 — 홀수 칸에만 세로 헤어라인 */
.s-doc .metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  border-top: 1px solid var(--line-soft);
}
.s-doc .metrics > div {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  padding: 9px var(--s5);
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
}
.s-doc .metrics dt { color: var(--ink-mute); margin: 0; white-space: nowrap; }
.s-doc .metrics dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 500;
}

.s-doc .doc-section {
  padding: var(--s5);
  border-top: 1px solid var(--line-soft);
}
.s-doc .doc-section h2 {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-mute);
  margin-bottom: var(--s3);
}
.s-doc .doc-section p { color: var(--ink-2); }

/* doc-body 안쪽에 표/지표를 이어 붙일 때는 자체 테두리를 지운다 */
.s-doc .doc-table { border: 0; border-radius: 0; }
.s-doc .metrics-flush { border-top: 0; }

.s-doc .doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.s-doc .search-field { max-width: 480px; }

/* 검색 결과 리스트 */
.s-doc .hitlist {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
}
.s-doc .hitlist li + li { border-top: 1px solid var(--line-soft); }
.s-doc .hitlist a {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s3) var(--s5);
  text-decoration: none;
  color: var(--ink);
}
.s-doc .hitlist a:hover { background: var(--surface-2); }
.s-doc .hitlist .meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-mute);
}
.s-doc .hitlist .none { padding: var(--s5); color: var(--ink-mute); font-size: var(--fs-sm); }


/* ══ B ─ 터미널 보드 (항상 다크. 라이트/다크 어느 호스트에서도 동일) ═════ */

.term {
  --t-bg:   #0B0E13;
  --t-pane: #11151D;
  --t-line: #1D2430;
  --t-ink:  #C9D1E0;
  --t-dim:  #727F94;   /* 옛 #5C6779 는 --t-pane 위에서 3.20 이었다 → 4.51 */
  --t-hi:   #F3F6FC;
  --t-key:  #E8B54B;
  --t-up:   #FF5C4D;
  --t-down: #5B9BFF;

  background: var(--t-bg);
  color: var(--t-ink);
  border: 1px solid var(--t-line);
  border-radius: var(--r);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.6;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--t-line);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--t-dim);
}
.term-bar .term-label { color: var(--t-key); font-weight: 600; }
.term-bar .term-clock { margin-left: auto; font-variant-numeric: tabular-nums; }

.term-panes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.term-pane {
  padding: var(--s3) var(--s4);
  border-right: 1px solid var(--t-line);
  border-bottom: 1px solid var(--t-line);
  min-width: 0;
}
.term-pane:last-child { border-right: 0; }
.term-pane .term-key {
  display: block;
  font-family: var(--font-sans);
  font-size: 10.5px;
  letter-spacing: .02em;
  color: var(--t-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.term-pane .term-val {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--t-hi);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.term-pane .term-delta { font-size: 11px; font-variant-numeric: tabular-nums; }

.term-up   { color: var(--t-up); }
.term-down { color: var(--t-down); }

.term-rows { padding: var(--s3) var(--s4) var(--s4); }
.term-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.term-row .term-name { color: var(--t-ink); font-family: var(--font-sans); font-size: var(--fs-xs); }
.term-row .term-qty  { color: var(--t-dim); }

.term-empty { padding: var(--s5); text-align: center; color: var(--t-dim); font-family: var(--font-sans); }

.term-foot {
  border-top: 1px solid var(--t-line);
  padding: var(--s2) var(--s4);
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: .01em;
  color: var(--t-dim);
}


/* ══ C ─ 설명 카드 ═══════════════════════════════════════════════════════ */

.s-story .story-hero {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--s7) var(--s6);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.s-story .story-hero h1 {
  font-size: var(--fs-3xl);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.14;
}
@media (max-width: 640px) {
  .s-story .story-hero { padding: var(--s6) var(--s5); }
  .s-story .story-hero h1 { font-size: var(--fs-2xl); }
}
.s-story .story-hero .lede { font-size: var(--fs-md); }

.s-story .story-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.s-story .story-card h2, .s-story .story-card h3 {
  font-size: var(--fs-md);
  font-weight: 600;
}
.s-story .story-card p { color: var(--ink-2); font-size: var(--fs-sm); }

.s-story .story-avatar {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: var(--fs-sm);
  flex: none;
}

.s-story .story-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.s-story .story-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  /* 아래 `.story-name::after` 가 기댈 자리 — 줄 전체가 링크가 된다. */
  position: relative;
}
.s-story .story-item .story-name { font-weight: 600; text-decoration: none; color: var(--ink); }
.s-story .story-item .story-name:hover { color: var(--accent); }
/* 종목명 앵커를 줄 전체에 펼친다(UIUX.md Fitts "목록 줄은 줄 전체가 링크").
   HTML 을 바꾸지 않으므로 `<a>` 안에 `<a>` 가 생기지 않고, 이 줄에 본문 문장이
   없어서(종목명·종목코드·시장뿐) 글자 선택을 잃을 것도 없다. */
.s-story .story-item .story-name::after { content: ""; position: absolute; inset: 0; }
.s-story .story-item .story-code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-mute); }
/* 줄 안의 폼(즐겨찾기 토글·목표가 입력)은 덮개 **위**로 올린다. position 이 없으면
   ::after 가 덮어 버려 폰에서 아무것도 못 누른다(UIUX.md Fitts 의 마지막 줄). */
.s-story .story-item form { margin-left: auto; position: relative; }

.s-story .story-pills { display: flex; flex-wrap: wrap; gap: var(--s2); }
.s-story .story-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;   /* 탭 대상 — 계산 높이가 31px 이었다 */
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  text-decoration: none;
}
.s-story .story-pill:hover { background: var(--accent); color: var(--on-accent); }

.s-story .story-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--s4);
}
.s-story .story-steps .story-card .step-mark {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--accent);
}


/* ══ D ─ 리서치 지면 ═════════════════════════════════════════════════════ */

/* 지면처럼 읽히도록 본문을 한 장의 종이 위에 올린다. */
.page.s-editorial {
  max-width: 940px;
  background: var(--surface);
  border-inline: 1px solid var(--line-soft);
  padding-inline: var(--s7);
}
@media (max-width: 700px) {
  .page.s-editorial { padding-inline: var(--s4); border-inline: 0; }
}

.s-editorial .ed-masthead {
  border-bottom: 2px solid var(--ink);
  padding-bottom: var(--s3);
  margin-bottom: var(--s5);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  flex-wrap: wrap;
}
.s-editorial .ed-masthead h1 {
  font-family: var(--font-serif);
  font-size: var(--fs-2xl);
  font-weight: 800;
  letter-spacing: -.02em;
}
.s-editorial .ed-masthead .ed-stamp {
  font-size: 11.5px;
  letter-spacing: .02em;
  color: var(--ink-mute);
}

.s-editorial .ed-prose { max-width: 66ch; display: flex; flex-direction: column; gap: var(--s4); }
.s-editorial .ed-prose h2 {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-top: var(--s4);
}
.s-editorial .ed-prose p { color: var(--ink-2); }
.s-editorial .ed-prose p strong { color: var(--ink); font-weight: 600; }
.s-editorial .ed-prose .ed-contact {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  color: var(--ink);
}

.s-editorial .ed-feed { list-style: none; margin: 0; padding: 0; }
.s-editorial .ed-item {
  padding: var(--s5) 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.s-editorial .ed-item:first-child { padding-top: 0; }
.s-editorial .ed-headline {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
  max-width: 60ch;
}
.s-editorial .ed-headline:hover { color: var(--accent); text-decoration: underline; }
.s-editorial .ed-dek { font-size: var(--fs-sm); color: var(--ink-2); max-width: 68ch; }
.s-editorial .ed-byline {
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--ink-mute);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
}


/* ══ E ─ 마켓 보드 ═══════════════════════════════════════════════════════ */

/* 화면 안 탭은 서피스와 무관하게 같은 모양이다. 2026-10-14 까지 `.s-board` 아래에만 있어서
   s-story(지수 사 모으기)·s-editorial(달걀 국면)의 탭이 꾸밈 없는 링크로 나갔다 —
   현재 탭 표시도 44px 탭 대상도 없었다. */
.board-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-bottom: var(--s4);
}
/* 탭 대상 44px — 계산 높이가 33px 이었다. */
.board-tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 5px var(--s3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-mute);
  text-decoration: none;
}
.board-tab:hover { color: var(--ink); }
.board-tab[aria-current="true"] { background: var(--ink); color: var(--ground); }

.s-board .board-section {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.s-board .board-section > h2 {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-mute);
}

/* 등락 히트맵 */
.s-board .heat {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 2px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
}
/* 글자색은 셀마다 다르다 — 옅은 세 단계(u1·z·d1) 위의 흰 글자는 2.83~3.20 이라
   먹글자로 뒤집는다. 변수로 두는 이유는 :hover 가 색을 되돌리지 않게 하기 위해서다. */
.s-board .heat-cell {
  padding: var(--s3);
  color: var(--heat-ink, #fff);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
/* 1.12 는 셀을 너무 밝혀 u2(4.40)·d2(4.15)의 흰 글자가 기준 아래로 떨어진다.
   1.06 이면 일곱 칸 전부 4.58 이상이면서 hover 가 그대로 보인다. */
.s-board .heat-cell:hover { filter: brightness(1.06); }
/* opacity 를 주면 글자가 바탕과 섞여 대비가 다시 떨어진다(u2 5.32 → 4.59,
   d2 5.03 → 4.40). 종목명은 히트맵의 본문이므로 온전한 색으로 둔다. */
.s-board .heat-cell .heat-name {
  font-size: var(--fs-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s-board .heat-cell .heat-val {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 등락 강도 5단계 — 국내 관행(상승 적색/하락 청색) */
.s-board .heat-u3 { background: #A81E14; }
.s-board .heat-u2 { background: #C6352A; }
.s-board .heat-u1 { background: #DE6F63; }
.s-board .heat-z  { background: #8A96A8; }
.s-board .heat-d1 { background: #6E9BE0; }
.s-board .heat-d2 { background: #2F6BD4; }
.s-board .heat-d3 { background: #17479E; }
/* 옅은 세 단계만 먹글자(5.80 · 6.20 · 6.57). 바탕 일곱 색은 그대로 둔다 —
   여기를 어둡게 하면 등락 강도 램프가 무너진다. */
.s-board .heat-u1,
.s-board .heat-z,
.s-board .heat-d1 { --heat-ink: #10131A; }

/* 필터 폼 */
.s-board .board-filters {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: var(--s4);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3) var(--s4);
  align-items: end;
}

/* 수급 막대 */
.s-board .flow-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.s-board .flow-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: var(--s3);
  align-items: center;
  font-size: var(--fs-sm);
}
.s-board .flow-row .flow-label { color: var(--ink-2); }
.s-board .flow-row .flow-track {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
  display: flex;
}
.s-board .flow-row .flow-fill { height: 100%; border-radius: var(--r-pill); }
.s-board .flow-row .flow-fill.buy  { background: var(--up); }
.s-board .flow-row .flow-fill.sell { background: var(--down); }
.s-board .flow-row .flow-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
@media (max-width: 560px) {
  .s-board .flow-row { grid-template-columns: 96px 1fr; }
  .s-board .flow-row .flow-val { grid-column: 2; text-align: right; }
}
