/* Market Brief — 종목 상세 페이지
   4테마 토큰(:root, html[data-theme=mode1..4])은 공용 모듈 common/report_themes.py 에서
   서버가 <style id="theme-tokens"> 로 주입한다(메인 리포트와 단일 소스). 여기엔 컴포넌트
   스타일만 둔다. 테마 전환은 카멜레온(shiba) 마스코트가 <html data-theme> 를 바꿔 처리. */

* { box-sizing:border-box; }
html { scroll-behavior:smooth; -webkit-text-size-adjust:100%; text-size-adjust:100%; }
body {
    margin:0; color:var(--ink);
    background:var(--body-bg); background-attachment:fixed;
    font-family:var(--sans); line-height:1.6; -webkit-font-smoothing:antialiased;
    letter-spacing:.005em; font-variant-numeric:tabular-nums; min-height:100vh;
  }
.mono { font-family:var(--round); font-weight:600; font-variant-numeric:tabular-nums; }
.up { color:var(--up); } .down { color:var(--down); } .flat { color:var(--flat); }

.wrap { max-width:1040px; margin:0 auto; padding:40px 24px 96px; }

/* ── 헤더 ── */
header { position:relative; margin-bottom:26px; padding-bottom:22px; text-align:center; }
header::after { content:""; position:absolute; left:50%; bottom:0; transform:translateX(-50%);
                width:80px; height:3px; border-radius:3px;
                background:linear-gradient(90deg,var(--up),var(--accent),var(--down)); }
.brand-row { display:flex; align-items:center; justify-content:center; gap:12px; margin-bottom:18px; }
.brand { display:inline-flex; align-items:center; gap:9px; text-decoration:none;
         padding:6px 16px; background:var(--accent-soft); border-radius:999px; }
.brand .dot { width:7px; height:7px; border-radius:50%; background:var(--accent);
              animation:pulse 2.6s ease-in-out infinite; }
.brand .kicker { font-family:var(--round); font-size:11px; letter-spacing:.24em;
                 color:var(--accent); text-transform:uppercase; font-weight:700; }
.back-link { display:inline-flex; align-items:center; gap:6px; text-decoration:none;
             font-family:var(--round); font-size:12px; font-weight:700; color:var(--sub);
             padding:6px 13px; border-radius:999px; border:1px solid var(--line);
             background:var(--panel); transition:color .15s ease, border-color .15s ease; }
.back-link:hover { color:var(--accent); border-color:var(--accent); }
.back-link svg { width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:2.2;
                 stroke-linecap:round; stroke-linejoin:round; }
.exch-tag { display:inline-block; font-family:var(--round); font-size:11px; font-weight:800;
            letter-spacing:.1em; color:var(--accent); background:var(--accent-soft);
            padding:5px 12px; border-radius:999px; margin-bottom:12px; }
header h1 { font-family:var(--serif); font-weight:700; font-size:clamp(32px,5vw,48px); line-height:1.12;
            margin:0 0 12px; letter-spacing:-.01em; color:var(--heading); }
.meta-row { display:inline-flex; flex-wrap:wrap; justify-content:center; gap:6px 16px;
            font-family:var(--round); font-size:12.5px; color:var(--sub); font-weight:600; }
.meta-row b { color:var(--ink); }
.meta-row .sep { color:var(--faint); }

/* ── 종목 검색(다른 종목으로 이동) ── */
.stock-search { position:relative; max-width:480px; margin:6px auto 26px; }
.ss-box { display:flex; align-items:center; gap:9px; padding:11px 14px;
          background:var(--panel); border:1.5px solid var(--line2); border-radius:15px;
          box-shadow:var(--section-shadow); transition:border-color .15s ease, box-shadow .15s ease; }
.ss-box:focus-within { border-color:var(--accent); box-shadow:0 0 0 4px var(--accent-soft); }
.ss-ic { width:19px; height:19px; flex:0 0 auto; fill:none; stroke:var(--accent); stroke-width:2.2; stroke-linecap:round; }
.ss-input { flex:1 1 auto; min-width:0; border:none; outline:none; background:none;
            font-family:var(--round); font-size:16px; font-weight:600; color:var(--ink); }
.ss-input::placeholder { color:var(--faint); font-weight:600; }
.ss-clear { flex:0 0 auto; border:none; background:var(--flat-soft); color:var(--sub);
            width:22px; height:22px; border-radius:50%; cursor:pointer; font-size:15px; line-height:1; }
.ss-list { position:absolute; left:0; right:0; top:calc(100% + 6px); z-index:40;
           background:var(--panel); border:1px solid var(--line); border-radius:14px;
           box-shadow:0 12px 34px rgba(0,0,0,.16); overflow-y:auto; max-height:330px; }
.ss-item { display:flex; align-items:center; justify-content:space-between; gap:12px;
           padding:11px 15px; text-decoration:none; color:inherit;
           border-bottom:1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.ss-item:last-child { border-bottom:0; }
.ss-item:hover, .ss-item.is-active { background:var(--bg2); }
.ss-name { font-size:14px; font-weight:700; color:var(--heading); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ss-code { flex:0 0 auto; font-size:12px; font-weight:700; color:var(--sub); letter-spacing:.02em; }
.ss-empty { padding:14px 15px; text-align:center; color:var(--faint); font-size:13px; }

/* ── 섹션 카드 ── */
section { background:var(--panel); border:1px solid var(--line);
          border-radius:24px; padding:26px 28px; margin-bottom:20px; position:relative;
          box-shadow:var(--section-shadow); }
.sec-head { display:flex; align-items:center; gap:12px; margin-bottom:22px; min-width:0; }
.num { font-family:var(--round); color:#fff;
       background:linear-gradient(135deg,var(--accent),var(--up));
       border-radius:50%; width:28px; height:28px; display:flex; align-items:center;
       justify-content:center; flex:0 0 auto; box-shadow:0 3px 8px rgba(217,138,168,.3); }
.num svg { width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:2.05;
           stroke-linecap:round; stroke-linejoin:round; }
.sec-head h2 { font-family:var(--serif); font-weight:700; font-size:22px; margin:0;
               letter-spacing:-.01em; color:var(--heading); }
.sec-note { margin-left:auto; font-family:var(--round); font-size:11.5px;
            color:var(--sub); letter-spacing:.03em; font-weight:600; }

/* ── 히어로(종목 요약) ── */
.hero-head { display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between;
             gap:20px 32px; margin-bottom:22px; }
.hero-quote { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 12px; }
.hero-price { font-family:var(--round); font-size:clamp(32px,5vw,46px); font-weight:800;
              line-height:1; letter-spacing:-.02em; color:var(--strong); }
.hero-cur { font-size:13px; font-weight:700; color:var(--sub); letter-spacing:.06em; }
.hero-change { display:inline-flex; align-items:baseline; gap:8px; font-family:var(--round);
               font-size:15px; font-weight:800; }
.hero-change.up { color:var(--up); }
.hero-change.down { color:var(--down); }
.hero-change .chg-pct { padding:4px 10px; border-radius:10px; font-size:14px;
                        background:var(--flat-soft); }
.hero-change.up .chg-pct { background:var(--up-soft); }
.hero-change.down .chg-pct { background:var(--down-soft); }
.hero-asof { font-family:var(--round); font-size:12px; font-weight:600; color:var(--faint); }
.hero-asof b { color:var(--sub); }

/* ── metric 카드 그리드 ── */
.metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.metric { padding:16px 16px; border-radius:18px; min-width:0; overflow:hidden;
          background:linear-gradient(180deg,var(--panel2),var(--panel)); border:1px solid var(--line); }
.metric.up-card { background:linear-gradient(180deg,var(--up-soft),var(--panel)); border-color:var(--up-mid); }
.metric.down-card { background:linear-gradient(180deg,var(--down-soft),var(--panel)); border-color:var(--down-mid); }
.m-label { font-family:var(--round); font-size:11.5px; color:var(--sub); margin-bottom:7px;
           letter-spacing:.02em; font-weight:700; }
.m-head { display:flex; align-items:baseline; justify-content:space-between; gap:6px; margin-bottom:7px; min-width:0; }
.m-head .m-label { margin-bottom:0; white-space:nowrap; }
.m-ratio { flex:0 1 auto; font-family:var(--round); font-size:10.5px; font-weight:700;
           color:var(--sub); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.m-value { font-family:var(--round); font-size:22px; font-weight:800; line-height:1.1;
           color:var(--heading); min-width:0; overflow:hidden; text-overflow:ellipsis; }
.m-value.up { color:var(--up); } .m-value.down { color:var(--down); }
.m-sub { margin-top:5px; font-family:var(--round); font-size:10.5px; color:var(--faint); font-weight:600; }

/* ── 차트 툴바 · 캔버스 ── */
.chart-tools { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-left:auto; }
.seg-tabs { display:inline-flex; gap:2px; padding:3px; border-radius:999px;
            background:var(--flat-soft); font-family:var(--round); }
.seg-tabs button { border:0; background:transparent; color:var(--sub);
                   padding:5px 12px; border-radius:999px; font:700 11.5px var(--round); cursor:pointer;
                   transition:color .15s ease, background .15s ease; }
.seg-tabs button.active { background:linear-gradient(135deg,var(--accent),var(--up)); color:#fff; }
.legend { display:flex; flex-wrap:wrap; gap:14px; margin:14px 2px 6px;
          font-family:var(--round); color:var(--sub); font-size:10.5px; font-weight:700; }
.legend span { display:inline-flex; align-items:center; }
.legend span::before { content:""; display:inline-block; width:16px; height:3px;
                       border-radius:2px; margin-right:6px; background:currentColor; }
.legend .k-close { color:var(--strong); }
.legend .k-ma20 { color:#e0a54a; }
.legend .k-ma60 { color:var(--down); }
.legend .k-ma120 { color:var(--flat); }
.legend .k-boll::before { height:10px; background:color-mix(in srgb, var(--accent) 22%, transparent);
                          border-radius:3px; }
.legend .k-boll { color:var(--accent); }
.ind-toggles { display:flex; flex-wrap:wrap; gap:7px; margin:2px 2px 12px; }
.ind-tog { display:inline-flex; align-items:center; gap:6px; font-family:var(--round);
           font-size:11.5px; font-weight:700; color:var(--sub); background:var(--flat-soft);
           border:1px solid var(--line); border-radius:999px; padding:5px 12px; cursor:pointer;
           transition:color .15s ease, background .15s ease, border-color .15s ease; }
.ind-tog::before { content:""; width:10px; height:3px; border-radius:2px;
                   background:var(--c,var(--sub)); opacity:.32; }
.ind-tog.on { color:var(--heading); background:var(--panel); border-color:var(--line2); }
.ind-tog.on::before { opacity:1; }
.chart-wrap { position:relative; min-width:0; overflow:hidden; }
.chart-wrap canvas { display:block; width:100%; touch-action:none; cursor:crosshair; }
.chart-hint { margin:10px 2px 0; font-family:var(--round); font-size:11px;
              color:var(--faint); font-weight:600; text-align:center; }
.chart-tip { position:absolute; pointer-events:none; z-index:5; min-width:150px;
             padding:10px 12px; border-radius:12px; background:var(--heading); color:var(--panel);
             font-family:var(--round); font-size:11px; line-height:1.7; font-weight:600;
             box-shadow:0 10px 28px rgba(0,0,0,.22); transform:translate(-50%,-112%);
             white-space:nowrap; }
.chart-tip .tip-d { font-weight:800; margin-bottom:3px; letter-spacing:.02em; }
.chart-tip i { font-style:normal; opacity:.7; }
.chart-tip b { font-weight:800; }
.chart-tip .t-up { color:#ff9db5; } .chart-tip .t-down { color:#a9c8f2; }
.sub-head { display:flex; align-items:center; gap:8px; margin:4px 2px 2px;
            font-family:var(--round); font-size:12px; font-weight:800; color:var(--heading); }
.sub-head .sub-now { margin-left:auto; font-size:12.5px; color:var(--sub); }

/* ── 지표 카드 그리드 ── */
.ind-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
@media (min-width:761px) { .ind-grid.cols6 { grid-template-columns:repeat(6,minmax(0,1fr)); } }
.ind-card { padding:15px 16px; border-radius:16px; min-width:0;
            background:linear-gradient(180deg,var(--panel2),var(--panel)); border:1px solid var(--line); }
.ind-card .i-label { font-family:var(--round); font-size:11px; font-weight:700; color:var(--sub);
                     margin-bottom:8px; display:flex; align-items:center; gap:6px; }
.ind-card .i-value { font-family:var(--round); font-size:19px; font-weight:800; color:var(--heading);
                     line-height:1.1; }
.ind-card .i-value.up { color:var(--up); } .ind-card .i-value.down { color:var(--down); }
.ind-card .i-sub { margin-top:6px; font-family:var(--round); font-size:10.5px; color:var(--faint); font-weight:600; }
.pill { display:inline-flex; align-items:center; padding:2px 8px; border-radius:999px;
        font-family:var(--round); font-size:10px; font-weight:800; letter-spacing:.02em; }
.pill.up { color:var(--up); background:var(--up-soft); }
.pill.down { color:var(--down); background:var(--down-soft); }
.pill.flat { color:var(--flat); background:var(--flat-soft); }

/* RSI 게이지 미니바 */
.gauge { height:6px; border-radius:999px; margin-top:9px; position:relative;
         background:linear-gradient(90deg,var(--down) 0%,var(--flat) 50%,var(--up) 100%); opacity:.85; }
.gauge i { position:absolute; top:50%; width:12px; height:12px; border-radius:50%;
           background:var(--panel); border:3px solid var(--heading);
           transform:translate(-50%,-50%); box-shadow:0 2px 6px rgba(0,0,0,.18); }

/* ── 수익률 바 ── */
.ret-rows { display:flex; flex-direction:column; gap:11px; }
.ret-row { display:grid; grid-template-columns:74px 1fr 72px; align-items:center; gap:14px; }
.ret-row .r-label { font-family:var(--round); font-size:12px; font-weight:700; color:var(--sub); white-space:nowrap; }
.ret-row .r-label .r-sub { font-size:10.5px; font-weight:600; color:var(--faint); letter-spacing:.01em; }
.ret-track { position:relative; height:8px; border-radius:999px; background:var(--flat-soft); overflow:hidden; }
.ret-track .r-mid { position:absolute; left:50%; top:0; bottom:0; width:1px; background:var(--line2); }
.ret-fill { position:absolute; top:0; bottom:0; border-radius:999px; }
.ret-fill.up { background:linear-gradient(90deg,#f6b0c1,var(--up)); left:50%; }
.ret-fill.down { background:linear-gradient(90deg,var(--down),#b7d0f1); right:50%; }
.ret-row .r-val { font-family:var(--round); font-size:14px; font-weight:800; text-align:right; }

/* ── 52주 레인지 미터 ── */
.range-panel { display:grid; grid-template-columns:minmax(0,.8fr) minmax(0,1.6fr);
               gap:20px 48px; align-items:center; }
.range-copy h3 { font-family:var(--serif); font-size:18px; margin:0 0 6px; color:var(--heading); font-weight:700; }
.range-copy p { margin:0; font-family:var(--round); font-size:12px; color:var(--sub); }
.range-values { display:flex; justify-content:space-between; align-items:baseline;
                font-family:var(--round); font-size:12px; font-weight:700; color:var(--sub); }
.range-values b { color:var(--accent); font-size:18px; font-weight:800; }
.meter-track { height:8px; background:var(--flat-soft); border-radius:999px; position:relative; margin:14px 0 8px; }
.meter-track i { display:block; height:100%; max-width:100%; border-radius:999px;
                 background:linear-gradient(90deg,var(--down),var(--flat),var(--up)); }
.meter-track em { position:absolute; top:50%; width:18px; height:18px; border:4px solid var(--panel);
                  border-radius:50%; background:var(--accent);
                  box-shadow:0 2px 8px rgba(0,0,0,.22); transform:translate(-50%,-50%); }
.range-labels { display:flex; justify-content:space-between;
                font-family:var(--round); font-size:10px; color:var(--faint); font-weight:600; }

/* ── 기업 개요 ── */
.company-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:18px; }
.company-desc { font-size:13.5px; line-height:1.85; color:var(--ink); margin:0; max-width:860px; }
.theme-wrap { display:flex; gap:12px; margin-top:16px; align-items:baseline; }
.theme-label { flex:0 0 auto; font-family:var(--round); font-size:12px; font-weight:800; color:var(--sub); padding-top:2px; }
.theme-chips { display:flex; flex-wrap:wrap; gap:6px; min-width:0; }
.theme-chip { font-family:var(--round); font-size:12px; font-weight:600; color:var(--chip-text);
              background:var(--accent-soft); border:1px solid var(--line2);
              border-radius:999px; padding:3px 10px; white-space:nowrap; }

/* ── 연간 실적 표 ── */
.fin-wrap { overflow-x:auto; }
.fin-table { width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.fin-table th, .fin-table td { padding:11px 12px; text-align:right; white-space:nowrap; font-size:13.5px;
  border-bottom:1px solid var(--line); }
.fin-table th { font-family:var(--round); font-size:11.5px; font-weight:800; color:var(--sub); }
.fin-table th:first-child, .fin-table td:first-child { text-align:left; }
.fin-table tbody tr:last-child td { border-bottom:0; }
.fin-table td { font-weight:700; color:var(--heading); }
.fin-table td.up { color:var(--up); } .fin-table td.down { color:var(--down); }
.fin-p { font-family:var(--round); font-weight:800; color:var(--heading); }
.fin-e { display:inline-block; margin-left:3px; padding:0 4px; border-radius:5px; font-size:9px;
  font-weight:800; color:var(--sub); background:var(--flat-soft); vertical-align:middle; }

/* ── 푸터 ── */
footer { margin-top:30px; text-align:center; font-family:var(--round);
         font-size:11px; color:var(--faint); font-weight:600; line-height:1.8; }
footer .disc { color:var(--sub); }

/* ── 404 ── */
.empty-state { max-width:520px; margin:14vh auto; text-align:center; }
.empty-state .brand { justify-content:center; margin-bottom:38px; }
.empty-state .code { font-family:var(--round); font-size:12px; letter-spacing:.28em;
                     color:var(--accent); font-weight:800; }
.empty-state h1 { font-family:var(--serif); font-size:40px; color:var(--heading); margin:14px 0 8px; }
.empty-state h2 { font-family:var(--round); font-size:15px; color:var(--sub); font-weight:600; margin:0; }
.empty-state a.home { display:inline-block; margin-top:28px; color:#fff; text-decoration:none;
                      background:linear-gradient(135deg,var(--accent),var(--up));
                      padding:11px 22px; border-radius:14px; font-family:var(--round);
                      font-weight:800; font-size:13px; }

@keyframes pulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.35);opacity:.55} }

/* mode2·mode4: accent+up 그라데이션이 탁해 단색 accent 로 평탄화 */
html[data-theme="mode2"] header::after,
html[data-theme="mode4"] header::after,
html[data-theme="mode2"] .num,
html[data-theme="mode4"] .num,
html[data-theme="mode2"] .seg-tabs button.active,
html[data-theme="mode4"] .seg-tabs button.active,
html[data-theme="mode2"] .empty-state a.home,
html[data-theme="mode4"] .empty-state a.home { background:var(--accent); }
html[data-theme="mode2"] .num svg,
html[data-theme="mode4"] .num svg,
html[data-theme="mode2"] .seg-tabs button.active,
html[data-theme="mode4"] .seg-tabs button.active { color:#fff; }
