/* 공통 틀. 값은 tokens.css 의 변수만 쓴다 (디자인 기준 1순위). */
*, *::before, *::after { box-sizing: border-box; }
/* 페이지 끝선 — 상단 메뉴·도구 막대·본문·하단이 모두 같은 좌우 끝선을 쓴다. 화면마다 body 에서 바꾼다 (차트 1600/16, 워크스페이스 전체폭) */
:root { --st-page: 1440px; --st-pad: 40px; }
@media (max-width: 760px) { :root { --st-pad: 16px; } }
/* display 를 준 클래스(.st-btn 등)가 hidden 속성을 이기지 못하게 */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--st-bg); color: var(--st-text);
  font: 400 var(--st-fs-md)/1.5 var(--st-font); font-feature-settings: "tnum" 1;
}
:lang(ko) body { word-break: keep-all; line-height: 1.75; }
:lang(ja) body, :lang(zh-Hans) body { line-break: strict; }
/* 기본 링크 — 무채색, 밑줄 없음. 마우스를 올리면 옅은 밑줄 (버튼 모양 링크는 제외) */
a { color: var(--st-text); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--st-text); text-decoration: underline; text-decoration-color: var(--st-text-muted); }
a.st-btn:hover { text-decoration: none; }
:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 2px; border-radius: var(--st-r-xs); }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
small { font-size: var(--st-fs-sm); }   /* 기본 smaller(부모의 0.83배)는 단계 밖 크기를 만든다 */
sup, sub { font-size: var(--st-fs-xs); }
.mono { font-family: var(--st-mono); }
.muted { color: var(--st-text-muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- 시세 띠 (주메뉴 위, 오른쪽→왼쪽으로 흐름) ---- */
.st-tk { position: relative; overflow: hidden; height: 32px; display: flex; align-items: center; background: var(--st-surface-2); border-bottom: 1px solid var(--st-border); font-size: var(--st-fs-sm); flex-shrink: 0; }
.st-tk-track { display: flex; width: max-content; animation: st-tk var(--tk-dur, 60s) linear infinite; will-change: transform; }
.st-tk-grp { display: flex; gap: 28px; padding-right: 28px; }
.st-tk a { display: inline-flex; align-items: baseline; gap: 6px; color: var(--st-text); text-decoration: none; white-space: nowrap; }
.st-tk a:hover b { color: var(--st-accent); }
.st-tk b { font-weight: 600; }
.st-tk:hover .st-tk-track, .st-tk:focus-within .st-tk-track { animation-play-state: paused; }
@keyframes st-tk { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .st-tk { overflow-x: auto; }
  .st-tk-track { animation: none; }
  .st-tk-grp[aria-hidden="true"] { display: none; }
}

/* ---- 머리 메뉴 ---- */
.st-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px;
  height: 56px; padding: 0 max(var(--st-pad), calc((100% - var(--st-page)) / 2 + var(--st-pad))); background: var(--st-surface); border-bottom: 1px solid var(--st-border);
}
.st-logo { display: inline-flex; align-items: center; gap: 8px; color: var(--st-text); text-decoration: none; font-weight: 600; font-size: var(--st-fs-lg); }
.st-logo:hover { color: var(--st-text); }
.st-nav { display: flex; gap: 4px; height: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.st-nav a {
  display: inline-flex; align-items: center; padding: 0 12px; height: 100%; white-space: nowrap;
  color: var(--st-text); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent;
}
.st-nav a[aria-current="page"] { color: var(--st-accent); border-bottom-color: var(--st-accent); }
.st-nav a:hover { color: var(--st-accent); }
.st-top-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.st-lang select { min-height: 36px; padding: 0 8px; font: 500 var(--st-fs-md) var(--st-font); color: var(--st-text); background: var(--st-surface); border: 1px solid var(--st-border); border-radius: var(--st-r-md); }

/* ---- 버튼·칩·상자 ---- */
.st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px;
  font: 500 var(--st-fs-md)/1 var(--st-font); color: var(--st-text); background: var(--st-surface);
  border: 1px solid var(--st-border); border-radius: var(--st-r-md); cursor: pointer;
  transition: border-color var(--st-dur-fast) var(--st-ease), background var(--st-dur-fast) var(--st-ease);
}
.st-btn:hover { border-color: var(--st-accent); }
.st-btn-ghost { background: transparent; }
.st-btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--st-fs-md); }
.st-btn[aria-pressed="true"] { background: var(--st-accent); color: var(--st-on-accent); border-color: var(--st-accent); }

.st-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: var(--st-r-xs);
  background: var(--st-chip); color: var(--st-text-muted); font: 400 var(--st-fs-sm)/1.5 var(--st-mono); white-space: nowrap;
}
/* AI·서버가 계산한 값 — 점선 calc 칩 (HandoffRules) */
.st-calc { border: 1px dashed var(--st-text-muted); background: transparent; }

.st-card { background: var(--st-surface); border: 1px solid var(--st-border); border-radius: var(--st-r-lg); box-shadow: var(--st-shadow-md); }
.st-alert {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--st-r-md);
  background: var(--st-err-soft); color: var(--st-err);
}
.st-note { padding: 10px 14px; border-radius: var(--st-r-md); background: var(--st-note); color: var(--st-text); }

/* 상승·하락 — 색은 거들 뿐, ▲▼ 와 부호가 늘 같이 간다 */
.dir-up { color: var(--st-up); }
.dir-down { color: var(--st-down); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--st-r-sm); font-weight: 500; white-space: nowrap; }
.pill.dir-up { background: color-mix(in srgb, var(--st-up) 12%, transparent); }
.pill.dir-down { background: color-mix(in srgb, var(--st-down) 12%, transparent); }
.pill.dir-flat { background: var(--st-chip); color: var(--st-text-muted); }

/* 시장 배지 */
.mk-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  color: #fff; font: 600 10px/1 var(--st-font);   /* 배지 글자는 아이콘 — 글자 크기 단계 밖 */ flex-shrink: 0;
}

/* 스켈레톤 */
.skel { background: linear-gradient(90deg, var(--st-chip) 25%, var(--st-surface-2) 50%, var(--st-chip) 75%); background-size: 200% 100%; border-radius: var(--st-r-sm); animation: skel 1.2s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---- 본문 ---- */
.st-main { max-width: var(--st-page); margin: 0 auto; padding: 36px var(--st-pad) 48px; }
.st-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.st-page-head h1 { font-size: var(--st-fs-2xl); font-weight: 600; }
.st-page-head p { margin: 4px 0 0; color: var(--st-text-muted); }
.st-seg { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.st-seg > span { color: var(--st-text-muted); font-size: var(--st-fs-md); }

.st-foot {
  max-width: var(--st-page); margin: 0 auto; padding: 16px var(--st-pad) 32px; display: flex; gap: 16px; justify-content: space-between;
  flex-wrap: wrap; color: var(--st-text-muted); font-size: var(--st-fs-sm); border-top: 1px solid var(--st-border);
}
.st-foot p { margin: 0; }
.st-foot a { color: var(--st-text-muted); }

@media (max-width: 760px) {
  /* 모바일: 1줄 = 로고 + 언어·테마·계정, 2줄 = 메뉴 (한 줄에 다 넣으면 메뉴가 언어 상자 밑으로 잘려 보였다) */
  .st-top { flex-wrap: wrap; gap: 0 12px; height: auto; padding-top: 8px; }
  .st-logo span { display: none; }
  .st-nav { order: 3; flex: 0 0 100%; height: 42px; margin: 4px calc(var(--st-pad) * -1) 0; padding: 0 calc(var(--st-pad) - 12px); border-top: 1px solid var(--st-border); }
  .st-main { padding-top: 20px; padding-bottom: 32px; }

  .st-top-r .st-btn span { display: none; }
}

/* ---- 경제 캘린더·뉴스 패널 (feeds-ui.js — 홈·Markets·차트 공통) ---- */
.fd-day { padding: 10px 16px 6px; border-bottom: 1px solid var(--st-border); }
.fd-day:last-of-type { border-bottom: 0; }
.fd-day h3 { margin: 0 0 4px; font: 500 var(--st-fs-sm)/1.4 var(--st-font); color: var(--st-text-muted); }
.fd-day h3 b { color: var(--st-text); font-weight: 600; }
.fd-day ul { list-style: none; margin: 0; padding: 0; }
.fd-ev { display: grid; grid-template-columns: 40px 8px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 5px 0; font-size: var(--st-fs-md); }
.fd-ev.is-past { color: var(--st-text-muted); }
.fd-ev.is-past b { color: var(--st-text-muted); font-weight: 500; }
.fd-ev.is-next { background: color-mix(in srgb, var(--st-accent) 7%, transparent); margin: 0 -8px; padding: 5px 8px; border-radius: var(--st-r-sm); }
.fd-time { color: var(--st-text-muted); font-family: var(--st-mono); font-size: var(--st-fs-sm); }
.fd-imp { width: 7px; height: 7px; border-radius: var(--st-r-full); align-self: center; }
.fd-imp-h { background: var(--st-warn); }
.fd-imp-m { background: transparent; box-shadow: inset 0 0 0 1.5px var(--st-text-muted); }
.fd-title { min-width: 0; overflow-wrap: anywhere; }
.fd-next { display: inline-block; margin-left: 6px; padding: 0 6px; font: 500 var(--st-fs-xs)/1.6 var(--st-font); color: var(--st-accent); background: var(--st-accent-soft); border-radius: var(--st-r-sm); white-space: nowrap; }
.fd-next.is-live { color: var(--st-warn); background: var(--st-warn-soft); }
.fd-val { display: flex; flex-direction: column; align-items: flex-end; font-size: var(--st-fs-sm); white-space: nowrap; }
.fd-act { color: var(--st-text); font-weight: 600; }
.fd-fp { color: var(--st-text-muted); font-size: var(--st-fs-xs); }
.fd-foot { margin: 0; padding: 8px 16px 12px; font-size: var(--st-fs-xs); color: var(--st-text-muted); }
.fd-empty { padding: 16px; }
.fd-empty strong { display: block; margin-bottom: 4px; }
.fd-empty p { margin: 0; color: var(--st-text-muted); font-size: var(--st-fs-md); }
.fd-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 16px 6px; }
.fd-chips button { flex: none; padding: 3px 10px; font: 500 var(--st-fs-sm)/1.4 var(--st-font); color: var(--st-text-muted); background: var(--st-surface); border: 1px solid var(--st-border); border-radius: var(--st-r-full); cursor: pointer; }
.fd-chips button:hover { color: var(--st-text); }
.fd-chips button[aria-pressed="true"] { color: var(--st-accent); border-color: var(--st-accent); background: var(--st-accent-soft); }
.fd-chips button:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 1px; }
.fd-news { list-style: none; margin: 0; padding: 0; }
.fd-news li { padding: 10px 16px; border-bottom: 1px solid var(--st-border); font-size: var(--st-fs-md); }
.fd-news li:last-child { border-bottom: 0; }
.fd-news li > a { display: block; color: var(--st-text); font-weight: 500; line-height: 1.45; }
.fd-news li > a:hover { text-decoration: underline; text-decoration-color: var(--st-text-muted); }
.fd-news li.is-new { background: color-mix(in srgb, var(--st-accent) 5%, transparent); }
.fd-new { display: inline-block; margin-right: 6px; padding: 0 5px; font: 600 var(--st-fs-xs)/1.6 var(--st-font); color: var(--st-on-accent); background: var(--st-accent); border-radius: var(--st-r-sm); vertical-align: 1px; }
.fd-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; font-size: var(--st-fs-sm); color: var(--st-text-muted); }
.fd-tag { padding: 0 6px; font-size: var(--st-fs-xs); background: var(--st-chip); border-radius: var(--st-r-sm); }
.fd-also a { color: var(--st-text-muted); }

/* ---- 머리 메뉴 계정 자리 ---- */
.st-user { position: relative; display: flex; align-items: center; gap: 6px; }
.st-btn-accent { background: var(--st-accent); color: var(--st-on-accent); border-color: var(--st-accent); }
.st-btn-accent:hover { background: var(--st-accent-hover); color: var(--st-on-accent); }
.st-user .st-btn { text-decoration: none; }
.st-avatar { width: 36px; height: 36px; border-radius: var(--st-r-full); border: 1px solid var(--st-border); background: var(--st-accent-soft); color: var(--st-accent); font: 600 var(--st-fs-lg)/1 var(--st-font); cursor: pointer; }
.st-avatar:hover, .st-avatar[aria-expanded="true"] { border-color: var(--st-accent); }
.st-avatar:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 2px; }
.st-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; min-width: 220px; padding: 6px; background: var(--st-surface); border: 1px solid var(--st-border); border-radius: var(--st-r-md); box-shadow: var(--st-shadow-pop); }
.st-menu-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--st-border); }
.st-menu-who span { font-size: var(--st-fs-sm); color: var(--st-text-muted); overflow-wrap: anywhere; }
.st-menu-warn { font-size: var(--st-fs-sm); color: var(--st-warn); }
.st-menu [role="menuitem"] { display: block; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--st-text); font: inherit; font-size: var(--st-fs-md); text-align: left; text-decoration: none; border-radius: var(--st-r-sm); cursor: pointer; }
.st-menu [role="menuitem"]:hover, .st-menu [role="menuitem"]:focus-visible { background: var(--st-surface-2); outline: none; }
@media (max-width: 760px) { .st-user .st-btn-ghost { display: none; } }

/* ---- 캘린더·뉴스 서랍 (feeds-ui.js mountDrawer) ---- */
.fd-tab {
  position: fixed; right: 0; bottom: 96px; z-index: 35;   /* 가운데 두면 차트 옆 관심 목록 숫자를 가린다 */
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px;
  font: 600 var(--st-fs-md)/1.2 var(--st-font); color: var(--st-on-accent); background: var(--st-accent);
  border: 1px solid var(--st-accent); border-right: 0; border-radius: var(--st-r-md) 0 0 var(--st-r-md);
  box-shadow: var(--st-shadow-pop); cursor: pointer; writing-mode: vertical-rl; text-orientation: sideways; letter-spacing: .02em;
}
.fd-tab svg { writing-mode: horizontal-tb; }
.fd-tab:hover { background: var(--st-accent-hover); }
/* 처음 온 사람: 탭이 몇 번 두근거리고 옆에 말풍선 */
.fd-tab.is-hint { animation: fd-pulse 1.2s ease-in-out 4; }
@keyframes fd-pulse { 0%, 100% { box-shadow: var(--st-shadow-pop), 0 0 0 0 color-mix(in srgb, var(--st-accent) 55%, transparent); } 50% { box-shadow: var(--st-shadow-pop), 0 0 0 10px transparent; } }
.fd-tab-tip { position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); writing-mode: horizontal-tb; white-space: nowrap; padding: 8px 12px; font: 500 var(--st-fs-md)/1.3 var(--st-font); color: var(--st-text); background: var(--st-surface); border: 1px solid var(--st-border); border-radius: var(--st-r-md); box-shadow: var(--st-shadow-pop); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .fd-tab.is-hint { animation: none; } }
.fd-tab:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 2px; }
.fd-dr-on .fd-tab { visibility: hidden; }
.fd-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(420px, 100vw);
  display: flex; flex-direction: column; background: var(--st-surface); border-left: 1px solid var(--st-border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, .14); transform: translateX(100%); visibility: hidden;
  transition: transform .22s ease, visibility 0s linear .22s;
}
.fd-drawer.is-open { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
.fd-dr-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 0 16px; border-bottom: 1px solid var(--st-border); }
.fd-dr-tabs { display: flex; gap: 4px; flex: 1; }
.fd-dr-tabs button { padding: 10px 12px; font: 600 var(--st-fs-md)/1.2 var(--st-font); color: var(--st-text-muted); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.fd-dr-tabs button[aria-selected="true"] { color: var(--st-text); border-bottom-color: var(--st-accent); }
.fd-dr-tabs button:focus-visible { outline: 2px solid var(--st-focus); outline-offset: -2px; }
.fd-dr-x { width: 36px; height: 36px; margin-bottom: 4px; font-size: var(--st-fs-xl); line-height: 1; color: var(--st-text-muted); background: none; border: 0; border-radius: var(--st-r-sm); cursor: pointer; }
.fd-dr-x:hover { background: var(--st-surface-2); color: var(--st-text); }
.fd-dr-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
@media (prefers-reduced-motion: reduce) { .fd-drawer, .fd-drawer.is-open { transition: none; } }
/* 휴대폰: 오른쪽 아래 둥근 단추, 서랍은 화면 전체 */
@media (max-width: 760px) {
  .fd-tab { bottom: 16px; right: 16px; writing-mode: horizontal-tb; flex-direction: row; padding: 10px 14px; border-radius: var(--st-r-full); }
  .fd-tab-tip { right: 0; top: auto; bottom: calc(100% + 8px); transform: none; }
  .fd-drawer { width: 100vw; }
}

/* 서랍 무한 목록 (10-09) */
.fd-sec { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 16px 6px; font: 600 var(--st-fs-sm)/1.4 var(--st-font); letter-spacing: .04em; color: var(--st-text-muted); background: var(--st-surface); border-bottom: 1px solid var(--st-border); }
.fd-more { padding: 14px 16px 22px; text-align: center; font-size: var(--st-fs-sm); color: var(--st-text-muted); min-height: 20px; }
.fd-more[data-state="loading"]::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--st-border); border-top-color: var(--st-accent); border-radius: 50%; animation: fd-spin .8s linear infinite; }
@keyframes fd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .fd-more[data-state="loading"]::before { animation: none; } }
/* 뉴스 설명문 (수집 세션이 desc 를 주면 보인다) — 두 줄로 접는다 */
.fd-desc { margin: 2px 0 4px; font-size: var(--st-fs-sm); line-height: 1.5; color: var(--st-text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 시세 띠 김프 (10-09) — 원화가 비싸면 빨강 계열(웃돈), 싸면 파랑 계열 — 상승·하락 색 설정과 무관한 고정색 */
.tk-kp-up { color: #e11d48; }
.tk-kp-dn { color: #2563eb; }

/* ---- 보고서 좋아요·보고서 탭 (10-09) ---- */
.like-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: var(--st-r-md); background: none; color: var(--st-text-muted); font: inherit; font-size: var(--st-fs-md); cursor: pointer; }
.like-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.like-btn:hover { color: #e11d48; }
.like-btn[aria-pressed="true"] { color: #e11d48; }
.like-btn[aria-pressed="true"] svg { fill: currentColor; }
.like-btn:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 2px; }
.like-btn:disabled { opacity: .6; cursor: progress; }
.like-btn.like-lb { border-color: var(--st-border); background: var(--st-surface); padding: 0 10px; color: var(--st-text); }
.like-btn.like-lb[aria-pressed="true"] { color: #e11d48; border-color: #e11d48; }
.rc-top .like-btn { margin: -4px -6px -4px 0; }   /* .rc-state 가 margin-left:auto 로 오른쪽에 붙여 둔다 */
#rp-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rs-tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--st-border); overflow-x: auto; }
.rs-tabs a { padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--st-text-muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.rs-tabs a:hover { color: var(--st-text); }
.rs-tabs a[aria-current="page"] { color: var(--st-text); border-bottom-color: var(--st-accent); }
.rs-empty { padding: 28px; text-align: center; grid-column: 1 / -1; }
.rs-empty h2 { font-size: var(--st-fs-lg); margin: 0 0 6px; }
.rs-empty p { margin: 0 0 14px; }
.rs-more-wrap { text-align: center; margin: 18px 0 0; }
