/* ───────────────────────────────────────────────────────────────────────────
   Noah Trading Desk — Terminal Design (dark only)
   참고: Bloomberg Terminal(앰버는 비의미 정보, 등락은 의미 색), IBKR TWS
   Mosaic(색으로 연결된 패널·하단 탭), Blueprint/Carbon 다크(촘촘한 데이터 밀도).
   토큰 이름은 기존 화면의 var(--*) 사용처가 그대로 바뀌도록 유지한다.
─────────────────────────────────────────────────────────────────────────── */
/* 페이지마다 중복 선언하지 않도록 웹폰트를 한 곳에서 제공한다. */
@font-face {
    font-family: 'Pretendard';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/Pretendard-Regular.woff2') format('woff2');
}
@font-face {
    font-family: 'Pretendard';
    font-style: normal;
    font-weight: 600 900;
    font-display: swap;
    src: url('/fonts/Pretendard-Bold.woff2') format('woff2');
}

:root {
    color-scheme: dark;

    /* 앰버: 라벨·코드·제목 같은 비의미 정보와 선택 상태 */
    --accent:        #FF9F1A;
    --accent-dark:   #FFB547;   /* 밝은 강조 글자(기존 이름 유지) */
    --accent-mid:    #E08600;
    --accent-light:  rgba(255,159,26,0.12);
    --accent-glow:   rgba(255,159,26,0.22);
    --accent-ink:    #000000;   /* 앰버 채움 위 글자 */

    /* Surfaces — 순수 검정 바탕 위 한 단계씩 밝아지는 패널 */
    --bg:            #000000;
    --surface:       #0B0D11;
    --surface-2:     #12151B;
    --surface-3:     #1A1E26;

    /* Text */
    --fg:            #E8E6E3;
    --fg-2:          #C9CDD4;
    --muted:         #8B919C;

    /* Borders */
    --border:        #262B35;
    --border-strong: #3A4150;
    --border-focus:  rgba(255,159,26,0.55);

    /* Shadows — 터미널은 면 대신 선으로 구분한다. */
    --shadow-sm:     none;
    --shadow-md:     0 12px 32px rgba(0,0,0,0.65);
    --shadow-glow:   none;

    --radius-xs:     2px;
    --radius-sm:     2px;
    --radius:        3px;
    --radius-lg:     4px;

    /* 페이지 키트 간격·글자 크기. 패널 사이는 --gap, 패널 안쪽은 --pad. */
    --gap:           6px;
    --pad:           10px;
    --fs-xs:         11px;
    --fs-sm:         12px;
    --fs-base:       13px;
    --fs-md:         14px;
    --fs-lg:         16px;
    --lh-prose:      1.65;
    --shadow-lg:     var(--shadow-md);

    /* 범주형 차트 색(common.js TERM_PALETTE와 같은 순서). 초록·빨강은 등락 전용이라 뺐다. */
    --series-1:       #FF9F1A;
    --series-2:       #4FC3F7;
    --series-3:       #B39DFF;
    --series-4:       #5EEAD4;
    --series-5:       #FF6FAE;
    --series-6:       #FFD60A;
    --series-7:       #90A4AE;
    --series-8:       #F97316;
    --series-neutral: #5B616C;

    /* 명령줄 GO 버튼·티커 테이프 바탕 */
    --go:            #1F7A3A;
    --go-hover:      #26944A;
    --surface-0:     #050608;

    /* 의미 색: 상승 초록 / 하락 빨강 (Bloomberg 기본) */
    --up:            #00D26A;
    --down:          #FF4D4D;
    --flat:          #9AA0A6;
    --up-bg:         rgba(0,210,106,0.12);
    --down-bg:       rgba(255,77,77,0.12);
    --info:          #4FC3F7;
    --info-bg:       rgba(79,195,247,0.10);
    --warn:          #FFD60A;
    --warn-bg:       rgba(255,214,10,0.10);

    --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    --font-mono: 'JetBrains Mono', 'D2Coding', ui-monospace, SFMono-Regular,
                 Menlo, Consolas, 'Liberation Mono', monospace;

    /* AG Grid(공식 dark 모드 위에 터미널 밀도만 조정) */
    --ag-background-color:        var(--surface);
    --ag-foreground-color:        var(--fg);
    --ag-header-background-color: var(--surface-2);
    --ag-header-text-color:       var(--muted);
    --ag-border-color:            var(--border);
    --ag-row-border-color:        var(--border);
    --ag-odd-row-background-color:var(--surface);
    --ag-row-hover-color:         var(--surface-3);
    --ag-selected-row-background-color: var(--accent-light);
    --ag-accent-color:            var(--accent);
    --ag-font-family:             var(--font-sans);
    --ag-font-size:               13px;
    --ag-wrapper-border-radius:   0;
    --ag-border-radius:           var(--radius-xs);
    --ag-row-height:              28px;
    --ag-header-height:           30px;
}

/* Bloomberg의 색각이상 대응 팔레트처럼 상승을 파랑으로 바꾼다(명령줄 CVD). */
:root[data-cvd] {
    --up:    #3D9BFF;
    --up-bg: rgba(61,155,255,0.14);
}

html { font-size: 15px; background: var(--bg); }
* {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-sizing: border-box;
}
code, pre, kbd, samp { font-family: var(--font-mono); }

/* 숫자는 자릿수가 흔들리지 않게 고정폭 숫자로 표시한다. */
body { font-variant-numeric: tabular-nums; }
.num, [data-num] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* 증권사 API를 실제로 호출하는 UI 영역의 출처 표시. */
.api-source-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 7px;
    padding: 2px 6px;
    border: 1px solid rgba(79,195,247,0.45);
    border-radius: var(--radius-xs);
    color: var(--info);
    background: var(--info-bg);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    vertical-align: middle;
    white-space: nowrap;
}
.api-source-badge--kb { border-color: rgba(255,214,10,0.45); color: var(--warn); background: var(--warn-bg); }
.api-source-badge--order { border-color: rgba(255,77,77,0.45); color: var(--down); background: var(--down-bg); }

html, body {
    margin: 0;
    background-color: var(--bg);
    color: var(--fg);
    font-size: 1rem;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--info); }

/* Tailwind 사용 여부와 관계없이 입력 요소의 글꼴·크기를 본문과 맞춘다. */
body :is(button, input, select, textarea) { font: inherit; }
body :is(h1, h2, h3, h4) { letter-spacing: -0.01em; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* ── Shared application frame ────────────────────────────────────────────
   Header/footer live in the outer grid.  Only main is scrollable, preventing
   every page from choosing a different fixed-footer workaround. */
body.app-shell-layout {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-bottom: 0 !important;
}
#header-mount { min-width: 0; }
body.app-shell-layout #site-header { position: static; }
body.app-shell-layout > main {
    width: 100% !important;
    max-width: none !important;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    margin: 0 !important;
    padding-inline: clamp(10px, 1.2vw, 20px) !important;
}
body.app-shell-layout > footer {
    min-width: 0;
    margin: 0 !important;
    position: static !important;
    inset: auto !important;
    flex-shrink: 0;
    border-top: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--muted);
}
body.app-shell-layout > footer:not(#site-footer) { padding: 6px clamp(8px, 1vw, 16px); font-size: 12px; }

/* ── Brand logo ─────────────────────────────────────────────────────────── */
.brand-logo-text {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 1.5px;
    line-height: 1;
    text-transform: uppercase;
}

/* ── Terminal header (common.js renderHeader) ───────────────────────────── */
#site-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border-strong);
}
.term-cmdbar {
    display: flex; align-items: center; gap: 8px;
    min-height: 34px; padding: 0 8px;
    background: var(--bg);
}
.term-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 26px; padding: 0 8px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    color: var(--fg-2); background: var(--surface-2);
    font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.term-icon-btn:hover { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.term-brand {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 10px;
    color: var(--accent-ink); background: var(--accent);
    font-family: var(--font-mono); font-size: 13px; font-weight: 900; letter-spacing: .08em;
    text-decoration: none; white-space: nowrap;
}
.term-brand small { font-size: 10px; font-weight: 800; opacity: .75; letter-spacing: .04em; }
.term-cmd {
    position: relative; flex: 1 1 360px; max-width: 560px; min-width: 0;
    display: flex; align-items: center;
    height: 26px; border: 1px solid var(--border-strong); background: var(--surface);
}
.term-cmd:focus-within { border-color: var(--accent); }
.term-cmd-prompt { padding: 0 6px 0 8px; color: var(--accent); font-family: var(--font-mono); font-size: 12px; font-weight: 800; }
.term-cmd input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0 4px;
    color: var(--warn); background: transparent;
    font-family: var(--font-mono) !important; font-size: 13px; text-transform: uppercase;
}
.term-cmd input::placeholder { color: var(--muted); text-transform: none; font-family: var(--font-sans); }
.term-go {
    height: 100%; padding: 0 10px; border: 0; border-left: 1px solid var(--border-strong);
    color: #fff; background: var(--go); font-family: var(--font-mono); font-size: 11px; font-weight: 900; cursor: pointer;
}
.term-go:hover { background: var(--go-hover); }
.term-cmd-help {
    position: absolute; z-index: 260; top: calc(100% + 4px); left: 0; right: 0;
    display: none; max-height: 60vh; overflow: auto; padding: 6px 0;
    border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-md);
}
.term-cmd-help.open { display: block; }
.term-cmd-help div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 3px 10px; font-size: 12px; color: var(--fg-2); }
.term-cmd-help b { color: var(--accent); font-family: var(--font-mono); font-weight: 800; }
.term-cmd-help div.active, .term-cmd-help div:hover { background: var(--surface-3); }
.term-meta { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.term-clock { color: var(--fg-2); font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.term-mode {
    padding: 2px 6px; border: 1px solid rgba(0,210,106,.5);
    color: var(--up); font-family: var(--font-mono); font-size: 11px; font-weight: 900; letter-spacing: .06em;
}
.term-user { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.term-user-name { color: var(--fg); font-size: 12px; font-weight: 700; }
.term-btn-danger { color: var(--down); border-color: rgba(255,77,77,.4); background: transparent; }
.term-btn-danger:hover { color: #fff; background: var(--down); border-color: var(--down); }
.term-btn-primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.term-btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.term-fkeys {
    display: flex; align-items: stretch; gap: 1px;
    min-height: 26px; padding: 0 8px;
    overflow-x: auto; scrollbar-width: none;
    background: var(--surface); border-top: 1px solid var(--border);
}
.term-fkeys::-webkit-scrollbar { display: none; }
.term-fkey {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 10px; color: var(--fg-2); text-decoration: none; white-space: nowrap;
    font-family: var(--font-mono); font-size: 12px; font-weight: 700;
    border-bottom: 2px solid transparent;
}
.term-fkey kbd {
    display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 3px;
    color: var(--accent-ink); background: var(--accent); font-size: 10px; font-weight: 900;
}
.term-fkey span { font-family: var(--font-sans); font-size: 11px; font-weight: 600; color: var(--muted); }
.term-fkey:hover { color: var(--accent); background: var(--surface-3); }
.term-fkey.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface-2); }
.term-fkey.active span { color: var(--fg-2); }
.term-fkeys-sep { flex: 1; }
.term-fkey--ai kbd { background: var(--info); }

/* 티커 테이프: 한 벌을 두 번 이어 붙여 끊김 없이 흐르게 한다. */
.term-tape {
    /* 흐르는 트랙의 폭이 그리드 열 폭으로 번지지 않게 가로 크기를 격리한다. */
    contain: inline-size;
    position: relative; overflow: hidden; height: 24px;
    background: var(--surface-0); border-top: 1px solid var(--border);
    font-family: var(--font-mono); font-size: 12px;
}
.term-tape-track {
    display: inline-flex; align-items: center; height: 100%; white-space: nowrap;
    animation: term-tape-scroll var(--tape-duration, 60s) linear infinite;
}
.term-tape:hover .term-tape-track { animation-play-state: paused; }
.term-tape-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-right: 1px solid var(--border); color: var(--fg-2); }
.term-tape-item b { color: var(--accent); font-weight: 800; }
.term-tape-item .px { color: var(--fg); }
.term-tape-empty { padding: 0 12px; color: var(--muted); line-height: 24px; }
@keyframes term-tape-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
    .term-tape { overflow-x: auto; }
    .term-tape-track { animation: none; }
}

@media (max-width: 760px) {
    .term-cmdbar { flex-wrap: wrap; padding: 4px 6px; gap: 6px; }
    .term-cmd { order: 5; flex-basis: 100%; max-width: none; }
    .term-clock, .term-menu-label, .term-user-name, .term-mode, .term-brand small { display: none; }
}

/* ── Status bar (footer) ────────────────────────────────────────────────── */
#site-footer, .term-status {
    margin-top: 0;
    border-top: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--muted);
}
#site-footer {
    padding: 4px clamp(8px, 1vw, 16px);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
}
.term-status-row { display: flex; align-items: center; gap: 14px; min-width: 0; overflow: hidden; white-space: nowrap; }
.term-status-row > span { display: inline-flex; align-items: center; gap: 5px; }
.term-status-row b { color: var(--fg-2); font-weight: 700; }
.term-status-row .term-status-brand { margin-left: auto; color: var(--accent); font-weight: 800; }
.term-status-row .term-status-note { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.term-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 6px var(--up); }
.term-dot.off { background: var(--down); box-shadow: 0 0 6px var(--down); }
#site-footer .brand-logo-text { color: var(--accent); font-size: 12px; }
#site-footer p { color: var(--muted) !important; margin: 0; }
#site-footer p a { color: var(--info) !important; }
@media (max-width: 760px) { .term-status-row .term-status-hide-sm { display: none; } }

/* ── Offcanvas ──────────────────────────────────────────────────────────── */
#oc-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 299; display: none;
}
#oc-overlay.open { display: block; }

#oc-panel {
    position: fixed; top: 0; left: 0;
    height: 100vh; width: 268px; max-width: 88vw;
    background: var(--surface);
    border-right: 1px solid var(--border-strong);
    box-shadow: var(--shadow-md);
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.4,0,0.2,1);
    display: flex; flex-direction: column;
}
#oc-panel.open { transform: translateX(0); }

.oc-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border-strong);
    background: var(--bg);
}
.oc-close-btn {
    width: 26px; height: 26px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    font-size: 12px; font-weight: 700; color: var(--fg-2);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.oc-close-btn:hover { background: var(--accent); color: var(--accent-ink); }

.oc-nav {
    padding: 0.35rem 0.4rem 0.8rem;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}
.oc-nav-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.42rem 0.6rem;
    font-size: 13px; font-weight: 600; color: var(--fg-2);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
}
.oc-nav-item i { color: var(--muted); }
.oc-nav-item:hover { background: var(--surface-3); color: var(--accent); }
.oc-nav-item:hover i { color: var(--accent); }
.oc-nav-item--sub {
    position: relative;
    margin: 1px 2px 1px 10px;
    padding: 0.38rem 0.55rem 0.38rem 1.25rem;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--fg-2);
    background: transparent;
}
.oc-nav-item--sub::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 50%;
    width: 4px;
    height: 4px;
    background: var(--border-strong);
    transform: translateY(-50%);
}
.oc-nav-item--sub.active {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 800;
}
.oc-nav-item--sub.active i { color: var(--accent-ink); }
.oc-nav-item--sub.active::before { background: var(--accent-ink); }

/* ── Offcanvas accordion 그룹 ───────────────────────────────────────────── */
.oc-group-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%;
    min-width: 0;
    margin: 3px 0 1px;
    padding: 0.45rem 0.6rem;
    font-size: 12.5px; font-weight: 800; color: var(--fg);
    letter-spacing: .02em;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs);
    appearance: none; -webkit-appearance: none;
    cursor: pointer; text-align: left; text-indent: 0;
}
.oc-group-toggle > span { display: block; flex: 1 1 auto; min-width: 0; }

/* Preserve guide card spacing across the shared stylesheet. */
.guide .card { margin: 18px 0 0; }
.oc-group-toggle:hover { border-color: var(--border-strong); color: var(--accent); }
.oc-group.open > .oc-group-toggle {
    color: var(--accent);
    background: var(--surface-3);
    border-color: var(--border-strong);
    box-shadow: inset 3px 0 0 var(--accent);
}
.oc-group-chevron { font-size: 11px; transition: transform 0.18s; }
.oc-group.open .oc-group-chevron { transform: rotate(180deg); }

.oc-group-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.22s ease;
}
/* 실제 펼침 높이는 common.js가 항목의 scrollHeight로 계산한다. */
.oc-group.open .oc-group-body { max-height: none; }

.oc-divider { height: 1px; background: var(--border); margin: 0.35rem 1.2rem; }

/* ── Offcanvas 비로그인 잠금 화면 ───────────────────────────────────────── */
.oc-guest-lock {
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    padding: 2.4rem 1.2rem;
    color: var(--muted);
}
.oc-guest-lock > i { font-size: 22px; color: var(--accent); margin-bottom: 0.8rem; }
.oc-guest-lock > p { font-size: 13px; font-weight: 600; line-height: 1.5; margin-bottom: 1rem; }
.oc-guest-actions { display: flex; gap: 0.5rem; width: 100%; }
.oc-guest-actions button {
    flex: 1;
    padding: 0.45rem 0;
    font-size: 12.5px;
    font-weight: 800;
    border-radius: var(--radius-xs);
    cursor: pointer;
}
.oc-guest-actions button:first-child { background: transparent; color: var(--fg-2); border: 1px solid var(--border-strong); }
.oc-guest-actions button:first-child:hover { color: var(--accent); border-color: var(--accent); }
.oc-guest-actions button:last-child { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.oc-guest-actions button:last-child:hover { background: var(--accent-dark); }
.oc-footer { padding: 0.7rem 0.9rem; border-top: 1px solid var(--border); font-family: var(--font-mono); }

/* 오른쪽 도구 메뉴 */
#ai-overlay { background: rgba(0,0,0,0.6) !important; backdrop-filter: none !important; }
#ai-panel {
    background: var(--surface) !important;
    border-left: 1px solid var(--border-strong) !important;
    box-shadow: var(--shadow-md) !important;
}
#ai-panel .right-tool-nav { flex: 1; }
.term-panel-head {
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
    padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border-strong); background: var(--bg);
}
.term-panel-head span { color: var(--accent); font-family: var(--font-mono); font-size: 13px; font-weight: 900; letter-spacing: .06em; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none;
}
.glow-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: none;
}

/* ── Terminal panel system ──────────────────────────────────────────────── */
.term-grid { display: grid; gap: 6px; }
.term-panel {
    display: flex; flex-direction: column; min-width: 0; min-height: 0;
    background: var(--surface); border: 1px solid var(--border);
}
.term-panel__bar {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    min-height: 26px; padding: 0 8px;
    background: var(--surface-2); border-bottom: 1px solid var(--border);
    color: var(--fg); font-size: 12px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
    white-space: nowrap;
}
.term-panel__bar .term-code {
    padding: 1px 5px; color: var(--accent-ink); background: var(--accent);
    font-family: var(--font-mono); font-size: 10.5px; font-weight: 900; letter-spacing: .04em;
}
.term-panel__bar .term-sub { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.term-panel__bar .term-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
/* TWS Mosaic처럼 같은 종목에 연결된 패널을 색 칩으로 표시한다. */
.term-link { width: 8px; height: 8px; border-radius: var(--radius-xs); background: var(--info); box-shadow: 0 0 0 1px var(--border-strong); }
.term-panel__body { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* 명령줄 화면번호로 들어온 패널을 잠깐 표시한다. */
.term-flash { box-shadow: 0 0 0 1px var(--accent), inset 0 0 0 1px var(--accent); transition: box-shadow .3s; }
.term-panel__body--pad { padding: 8px 10px; }

.term-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.term-table th {
    position: sticky; top: 0; z-index: 1;
    padding: 4px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border);
    color: var(--muted); font-size: 11px; font-weight: 700; text-align: right; white-space: nowrap;
}
.term-table th:first-child, .term-table td:first-child { text-align: left; }
.term-table td {
    padding: 3px 8px; border-bottom: 1px solid rgba(38,43,53,.7);
    color: var(--fg); text-align: right; white-space: nowrap;
    font-family: var(--font-mono); font-size: 12.5px;
}
.term-table td.txt { font-family: var(--font-sans); }
.term-table tbody tr:hover { background: var(--surface-3); }
.term-table tbody tr.is-selected { background: var(--accent-light); box-shadow: inset 2px 0 0 var(--accent); }
.term-table .empty { padding: 14px; text-align: center; color: var(--muted); font-family: var(--font-sans); }

.term-dock-tabs { display: flex; align-items: stretch; gap: 1px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.term-dock-tab {
    padding: 5px 12px; border: 0; border-bottom: 2px solid transparent;
    color: var(--muted); background: transparent;
    font-size: 12px; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.term-dock-tab:hover { color: var(--fg); }
.term-dock-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); }

.term-kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 12.5px; }
.term-kv dt { color: var(--muted); }
.term-kv dd { margin: 0; color: var(--fg); text-align: right; font-family: var(--font-mono); }

/* 호가 사다리: 매도(위) → 현재가 → 매수(아래) */
.term-ladder { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12.5px; }
.term-ladder td { position: relative; padding: 2px 8px; border-bottom: 1px solid rgba(38,43,53,.6); text-align: right; }
.term-ladder .ask td.px { color: var(--down); }
.term-ladder .bid td.px { color: var(--up); }
.term-ladder .bar { position: absolute; top: 2px; bottom: 2px; right: 0; opacity: .22; pointer-events: none; }
.term-ladder .ask .bar { background: var(--down); }
.term-ladder .bid .bar { background: var(--up); }
.term-ladder-mid { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 8px; background: var(--surface-2); border-block: 1px solid var(--border-strong); font-family: var(--font-mono); }
.term-ladder-mid strong { color: var(--fg); font-size: 15px; }
.term-ladder-mid span { color: var(--muted); font-size: 11px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.dark-table { width: 100%; border-collapse: collapse; }
.dark-table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    padding: 5px 10px; white-space: nowrap;
}
.dark-table tbody td {
    padding: 5px 10px; color: var(--fg);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.dark-table tbody tr:hover { background: var(--surface-3); }
.dark-table tbody tr:last-child td { border-bottom: none; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.dark-input {
    background: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--fg);
    border-radius: var(--radius-xs);
    padding: 0.4rem 0.6rem;
    width: 100%; font-size: 13.5px;
    font-family: var(--font-mono);
    outline: none;
}
.dark-input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dark-input::placeholder { color: var(--muted); font-family: var(--font-sans); }

.dark-select {
    background: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--fg);
    border-radius: var(--radius-xs);
    padding: 0.3rem 0.55rem; font-size: 13px; outline: none;
    cursor: pointer;
}
.dark-select:focus { border-color: var(--accent); }
select option { background: var(--surface); color: var(--fg); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-gold {
    background: var(--accent);
    color: var(--accent-ink); font-weight: 800; font-size: 14px;
    border-radius: var(--radius-xs); padding: 0.5rem 1.2rem;
    border: 1px solid var(--accent); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%; letter-spacing: 0.02em;
}
.btn-gold:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost {
    background: transparent; color: var(--fg-2); font-weight: 700; font-size: 14px;
    border-radius: var(--radius-xs); padding: 0.5rem 1.2rem;
    border: 1px solid var(--border-strong); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; width: 100%;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-buy, .btn-sell {
    color: #000; font-weight: 900; font-size: 14px; letter-spacing: .04em;
    border-radius: var(--radius-xs); padding: 0.5rem 1rem;
    border: 1px solid transparent; cursor: pointer; width: 100%;
}
.btn-buy  { background: var(--up); border-color: var(--up); }
.btn-sell { background: var(--down); border-color: var(--down); }
.btn-buy:hover, .btn-sell:hover { filter: brightness(1.12); }
.btn-buy:disabled, .btn-sell:disabled { opacity: .5; cursor: not-allowed; }

.btn-pct-buy, .btn-pct-sell {
    border: 1px solid; border-radius: var(--radius-xs);
    padding: 0.22rem 0; font-size: 12px; font-weight: 800; font-family: var(--font-mono);
    cursor: pointer; text-align: center;
}
.btn-pct-buy  { border-color: rgba(0,210,106,.4); color: var(--up); background: var(--up-bg); }
.btn-pct-sell { border-color: rgba(255,77,77,.4); color: var(--down); background: var(--down-bg); }
.btn-pct-buy:hover  { background: rgba(0,210,106,.24); }
.btn-pct-sell:hover { background: rgba(255,77,77,.24); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
    border-radius: var(--radius-xs); padding: 0.1rem 0.45rem;
    font-size: 11px; font-weight: 800; font-family: var(--font-mono);
    display: inline-flex; align-items: center; letter-spacing: 0.03em;
}
.badge-gold  { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.badge-muted { background: var(--surface-2); color: var(--fg-2); border: 1px solid var(--border-strong); }
.badge-green { background: var(--up-bg); color: var(--up); border: 1px solid rgba(0,210,106,0.35); }
.badge-red   { background: var(--down-bg); color: var(--down); border: 1px solid rgba(255,77,77,0.35); }

/* ── Period buttons / tabs ──────────────────────────────────────────────── */
.period-btn, .market-tab, .exchange-tab {
    border-radius: var(--radius-xs); padding: 0.15rem 0.6rem;
    font-size: 12px; font-weight: 700; font-family: var(--font-mono); cursor: pointer;
    border: 1px solid var(--border-strong); background: transparent; color: var(--fg-2);
}
.period-btn.active, .market-tab.active, .exchange-tab.active {
    background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.period-btn:not(.active):hover, .market-tab:not(.active):hover, .exchange-tab:not(.active):hover {
    border-color: var(--accent); color: var(--accent);
}
.dom-inline-item {
    cursor: pointer; padding: 2px 6px; border-radius: var(--radius-xs); border: 1px solid transparent;
}
.dom-inline-item:hover { background: var(--surface-3); }
.dom-inline-item.selected { background: var(--accent-light); border-color: rgba(255,159,26,0.4); }

/* ── Price colors ───────────────────────────────────────────────────────── */
.text-up, .up     { color: var(--up) !important; }
.text-down, .down { color: var(--down) !important; }
.flat             { color: var(--flat) !important; }
.text-muted       { color: var(--muted); }

/* ── Table helpers ──────────────────────────────────────────────────────── */
td, th { vertical-align: middle; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
* { scrollbar-color: var(--border-strong) var(--bg); scrollbar-width: thin; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
}
.stat-card .stat-label {
    font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 0.15rem;
}
.stat-card .stat-value { font-size: 20px; font-weight: 800; color: var(--fg); line-height: 1.2; font-family: var(--font-mono); }
.stat-card.gold-stat { background: var(--surface-2); border: 1px solid var(--accent); }
.stat-card.gold-stat .stat-value { color: var(--accent); }
.stat-card.gold-stat .stat-label { color: var(--fg-2); }

/* ── Section label ──────────────────────────────────────────────────────── */
.section-label {
    font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--accent);
}

/* ── Asset bar ──────────────────────────────────────────────────────────── */
.asset-bar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.4rem 0.7rem; font-size: 13px;
}

/* ── Auth page ──────────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg);
    background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 48px 48px;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 2rem 1.8rem;
    box-shadow: var(--shadow-md);
}
.auth-logo {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 24px; font-weight: 900; letter-spacing: 3px;
    display: block; text-align: center; text-transform: uppercase;
}

/* ── Live indicator ─────────────────────────────────────────────────────── */
.live-dot {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--up); box-shadow: 0 0 5px var(--up);
    animation: pulse-dot 1.5s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.75); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ── 공개 API 테스트 버튼 ────────────────────────────────────────────────── */
/* Tailwind CDN의 button 초기화보다 우선해 공개 API 테스트 버튼을 명확히 표시한다. */
body[data-exchange] .row button {
    padding: 8px 12px !important;
    border: 1px solid var(--accent) !important;
    border-radius: var(--radius-xs) !important;
    background: var(--accent) !important;
    color: var(--accent-ink) !important;
    font-weight: 800 !important;
    cursor: pointer;
}
body[data-exchange] .row button:disabled { opacity: .6; }

.dataset-composer-open { width:100%; margin-top:16px; padding:9px 12px; border:1px solid var(--accent); border-radius:var(--radius-xs); color:var(--accent-ink); background:var(--accent); font:inherit; font-size:13px; font-weight:800; cursor:pointer; }
.dataset-composer-modal { position:fixed; z-index:500; inset:0; display:none; align-items:center; justify-content:center; padding:20px; background:rgba(0,0,0,.7); }
.dataset-composer-modal.open { display:flex; }
.dataset-composer-dialog { width:min(620px,100%); max-height:calc(100dvh - 40px); overflow:auto; border:1px solid var(--border-strong); border-top:2px solid var(--accent); border-radius:var(--radius); background:var(--surface); box-shadow:var(--shadow-md); }
.dataset-composer-dialog header { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:12px 16px; border-bottom:1px solid var(--border); background:var(--surface-2); }
.dataset-composer-dialog h2 { margin:0; color:var(--fg); font-size:15px; font-weight:900; }
.dataset-composer-close { width:28px; height:28px; border:1px solid var(--border-strong); border-radius:var(--radius-xs); color:var(--fg-2); background:var(--surface); font-size:18px; line-height:1; cursor:pointer; }
.dataset-composer-body { padding:16px; }
.dataset-composer-body input,
.dataset-composer-body select,
.dataset-composer-body textarea { font-size:13px !important; }
.dataset-composer-body textarea { min-height:230px; }
.dataset-composer-body .btn { font-size:13px !important; }
@media(max-width:600px) { .dataset-composer-modal { padding:12px; }.dataset-composer-dialog header,.dataset-composer-body { padding:12px; } }

/* 트레이딩 페이지: content-ctrl-bar는 trading-body 위에 위치 */
.trading-root #content-ctrl-bar {
    position: relative;
    top: unset;
    flex-shrink: 0;
}

/* API 테스트 화면: 실제 호출 범위와 성공 기준을 화면 안에서 확인한다. */
.api-test-guide { margin-top:16px; border:1px solid var(--border-strong); border-radius:var(--radius); background:var(--surface); color:var(--fg); }
.api-test-guide summary { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 14px; cursor:pointer; font-size:13px; font-weight:900; color:var(--accent); }
.api-test-guide summary span { color:var(--muted); font-size:12px; font-weight:700; }
.api-test-guide-rate { margin:0; padding:9px 14px; border-top:1px solid var(--border); border-bottom:1px solid var(--border); background:var(--warn-bg); color:var(--warn); font-size:12px; line-height:1.65; }
.api-test-guide-scroll { overflow-x:auto; border-top:1px solid var(--border); }
.api-test-guide table { width:100%; min-width:820px; border-collapse:collapse; font-size:12px; line-height:1.55; }
.api-test-guide th,.api-test-guide td { padding:8px 12px; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }
.api-test-guide thead th { color:var(--fg-2); background:var(--surface-2); font-weight:850; }
.api-test-guide tbody th { color:var(--fg); font-weight:800; white-space:nowrap; }
.api-test-guide code { overflow-wrap:anywhere; color:var(--info); font-size:11px; }
.api-test-guide-note { margin:0; padding:9px 14px; color:var(--fg-2); font-size:12px; line-height:1.65; }
.api-test-guide-note + .api-test-guide-note { padding-top:0; }
@media(max-width:600px) { .api-test-guide summary { align-items:flex-start; flex-direction:column; }.api-test-guide summary span { font-size:11px; } }

/* ── 페이지 키트 ────────────────────────────────────────────────────────────
   대시보드·거래 화면과 같은 패널 문법을 나머지 화면에도 쓴다.
   main에 .term-page(도구·로그·차트) 또는 .term-doc(학습 문서)을 붙여 적용한다.
   페이지마다 복사돼 있던 .card/.result/.notice 같은 옛 클래스는 이 범위 안에서만
   다시 정의하므로, 아직 옮기지 않은 화면에는 영향이 없다. */
body.app-shell-layout > main.term-page { padding: var(--gap) !important; }
.term-page { display: flex; flex-direction: column; gap: var(--gap); }
.term-page > * { flex-shrink: 0; }

/* 히어로 대신 쓰는 한 줄 제목 바 */
.term-pagehead {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
    min-height: 34px; padding: 5px var(--pad);
    background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--accent);
}
.term-pagehead .term-code {
    padding: 1px 6px; color: var(--accent-ink); background: var(--accent);
    font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 900; letter-spacing: .04em;
}
.term-pagehead h1 { margin: 0; color: var(--fg); font-size: var(--fs-lg); font-weight: 800; line-height: 1.3; }
.term-pagehead p { flex: 1 1 320px; min-width: 0; margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; }
.term-pagehead .term-right { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }

/* 단계 이동 막대(가입 → 키 → 설치 → …) */
.term-steps {
    display: flex; gap: 1px; overflow-x: auto; scrollbar-width: none;
    background: var(--border); border: 1px solid var(--border);
}
.term-steps::-webkit-scrollbar { display: none; }
.term-steps a {
    flex: 1 0 auto; padding: 4px 10px; text-align: center; white-space: nowrap; text-decoration: none;
    color: var(--fg-2); background: var(--surface); font-size: var(--fs-sm); font-weight: 700;
}
.term-steps a b { font-weight: 800; }
.term-steps a small { margin-left: 6px; color: var(--muted); font-size: var(--fs-xs); font-weight: 500; }
.term-steps a:hover { color: var(--accent); background: var(--surface-3); }
.term-steps a:is(.active, .on, [aria-current="page"]) { color: var(--accent-ink); background: var(--accent); }
.term-steps a:is(.active, .on, [aria-current="page"]) small { color: var(--accent-ink); opacity: .75; }

/* 레이아웃. 1100px 이하에서는 모두 한 열로 접힌다. */
.term-layout { display: grid; gap: var(--gap); min-width: 0; align-items: start; }
.term-layout > * { min-width: 0; }
.term-layout--tool { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); }
.term-layout--tool > .term-rail { position: sticky; top: 0; }
.term-layout--log { flex: 1 1 auto; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); align-items: stretch; min-height: 460px; }
.term-layout--chart { flex: 1 1 auto; grid-template-columns: minmax(250px, 300px) minmax(0, 1fr); align-items: stretch; min-height: 520px; }
.term-layout--split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.term-layout--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.term-layout--wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
.term-span { grid-column: 1 / -1; }
@media (max-width: 1100px) {
    .term-layout--tool, .term-layout--log, .term-layout--chart, .term-layout--split, .term-layout--3, .term-layout--wide-left { grid-template-columns: minmax(0, 1fr); }
    .term-layout--tool > .term-rail { position: static; }
}
.term-stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.term-fill { flex: 1 1 auto; min-height: 0; }

/* 패널 안 설명·버튼 줄 */
.term-panel__body > p, .term-note { margin: 0; color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.6; }
.term-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* 큰 통계 카드 대신 쓰는 KPI 줄 */
.term-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px;
    background: var(--border); border: 1px solid var(--border);
}
.term-kpis > * { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; padding: 4px var(--pad); background: var(--surface); }
.term-kpis small, .term-kpis span { color: var(--muted); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.term-kpis b, .term-kpis strong { color: var(--fg); font-family: var(--font-mono); font-size: 15px; font-weight: 800; white-space: nowrap; }
.term-kpis .ok b { color: var(--up); }
.term-kpis .fail b { color: var(--down); }

/* 필터·검색 줄 */
.term-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 5px 8px; background: var(--surface); border: 1px solid var(--border);
}
.term-toolbar :is(input, select) {
    height: 26px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    background: var(--bg); color: var(--fg); font-size: var(--fs-sm);
}
.term-toolbar input[type=search], .term-toolbar input[type=text] { flex: 0 1 300px; min-width: 180px; }
.term-toolbar > span { color: var(--muted); font-size: var(--fs-sm); }
.term-toolbar > .term-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* 요청·응답 JSON과 결과 출력 */
.term-console {
    margin: 0; padding: 8px var(--pad); overflow: auto;
    background: var(--bg); border: 1px solid var(--border); border-radius: 0;
    color: var(--fg-2); font: 12px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-word;
}
.term-console.is-error { color: var(--down); border-color: rgba(255,77,77,.45); background: var(--down-bg); }

/* 버튼 */
.term-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 26px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    color: var(--fg-2); background: var(--surface-2); font-size: var(--fs-sm); font-weight: 800;
    text-decoration: none; white-space: nowrap; cursor: pointer;
}
.term-btn:hover { color: var(--accent); border-color: var(--accent); }
.term-btn.term-btn-primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.term-btn.term-btn-primary:hover { color: var(--accent-ink); background: var(--accent-dark); }
.term-btn:disabled { opacity: .55; cursor: wait; }

/* ── 옛 페이지 클래스 호환(.term-page / .term-doc 범위) ───────────────── */
:is(.term-page, .term-doc) .kicker {
    color: var(--accent); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 800;
    letter-spacing: .06em; text-transform: uppercase;
}
:is(.term-page, .term-doc) :is(.notice, .note, .danger, .warn, .ok-box) {
    margin: 6px 0 0; padding: 6px var(--pad); border: 0; border-left: 2px solid var(--warn); border-radius: 0;
    background: var(--warn-bg); color: var(--warn); font-size: 12.5px; line-height: 1.6;
}
:is(.term-page, .term-doc) .danger { border-left-color: var(--down); background: var(--down-bg); color: var(--fg); }
:is(.term-page, .term-doc) .danger strong { color: var(--down); }
:is(.term-page, .term-doc) :is(.run, .btn) {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    margin: 6px 0 0; padding: 5px 12px; border: 1px solid var(--accent); border-radius: var(--radius-xs);
    color: var(--accent-ink); background: var(--accent); font-size: 12.5px; font-weight: 800;
    text-decoration: none; cursor: pointer;
}
:is(.term-page, .term-doc) :is(.run, .btn):hover { background: var(--accent-dark); border-color: var(--accent-dark); }
:is(.term-page, .term-doc) :is(.run, .btn):disabled { opacity: .6; cursor: wait; }
:is(.term-page, .term-doc) :is(.run-sm, .btn-alt) {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    color: var(--fg); background: var(--surface-2); font-size: var(--fs-sm); font-weight: 800;
    text-decoration: none; white-space: nowrap; cursor: pointer;
}
:is(.term-page, .term-doc) .btn-alt { margin: 6px 0 0 6px; }
:is(.term-page, .term-doc) :is(.run-sm, .btn-alt):hover { color: var(--accent); border-color: var(--accent); }
:is(.term-page, .term-doc) .run-sm:disabled { opacity: .6; cursor: wait; }
.term-page .result {
    display: block; min-height: 120px; margin: 6px 0 0; padding: 8px var(--pad); overflow: auto;
    border: 1px solid var(--border); border-radius: 0; background: var(--bg);
    color: var(--fg-2); font: 12px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-word;
}
.term-page .result--sm { min-height: 0; max-height: 220px; margin: 0; padding: 6px 8px; font-size: 11.5px; }
.term-page :is(.result--error, .result.error) { color: var(--down); border-color: rgba(255,77,77,.45); background: var(--down-bg); }
/* 개별 테스트: 형제인 .test-row(라벨·버튼)와 .result를 한 줄 좌우로 놓는다. */
.term-page .test-list {
    display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 0;
    margin: 0; padding: 0; border: 0;
}
.term-page .test-list > * { border-bottom: 1px solid var(--border); }
.term-page .test-list > .test-row {
    display: flex; flex-wrap: wrap; align-content: flex-start; align-items: center; gap: 6px;
    padding: 6px 8px; background: var(--surface-2); border-right: 1px solid var(--border);
}
.term-page .test-list > .test-row label { flex: 1 1 100%; min-width: 0; color: var(--fg); font-size: var(--fs-sm); font-weight: 800; }
.term-page .test-list > .test-row :is(input, select) {
    width: 96px; height: 26px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    background: var(--bg); color: var(--fg); font-family: var(--font-mono); font-size: var(--fs-sm);
}
.term-page .test-list > .result, .term-page .test-list > .test-results > .result { min-height: 36px; max-height: 220px; margin: 0; border: 0; border-bottom: 1px solid var(--border); }
/* 버튼 행 하나에 결과가 여럿이면 .test-results로 묶어 오른쪽 칸에 쌓는다. */
.term-page .test-list > .test-results { display: grid; min-width: 0; border-bottom: 0; }
.term-page .test-list > .test-results > .result:last-child { border-bottom: 1px solid var(--border); }
:is(.term-page, .term-doc) :is(.status-grid, .alpaca-status-grid, .kb-status-grid) > * {
    margin: 0; padding: 4px 8px; border: 0; border-radius: 0; background: var(--surface);
    color: var(--muted); font-size: var(--fs-sm); font-weight: 700;
}
:is(.term-page, .term-doc) :is(.status-grid, .alpaca-status-grid, .kb-status-grid) > .ok { color: var(--up); }
:is(.term-page, .term-doc) :is(.status-grid, .alpaca-status-grid, .kb-status-grid) > .bad { color: var(--down); }
/* 입력 + 실행 버튼 한 줄 */
.term-page .controls { display: flex; gap: 6px; margin: 0; }
.term-page .controls :is(input, select) {
    flex: 1; min-width: 0; height: 28px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    background: var(--bg); color: var(--fg); font-family: var(--font-mono); font-size: 12.5px;
}
.term-page .controls .run { margin: 0; }
.term-page .note ul { margin: 4px 0 0; padding-left: 16px; }
.term-page .notice-grid { display: grid; gap: 6px; margin: 0; }
/* 준비 순서: 레일 안에서는 한 열 목록으로 쌓는다. */
.term-page .setup-grid { display: grid; grid-template-columns: 1fr; gap: 1px; margin: 6px 0 0; background: var(--border); border: 1px solid var(--border); }
.term-page .setup-step { margin: 0; padding: 6px 8px; border: 0; border-radius: 0; background: var(--surface); color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.55; }
.term-page .setup-step b { display: block; margin-bottom: 2px; color: var(--fg); font-size: 12.5px; }
.term-page .setup-step code { word-break: break-word; }
.term-page .api-test-guide { margin-top: 0; }
/* 실행 전 확인 체크 */
.term-page :is(.check, .confirm) { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 0; padding: 6px 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--fg-2); font-size: 12.5px; line-height: 1.55; cursor: pointer; }
.term-page :is(.check, .confirm) input { margin-top: 3px; accent-color: var(--accent); }
/* 단계 설명 목록(레일 안) */
.term-page .steps { display: grid; gap: 0; margin: 0; border: 1px solid var(--border); }
.term-page .steps .step { margin: 0; padding: 6px 8px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--surface); color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.55; }
.term-page .steps .step:last-child { border-bottom: 0; }
.term-page .steps .step b { display: block; color: var(--fg); font-size: 12.5px; }
/* 증권사 안내 링크 */
.term-page .guide-link { display: inline-block; margin-top: 6px; color: var(--accent); font-size: var(--fs-sm); font-weight: 800; text-decoration: none; }
.term-page .guide-link:hover { text-decoration: underline; }
/* 좁은 레일·2열 분할 안에서는 결과를 버튼 아래에 둔다. */
.term-page :is(.term-rail, .term-layout--split) .test-list { grid-template-columns: minmax(0, 1fr); }
.term-page :is(.term-rail, .term-layout--split) .test-list > .test-row { border-right: 0; }
@media (max-width: 700px) {
    .term-page .test-list { grid-template-columns: minmax(0, 1fr); }
    .term-page .test-list > .test-row { border-right: 0; }
}
:is(.term-page, .term-doc) :is(.status-grid, .alpaca-status-grid, .kb-status-grid) {
    display: grid; grid-template-columns: 1fr; gap: 1px; margin: 0; background: var(--border); border: 1px solid var(--border);
}

/* ── 학습 문서: 목차 레일 + 읽기 폭 본문 ─────────────────────────────── */
body.app-shell-layout > main.term-doc { padding: 10px clamp(10px, 2vw, 28px) 32px !important; }
.term-doc {
    display: grid; grid-template-columns: 210px minmax(0, 940px); column-gap: 24px; row-gap: 0;
    /* main 높이가 정해져 있어도 overflow:hidden 섹션이 눌리지 않게 행은 내용 높이로 잡는다. */
    grid-auto-rows: max-content; justify-content: center; align-content: start;
}
.term-doc > * { grid-column: 2; min-width: 0; }
/* 절이 하나뿐이라 목차가 없는 문서는 가운데 한 열로 둔다. */
.term-doc:not(:has(> .term-toc)) { grid-template-columns: minmax(0, 940px); }
.term-doc:not(:has(> .term-toc)) > * { grid-column: 1; }
.term-doc > .term-toc { grid-column: 1; grid-row: 1 / span 300; align-self: start; position: sticky; top: 0; }
.term-toc { max-height: calc(100dvh - 150px); overflow: auto; padding: 4px 0; font-size: var(--fs-sm); }
.term-toc summary {
    padding: 4px 8px; color: var(--accent); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 900;
    letter-spacing: .06em; list-style: none; cursor: pointer;
}
.term-toc summary::-webkit-details-marker { display: none; }
.term-toc ol { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border); }
.term-toc a {
    display: block; margin-left: -1px; padding: 3px 8px; border-left: 2px solid transparent;
    color: var(--muted); text-decoration: none; line-height: 1.4;
}
.term-toc a small { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 10px; font-weight: 700; opacity: .8; }
.term-toc a:hover { color: var(--fg); }
.term-toc a.active { color: var(--accent); border-left-color: var(--accent); background: var(--surface); }
.term-toc .term-toc-sub a { padding-left: 18px; font-size: var(--fs-xs); }
@media (max-width: 1100px) {
    .term-doc { grid-template-columns: minmax(0, 1fr); }
    .term-doc > * { grid-column: 1; }
    .term-doc > .term-toc { grid-column: 1; grid-row: auto; position: static; max-height: none; margin-bottom: 6px; border: 1px solid var(--border); background: var(--surface); }
}

/* 문서 머리(히어로) */
.term-doc > section.term-hero, .term-page > section.term-hero {
    margin: 0 0 8px; padding: 10px 12px;
    border: 1px solid var(--border); border-left: 2px solid var(--accent); border-radius: 0;
    background: var(--surface); box-shadow: none;
}
.term-hero h1 { margin: 2px 0 4px; color: var(--fg); font-size: 20px; font-weight: 800; line-height: 1.3; }
.term-hero :is(p, .desc) { max-width: none; margin: 0; color: var(--fg-2); font-size: var(--fs-base); line-height: 1.6; }
.term-hero .term-steps, .term-hero .flow { margin-top: 8px; }
.term-hero > small, .term-hero > span:first-child { color: var(--accent); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; }
.term-hero .actions, .term-hero > div[style*="flex"] { margin-top: 8px !important; }

/* 카드 → 선으로 나눈 평면 섹션 */
.term-doc :is(.card, .learn-card, .guide-card, .cur-card, .glass-card, .term-section) {
    margin: 0; padding: 14px 0 18px; border: 0; border-top: 1px solid var(--border); border-radius: 0;
    background: none; box-shadow: none;
}
.term-doc :is(.title, .lesson-title, .cur-title, .term-section > h2) {
    margin: 3px 0 6px; color: var(--fg); font-size: 17px; font-weight: 800; line-height: 1.35;
}
.term-doc :is(h3) { font-size: var(--fs-md); }
.term-doc :is(.desc, .cur-desc, section > p) { color: var(--fg-2); font-size: 13.5px; line-height: var(--lh-prose); }
.term-doc :is(ul, ol):not(.term-toc ol) { line-height: var(--lh-prose); }
.term-doc .flow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.term-doc .flow span {
    padding: 2px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
    background: var(--surface-2); color: var(--fg); font-size: var(--fs-sm); font-weight: 700;
}
.term-doc .flow i { color: var(--accent); font-style: normal; font-weight: 900; }
.term-doc .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--gap); margin-top: 8px; }
.term-doc :is(.box, .step) { padding: 8px var(--pad); border: 1px solid var(--border); border-radius: 0; background: var(--surface); }
.term-doc .box b { color: var(--fg); font-size: var(--fs-base); }
.term-doc .box p { margin: 3px 0 0; color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.6; }
.term-doc .steps { display: grid; gap: 0; margin-top: 8px; border: 1px solid var(--border); }
.term-doc .steps .step { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; border: 0; border-bottom: 1px solid var(--border); }
.term-doc .steps .step:last-child { border-bottom: 0; }
.term-doc .num {
    display: grid; place-items: center; width: 20px; height: 20px; border-radius: 0;
    background: var(--accent); color: var(--accent-ink); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 900;
}
.term-doc .step h3 { margin: 0; color: var(--fg); font-size: var(--fs-base); font-weight: 800; }
.term-doc .step p { margin: 3px 0 0; color: var(--fg-2); font-size: var(--fs-sm); line-height: 1.6; }
.term-doc :is(.table-wrap, .cur-table-wrap) { margin-top: 8px; overflow: auto; }
.term-doc :is(.table, .cur-table) { width: 100%; min-width: 600px; border-collapse: collapse; background: var(--surface); font-size: 12.5px; }
.term-doc :is(.table, .cur-table) :is(th, td) { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; line-height: 1.55; }
.term-doc :is(.table, .cur-table) th { background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.term-doc :is(.code, .cur-code) {
    margin: 8px 0 0; padding: 8px var(--pad); overflow: auto; border: 1px solid var(--border); border-radius: 0;
    background: var(--bg); color: var(--fg-2); font: 12px/1.6 var(--font-mono); white-space: pre;
}
.term-doc :is(figure, .guide-figure, .tv-guide-figure) {
    width: auto; max-width: min(100%, 820px); margin: 10px 0 0; overflow: hidden;
    border: 1px solid var(--border); border-radius: 0; background: var(--surface); box-shadow: none;
}
.term-doc figure img { display: block; width: 100%; height: auto; }
.term-doc figcaption { padding: 5px var(--pad); border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; }
.term-doc .check { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; color: var(--fg-2); font-size: var(--fs-base); line-height: 1.55; }
.term-doc .check input { margin-top: 3px; accent-color: var(--accent); }
.term-doc .tip { margin-top: 8px; padding: 6px var(--pad); border-left: 2px solid var(--info); background: var(--info-bg); color: var(--fg-2); font-size: 12.5px; line-height: 1.6; }

/* ── 학습 화면 가이드 이미지 ────────────────────────────────────────────────
   흰 배경 기준으로 그린 안내도는 밝은 판 위에 올려 다크 화면에서도 읽히게 한다. */
main img[src*="/images/"], .guide img, figure img[src$=".svg"] {
    background: #F2F2F0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    padding: 6px;
}

/* ── 레거시 호환층 ──────────────────────────────────────────────────────────
   페이지마다 복제된 .card/.notice/코드 블록이 남긴 밝은 표면을 다크로 맞춘다.
   style.css 링크 위치가 페이지 <style>보다 앞이든 뒤든 이기도록 body를 앞에 붙인다. */
body pre { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: var(--radius-xs); }
body :not(pre) > code { color: var(--warn); background: rgba(255,214,10,.06); border-radius: var(--radius-xs); }
body table th { border-color: var(--border); }
body hr { border-color: var(--border); }
body input:not([type=checkbox]):not([type=radio]):not([type=range]), body select, body textarea {
    color-scheme: dark;
}
