/* =====================================================================
   주식 참모 — UI 전면 개편 (v2)
   원칙: 폰 우선 · 결론이 먼저 · 한 화면 한 위계 · 카드는 평평하게
   ===================================================================== */
:root {
  --bg: #f2f4f6;          /* 페이지 바탕 */
  --card: #ffffff;
  --soft: #f4f5f7;        /* 카드 안쪽 면(입력칸·보조 타일) */
  --line: #eceff3;
  --text: #191f28;
  --sub: #4e5968;
  --muted: #8b95a1;
  --accent: #3182f6;
  --accent-soft: rgba(49,130,246,.10);
  --up: #e8344a;          /* 한국 관례: 상승 빨강 */
  --up-soft: rgba(232,52,74,.09);
  --down: #2272eb;        /* 하락 파랑 */
  --goal: #c98a00;
  --goal-soft: rgba(201,138,0,.12);
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(20,30,50,.04), 0 6px 20px rgba(20,30,50,.045);
  --nav-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d10;
    --card: #17191e;
    --soft: #1e2127;
    --line: #262a31;
    --text: #f2f4f6;
    --sub: #b0b8c1;
    --muted: #8b95a1;
    --accent: #4c94ff;
    --accent-soft: rgba(76,148,255,.14);
    --up: #ff5b6c;
    --up-soft: rgba(255,91,108,.12);
    --down: #4d94ff;
    --goal: #e6b84f;
    --goal-soft: rgba(230,184,79,.14);
    --shadow: 0 0 0 1px rgba(255,255,255,.02);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
               "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom, 0px));
}
b { font-weight: 700; }
button { -webkit-tap-highlight-color: transparent; }

/* ---------- 상단 ---------- */
.topbar {
  max-width: 1040px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 2px;
  display: flex; align-items: baseline; gap: 10px;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.03em; }
.topbar .logo { margin-right: 6px; }
.topbar .sub { margin: 0; color: var(--muted); font-size: 12.5px; }

main {
  max-width: 1040px; margin: 0 auto;
  padding: 8px 16px 32px;
  display: flex; flex-direction: column; gap: 16px;
}
section { display: flex; flex-direction: column; gap: 12px; }

/* ---------- 카드 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.card h2 .unit { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }

/* 섹션 제목 */
.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 14px 4px 2px; }
.sec-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.04em; line-height: 1.15; }
.sec-date { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding-bottom: 3px; }

/* ---------- 폼 ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.field:last-child { margin-bottom: 0; }
label { font-size: 13px; font-weight: 700; color: var(--sub); }
.unit { font-weight: 500; color: var(--muted); font-size: 12px; }
input[type=text], input[type=date], input[type=password], select {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;            /* iOS 자동 확대 방지 */
  font-family: inherit;
  letter-spacing: -.01em;
  color: var(--text);
  background: var(--soft);
  border: 1.5px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, background .15s;
}
input::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=date] { min-height: 48px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.grid:last-child { margin-bottom: 0; }
.grid .field { margin-bottom: 0; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
.grid.fees { grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 0; }
@media (max-width: 560px) { .grid.fees { grid-template-columns: 1fr 1fr 1fr; } .grid.fees label { font-size: 11.5px; } }

.hint { font-size: 12.5px; color: var(--muted); min-height: 1.2em; line-height: 1.55; }
.mini {
  align-self: flex-start;
  background: none; border: none; padding: 4px 0;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--accent);
  cursor: pointer;
}
.mini:hover { opacity: .75; }

/* 검색 */
.search-wrap { position: relative; }
.suggest {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 300px; overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(10,20,40,.2), 0 0 0 1px var(--line);
}
.suggest div {
  padding: 13px 14px; cursor: pointer; font-size: 15px; font-weight: 600;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.suggest div + div { border-top: 1px solid var(--line); }
.suggest div:hover, .suggest div.on { background: var(--accent-soft); }
.suggest .code { color: var(--muted); font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.picked {
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--accent-soft); border-radius: 12px;
}
.picked .badge {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: #fff;
}

/* 접이식 옵션 */
.opts { margin: 0 0 22px; background: var(--soft); border-radius: var(--radius-sm); padding: 0 16px; }
.opts summary {
  cursor: pointer; font-size: 14px; font-weight: 700; color: var(--sub);
  padding: 15px 0; list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.opts summary::-webkit-details-marker { display: none; }
.opts summary::after { content: "＋"; color: var(--muted); font-weight: 400; }
.opts[open] summary::after { content: "－"; }
.opts[open] { padding-bottom: 18px; }
.opts > *:not(summary) { margin-top: 14px; }
.opts > summary + * { margin-top: 2px; }
.opts input[type=text], .opts input[type=date] { background: var(--card); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.note { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.65; }

.run {
  width: 100%; padding: 16px; font: inherit; font-size: 16px; font-weight: 800; letter-spacing: -.02em;
  color: #fff; background: var(--accent); border: none; border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(49,130,246,.32);
  transition: transform .1s, opacity .15s;
}
.run:hover { opacity: .93; }
.run:active { transform: scale(.985); }
.run:disabled { opacity: .55; cursor: default; box-shadow: none; }
/* 폰: 계산 버튼은 항상 손 닿는 곳에 */
@media (max-width: 767px) {
  .card > .run {
    position: sticky; z-index: 5;
    bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
    margin-top: 6px;
  }
}

.err {
  margin-top: 14px; padding: 13px 15px; border-radius: 12px; font-size: 13.5px; line-height: 1.55;
  background: var(--up-soft); color: var(--up); font-weight: 600;
}

/* ---------- 결과 정렬: 결론 먼저 ---------- */
#result, #pResult, #cResult { gap: 12px; }
#result > .summary       { order: 1; }
#result > .cards         { order: 2; }
#result > #targetCard    { order: 3; }
#result > .chart-card    { order: 4; }
#result > #levCard       { order: 5; }
#result > #dcaCard       { order: 6; }
#result > .ep-card       { order: 7; }
#result > #feasCard      { order: 8; }
#result > .toolbar       { order: 0; }

#pResult > .summary      { order: 1; }
#pResult > #pTargetCard  { order: 2; }
#pResult > .pt-card      { order: 3; }
#pResult > .chart-card   { order: 4; }
#pResult > #pFeasCard    { order: 5; }
#pResult > .toolbar      { order: 0; }

/* 결과 요약 (히어로) */
.summary { padding: 22px 20px; }
.summary .sum-head {
  display: flex; flex-direction: column; gap: 14px;
}
.sum-name { font-size: 16px; font-weight: 700; letter-spacing: -.02em; color: var(--sub); }
.sum-period { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.sum-now { text-align: left; }
.sum-now .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.sum-now .val { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.04em; line-height: 1.2; margin-top: 2px; }
.sum-now .pct { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.sum-meta {
  margin-top: 18px; padding: 14px; background: var(--soft); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--muted);
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
}
.sum-meta > * { min-width: 0; }
.sum-meta > span:last-child { grid-column: 1 / -1; }
.sum-meta b { display: block; color: var(--text); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
@media (min-width: 560px) { .sum-meta { grid-template-columns: repeat(3, 1fr); } }

/* 지표 3카드 */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; gap: 10px; } }
.metric { padding: 18px 20px; }
.metric .mlabel { font-size: 13px; color: var(--sub); font-weight: 700; display: flex; gap: 6px; align-items: center; }
.metric .tag {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--soft); color: var(--muted);
}
.metric .mvalue { font-size: 28px; font-weight: 800; letter-spacing: -.04em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.metric .mamount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .mdate { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric .mfoot { font-size: 12px; color: var(--muted); margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); line-height: 1.5; }
.metric.up .mvalue, .metric.up .mamount { color: var(--up); }
.metric.down .mvalue, .metric.down .mamount { color: var(--down); }

.up-c { color: var(--up); }
.down-c { color: var(--down); }
.flat-c { color: var(--muted); }

/* 목표 */
.goal-hit { display: flex; flex-direction: column; gap: 14px; }
.goal-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.goal-big { font-size: 30px; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.goal-sub { font-size: 13px; color: var(--muted); line-height: 1.55; }
.goal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gstat { background: var(--soft); border-radius: 12px; padding: 12px; }
.gstat .k { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.gstat .v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin-top: 2px; }
.miss { font-size: 14px; }
.miss .goal-big { color: var(--muted); font-size: 20px; }

/* 차트 */
.chart-wrap { width: 100%; overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
#chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.line { background: var(--accent); }
.sw.band { background: var(--accent); opacity: .22; height: 10px; }
.sw.base { background: var(--muted); }
.sw.goal { background: var(--goal); }
.sw.buy { background: var(--text); width: 8px; height: 8px; border-radius: 50%; }
.sw.vol { background: var(--up); opacity: .5; height: 9px; }
.sw.bench { background: var(--muted); height: 2px; background-image: linear-gradient(90deg, var(--muted) 60%, transparent 60%); background-size: 5px 2px; }
@media (max-width: 620px) {
  #chart svg, #cChart svg, #pChart svg { min-width: 560px; }
  .chart-wrap { -webkit-overflow-scrolling: touch; }
}

/* 표 */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 8px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
tbody tr:last-child td { border-bottom: none; }
.empty { color: var(--muted); font-size: 13.5px; }
.tbl-wrap { width: 100%; overflow-x: auto; }
.tbl-wrap table { min-width: 560px; }
.tbl-wrap th:first-child, .tbl-wrap td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }

footer { display: none; }

/* ---------- 가정 현실성 점검 ---------- */
.feas.blocked { box-shadow: var(--shadow), inset 0 0 0 1.5px rgba(232,52,74,.4); }
.feas-head { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm); }
.feas-head.bad { background: var(--up-soft); }
.feas-head.ok  { background: var(--accent-soft); }
.feas-head .ic {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 800; color: #fff;
}
.feas-head.bad .ic { background: var(--up); }
.feas-head.ok .ic  { background: var(--accent); }
.feas-head .ft { font-weight: 800; font-size: 14.5px; letter-spacing: -.02em; }
.feas-head.bad .ft { color: var(--up); }
.feas-head .fs { font-size: 12.5px; color: var(--sub); margin-top: 2px; line-height: 1.55; }
.feas-more { margin-top: 12px; }
.feas-more > summary {
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--accent);
  list-style: none; padding: 4px 2px;
}
.feas-more > summary::-webkit-details-marker { display: none; }
.feas-more > summary::after { content: " ▾"; }
.feas-more[open] > summary::after { content: " ▴"; }
.feas-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.feas-list li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.feas-list .dot {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--soft); color: var(--muted);
}
.feas-list .ct { font-size: 13.5px; font-weight: 700; line-height: 1.45; }
.feas-list .cb { font-size: 12.5px; color: var(--muted); line-height: 1.65; margin-top: 3px; }
.feas-list .cb b { color: var(--text); font-variant-numeric: tabular-nums; }
.feas-list .lv-ok   .dot { background: var(--accent-soft); color: var(--accent); }
.feas-list .lv-warn .dot { background: var(--goal-soft); color: var(--goal); }
.feas-list .lv-warn .ct { color: var(--goal); }
.feas-list .lv-bad  .dot, .feas-list .lv-fail .dot { background: var(--up); color: #fff; }
.feas-list .lv-bad  .ct, .feas-list .lv-fail .ct { color: var(--up); }
.feas-list .lv-bad .cb b, .feas-list .lv-fail .cb b { color: var(--up); }

/* ---------- 매수 내역 (분할매수) ---------- */
.buys-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.avg-live { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.avg-live b { color: var(--accent); font-weight: 800; }
.buy-rows { display: flex; flex-direction: column; gap: 10px; }
.buy-row {
  display: grid;
  grid-template-columns: 1fr 34px;
  grid-template-areas: "idx del" "fields fields" "amt amt" "hint hint" "fill fill";
  gap: 4px 10px; align-items: center;
  padding: 14px; border-radius: var(--radius-sm); background: var(--soft);
}
.buy-row .bidx { grid-area: idx; font-size: 12.5px; font-weight: 800; color: var(--accent); }
.buy-row .bfields { grid-area: fields; display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 8px; margin-top: 4px; }
@media (max-width: 560px) { .buy-row .bfields { grid-template-columns: 1fr 1fr; } .buy-row .bfields .bf:first-child { grid-column: 1 / -1; } }
.buy-row .bf { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.buy-row .bl { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.buy-row .bl em { font-style: normal; font-weight: 500; }
.buy-row input, .buy-row select { padding: 11px 12px; font-size: 15px; background: var(--card); }
.buy-row .bdel {
  grid-area: del; justify-self: end; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--card); border: none; color: var(--muted); font-size: 12px;
}
.buy-row .bdel:hover:not(:disabled) { background: var(--up-soft); color: var(--up); }
.buy-row .bdel:disabled { opacity: .3; cursor: default; }
.brow-hint { grid-area: hint; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 0; line-height: 1.55; }
.brow-hint:empty { display: none; }
.brow-hint.lv-warn { color: var(--goal); }
.brow-hint.lv-bad, .brow-hint.lv-fail { color: var(--up); font-weight: 700; }
.buy-row .bfill { grid-area: fill; justify-self: start; font-size: 12.5px; }
.brow-amt { grid-area: amt; font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.brow-amt:empty { display: none; }
.brow-amt b { font-weight: 800; }
.brow-amt .amt-sub { color: var(--muted); font-weight: 400; }
.buys-foot { display: flex; gap: 18px; margin-top: 2px; }
.buys-foot .mini:first-child {
  padding: 11px 14px; border: 1.5px dashed var(--line); border-radius: 12px; flex: 1; text-align: center;
}

/* 포트폴리오 줄 */
.port-fields { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 640px) { .buy-row .port-fields { grid-template-columns: 1fr 1fr; } .buy-row .port-fields .bf:first-child { grid-column: 1 / -1; } }
.port-row .bidx { display: flex; align-items: center; }
.cdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.brange { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; margin-left: 4px; }
.brange.bad { color: var(--up); }

/* 목표 금액/수익률 듀얼 */
.dual { display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; }
.dual-item { display: flex; flex-direction: column; gap: 5px; }
.dual-item .dl { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.dual-item .dl em { font-style: normal; font-weight: 500; }

/* 연환산 · 벤치마크 */
.sum-now .cagr { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.sum-now .cagr b { color: var(--text); display: inline; font-size: inherit; }
.bench-line { font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.bench-line b { font-weight: 700; }

/* ---------- 분할매수 · 레버리지 결과 ---------- */
.dca-top, .lev-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
@media (max-width: 640px) { .dca-top, .lev-grid { grid-template-columns: 1fr; } }
.dca-big, .lev-big { background: var(--soft); border-radius: 12px; padding: 14px; }
.dca-big .k, .lev-big .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.dca-big .v { font-size: 21px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 3px 0; }
.lev-big .v { font-size: 22px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 3px 0; }
.dca-big .s, .lev-big .s { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.lev-card .unit { font-weight: 500; }
.lev-call { font-size: 13.5px; line-height: 1.65; padding: 13px 15px; border-radius: 12px; }
.lev-call.ok { background: var(--soft); color: var(--sub); }
.lev-call.ok b { color: var(--text); }
.lev-call.warn { background: var(--goal-soft); color: var(--goal); }
.lev-call.warn b { color: var(--goal); }
.lev-call.danger { background: var(--up-soft); color: var(--up); }
.lev-call.danger b { color: var(--up); }
.lev-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.lev-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.lev-warn-box { font-size: 13.5px; color: var(--up); background: var(--up-soft); border-radius: 12px; padding: 13px 15px; }

.opts.lev > summary { color: var(--accent); }
.lev-body { display: flex; flex-direction: column; gap: 16px; }
.lev-body .grid { margin-bottom: 0; }
.lev-quick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lev-quick button {
  font: inherit; font-size: 12.5px; font-weight: 700; padding: 6px 12px;
  background: var(--card); color: var(--sub); border: none; border-radius: 999px; cursor: pointer;
}
.lev-quick button:hover { color: var(--accent); }
.lev-quick .hint { margin-left: 4px; }

/* ---------- 툴바 · 저장 · 토스트 ---------- */
.toolbar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.tb {
  font: inherit; font-size: 13px; font-weight: 700; padding: 10px 15px; white-space: nowrap; flex: none;
  color: var(--sub); background: var(--card);
  border: none; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow);
}
.tb:hover { color: var(--accent); }
.tb:active { transform: scale(.97); }

.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-item { display: flex; gap: 8px; align-items: stretch; }
.si-main {
  flex: 1; text-align: left; font: inherit; cursor: pointer;
  background: var(--soft); border: none; border-radius: 12px;
  padding: 13px 15px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  color: var(--text);
}
.si-main:hover { background: var(--accent-soft); }
.si-title { font-size: 14px; font-weight: 700; }
.si-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.si-del { width: 42px; border-radius: 12px; cursor: pointer; font-size: 12px; background: var(--soft); border: none; color: var(--muted); }
.si-del:hover { color: var(--up); background: var(--up-soft); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--text); color: var(--bg);
  padding: 13px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,.28); z-index: 100;
}

/* ---------- 분석 세그먼트 탭 ---------- */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
}
.tabs button {
  font: inherit; font-size: 14px; font-weight: 700; padding: 11px 6px;
  background: transparent; border: none; border-radius: 11px; cursor: pointer; color: var(--muted);
  transition: background .15s, color .15s;
}
.tabs button.on { background: var(--text); color: var(--bg); }
#sec-lab .tabs { margin-bottom: 2px; }
#view-single, #view-compare, #view-port { display: flex; flex-direction: column; gap: 12px; }

/* 차트 모드 */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-head h2 { margin: 0; }
.chart-modes { display: flex; gap: 2px; padding: 3px; background: var(--soft); border-radius: 10px; }
.chart-modes button {
  font: inherit; font-size: 12px; font-weight: 700; padding: 6px 12px;
  background: transparent; border: none; border-radius: 8px; cursor: pointer; color: var(--muted);
}
.chart-modes button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- 종목 비교 · 칩 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 700; padding: 8px 8px 8px 13px;
  background: var(--soft); border-radius: 999px;
}
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip button {
  font: inherit; font-size: 11px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card); border: none; cursor: pointer; color: var(--muted); padding: 0;
}
.chip button:hover { color: var(--up); }
.cmp-table td, .cmp-table th { white-space: nowrap; }
.cmp-table .sub, .tbl-wrap .sub { font-size: 11.5px; color: var(--muted); }
.cmp-table .cdot { margin-right: 8px; }
.cmp-table td:first-child { font-weight: 700; }
.cmp-warn { display: inline-block; font-size: 11.5px; color: var(--goal); }
.cmp-warn.lv-bad, .cmp-warn.lv-fail { color: var(--up); font-weight: 700; }
.cmp-bad td { color: var(--muted); }
.cmp-table { min-width: 720px; }
.goal-cell b { font-size: 15px; }
.miss-cell { color: var(--muted); }

/* ---------- 잠금 ---------- */
.lock { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.lock-box {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--card); border-radius: 24px; padding: 36px 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.lock-emoji { font-size: 44px; }
.lock-box h1 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.lock-box p { margin: 0 0 6px; font-size: 13.5px; color: var(--muted); }
.lock-box button {
  width: 100%; padding: 14px; font: inherit; font-size: 15px; font-weight: 800;
  color: #fff; background: var(--accent); border: none; border-radius: 12px; cursor: pointer;
}
.lock-box button:disabled { opacity: .55; cursor: default; }
.lock-err { font-size: 13px; color: var(--up); }
body.locked > *:not(#lockScreen) { display: none !important; }

/* ---------- 하단 탭바 (폰) → 사이드바 (데스크톱) ---------- */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
}
.navbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; padding: 6px 0; border-radius: 12px;
  font: inherit; font-size: 11px; font-weight: 700; color: var(--muted);
  filter: grayscale(1); opacity: .75;
}
.navbar button .ni { font-size: 21px; line-height: 1; }
.navbar button.on { color: var(--accent); filter: none; opacity: 1; }

@media (min-width: 768px) {
  body { padding-bottom: 40px; }
  main { padding-left: 112px; padding-right: 24px; }
  .topbar { padding-left: 112px; }
  .toast { bottom: 24px; }
  .navbar {
    top: 0; right: auto; bottom: 0; width: 84px;
    grid-template-columns: 1fr; grid-auto-rows: max-content; gap: 4px;
    border-top: none; border-right: 1px solid var(--line);
    padding: 24px 8px; align-content: start; background: var(--card);
  }
  .navbar button { padding: 12px 0; }
  .navbar button:hover { background: var(--soft); }
  .navbar button.on { background: var(--accent-soft); }
  .navbar button .ni { font-size: 22px; }
  .sec-title { font-size: 30px; }
  .tabs { max-width: 440px; }
  .card { padding: 24px; }
  .run { max-width: 100%; }
}
/* 넓은 화면: 입력(좌, 고정) | 결과(우) 2단 */
@media (min-width: 1100px) {
  .topbar, main { max-width: 1280px; }
  #view-single, #view-port, #view-compare {
    display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 16px; align-items: start;
  }
  #view-single[hidden], #view-port[hidden], #view-compare[hidden] { display: none !important; }
  #form-card, #view-compare > .card:first-child, #view-compare > section.card, #view-port > section.card {
    position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
  }
  #result, #pResult, #cResult { min-width: 0; }
  .cards { grid-template-columns: 1fr; }
  #result .cards { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 오늘: 시장 지표 (묶음별 한 줄 목록) ---------- */
.mk-list { display: grid; grid-template-columns: 1fr; gap: 14px; }
.mk-g { min-width: 0; }
.mk-h { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 4px 2px; }
.mk-r { display: grid; grid-template-columns: 1fr auto 74px; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line, rgba(128,128,128,.12)); }
.mk-g .mk-r:last-child { border-bottom: 0; }
.mk-n { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mk-c { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mk-foot { font-size: 11.5px; color: var(--muted); margin: 0 4px; }
#todayIndexCard { padding: 16px 16px 14px; }
#todayIndexCard h2 { margin-left: 4px; }
@media (min-width: 768px) {
  .mk-list { grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .mk-foot { grid-column: 1 / -1; }
}

/* 준비 중 / 설정 */
.soon-p { font-size: 13.5px; color: var(--sub); line-height: 1.65; margin: 0 0 16px; }
.soon-p b { color: var(--text); }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.set-row .tb { box-shadow: none; background: var(--soft); }

/* ---------- 아침 브리핑 ---------- */
.brief-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.brief-head h2 { margin: 0; }
.brief-macro {
  font-size: 15px; font-weight: 700; line-height: 1.65; color: var(--text); letter-spacing: -.02em;
  padding: 15px 16px; background: var(--accent-soft); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.brief-src { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.brief-item { padding: 16px 0; border-top: 1px solid var(--line); }
.brief-item:first-of-type { border-top: none; }
.brief-title { font-size: 15px; font-weight: 700; color: var(--text); text-decoration: none; display: inline-block; line-height: 1.5; letter-spacing: -.02em; }
a.brief-title:hover { color: var(--accent); }
.brief-sum { font-size: 13.5px; color: var(--sub); line-height: 1.7; margin-top: 6px; }
.brief-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.brief-chip {
  font: inherit; font-size: 12.5px; font-weight: 700; padding: 6px 12px;
  background: var(--accent-soft); color: var(--accent); border: none; border-radius: 999px; cursor: pointer;
}
.brief-chip:hover { filter: brightness(.95); }
.brief-chip.off { background: var(--soft); color: var(--muted); cursor: default; }
#briefJson {
  width: 100%; padding: 13px 14px; font-size: 13px; font-family: ui-monospace, Menlo, monospace;
  color: var(--text); background: var(--soft); border: 1.5px solid transparent; border-radius: 12px;
  outline: none; resize: vertical; margin-bottom: 10px;
}
#briefJson:focus { border-color: var(--accent); }
.brief-input-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.brief-input-foot .tb { box-shadow: none; background: var(--soft); }

/* ---------- 내 종목 (보유 대시보드) ---------- */
.mine-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.mine-btns .run { width: auto; flex: 1; min-width: 160px; }
.mine-btns .tb { padding: 16px 20px; border-radius: 14px; font-size: 14.5px; }

.hold-hero { padding: 24px 22px 22px; }
.hold-hero.skel { opacity: .6; }
.hh-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.hh-val { font-size: 38px; font-weight: 800; letter-spacing: -.045em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.hh-pl { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -.02em; }
.hh-pl span { font-size: 14px; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--soft); }
.hh-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.hh-sub span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.hh-sub b { font-size: 14px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.wbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; gap: 2px; margin-top: 18px; }
.wbar i { display: block; min-width: 4px; }

.hold-list { padding: 20px 20px 8px; }
.hold-row { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.hold-row:first-of-type { border-top: none; padding-top: 6px; }
.hdot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.hr-main { flex: 1; min-width: 0; }
.hr-name { font-size: 16px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hr-w { margin-left: 7px; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--soft); padding: 1px 7px; border-radius: 999px; vertical-align: 2px; }
.hr-sub { white-space: nowrap; font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.hr-right { text-align: right; flex: none; }
.hr-val { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.hr-amt { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: .85; }
.hr-pl { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 1px; }
.hr-day { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 1px; }
.empty-card { text-align: center; padding: 40px 24px; }
.empty-card .empty-ic { font-size: 40px; margin-bottom: 6px; }
.empty-card h2 { font-size: 17px; }
.empty-card .run { max-width: 280px; margin: 0 auto; }

/* 날짜: 숫자로 바로 입력 + 오른쪽 달력 아이콘(투명 네이티브 달력을 위에 겹침) */
.date-wrap { position: relative; display: block; }
.date-wrap > input[type=text] { width: 100%; padding-right: 48px; font-variant-numeric: tabular-nums; min-height: 48px; }
.date-wrap > input.bad { border-color: var(--up, #f04452); }
.date-wrap::after {
  content: ''; position: absolute; right: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  pointer-events: none; background: currentColor; opacity: .55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") center/contain no-repeat;
}
.date-wrap > input.date-pick {
  position: absolute; right: 0; top: 0; bottom: 0; width: 48px; min-height: 0; padding: 0; margin: 0;
  opacity: 0; border: 0; cursor: pointer; z-index: 1;
}
.date-wrap > input.date-pick::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.date-note { font-size: 12.5px; margin-top: 6px; min-height: 0; color: var(--muted); }
.date-note:empty { display: none; }
.date-note.ok { color: var(--accent); }
.date-note.bad { color: var(--up); font-weight: 600; }
.date-note.warn { color: #e0a100; }
.brief-days { display: flex; gap: 6px; overflow-x: auto; margin: -2px 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.brief-days::-webkit-scrollbar { display: none; }
.brief-day { flex: none; border: 0; border-radius: 999px; padding: 6px 11px; font: inherit; font-size: 12.5px; font-weight: 700; background: var(--soft); color: var(--sub); cursor: pointer; font-variant-numeric: tabular-nums; }
.brief-day.on { background: var(--text); color: var(--card); }
.brief-impact { font-size: 13px; color: var(--text); line-height: 1.6; margin-top: 6px; }
.brief-whys { font-size: 12.5px; color: var(--sub); line-height: 1.65; margin-top: 8px; }
.brief-whys b { color: var(--text); font-weight: 700; margin-right: 4px; }

/* ===================== 발굴: 종목 카드 시트 ===================== */
body.sheet-on { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 200; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.sheet[hidden] { display: none; }
.sh-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 12px 0 10px; background: var(--bg); }
.sh-x { border: 0; background: var(--card); color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 20px; cursor: pointer; box-shadow: var(--shadow); flex: none; }
.sh-ttl { display: flex; flex-direction: column; min-width: 0; }
.sh-ttl b { font-size: 20px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-ttl span { font-size: 12px; color: var(--muted); }
.sh-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 2px 2px 14px; }
.sh-price b { font-size: 26px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.sh-price span { font-size: 15px; font-weight: 700; }
.sh-price em { font-style: normal; font-size: 12px; color: var(--muted); }
#shBody { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.sh-skel { color: var(--muted); padding: 30px 0; text-align: center; }
.sh-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sh-actions .run { padding: 14px; font-size: 15px; }
.sh-star { padding: 0 18px; font-size: 14px; }
.sh-star.on { color: var(--goal); }
.sh-sec { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.sh-sec h3 { margin: 0 0 12px; font-size: 15px; font-weight: 800; letter-spacing: -.02em; }
.sh-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.sh-h h3 { margin: 0; }
.h-sub { font-size: 12px; font-weight: 500; color: var(--muted); }
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kv-grid.four { grid-template-columns: repeat(4, 1fr); }
.kv { background: var(--soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv span { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv em { font-style: normal; font-size: 11.5px; color: var(--muted); }
@media (min-width: 600px) { .kv-grid { grid-template-columns: repeat(4, 1fr); } }
.cons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cons div { background: var(--soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.cons span { font-size: 12px; color: var(--muted); font-weight: 600; }
.cons b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cons em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.seg-mini { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg-mini button { border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 5px 12px; border-radius: 8px; cursor: pointer; }
.seg-mini button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.growth { font-size: 13px; line-height: 1.7; margin-bottom: 10px; color: var(--sub); }
.fin-cap { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.fin-cap em { font-style: normal; font-weight: 400; margin-left: 6px; }
.fin-bars { display: flex; align-items: flex-end; gap: 6px; height: 104px; margin-bottom: 12px; }
.fb { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 0; }
.fb i { display: block; width: 70%; max-width: 38px; background: var(--accent); border-radius: 5px 5px 2px 2px; }
.fb i.neg { background: var(--down); opacity: .7; }
.fb.est i { background: transparent; border: 2px dashed var(--accent); }
.fb em { font-style: normal; font-size: 10.5px; font-weight: 700; color: var(--sub); white-space: nowrap; }
.fb span { font-size: 11px; color: var(--muted); }
.tbl-scroll { overflow-x: auto; }
.fin-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.fin-tbl th, .fin-tbl td { padding: 7px 6px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.fin-tbl th { font-weight: 700; color: var(--muted); font-size: 11.5px; }
.fin-tbl td:first-child, .fin-tbl th:first-child { text-align: left; color: var(--sub); font-weight: 600; }
.fin-tbl .est { color: var(--accent); }
.fin-tbl tr:last-child td { border-bottom: 0; }
.spark { width: 100%; height: 70px; display: block; }
.spark-cap { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 4px 0 12px; }
.deal-sig { font-size: 13px; font-weight: 700; color: var(--up); margin-bottom: 8px; }
.peer-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.peer { border: 0; background: var(--soft); border-radius: 12px; padding: 10px 12px; text-align: left; font: inherit; color: var(--text); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; }
.peer b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer span { font-size: 12.5px; font-weight: 700; }
.peer em { grid-column: 1 / -1; font-style: normal; font-size: 11.5px; color: var(--muted); }
.rep { border-top: 1px solid var(--line); padding: 12px 0; }
.rep:first-of-type { border-top: 0; padding-top: 0; }
.rep-h { border: 0; background: none; padding: 0; text-align: left; font: inherit; color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 3px; width: 100%; }
.rep-m { font-size: 12px; color: var(--muted); }
.rep-h b { font-size: 14.5px; line-height: 1.45; }
.rep-pre { font-size: 12.5px; color: var(--sub); line-height: 1.6; margin-top: 4px; }
.rep-body { margin-top: 8px; }
.rep-text { font-size: 13px; line-height: 1.75; color: var(--sub); white-space: pre-wrap; background: var(--soft); border-radius: 12px; padding: 12px; max-height: 420px; overflow-y: auto; }
.ai-note { font-size: 13.5px; line-height: 1.75; color: var(--text); }
.ai-note h4 { font-size: 14px; margin: 14px 0 4px; }
.ai-note h4:first-child { margin-top: 0; }
.ai-note p { margin: 0 0 6px; }
.ai-note ul { margin: 0 0 6px; padding-left: 18px; }
.note-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.note-btns .tb { box-shadow: none; background: var(--soft); }
#noteText { width: 100%; margin-top: 10px; font: inherit; font-size: 13px; line-height: 1.6; background: var(--soft); color: var(--text); border: 1px solid transparent; border-radius: 12px; padding: 12px; resize: vertical; box-sizing: border-box; }
/* 관심종목 담기 폼 */
.wform { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.wf-old { font-size: 12.5px; color: var(--goal); background: var(--goal-soft); padding: 8px 10px; border-radius: 10px; }
.wf-l { font-size: 13px; font-weight: 700; margin-top: 4px; }
.wf-l em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.wf-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.wtag, .wf-conf button { border: 0; font: inherit; font-size: 13px; font-weight: 700; padding: 8px 13px; border-radius: 999px; background: var(--soft); color: var(--sub); cursor: pointer; }
.wtag.on, .wf-conf button.on { background: var(--accent); color: #fff; }
.wf-conf { display: flex; gap: 6px; }
#wfReason { width: 100%; box-sizing: border-box; margin-top: 4px; }
/* 관심종목 목록 */
#watchArea { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.wlist { display: flex; flex-direction: column; }
.wrow { border: 0; border-top: 1px solid var(--line); background: none; padding: 12px 0; display: grid; grid-template-columns: 1fr auto; gap: 10px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.wrow:first-child { border-top: 0; padding-top: 0; }
.wr-main b { font-size: 15px; }
.wr-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wr-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
.wr-tags i { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.wr-tags span { font-size: 12px; color: var(--sub); }
.wr-h { display: flex; gap: 10px; margin-top: 5px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.wr-h .dim { opacity: .6; }
.wr-right { text-align: right; font-variant-numeric: tabular-nums; }
.wr-right div { font-size: 16px; font-weight: 800; }
.wr-right em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.gmap-t { font-size: 12.5px; font-weight: 700; color: var(--sub); margin: 6px 0 4px; }
.gmap { margin-bottom: 10px; }
/* 레이더 */
.radar-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -2px 0 10px; }
.radar-tabs::-webkit-scrollbar { display: none; }
.radar-tabs button { flex: none; border: 0; font: inherit; font-size: 13px; font-weight: 700; padding: 8px 13px; border-radius: 999px; background: var(--soft); color: var(--sub); cursor: pointer; }
.radar-tabs button.on { background: var(--text); color: var(--card); }
.rr-date { font-size: 12px; color: var(--muted); margin: 0 2px 6px; }
.rlist { display: flex; flex-direction: column; }
.rrow { border: 0; border-top: 1px solid var(--line); background: none; padding: 10px 2px; display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.rrow:first-child { border-top: 0; }
.rr-i { font-size: 12px; color: var(--muted); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.rr-m { min-width: 0; }
.rr-m b { font-size: 14.5px; margin-right: 4px; }
.rr-sig { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--up-soft); color: var(--up); margin-right: 3px; white-space: nowrap; }
.rr-s { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow > span:last-child { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.brief-chip.hot { box-shadow: inset 0 0 0 1.5px var(--up); }
.brief-chip i { font-style: normal; font-size: 10.5px; color: var(--up); margin-left: 2px; }
.picked-info { margin-left: 6px; }
.dtag { font-style: normal; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; margin-right: 6px; background: var(--soft); color: var(--sub); }
.dtag.s1 { background: var(--up-soft); color: var(--up); }
.dtag.s-1 { background: var(--accent-soft); color: var(--down); }
.rr-link { font-size: 12.5px; font-weight: 700; color: var(--accent); text-decoration: none; padding: 6px 2px; }
div.rrow { cursor: pointer; }
/* 신호 성적표 */
.sh-actions.one { grid-template-columns: 1fr; }
.prog { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.prog i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.sig-tbl td { vertical-align: top; }
.sig-tbl td b { display: block; font-size: 13px; }
.sig-tbl td em { display: block; font-style: normal; font-size: 10.5px; color: var(--muted); }
.sig-tbl td.few { opacity: .45; }
.sig-tbl td.dim { color: var(--muted); }
.few-ex { opacity: .45; font-weight: 700; }
.rr-stat { display: block; width: 100%; text-align: left; border: 0; background: var(--soft); color: var(--sub); font: inherit; font-size: 12px; line-height: 1.6; padding: 8px 10px; border-radius: 10px; margin: 0 0 8px; cursor: pointer; }
.sig-open { margin-top: 10px; width: 100%; box-shadow: none; background: var(--soft); }
.sig-tbl th, .sig-tbl td { padding: 7px 3px; }
.sig-tbl td:first-child { white-space: normal; min-width: 76px; font-size: 12px; line-height: 1.35; }
.sig-tbl td:nth-child(2) { color: var(--muted); font-size: 11.5px; }
.dis-list { display: flex; flex-direction: column; }
.dis { display: grid; grid-template-columns: 58px 1fr; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--text); }
.dis:first-child { border-top: 0; }
.dis-d { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.dis-t { font-size: 13.5px; line-height: 1.5; }
.dis-t .dtag { margin-right: 6px; }
.dis-t em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.dis:hover .dis-t { color: var(--accent); }
.acc-min { display: inline-flex; margin: 0 0 8px; }
.acc-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.acc-c { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.acc-c.d { background: var(--up-soft); color: var(--up); }
.acc-c.m { background: var(--goal-soft); color: var(--goal); }
.rr-warn { font-style: normal; font-size: 10.5px; font-weight: 700; color: var(--down); margin-left: 4px; white-space: nowrap; }
.acc-n { text-align: right; font-variant-numeric: tabular-nums; }
.acc-n b { font-size: 17px; font-weight: 800; }
.acc-n em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.mk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.mk-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.ctr { font-size: 12px; color: var(--sub); margin-top: 3px; }
.ctr b { font-weight: 800; }
.ctr.big b { color: var(--up); }
.th-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.th-row div { background: var(--soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.th-row span { font-size: 12px; color: var(--muted); font-weight: 600; }
.th-row b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.th-movers { display: flex; flex-direction: column; margin-top: 8px; }
.th-m { border: 0; border-top: 1px solid var(--line); background: none; font: inherit; color: var(--text); display: flex; align-items: center; gap: 8px; padding: 9px 2px; cursor: pointer; text-align: left; }
.th-m:first-child { border-top: 0; }
.th-m b { font-size: 14px; flex: 1; }
.th-m span { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wf-ts { display: flex; gap: 10px; }
.wf-ts label { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--sub); }
.wf-ts input { width: 64px; text-align: right; padding: 8px 10px; min-height: 0; }
.wr-ts { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ===== 매도전략·포트 레버리지 ===== */
.sw.sell { width: 0; height: 0; border-radius: 0; background: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--up); }
.sell-card .tbl-wrap { margin-bottom: 12px; }
.sell-card .lev-call { margin-bottom: 4px; }
.sell-gap { font-size: 10.5px; font-weight: 700; color: var(--goal); background: var(--goal-soft); border-radius: 999px; padding: 1px 6px; margin-left: 4px; white-space: nowrap; }
/* 결과 카드 순서: 요약 바로 아래 (같은 order 1이면 DOM 순서로 요약 다음) */
#result > #sellCard   { order: 1; }
#pResult > #pLevCard  { order: 1; }
.us-th { border-top: 1px solid var(--line); padding: 12px 0; }
.us-th:first-of-type { border-top: 0; }
.us-th.hot .us-h b { color: var(--up); }
.us-th.cold .us-h b { color: var(--down); }
.us-h { display: flex; justify-content: space-between; align-items: center; font-size: 14.5px; }
.us-h span { font-weight: 800; font-variant-numeric: tabular-nums; }
.us-us { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.us-us span span { font-weight: 700; }
/* 테마 */
.thm { border-top: 1px solid var(--line); padding: 10px 0; }
.thm:first-child { border-top: 0; }
.thm-h { width: 100%; border: 0; background: none; padding: 0; font: inherit; color: var(--text); display: flex; align-items: center; gap: 6px; cursor: pointer; text-align: left; }
.thm-h b { font-size: 14.5px; flex: 1; min-width: 0; }
.thm-h span { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.thm-sig { font-style: normal; font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: var(--up-soft); color: var(--up); white-space: nowrap; }
.thm-s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.thm-body { margin-top: 8px; background: var(--soft); border-radius: 12px; padding: 4px 12px; }
.thm-desc { font-size: 12.5px; color: var(--sub); line-height: 1.6; margin: 8px 0; }
.thm-st { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; font: inherit; color: var(--text); display: flex; align-items: center; gap: 10px; padding: 9px 0; cursor: pointer; text-align: left; }
.thm-st div { flex: 1; min-width: 0; }
.thm-st b { font-size: 14px; }
.thm-st em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.thm-st span { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.home-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; cursor: pointer; }
/* 레이더 탭: 옆으로 밀지 않고 한눈에(3열 격자) */
.radar-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; overflow: visible; margin: -2px 0 10px; }
.radar-tabs button { padding: 9px 4px; font-size: 13px; text-align: center; white-space: nowrap; }
@media (min-width: 600px) { .radar-tabs { grid-template-columns: repeat(5, 1fr); } }
.rf-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.rf-bar select { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 28px 7px 10px; border-radius: 10px; border: 0; background-color: var(--soft); color: var(--text); min-height: 0; width: auto; }
.rf-pct { font-size: 11.5px; color: var(--muted); margin: 0 2px 6px; }
.rr-s b { font-size: inherit; font-weight: 800; margin: 0; }
.mkt-sw { display: inline-flex; margin: -4px 0 10px; }
/* ===== 미국 백테스트·보유 ===== */
.tabs { grid-template-columns: repeat(4, 1fr); }
#view-us { display: flex; flex-direction: column; gap: 12px; }
#view-us[hidden] { display: none; }
.us-fee { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.us-fee label { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--sub); }
.us-fee input[type=text] { width: 64px; text-align: right; padding: 8px 10px; min-height: 0; }
.us-fee label.chk { width: 100%; }
.us-hold { cursor: pointer; }
.us-del { padding: 2px 0; font-size: 12px; color: var(--muted); }
.th-us { font-size: 13px; color: var(--sub); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.us-preset { width: 100%; display: flex; gap: 14px; }
/* ===== 미국 카드·레이더 ===== */
.sh-price em.us-krw { font-size: 14px; font-weight: 700; color: var(--sub); }
.us-ov { font-size: 13.5px; line-height: 1.7; color: var(--sub); margin: 0; word-break: keep-all; overflow-wrap: anywhere; }
.us-ret td:first-child { text-align: left; color: var(--muted); font-weight: 600; }
.us-ins-cap { margin-top: 16px; }
.us-ins { margin-top: 8px; }
.us-sum { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 3px; }
.us-sym { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-right: 5px; }
.us-irow .rr-s { white-space: normal; }
.us-irow > span:last-child { font-size: 13.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rrow[disabled] { cursor: default; }
.peer.us-peer em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* AI */
.ai-picks { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ai-p { border: 0; background: var(--soft); border-radius: 14px; padding: 12px 14px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.ai-h { display: flex; justify-content: space-between; align-items: center; }
.ai-h b { font-size: 15px; }
.ai-s { color: var(--goal); font-size: 12px; letter-spacing: 1px; }
.ai-p ul, .ai-rv ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; color: var(--sub); }
.ai-r { font-size: 12.5px; color: var(--down); margin-top: 6px; }
.ai-c { font-size: 12.5px; color: var(--sub); margin-top: 3px; }
.ai-avoid { margin-top: 10px; font-size: 13px; color: var(--sub); line-height: 1.6; }
.ai-avoid b { display: block; color: var(--text); margin-bottom: 2px; }
.ai-rv { margin-top: 10px; }
.ai-rv b { font-size: 13.5px; }
/* 맨 위 국내/미국 */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gmkt { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 3px; flex: none; }
.gmkt button { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 800; color: var(--muted); padding: 6px 11px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.gmkt button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
body.mkt-us #mineArea, body.mkt-us #watchArea, body.mkt-us #mineSync { display: none; }
body:not(.mkt-us) #usMineArea { display: none; }
body.mkt-us #sec-lab .tabs, body.mkt-us #view-single, body.mkt-us #view-compare, body.mkt-us #view-port { display: none !important; }
body:not(.mkt-us) #view-us { display: none !important; }
body.mkt-us #view-us { display: flex !important; }
body.mkt-us #briefInput { display: none; }
/* 오늘 요약: 지표 띠 */
.mstrip { width: 100%; border: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; font: inherit; color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.ms-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ms-i { display: flex; flex-direction: column; min-width: 0; }
.ms-i em { font-style: normal; font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.ms-i b { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-i i { font-style: normal; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ms-more { font-size: 11.5px; color: var(--accent); font-weight: 700; align-self: flex-end; }
.navbar { grid-template-columns: repeat(5, 1fr); }
#sec-find { display: flex; flex-direction: column; gap: 12px; }
#sec-find[hidden] { display: none; }
#mktSheet .card { max-width: 720px; margin: 0 auto; }
.topbar { justify-content: flex-start; gap: 12px; }
.topbar h1 { margin: 0; }
.th-row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); }
.th-row b { font-size: 14.5px; white-space: nowrap; }
.tabs-us { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.tabs-us button { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 700; color: var(--muted); padding: 10px 4px; border-radius: 10px; cursor: pointer; }
.tabs-us button.on { background: var(--text); color: var(--card); }
.us-pane { display: flex; flex-direction: column; gap: 12px; }
.us-pane[hidden] { display: none; }
.up-stock { border-top: 1px solid var(--line); padding: 10px 0; }
.up-b { margin: 6px 0; }
.lock-hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 4px; text-align: left; }
.pw-form { display: flex; flex-direction: column; gap: 8px; }
.pw-form input { width: 100%; box-sizing: border-box; }
body:not(.mkt-us) #usWatchArea { display: none; }
#usWatchArea { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.ai-star { float: right; border: 0; background: var(--card); color: var(--goal); font: inherit; font-size: 12.5px; font-weight: 800; padding: 4px 9px; border-radius: 999px; cursor: pointer; margin-left: 8px; }
.ai-star.on { color: var(--muted); }
/* 내 종목 브리핑 */
.mb-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mb-i { border: 0; background: var(--soft); border-radius: 14px; padding: 11px 13px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.mb-h { display: flex; align-items: center; gap: 6px; }
.mb-h b { font-size: 14.5px; }
.mb-h em { font-style: normal; font-size: 11px; color: var(--muted); margin-left: auto; }
.mb-lv { font-style: normal; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--card); color: var(--sub); }
.mb-lv.down { background: var(--accent-soft); color: var(--down); }
.mb-lv.up { background: var(--up-soft); color: var(--up); }
.mb-lv.goal { background: var(--goal-soft); color: var(--goal); }
.mb-s { font-size: 13px; color: var(--sub); line-height: 1.6; margin-top: 4px; }
.mk-v small { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.wr-right em { display: block; white-space: nowrap; }
.held-b { font-style: normal; font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: 2px; }
/* 내 코인 */
.cn-tbl { display: flex; flex-direction: column; margin-top: 6px; }
.cn-r { display: grid; grid-template-columns: 1.1fr 1.2fr .8fr .8fr .7fr; gap: 6px; align-items: center; padding: 8px 2px; border-top: 1px solid var(--line); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cn-r > *:not(:first-child) { text-align: right; }
.cn-r b { font-size: 14px; }
.cn-hd { border-top: 0; font-size: 11.5px; color: var(--muted); font-weight: 600; padding-top: 0; }
.cn-r .muted { color: var(--muted); }
.cn-news { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.cn-news a { font-size: 12px; color: var(--sub); text-decoration: none; line-height: 1.45; }
.cn-news a em { font-style: normal; color: var(--muted); font-size: 11px; }
/* 🪙 코인 모드 */
.gmkt button { padding: 6px 9px; }
body.mkt-coin #myBrief, body.mkt-coin #todayHold, body.mkt-coin #aiCard, body.mkt-coin #todayAcc, body.mkt-coin #todayNews,
body.mkt-coin #mineArea, body.mkt-coin #watchArea, body.mkt-coin #mineSync, body.mkt-coin #usMineArea, body.mkt-coin #usWatchArea,
body.mkt-coin #sec-lab .tabs, body.mkt-coin #view-single, body.mkt-coin #view-compare, body.mkt-coin #view-port, body.mkt-coin #view-us, body.mkt-coin #briefInput { display: none !important; }
body:not(.mkt-coin) #myCoins, body:not(.mkt-coin) #coinMineArea, body:not(.mkt-coin) #view-coin { display: none !important; }
body.mkt-coin #view-coin { display: flex !important; flex-direction: column; gap: 12px; }
#coinMineArea { margin-top: 0; }
/* 악어 우상향(머리가 오른쪽 위) */
.logo-img { width: 26px; height: 26px; border-radius: 7px; margin-right: 8px; vertical-align: -6px; }
.lock-emoji img { width: 64px; height: 64px; border-radius: 15px; }
.gator { color: #3fbf6f; }
.lock-tag { margin: -6px 0 6px; font-size: 13px; color: var(--muted); letter-spacing: .08em; }
