/* 네이버 금융 뉴스 화면을 참고한 조밀한 목록형 레이아웃 */

:root {
  --page: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e8;
  --border-soft: #eef0f2;
  --text: #1f2126;
  --link: #26313d;
  --link-hover: #0b62c4;
  --muted: #8b8f96;
  --accent: #0b62c4;
  --lnb-bg: #fafbfc;

  --up: #c8322c;
  --down: #1560ac;

  --watch-bg: #fff3c4;
  --watch-fg: #6b4e00;
  --pos-bg: #ffe0dd;
  --pos-fg: #8c2420;
  --neg-bg: #dbe9f7;
  --neg-fg: #1a4f7d;
  --macro-bg: #e8e6f6;
  --macro-fg: #443a7a;

  --tooltip-bg: #2b2d31;
  --tooltip-fg: #f4f4f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #14161a;
    --surface: #1c1f24;
    --border: #2d3138;
    --border-soft: #262a30;
    --text: #e7e8ea;
    --link: #dcdee2;
    --link-hover: #6fb2e8;
    --muted: #878b93;
    --accent: #6fb2e8;
    --lnb-bg: #191c21;

    --up: #f0736c;
    --down: #6fb2e8;

    --watch-bg: #4d3c00;
    --watch-fg: #ffe28a;
    --pos-bg: #4d211e;
    --pos-fg: #ffb3ad;
    --neg-bg: #17364f;
    --neg-fg: #9fcdf2;
    --macro-bg: #2f2a4d;
    --macro-fg: #c3bdf0;

    --tooltip-bg: #3b3f46;
    --tooltip-fg: #f0f1f3;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 13px/1.5 "Malgun Gothic", "맑은 고딕", "Segoe UI", system-ui, sans-serif;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ------------------------------------------------------------ 상단 헤더 */

.gnb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 12px;
  border-bottom: 2px solid var(--text);
}

.gnb h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gnb-right { display: flex; align-items: center; gap: 12px; }

.updated {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: progress; }

/* -------------------------------------------------------------- 레이아웃 */

.layout {
  display: grid;
  grid-template-columns: 186px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding-top: 16px;
}

@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------- 좌측 메뉴 */

.lnb { position: sticky; top: 12px; }

.lnb-title {
  margin: 0;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--lnb-bg);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.lnb-menu {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--surface);
}

.lnb-menu li + li { border-top: 1px solid var(--border-soft); }

.lnb-menu a {
  display: block;
  padding: 9px 10px;
  color: var(--link);
  text-decoration: none;
  font-size: 13px;
}

.lnb-menu a:hover { color: var(--link-hover); background: var(--lnb-bg); }

.lnb-menu a.on {
  background: var(--lnb-bg);
  border-left: 3px solid var(--accent);
  padding-left: 7px;
  color: var(--accent);
  font-weight: 700;
}

.lnb-box {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.lnb-box .lnb-title { border-bottom: 1px solid var(--border); }

/* 시세 목록 */

.quote-list { margin: 0; padding: 0; list-style: none; }

.quote-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
}

.quote-list li + li { border-top: 1px solid var(--border-soft); }

.quote-name { color: var(--muted); font-size: 12px; }

.quote-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quote-price { font-size: 12.5px; font-weight: 700; }

.quote-change { display: block; font-size: 11px; }
.quote-change.up { color: var(--up); }
.quote-change.down { color: var(--down); }
.quote-change.flat { color: var(--muted); }

.quote-empty { color: var(--muted); font-size: 12px; padding: 8px 10px; }

/* 키워드 범례 */

.legend { margin: 0; padding: 8px 10px; list-style: none; }
.legend li + li { margin-top: 5px; }

.key {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* --------------------------------------------------------------- 본문 */

.content { min-width: 0; }

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.search {
  flex: 0 1 320px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search:focus { outline: 1px solid var(--accent); outline-offset: -1px; }

.result-note { color: var(--muted); font-size: 12px; }

.block { margin-bottom: 26px; }
.block[hidden] { display: none; }

.block-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 2px;
  padding: 0 0 7px 9px;
  border-bottom: 1px solid var(--text);
  font-size: 14.5px;
  font-weight: 700;
  position: relative;
}

/* 제목 왼쪽 세로 강조선 */
.block-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 3px;
  height: 13px;
  background: var(--accent);
}

.block-title .count { color: var(--muted); font-size: 12px; font-weight: 400; }
.block-title .tip { margin-left: auto; color: var(--muted); font-size: 11.5px; font-weight: 400; }

/* ------------------------------------------------------------ 뉴스 목록 */

.nlist { margin: 0; padding: 0; list-style: none; }

.nitem {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 4px 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
}

.nitem::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: var(--muted);
}

/* 한 줄 고정 + 말줄임. 열이 흐트러지지 않게 언론사·시각은 고정폭 */
.nitem .tit {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--link);
  text-decoration: none;
  font-size: 13.5px;
}

.nitem .tit:hover { color: var(--link-hover); text-decoration: underline; }
.nitem .tit:visited { color: var(--muted); }

.nitem .press {
  flex: 0 0 112px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: right;
  color: var(--muted);
  font-size: 11.5px;
}

.nitem .time {
  flex: 0 0 76px;
  text-align: right;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.nitem.empty { color: var(--muted); padding-left: 10px; }
.nitem.empty::before { content: ""; }

.more { padding-top: 10px; text-align: center; }

.more button {
  width: 100%;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.more button:hover { border-color: var(--accent); color: var(--accent); }

/* 하이라이트 — 한글 사이 여백이 띄어쓰기처럼 보이지 않게 음수 마진으로 되돌린다 */

mark {
  padding: 1px 2px;
  margin: 0 -1px;
  border-radius: 2px;
  background: none;
  color: inherit;
  font-weight: 700;
}

.hl-watch    { background: var(--watch-bg); color: var(--watch-fg); }
.hl-positive { background: var(--pos-bg);   color: var(--pos-fg); }
.hl-negative { background: var(--neg-bg);   color: var(--neg-fg); }
.hl-macro    { background: var(--macro-bg); color: var(--macro-fg); }

/* 마우스를 올리면 영어 원문(번역된 기사) 또는 잘린 제목 전체를 띄운다 */

.nitem.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 10px;
  top: calc(100% - 6px);
  z-index: 5;
  max-width: min(560px, calc(100% - 20px));
  padding: 6px 9px;
  border-radius: 4px;
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

.nitem.has-tip:hover::after { opacity: 1; transition-delay: 0.25s; }

/* --------------------------------------------------------------- 푸터 */

.footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
}
