/* 스팀틱커 — 딥 네이비 트레이딩 터미널.
   한국 증시 관례: 상승 빨강 / 하락 파랑. 통화(골드)는 앰버. */
:root {
  --bg: #16202B;
  --panel: #1C2938;
  --panel-2: #223141;
  --line: #2A3A4D;
  --ink: #E8EEF4;
  --ink-2: #8FA3B5;
  --ink-3: #5A7086;
  --up: #F04E58;
  --down: #3F8FDE;
  --alert: #F04E58;     /* VI/오류 — 색상 규칙과 무관하게 항상 경고색 */
  --ok: #3DBE7B;        /* 연결 정상 — 등락 색 테마와 무관하게 항상 초록 */
  --gold: #D9A93F;      /* 텍스트용 골드 */
  --gold-mark: #B4842A; /* 차트 마크용 (검증 통과 팔레트) */
  --font-ui: 'Malgun Gothic', 'Segoe UI', sans-serif;
  --font-num: Consolas, 'Cascadia Mono', monospace;
}

/* 미국식 등락 색: 상승 초록 / 하락 빨강 */
:root[data-scheme="us"] {
  --up: #3DBE7B;
  --down: #E5484D;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* display:flex 등 저자 CSS가 UA의 [hidden]{display:none}을 덮어쓰는 것 방지 */
[hidden] { display: none !important; }
[data-auth="out"] .needs-auth,
[data-auth="in"] .needs-guest { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  /* zoom(UI 배율)은 vh를 스케일하지 않음 — 배율로 나눠야 확대 시 화면에 딱 맞는다 */
  height: calc(100vh / var(--ui-scale, 1));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── 커스텀 툴팁 ─────────────────────────── */
/* body 직속 fixed 단일 요소(JS 배치) — overflow 클리핑·스태킹 컨텍스트에 안 막힘 */
.tip-pop {
  position: fixed;
  width: max-content;
  max-width: 280px;
  padding: 8px 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  pointer-events: none;
  z-index: 1000;
  animation: tip-in 0.15s ease;
}
@keyframes tip-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tip-pop { animation: none; } }

.tip-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  user-select: none;
  vertical-align: 1px;
}
.tip-dot:hover { color: var(--ink); border-color: var(--gold-mark); }

/* ── 커스텀 스크롤바 ─────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }
::-webkit-scrollbar-corner { background: transparent; }

/* ── 상단 바 ─────────────────────────────── */
.topbar {
  container: topbar / inline-size;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand-mark {
  font-family: var(--font-num);
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 14px;
}
/* 등분 fr 트랙이 가장 긴 라벨 너비로 수렴 — 언어 바뀌어도 버튼 폭 통일 */
.nav { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.nav-btn {
  background: none;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  text-align: center;
  color: var(--ink-2);
  font-weight: 700;
  cursor: pointer;
}
.nav-btn:hover { color: var(--ink); background: var(--panel-2); }
.nav-btn.active { color: var(--gold); background: var(--panel-2); }
.live { display: flex; align-items: center; gap: 7px; color: var(--ink-2); margin-left: auto; }
/* 레이아웃 박스는 항상 13px 고정 — 점·스피너·체크가 커져도 주변이 안 밀림.
   시각적 점은 ::before가 그리고 scale로만 커져서 중앙 기준 확대. */
.live-dot {
  position: relative;
  width: 13px; height: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.live-dot::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--alert);
  transform: scale(.54); /* 13px × .54 ≈ 7px 점 */
  transition: transform .25s ease, background-color .25s ease, border-color .25s ease;
}
.live.ok .live-dot::before { background: var(--ok); }

/* 카운트다운 0초 → 점이 중앙에서 링으로 커지며 회전 (새 시세 대기) */
.live.loading .live-dot { animation: live-spin .8s linear infinite; } /* 회전은 박스에 — ::before의 scale 전환과 transform 충돌 방지 */
.live.loading .live-dot::before {
  transform: scale(1);
  background: transparent;
  border-color: var(--line);
  border-top-color: var(--gold);
}
@keyframes live-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 재조회·첫 로드 대기 — 콘텐츠 디밍 + 중앙 스피너, 데이터 도착 렌더가 해제.
   디밍은 자식에만 걸어 ::after 스피너는 선명하게 유지 */
.reloading { pointer-events: none; }
.reloading > * { opacity: .45; transition: opacity .15s ease; }
.reloading::after {
  content: '';
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: live-spin .8s linear infinite;
}
.view.reloading::after { position: fixed; } /* 뷰가 스크롤돼 있어도 화면 중앙 */
.rows.reloading { position: relative; }     /* 목록 첫 로드 — 목록 영역 중앙 */
.rows.reloading::after { position: absolute; }
.sec-panel.reloading { position: relative; } /* 종목 정보 — 패널 영역 중앙 */
.sec-panel.reloading::after { position: absolute; }
@media (prefers-reduced-motion: reduce) {
  .reloading::after { animation: none; border-color: var(--gold); border-top-color: transparent; }
}

/* 새 시세 수신 → 초록 원이 팝되며 체크 스트로크 드로우, 끝나면 JS가 ok로 복귀 */
.live-check {
  position: relative; /* ::before(원) 위에 체크가 그려지도록 */
  width: 9px; height: 9px;
  fill: none; stroke: var(--bg); stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 12; stroke-dashoffset: 12;
  opacity: 0;
  transition: opacity .15s ease; /* done 해제 시 원 줄어드는 동안 체크는 페이드아웃 */
}
.live.done .live-dot { animation: live-pop .3s ease; }
.live.done .live-dot::before {
  transform: scale(1);
  background: var(--ok);
}
.live.done .live-check {
  opacity: 1;
  animation: live-draw .35s ease-out .12s both;
}
@keyframes live-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes live-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
}
@media (prefers-reduced-motion: reduce) {
  .live.loading .live-dot, .live.done .live-dot { animation: none; }
  .live.done .live-check { animation: none; stroke-dashoffset: 0; }
}
/* 종목명 앞 스팀 앱 아이콘 */
.sym-icon {
  width: 16px; height: 16px; border-radius: 3px;
  vertical-align: -3px; margin-right: 6px;
}
/* 아이콘 높이 = 타이틀 line-height(34px) — 위아래 정확히 맞음.
   제목이 여러 줄로 꺾여도 첫 줄 기준 정렬되도록 상단 정렬. */
.title-row { display: flex; align-items: flex-start; gap: 10px; }
.store-btn {
  flex-shrink: 0;
  height: 22px; margin-top: 6px; /* 34px 첫 줄 안에서 세로 중앙 */
  padding: 0 8px;
  background: none;
  border: 1px solid var(--line); border-radius: 4px;
  color: var(--ink-2); font-size: 11px;
  cursor: pointer;
}
.store-btn:hover { color: var(--gold); border-color: var(--gold-mark); }
.sym-icon-lg { width: 34px; height: 34px; border-radius: 5px; margin-right: 0; flex-shrink: 0; }

.wallet { text-align: right; cursor: pointer; }
.wallet:hover .wallet-label { color: var(--ink); }
.wallet-label { color: var(--ink-3); margin-right: 10px; }
.wallet-total { font-family: var(--font-num); font-size: 17px; font-weight: 700; color: var(--gold); }
.wallet-cash { display: block; color: var(--ink-3); font-family: var(--font-num); font-size: 11px; }
.login-btn {
  height: 34px;
  padding: 0 14px;
  background: var(--gold-mark);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.login-btn:hover { background: var(--gold); }

/* zoom(UI 배율)은 미디어 쿼리 뷰포트 판정에 반영되지 않음 — 배율이 반영된 컨테이너 폭으로 좁음을 판단 */
@container topbar (max-width: 980px) {
  .topbar { gap: 12px; }
  #live-text { display: none; }
}
@container topbar (max-width: 820px) {
  .wallet-label, .wallet-cash { display: none; }
  .nav-btn { padding: 7px 10px; }
}
@container topbar (max-width: 720px) {
  .topbar { gap: 8px; }
  .brand-mark { font-size: 12px; letter-spacing: 0.08em; }
  .nav-btn { padding: 7px 8px; font-size: 12px; }
  .wallet-total { font-size: 15px; }
}

/* ── 레이아웃 ────────────────────────────── */
.layout { container: layout / inline-size; flex: 1; display: flex; min-height: 0; }

/* ── 종목 리스트 ─────────────────────────── */
.list-pane {
  width: 340px;
  min-width: 260px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
@container layout (max-width: 760px) {
  .list-pane { width: 280px; }
}
/* 시장 세그먼트 (전체/메이저/마이너) — 차트 범위 버튼과 같은 시각 언어 */
.market-seg { display: flex; gap: 6px; padding: 10px 10px 0; }
.seg-btn {
  flex: 1;
  min-width: 0;
  padding: 5px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
}
.seg-btn.active { color: var(--ink); border-color: var(--gold-mark); }
.seg-n { color: var(--ink-3); font-family: var(--font-num); font-size: 11px; }
.seg-btn.active .seg-n { color: var(--ink-2); }
/* 관심종목만 보기 — 시장 세그먼트 옆 작은 별 토글. 텍스트 ★는 폰트 메트릭 따라
   세로가 틀어져 SVG로 그린다 */
.seg-btn-watch {
  flex: 0 0 auto;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.seg-btn-watch svg { width: 13px; height: 13px; fill: currentColor; flex-shrink: 0; }
.seg-btn-watch.active { color: var(--gold); }
.rows-empty { color: var(--ink-3); font-size: 14px; padding: 14px 12px; }

.list-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.list-tools input, .list-tools select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
}
.list-tools input { flex: 1 1 100%; min-width: 0; }
.list-tools select { flex: 1 1 0; min-width: 0; }
/* 합성 스크롤 승격을 상시 유지 — 부팅·포커스 복귀 뒤 메인 스레드 스크롤로 떨어지는 렉을 막는다 */
.rows { --row-pad-y: 8px; --row-pad-x: 12px; flex: 1; overflow-y: auto; overflow-x: hidden; list-style: none; will-change: scroll-position; }
/* 스크롤 동안 행 히트테스트 차단 — hover 변화가 배너 blur 재래스터를 매 스텝 일으키는 것을 막는다 */
.rows.scrolling .row { pointer-events: none; }
.row {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  align-items: start;
  width: 100%;
  padding: var(--row-pad-y) var(--row-pad-x);
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}
/* 게임 배너 배경 — 좌측(이름 영역)일수록 네이비를 진하게 깔아 텍스트 가독성 유지. */
.row::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(90deg, rgba(22, 32, 43, 0.95) 0%, rgba(22, 32, 43, 0.82) 50%, rgba(22, 32, 43, 0.66) 100%),
    var(--banner, none);
  background-size: cover;
  background-position: center;
  filter: blur(3px) saturate(0.85);
  transform: scale(1.1);
}
.row > * { position: relative; z-index: 1; min-width: 0; }
.row:hover::before { filter: blur(3px) saturate(0.85) brightness(1.3); }
.row.selected::before { filter: blur(3px) saturate(0.9) brightness(1.45); }
/* 구운 배너는 blur·채도가 이미 반영돼 실시간 필터를 걷어내 스크롤 래스터를 싸게 만든다 */
.row.baked::before { filter: none; transform: none; }
.row.baked:hover::before { filter: brightness(1.3); }
.row.baked.selected::before { filter: brightness(1.45); }
.row.selected::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold-mark);
  z-index: 2;
}
/* 카드 높이 통일: 제목 3줄 분량을 항상 예약 — 제목 길이가 높이를 못 흔들게.
   3줄 초과분만 말줄임. */
.row-main {
  display: flex;
  flex-direction: column;
  min-height: 107px;  /* 제목 3줄(69px) + 여백(4) + 동접(17) + 평소 대비(17) */
}
.row-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: 17px;
  line-height: 23px;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}
.row-sub {
  color: var(--ink-3);
  font-size: 13px;
  line-height: 17px;
  font-family: var(--font-num);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-dev.flat { color: var(--ink-3); }
/* 카드 좌측 하단 배지 줄 — 제목 3줄 예약 공간의 남는 바닥에 붙임 */
.row-badges { display: flex; gap: 4px; margin-top: auto; padding-top: 4px; }
.row-badges .vi-chip, .row-badges .mkt-chip { margin-left: 0; }
/* 우측: 가격 줄(타이틀과 같은 y) → ±₩ → 남는 높이 전부 스파크 차트 */
.row-side { display: flex; flex-direction: column; align-items: flex-end; align-self: stretch; }
.row-line { display: flex; align-items: baseline; gap: 8px; }
.row-price { font-family: var(--font-num); font-size: 17px; }
.row-abs { font-family: var(--font-num); font-size: 11px; }
.row-change { font-family: var(--font-num); font-size: 16px; }
.row-spark { width: 100%; flex: 1; min-height: 34px; margin-top: 4px; }
.row-spark.suspended path { stroke-dasharray: 4 4; }
/* data-ad-status는 AdSense가 광고 채움 결과로 붙이는 속성 */
.ad-slot { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-inline: var(--row-pad-x); }
.ad-slot:has([data-ad-status="unfilled"]) { display: none; }
.ad-slot:has([data-ad-status="filled"]) { padding-block: var(--row-pad-y); border-bottom: 1px solid var(--line); }
.ad-slot .ad-label { display: none; margin-left: 0; }
.ad-slot:has([data-ad-status="filled"]) .ad-label { display: block; }
.ad-unit { align-self: stretch; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-3); }
.gold { color: var(--gold); }

/* ── 상세 ────────────────────────────────── */
.detail-pane { container: detail / inline-size; flex: 1; overflow-y: auto; overflow-x: hidden; min-width: 0; }
.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-2);
}

.detail { padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.detail-head > div:first-child { min-width: 0; flex: 1; }
.detail-head h1 {
  font-size: 30px;  /* 현재가(quote-price)와 동일 크기 */
  font-weight: 700;
  line-height: 34px; /* 아이콘(.sym-icon-lg)과 딱 맞추기 위해 명시 */
  overflow-wrap: anywhere;  /* 제목은 절대 자르지 않음 — 길면 줄바꿈 */
}
.quote { flex-shrink: 0; }
.detail-meta { display: flex; gap: 6px; margin-top: 6px; }
.chip {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 9px;
}
.quote { text-align: right; }
.quote-price { font-family: var(--font-num); font-size: 30px; font-weight: 700; }
.quote-change { font-family: var(--font-num); font-size: 13px; margin-top: 2px; }
@container detail (max-width: 420px) {
  .detail-head { flex-direction: column; gap: 8px; }
  .title-row { flex-wrap: wrap; }
  .quote { text-align: left; }
  .quote-price { font-size: 24px; }
}

/* ── 차트 ────────────────────────────────── */
.range-row { display: flex; gap: 6px; }
.tab-strip.range-strip { gap: 6px; }
.range-btn {
  min-width: 80px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  text-align: center;
  color: var(--ink-2);
  cursor: pointer;
}
.range-btn.active { color: var(--ink); border-color: var(--gold-mark); }
.ct-seg {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.ct-btn {
  background: var(--panel-2);
  border: none;
  padding: 4px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.ct-btn + .ct-btn { border-left: 1px solid var(--line); }
.ct-btn svg { width: 20px; height: 14px; fill: none; stroke: var(--ink-3); stroke-width: 1.6; }
.ct-btn[data-ct="candle"] svg rect { fill: var(--ink-3); stroke: none; }
.ct-btn.active { background: var(--panel); }
.ct-btn.active svg { stroke: var(--gold-mark); }
.ct-btn.active[data-ct="candle"] svg rect { fill: var(--gold-mark); }
@container detail (max-width: 560px) {
  .range-row { flex-wrap: wrap; }
  .range-btn { min-width: 60px; }
}
.chart-wrap { position: relative; }
#chart { width: 100%; height: clamp(320px, calc(44vh / var(--ui-scale, 1)), 480px); display: block; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--font-num);
  font-size: 14px;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 2;
}
/* 값 시작점을 맞추는 고정폭 라벨. 가장 긴 마지막 3글자에 맞춘다 */
.tooltip .tl { display: inline-block; width: 3.9em; }

/* ── 기대 이탈 미터 (시그니처) ───────────── */
.meter-block { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel); }
.meter-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.meter { position: relative; height: 14px; background: var(--panel-2); border-radius: 7px; overflow: hidden; }
.meter-center {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; background: var(--ink-3);
}
.meter-bar {
  position: absolute; top: 2px; bottom: 2px;
  /* border-radius는 JS가 방향에 따라 설정 — 중앙 각지게, 바깥 끝만 둥글게 */
  transition: left 0.4s, width 0.4s, background 0.4s;
}
@media (prefers-reduced-motion: reduce) { .meter-bar { transition: none; } }
.meter-legend {
  display: flex; justify-content: space-between;
  margin-top: 8px; color: var(--ink-3); font-family: var(--font-num); font-size: 13px;
}
/* 라벨은 흐리게, 숫자만 크고 밝고 굵게 — 시선이 숫자에 꽂히도록 */
.meter-legend b { color: var(--ink); font-weight: 700; font-size: 16px; }
/* 미터 중앙 상단(±명)·하단(±%) — 등락색 연동 */
.meter-delta, .meter-pct {
  text-align: center;
  font-family: var(--font-num);
  font-size: 16px;
  font-weight: 700;
  min-height: 20px;  /* 데이터 없을 때도 자리 유지 — 레이아웃 출렁임 방지 */
}
.meter-delta { margin-bottom: 6px; }
.meter-pct { margin-top: 6px; }

/* ── 배지·VI ──────────────────────────────── */
.vi-banner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border: 1px solid var(--alert);
  border-radius: 20px;
  color: var(--alert);
  font-weight: 700;
  font-size: 11px;
}
.vi-banner[data-tip] { cursor: help; }
.vi-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--alert);
  border-radius: 4px;
  color: var(--alert);
  font-family: var(--font-num);
  font-size: 10px;
  vertical-align: 1px;
}
/* 시장 배지 — 통계 표 종목명 옆 (설정으로 켬/끔) */
.mkt-chip, .ad-label {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-3);
  font-size: 10px;
  vertical-align: 1px;
}
/* 시장 배지 — 상세 메타 칩 (#appid 옆, 항상 표시) */
.chip-tier { color: var(--ink-3); }
/* 신규 배지 — 상장 7일 이내, 골드로 강조 */
.chip-new { color: var(--gold); border-color: var(--gold-mark); }

/* ── 상세 섹션 탭 (헤더) ──────────────────── */
.sec-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}
/* 등분 fr 트랙이 가장 긴 라벨 너비로 수렴 — 언어 바뀌어도 그룹 내 버튼 폭 통일 */
.tab-strip { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.sec-tab {
  position: relative;
  min-width: 80px;
  background: none;
  border: none;
  padding: 10px 12px;
  text-align: center;
  color: var(--ink-3);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.sec-tab:hover { color: var(--ink-2); }
.sec-tab.active { color: var(--ink); }
/* 활성 탭 하단 골드 인디케이터 — 헤더 경계선 위에 겹침 */
.sec-tab.active::after {
  content: '';
  position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; background: var(--gold-mark); border-radius: 2px;
}
/* 섹션 탭 행 우측 끝의 매수·매도 버튼 */
.order-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.order-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}
.order-btn.buy { background: var(--up); }
.order-btn.sell { background: var(--down); }
.order-btn:hover { filter: brightness(1.1); }
.order-btn:disabled { opacity: 0.4; cursor: default; filter: none; }
@container detail (max-width: 480px) {
  .sec-tabs { flex-wrap: wrap; }
  .order-actions { padding-bottom: 8px; }
}

.sec-panel { display: flex; flex-direction: column; gap: 14px; }
/* 종목 정보 */
.info-desc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold-mark);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.7;
}
/* 요일 선택 버튼 — 누른 요일만 골드 테두리 */
.exp-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.exp-head .info-group-title { margin-bottom: 0; }
.dow-row { flex: 1 1 auto; min-width: 0; display: flex; justify-content: flex-end; gap: 6px; }
.dow-btn {
  flex: 1 1 0;
  max-width: 80px;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 0;
  text-align: center;
  color: var(--ink-2);
  font-family: var(--font-num);
  cursor: pointer;
}
.dow-btn.active { color: var(--ink); border-color: var(--gold-mark); }
/* 시간대별 기대 동접 막대 곡선 — 현재 시간대만 골드 */
.exp-curve {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 14px 8px;
}
.exp-col { flex: 1; min-width: 0; height: 122px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.exp-bar { background: var(--ink-3); border-radius: 2px 2px 0 0; }
.exp-col.cur .exp-bar { background: var(--gold-mark); }
.exp-hour { height: 14px; font-size: 11px; color: var(--ink-3); text-align: center; font-family: var(--font-num); }
.exp-col.cur .exp-hour { color: var(--gold); }
.info-group-title { color: var(--ink-3); font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.info-rows {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.info-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 14px; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info-row dt { color: var(--ink-3); font-size: 14px; flex-shrink: 0; }
.info-row dd { font-size: 14px; text-align: right; overflow-wrap: anywhere; }
/* 스팀 평가 라벨 — 등락 색 테마와 무관하게 스팀 상점 원색 고정 */
.rv-pos { color: #66C0F4; }
.rv-mixed { color: #B9A074; }
.rv-neg { color: #A34C25; }
/* ── 내 주식 섹션: 보유 현황 ─────────────── */
/* 좌: 보유 현황 · 우: 대기 주문 + 거래 내역 */
.hold-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 20px;
  align-items: start;
}
.hold-col-r { display: flex; flex-direction: column; gap: 16px; }
.hold-col-r .orders:empty { display: none; }
@container detail (max-width: 640px) { .hold-layout { grid-template-columns: 1fr; } }

.hold-head, .ord-head { color: var(--ink-3); font-size: 15px; font-weight: 600; margin-bottom: 13px; }
.hold-empty { color: var(--ink-3); font-size: 15px; padding: 12px 2px; }
.hold-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}
.hold-main { padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.hold-main-lbl { color: var(--ink-3); font-size: 15px; margin-bottom: 8px; }
.hold-main-val { font-family: var(--font-num); font-size: 32px; font-weight: 700; line-height: 1.05; }
.hold-stats { display: flex; flex-direction: column; }
.hold-stat { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 11px 0; }
.hold-stat + .hold-stat { border-top: 1px solid var(--line); }
.hold-stat dt { color: var(--ink-3); font-size: 16px; }
.hold-stat dd { font-family: var(--font-num); font-size: 19px; color: var(--ink); }
.hold-total { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hold-pnl { font-size: 15px; }

/* 종목별 거래 내역 */
.d-trades { display: flex; flex-direction: column; }
.tr-line {
  display: flex; align-items: baseline; gap: 12px;
  max-width: 480px;
  padding: 9px 2px;
  font-family: var(--font-num); font-size: 14px;
  border-top: 1px solid var(--line);
}
.tr-line:last-child { border-bottom: 1px solid var(--line); }
.tr-time { flex-shrink: 0; color: var(--ink-3); font-size: 13px; min-width: 82px; }
.tr-side { flex-shrink: 0; font-size: 12px; font-weight: 700; min-width: 30px; }
.tr-side.buy { color: var(--up); }
.tr-side.sell { color: var(--down); }
.tr-qty { color: var(--ink); }
.tr-per { margin-left: auto; color: var(--ink-2); }

/* ── 페이지 (통계/마이페이지/설정) ────────── */
.page { container: page / inline-size; flex: 1; overflow-y: auto; min-height: 0; scrollbar-gutter: stable; }
.page-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page-inner h2 { font-size: 19px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
/* 통계 페이지 시장 세그먼트 — 제목 왼쪽, 컨트롤 오른쪽 정렬 */
.page-head .market-seg { margin-left: auto; padding: 0; }
.page-head .seg-btn { flex: 0 0 108px; padding: 5px 0; font-size: 14px; }
.page-head select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 16px;
}
.page-inner h3 { font-size: 16px; color: var(--ink-2); margin-bottom: 8px; }
.h-sub { color: var(--ink-3); font-weight: 400; font-size: 14px; margin-left: 6px; }
.col2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* 상세 안에서는 detail, 페이지 안에서는 page — 가장 가까운 컨테이너 기준 */
@container (max-width: 640px) { .col2 { grid-template-columns: 1fr; } }

/* 타일 */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--gold-mark); }
.tile-label { color: var(--ink-3); font-size: 14px; }
.tile-value { font-family: var(--font-num); font-size: 22px; font-weight: 700; margin-top: 4px; }
.tile-value.alert { color: var(--alert); }
.tile-sub { font-family: var(--font-num); font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.tile-sub.alert { color: var(--alert); }

/* ── 보유 종목 카드 (내 주식) ─────────────── */
/* 거래 리스트와 같은 배너 카드 문법. 하단 골드 바가 포트폴리오 비중을 표시 —
   목록을 훑으면 자산 배분이 막대 길이로 한눈에 보인다. */
.h-cards { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.h-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px 240px;
  gap: 8px 24px;
  align-items: start;
  width: 100%;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}
.h-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(90deg, rgba(22, 32, 43, 0.97) 0%, rgba(22, 32, 43, 0.9) 50%, rgba(22, 32, 43, 0.78) 100%),
    var(--banner, none);
  background-size: cover;
  background-position: center;
  filter: blur(3px) saturate(0.85);
  transform: scale(1.1);
}
.h-card > * { position: relative; z-index: 1; min-width: 0; }
.h-card:hover::before { filter: blur(3px) saturate(0.85) brightness(1.3); }
/* 제목 2줄 분량을 항상 예약 — 제목 길이가 카드 높이·내부 배치를 못 흔들게 */
.hc-main { display: flex; flex-direction: column; min-height: 106px; }
.hc-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: 52px;
  font-size: 20px;
  line-height: 26px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.hc-sub {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 22px;
  font-family: var(--font-num);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 그래프는 자기 칸을 가짐 — 숫자 열과 섞지 않는다 */
.hc-chart { align-self: stretch; display: flex; }
.hc-spark { width: 100%; flex: 1; min-height: 72px; }
.hc-side { display: flex; flex-direction: column; align-items: flex-end; align-self: stretch; }
.hc-pct { font-family: var(--font-num); font-size: 25px; font-weight: 700; line-height: 1.2; }
.hc-pnl { font-family: var(--font-num); font-size: 15px; margin: 2px 0 6px; }
.hc-weight {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--gold-mark);
  z-index: 2;
}
@container page (max-width: 820px) {
  .h-card { grid-template-columns: minmax(0, 1fr) 220px; }
  .hc-chart { grid-column: 1 / -1; }
}

/* ── 리더보드 카드 ────────────────────────── */
/* 보유 종목 카드와 같은 배너 문법 — 배경은 스팀 프로필 배경 */
.lb-cards { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.lb-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 52px 64px minmax(0, 1fr) 170px 170px 230px;
  gap: 18px;
  align-items: center;
  padding: 14px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.lb-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(90deg, rgba(22, 32, 43, 0.95) 0%, rgba(22, 32, 43, 0.84) 50%, rgba(22, 32, 43, 0.68) 100%),
    var(--lb-bg, none);
  background-size: cover;
  background-position: center;
  filter: saturate(0.9);
}
.lb-card > * { position: relative; z-index: 1; min-width: 0; }
.lb-rank { font-family: var(--font-num); font-size: 19px; font-weight: 700; color: var(--ink-3); text-align: center; }
.lb-top1 .lb-rank { color: var(--gold); }
.lb-top2 .lb-rank { color: #C8D2DC; }
.lb-top3 .lb-rank { color: #D29A68; }
.lb-top1, .lb-top2, .lb-top3 { border-color: color-mix(in srgb, var(--gold-mark) 40%, var(--line)); }
/* 내 카드 — 목록에서 자기 위치가 바로 보이게 골드 테두리 */
.lb-mine { border-color: var(--gold-mark); }
.lb-ava { width: 64px; height: 64px; }
.lb-ava-empty { display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: var(--ink-3); }
.lb-ava-btn { padding: 0; background: none; border: none; cursor: pointer; }
.lb-ava-btn:hover .lb-ava { border-color: var(--gold-mark); }
.lb-fav-btn {
  max-width: 100%;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.lb-fav-btn:hover { color: var(--gold); }
.lb-name {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-name-btn { max-width: 100%; justify-self: start; padding: 0; background: none; border: none; color: inherit; text-align: left; cursor: pointer; }
.lb-name-btn:hover { color: var(--gold); }
.lb-col { display: flex; flex-direction: column; gap: 3px; }
.lb-col-label { color: var(--ink-3); font-size: 13px; }
.lb-col-value {
  font-family: var(--font-num);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@container page (max-width: 1000px) {
  .lb-card { grid-template-columns: 40px 52px minmax(0, 1fr); gap: 8px 14px; }
  .lb-ava { width: 52px; height: 52px; }
  .lb-col { grid-column: 3; }
  .lb-col-label { font-size: 12px; }
  .lb-col-value { font-size: 15px; }
}

/* 표 */
.tbl { width: 100%; border-collapse: collapse; font-family: var(--font-num); font-size: 14px; }
.tbl th {
  text-align: right;
  color: var(--ink-3);
  font-weight: 400;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child {
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: var(--panel-2); }
.tbl time { color: var(--ink-3); font-size: 13px; }
.delta-g { color: var(--ink-3); font-size: 12px; margin-right: 8px; }
.tbl-empty { color: var(--ink-3); font-size: 14px; padding: 10px 2px; }

/* 미체결 주문 */
.orders { display: flex; flex-direction: column; gap: 8px; }
.ord-card {
  max-width: 480px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 14px;
}
.ord-card.buy { border-left-color: var(--up); }
.ord-card.sell { border-left-color: var(--down); }
.ord-card-top { display: flex; align-items: center; gap: 10px; }
.ord-side {
  flex-shrink: 0;
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 4px;
}
.ord-side.buy { color: var(--up); background: color-mix(in srgb, var(--up) 14%, transparent); }
.ord-side.sell { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.ord-line { flex: 1; min-width: 0; font-family: var(--font-num); font-size: 15px; color: var(--ink); }
.ord-line b { font-weight: 700; }
.ord-card-bot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ord-exp { flex: 1; font-family: var(--font-num); font-size: 13px; color: var(--ink-3); }
.ord-edit, .order-cancel {
  flex-shrink: 0;
  border: 1px solid; border-radius: 5px;
  font-size: 13px; font-weight: 600; padding: 3px 14px; cursor: pointer;
}
.ord-edit {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold-mark) 55%, transparent);
  background: color-mix(in srgb, var(--gold-mark) 14%, transparent);
}
.ord-edit:hover { background: color-mix(in srgb, var(--gold-mark) 26%, transparent); }
.order-cancel {
  color: var(--alert);
  border-color: color-mix(in srgb, var(--alert) 55%, transparent);
  background: color-mix(in srgb, var(--alert) 14%, transparent);
}
.order-cancel:hover { background: color-mix(in srgb, var(--alert) 26%, transparent); }
.ord-detail {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-2); font-size: 13px; padding: 3px 12px; cursor: pointer;
}
.tbl tr.clickable:hover .ord-detail { border-color: var(--gold-mark); color: var(--gold); }

/* 공용 탭·카드·버튼 */
/* 부모 세로 flex의 stretch가 폭을 강제로 늘리지 않게 시작점 정렬 */
.sub-tabs { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; align-self: flex-start; max-width: 100%; }
@container page (max-width: 640px) {
  .sub-tabs { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); align-self: stretch; }
}
.sub-tab {
  background: none;
  border: none;
  border-radius: 6px;
  padding: 7px 18px;
  min-width: 76px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.sub-tab:hover { color: var(--ink); background: var(--panel-2); }
.sub-tab.active { color: var(--gold); background: var(--panel-2); }
.sub-pane { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; font-size: 16px; }
.card h3 { color: var(--ink); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.ghost-btn { padding: 10px 20px; background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.ghost-btn:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); }
.ghost-btn:disabled { opacity: 0.4; cursor: default; }
.solid-btn { padding: 10px 20px; background: var(--gold-mark); border: none; border-radius: 8px; color: #16202B; font-weight: 700; cursor: pointer; }
.solid-btn:hover:not(:disabled) { background: var(--gold); }
.solid-btn:disabled { background: var(--line); color: var(--ink-3); cursor: default; }
.ava {
  display: block;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: var(--panel-2);
}

/* 도움말 문서 */
.doc { max-width: 880px; }
:root:lang(ko) :is(.doc, .sub-tabs) { word-break: keep-all; }
.doc .card { display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.6; }
.doc .card h3 { margin-bottom: 0; }
.doc ol, .doc ul { display: flex; flex-direction: column; gap: 4px; padding-left: 1.5em; }
.doc ol ::marker { color: var(--gold); font-family: var(--font-num); font-weight: 700; }
.doc ul ::marker { color: var(--ink-3); }
.doc dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; }
.doc dt { font-weight: 700; }
.doc dd { color: var(--ink-2); }
.doc .tbl { font-family: inherit; }
.doc .tbl th, .doc .tbl td { text-align: left; white-space: normal; }
.doc a { color: var(--gold); text-underline-offset: 2px; overflow-wrap: anywhere; }
.doc-ui { color: var(--gold); }
@container page (max-width: 640px) {
  .doc dl { grid-template-columns: 1fr; gap: 2px; }
  .doc dd + dt { margin-top: 8px; }
}

/* 설정 */
.set-radio { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.set-sub { color: var(--ink-3); font-size: 13px; margin: 8px 0 2px; }
.set-sub:first-of-type { margin-top: 0; }
.set-radio input { accent-color: var(--gold); }
.set-select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; color: var(--ink); min-width: 160px; cursor: pointer; }
.set-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 60%, transparent); }
.swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
}
.swatch-kr-up { background: #F04E58; }
.swatch-kr-down { background: #3F8FDE; }
.swatch-us-up { background: #3DBE7B; }
.swatch-us-down { background: #E5484D; }
#set-sort {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  /* backdrop-filter 블러는 키 입력마다 뒤 화면 전체를 재합성해 입력이 밀리므로 불투명도로 대체 */
  background: rgba(10, 16, 22, 0.85);
}
.modal-box {
  width: 380px;
  /* vw도 zoom(UI 배율)에 스케일되지 않음 — 배율로 나눠야 화면 폭 기준이 맞는다 */
  max-width: calc(100vw / var(--ui-scale, 1) - 40px);
  padding: 22px 24px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.modal-title { color: var(--ink); font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-detail { color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.modal-detail[hidden] { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-btn { padding: 9px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--ink-2); }
.modal-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.modal-btn.danger { border: none; background: var(--alert); color: #fff; }
.modal-btn.danger:hover { filter: brightness(1.1); }

/* ── 주문 모달 ─────────────────────────── */
.order-sheet {
  container: sheet / inline-size;
  width: 700px;
  max-width: calc(100vw / var(--ui-scale, 1) - 40px);
  padding: 22px 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.order-cols { display: flex; gap: 40px; }
.order-left { flex: 1.4; min-width: 0; }
.order-right { flex: 1; min-width: 210px; display: flex; flex-direction: column; }
@container sheet (max-width: 560px) {
  .order-cols { flex-direction: column; gap: 0; }
  .order-right { min-width: 0; }
}
.order-head { display: flex; align-items: center; gap: 12px; }
.order-head-txt { flex: 1; min-width: 0; }
.order-title { color: var(--ink); font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.order-sub b { color: var(--ink); font-family: var(--font-num); }
.order-side-badge { font-weight: 700; }
.order-side-badge.up { color: var(--up); }
.order-side-badge.down { color: var(--down); }
.order-close {
  border: none; background: transparent; color: var(--ink-3);
  font-size: 16px; cursor: pointer; padding: 4px 7px; border-radius: 6px;
}
.order-close:hover { color: var(--ink); background: var(--panel-2); }

.order-vi {
  margin-top: 14px; padding: 9px 12px;
  background: rgba(240, 78, 88, 0.12);
  border: 1px solid var(--alert); border-radius: 8px;
  color: var(--alert); font-size: 12px; line-height: 1.45;
}

.order-field { margin-top: 18px; }
.order-lbl { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 8px; }
.order-lbl-sub { color: var(--ink-3); font-size: 11px; font-weight: 400; }
.qty-row { display: flex; gap: 8px; }
.qty-step {
  width: 42px; flex: none;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--ink);
  font-size: 19px; font-weight: 600; cursor: pointer;
}
.qty-step:hover { border-color: var(--ink-3); }
.qty-input {
  flex: 1; min-width: 0; width: 100%; text-align: center;
  padding: 11px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-num); font-size: 18px; font-weight: 700;
}
.qty-input:focus { outline: none; border-color: var(--gold); }
/* 지정가 입력은 우측에 G 단위를 겹쳐 표시 */
.price-box { flex: 1; min-width: 0; position: relative; display: flex; }
.price-box .qty-input { padding-right: 30px; }
.price-unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gold); font-family: var(--font-num); font-size: 15px; font-weight: 700; pointer-events: none;
}
.qty-unit { color: var(--ink-2); }

/* 현재 가격으로 되돌리는 링크형 버튼 */
.link-btn {
  border: none; background: transparent; padding: 0;
  color: var(--gold); font-size: 12px; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; white-space: nowrap;
}
.link-btn:hover { filter: brightness(1.15); }
.order-diff-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price-diff.up { color: var(--up); }
.price-diff.down { color: var(--down); }

/* 유지 기한 선택 */
.order-ttl-sel {
  width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  padding: 10px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.order-ttl-sel:focus { outline: none; border-color: var(--gold); }
.qty-max {
  flex: none; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.qty-max:hover { border-color: var(--ink-3); color: var(--ink); }
.qty-quick { display: flex; gap: 8px; margin-top: 8px; }
.quick-btn {
  flex: 1; padding: 8px 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.quick-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.qty-avail { color: var(--ink-3); font-size: 12px; margin-top: 8px; }

.order-summary {
  margin-top: 16px; padding: 14px 16px;
  background: var(--panel-2); border-radius: 10px;
  display: flex; flex-direction: column; gap: 11px;
}
.os-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.os-row span { color: var(--ink-2); font-size: 13px; }
.os-row b { color: var(--ink); font-family: var(--font-num); font-size: 16px; text-align: right; }
.os-row b.up { color: var(--up); }
.os-row b.down { color: var(--down); }
.os-note { margin-top: -7px; }
.os-note b { font-size: 14px; }

/* 체결 조건 안내: 가격 강조 */
.order-cond { color: var(--ink-2); font-size: 13px; line-height: 1.55; margin-top: 16px; }
.order-cond b { color: var(--gold); font-family: var(--font-num); }
.order-err { color: var(--alert); font-size: 12px; min-height: 16px; margin-top: auto; padding-top: 10px; }

.order-submit {
  width: 100%; margin-top: 10px; padding: 13px;
  border: none; border-radius: 10px;
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.order-submit.buy { background: var(--up); }
.order-submit.sell { background: var(--down); }
.order-submit:hover { filter: brightness(1.1); }
.order-submit:disabled { opacity: 0.4; cursor: default; filter: none; }

/* ── 전역 토스트 ─────────────────────────── */
.toast-stack {
  position: fixed;
  left: 40px;
  bottom: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.toast-stack.center {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  align-items: center;
}
.toast-stack.right {
  left: auto;
  right: 40px;
  align-items: flex-end;
}
.toast {
  max-width: min(80vw, 360px);
  padding: 10px 16px;
  background: var(--ok);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  pointer-events: auto;
  animation: toast-in 0.18s ease;
}
.toast.error { background: var(--alert); }
.toast.hiding { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.hiding { animation: none; } }

/* ── 헤더 알림함 ─────────────────────────── */
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.notif { position: relative; }
.notif-btn,
.settings-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.notif-btn:hover,
.settings-btn:hover { border-color: var(--ink-3); }
.notif-btn svg,
.settings-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.notif-btn:hover svg,
.settings-btn:hover svg { stroke: var(--ink); }
.settings-btn.active,
.notif-btn[aria-expanded="true"] { border-color: var(--gold); }
.settings-btn.active svg,
.notif-btn[aria-expanded="true"] svg { stroke: var(--gold); }
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--alert);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-num);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 1500;
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.notif-clear {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 11px;
  cursor: pointer;
}
.notif-clear:hover { color: var(--ink); }
.notif-list { overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  /* 배너 위에서도 보이도록 기본 --line보다 밝게. 읽은 항목은 opacity 0.5가 줄도 누르는 것 감안 */
  border-bottom: 1px solid var(--ink-3);
  background-size: cover;
  background-position: center;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.seen { opacity: 0.5; }
.notif-item.clickable { cursor: pointer; }
.notif-item.clickable:hover { filter: brightness(1.18); opacity: 1; }
.notif-ic { width: 26px; height: 26px; border-radius: 6px; flex: none; }
/* 아이콘 테두리 색 = 알림 성격. 구매·승격은 상승색, 판매·강등은 하락색, 중립은 없음 */
.notif-item.tone-up .notif-ic { outline: 3px solid var(--up); }
.notif-item.tone-down .notif-ic { outline: 3px solid var(--down); }
.notif-txt { min-width: 0; }
.notif-msg { color: var(--ink); font-size: 12px; line-height: 1.5; }
.notif-item.error .notif-msg { color: var(--alert); }
.notif-item.market .notif-msg { color: var(--gold); }
.notif-time { margin-top: 3px; color: var(--ink-3); font-family: var(--font-num); font-size: 11px; }
/* 읽은 항목은 전체 opacity 0.5로 눌리므로 시각만 밝은 잉크로 보상 */
.notif-item.seen .notif-time { color: var(--ink); }
.notif-empty { padding: 24px 0; text-align: center; color: var(--ink-3); font-size: 12px; }

/* ── 관심종목 ─────────────────────────────── */
.row-name .star { color: var(--gold); }
/* 상세 별 버튼 — 세그먼트 쪽과 같은 이유로 텍스트 글리프 대신 SVG */
.watch-btn { width: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.watch-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.watch-btn.active { color: var(--gold); border-color: var(--gold-mark); }
.watch-btn.active svg { fill: currentColor; stroke: none; }

/* ── 가격 알림 ────────────────────────────── */
.alert-wrap { position: relative; }
#d-alert.active { color: var(--gold); border-color: var(--gold-mark); }
.alert-pop {
  position: absolute; top: 30px; left: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 8px;
  width: 190px; padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.alert-pop input {
  width: 100%; height: 28px; padding: 0 8px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--font-num); font-size: 13px;
}
.alert-btns { display: flex; gap: 6px; }
.alert-btns .store-btn { flex: 1; margin-top: 0; height: 26px; }
.alert-on { color: var(--gold); font-size: 11px; }

/* ── 내 자산 ──────────────────────────────── */
.me-ava { width: 36px; height: 36px; }
.me-title { display: flex; align-items: center; gap: 10px; }

/* ── 자산 추이 ────────────────────────────── */
.asset-wrap { height: 220px; margin-top: 10px; }
#asset-chart { width: 100%; height: 100%; }
