:root {
  --bg: #f2f4f6;
  --layer: #ffffff;
  --grey50: #f9fafb;
  --grey100: #f2f4f6;
  --grey200: #e5e8eb;
  --grey300: #d1d6db;
  --grey400: #b0b8c1;
  --grey500: #8b95a1;
  --grey600: #6b7684;
  --grey700: #4e5968;
  --grey800: #333d4b;
  --grey900: #191f28;
  --blue: #3182f6;
  --blue-weak: #e8f3ff;
  --up: #f04452;
  --down: #3182f6;
  --up-weak: #ffeeee;
  --down-weak: #e8f3ff;
  --green: #03b26c;
  --green-weak: #e5f8ef;
  --seg-on: #ffffff;
  --shadow-seg: 0 1px 3px rgba(0, 0, 0, 0.08);
  color-scheme: light;
  --ma5: #f59e0b; --ma20: #8b5cf6; --ma60: #03b26c; --ma120: #a16207;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101013; --layer: #1c1c21; --grey50: #202027; --grey100: #26262e; --grey200: #2f2f39; --grey300: #3c3c47;
    --grey400: #62626d; --grey500: #7e7e87; --grey600: #9e9ea4; --grey700: #c3c3c6; --grey800: #e4e4e5; --grey900: #ffffff;
    --blue: #4593fc; --blue-weak: #1d2a3f; --up: #f7525f; --down: #4593fc; --up-weak: #3a1f24; --down-weak: #1d2a3f;
    --green: #2ac983; --green-weak: #173327; --seg-on: #3c3c47; --shadow-seg: none; color-scheme: dark;
    --ma5: #c98208; --ma20: #8b6cf0; --ma60: #12a064; --ma120: #a87426;
  }
}
:root[data-theme="dark"] {
  --bg: #101013; --layer: #1c1c21; --grey50: #202027; --grey100: #26262e; --grey200: #2f2f39; --grey300: #3c3c47;
  --grey400: #62626d; --grey500: #7e7e87; --grey600: #9e9ea4; --grey700: #c3c3c6; --grey800: #e4e4e5; --grey900: #ffffff;
  --blue: #4593fc; --blue-weak: #1d2a3f; --up: #f7525f; --down: #4593fc; --up-weak: #3a1f24; --down-weak: #1d2a3f;
  --green: #2ac983; --green-weak: #173327; --seg-on: #3c3c47; --shadow-seg: none; color-scheme: dark;
    --ma5: #c98208; --ma20: #8b6cf0; --ma60: #12a064; --ma120: #a87426;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--grey900);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
.num, .big, .stat-v, .row, .o-row, .m-row { font-variant-numeric: tabular-nums; }
.muted { color: var(--grey600); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--grey600); }

/* 상단 바 */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--layer); border-bottom: 1px solid var(--grey100); }
.topbar-inner { max-width: 1240px; margin: 0 auto; height: 60px; padding: 0 24px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--grey900); text-decoration: none; flex: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--blue), #6aa8ff); }
.nav a { color: var(--grey600); text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 2px; }
.nav a.active { color: var(--grey900); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--grey100); color: var(--grey700); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--grey400); }
.pill.live { background: var(--green-weak); color: var(--green); }
.pill.live::before { background: var(--green); }
.pill.dry { background: var(--blue-weak); color: var(--blue); }
.pill.dry::before { background: var(--blue); }
.pill-btn { border: 0; font-family: inherit; cursor: pointer; transition: filter .15s; }
.pill-btn:hover { filter: brightness(.96); }
.pill-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.pill-btn:disabled { cursor: progress; opacity: .6; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--grey700); font-size: 18px; cursor: pointer; }
.icon-btn:hover { background: var(--grey100); }

/* 레이아웃 */
.layout { max-width: 1240px; margin: 0 auto; padding: 24px; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.main-col, .side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stock-view { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--layer); border-radius: 20px; padding: 24px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h2 { margin: 0; font-size: 18px; font-weight: 700; }
.count { color: var(--blue); margin-left: 2px; }

/* 총 자산 */
.acct { display: flex; justify-content: space-between; gap: 12px; color: var(--grey700); font-weight: 600; font-size: 14px; margin-bottom: 18px; }
.label { color: var(--grey600); font-weight: 500; font-size: 15px; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 10px; }
.pl-row { display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: 15px; font-weight: 600; }
.pl-item { display: flex; gap: 8px; }
.pl-item .muted { font-weight: 500; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 22px; }
.stat { background: var(--grey50); border-radius: 14px; padding: 14px 16px; font-size: 13px; }
.stat-v { font-size: 17px; font-weight: 700; color: var(--grey900); margin-top: 4px; overflow-wrap: anywhere; }
.stat-s { color: var(--grey600); margin-top: 2px; }
.fx { margin-top: 12px; }
.err { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--up-weak); color: var(--up); font-size: 14px; font-weight: 500; }

/* 세그먼트·셀렉트 */
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--grey100); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--grey600); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--seg-on); color: var(--grey900); box-shadow: var(--shadow-seg); }
select { font: inherit; font-size: 13px; font-weight: 600; color: var(--grey700); background: var(--grey100); border: 0; border-radius: 10px; padding: 8px 10px; cursor: pointer; }

/* 보유 주식 표 */
.thead, .row { display: grid; grid-template-columns: minmax(170px, 2.1fr) 1fr 1fr 1.15fr 1.25fr; gap: 12px; align-items: center; }
.thead { color: var(--grey500); font-size: 13px; font-weight: 500; padding: 8px 8px; border-bottom: 1px solid var(--grey100); }
.r { text-align: right; }
.row { padding: 14px 8px; border-radius: 12px; }
.row:hover { background: var(--grey50); }
.stock { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.stock-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-sub { color: var(--grey500); font-size: 13px; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 13px; }
.hold-note { padding: 12px 8px 0; border-top: 1px solid var(--grey100); margin-top: 6px; }
.empty { color: var(--grey500); text-align: center; padding: 40px 0; font-size: 14px; }

/* 사이드 목록 */
.side-list { display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; margin: 0 -8px; }
.o-row, .m-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 8px; border-radius: 12px; }
.o-row:hover, .m-row:hover { background: var(--grey50); }
.chip { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 8px; white-space: nowrap; }
.chip.buy { background: var(--up-weak); color: var(--up); }
.chip.sell { background: var(--down-weak); color: var(--down); }
.o-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-sub { color: var(--grey500); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-right { text-align: right; font-size: 13px; }
.st { font-weight: 600; }
.st.placed, .st.filled { color: var(--green); }
.st.skipped, .st.canceled, .st.dry { color: var(--grey500); }
.st.rejected { color: var(--up); }
.st.pending { color: var(--blue); }

.foot { text-align: center; padding: 8px 16px 32px; }

@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-col { position: static; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; gap: 14px; }
  .nav { display: none; }
  .layout { padding: 16px; }
  .card { padding: 20px 16px; border-radius: 18px; }
  .big { font-size: 28px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .thead, .row { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); }
  .hide-sm { display: none; }
  .pill { font-size: 12px; padding: 5px 10px; }
}

/* ── 종목 검색 ── */
.search { position: relative; flex: 1 1 auto; max-width: 420px; min-width: 0; }
.search input {
  width: 100%; height: 40px; border: 0; border-radius: 12px; padding: 0 14px 0 36px;
  background: var(--grey100); color: var(--grey900); font: inherit; font-size: 14px; outline: none;
}
.search input::placeholder { color: var(--grey500); }
.search input:focus { box-shadow: 0 0 0 2px var(--blue); background: var(--layer); }
.search input::-webkit-search-cancel-button { display: none; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--grey500); font-size: 17px; pointer-events: none; }
.q-results {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 20; max-height: 420px; overflow-y: auto;
  background: var(--layer); border-radius: 16px; padding: 6px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16); border: 1px solid var(--grey100);
}
.q-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.q-item.on, .q-item:hover { background: var(--grey100); }
.q-item .logo { width: 32px; height: 32px; font-size: 13px; }
.q-main { min-width: 0; flex: 1; }
.q-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-sub { color: var(--grey500); font-size: 12px; }
.q-badge { font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-weak); padding: 3px 7px; border-radius: 6px; flex: none; }
.q-empty { color: var(--grey500); font-size: 13px; padding: 14px 10px; text-align: center; }

/* 클릭 가능한 행 */
.row[data-symbol], .o-row[data-symbol], .m-row[data-symbol] { cursor: pointer; }
.row[data-symbol]:focus-visible, .o-row[data-symbol]:focus-visible, .m-row[data-symbol]:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

/* ── 종목 상세 ── */
.back { border: 0; background: transparent; color: var(--grey600); font: inherit; font-size: 14px; font-weight: 600; padding: 4px 6px 4px 0; cursor: pointer; margin-bottom: 14px; }
.back:hover { color: var(--grey900); }
.sd-head { display: flex; align-items: center; gap: 12px; }
.sd-logo { width: 44px; height: 44px; font-size: 17px; }
.sd-title { min-width: 0; flex: 1; }
.sd-name { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--grey600); background: var(--grey100); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.sd-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--grey400); }
.sd-live.on { color: var(--up); background: var(--up-weak); }
.sd-live.on::before { background: var(--up); animation: pulse 1.4s ease-in-out infinite; }
.sd-live.wait { color: var(--blue); background: var(--blue-weak); }
.sd-live.wait::before { background: var(--blue); }
.sd-live.off::before { background: var(--grey400); }
@keyframes pulse { 50% { opacity: 0.25; } }
.sd-price-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 16px 0 4px; }
.sd-price { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; border-radius: 8px; }
.sd-price.flash { animation: flash 0.6s ease-out; }
@keyframes flash { from { background: var(--grey200); } to { background: transparent; } }
.sd-chg { font-size: 15px; font-weight: 600; }
.sd-hold { display: grid; grid-template-columns: repeat(4, auto auto); justify-content: start; gap: 4px 8px; align-items: baseline; background: var(--grey50); border-radius: 14px; padding: 12px 16px; margin-top: 14px; font-size: 14px; }
.sd-hold b { margin-right: 14px; }
.chart-tools { display: flex; align-items: center; gap: 10px; margin: 20px 0 8px; flex-wrap: wrap; }
.ohlc { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--grey600); flex: 1; min-width: 0; }
.ohlc b { color: var(--grey900); font-weight: 600; }
.ohlc b.up { color: var(--up); }
.ohlc b.down { color: var(--down); }
.chart-wrap { position: relative; }
.chart { height: 440px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--layer); }
.chart-table { max-height: 440px; overflow: auto; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chart-table th { position: sticky; top: 0; background: var(--layer); color: var(--grey500); font-weight: 500; text-align: right; padding: 8px; border-bottom: 1px solid var(--grey100); }
.chart-table td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grey100); }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-note { margin-top: 10px; }
.pill-short { display: none; }

@media (max-width: 720px) {
  .brand-text { display: none; }
  .search { max-width: none; }
  .pill-full { display: none; }
  .pill-short { display: inline; }
  .chart { height: 320px; }
  .sd-price { font-size: 26px; }
  .sd-hold { grid-template-columns: auto auto; }
}

/* ── 이동평균선 범례 ── */
.ma-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 6px; min-height: 26px; }
.ma-item { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--grey50); color: var(--grey600); font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 8px; cursor: pointer; }
.ma-item b { color: var(--grey900); font-weight: 600; }
.ma-item.off { opacity: 0.45; }
.ma-item.off b { text-decoration: line-through; }
.ma-sw { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.ma-sw-5 { border-color: var(--ma5); }
.ma-sw-20 { border-color: var(--ma20); }
.ma-sw-60 { border-color: var(--ma60); }
.ma-sw-120 { border-color: var(--ma120); border-top-style: dashed; }
#iv-seg button { padding: 6px 10px; }

/* ── 주문 패널 ── */
.order-card .card-head { margin-bottom: 14px; }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; padding: 9px 0; font-size: 14px; }
#ord-side button[data-v="BUY"].on { color: var(--up); }
#ord-side button[data-v="SELL"].on { color: var(--down); }
#ord-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
#f-price-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: end; }
#f-price-row .f-label { grid-column: 1 / -1; }
.f-label { font-size: 13px; font-weight: 600; color: var(--grey700); }
.input-unit { display: flex; align-items: center; background: var(--grey100); border-radius: 12px; padding: 0 12px; height: 44px; min-width: 0; flex: 1; }
.input-unit:focus-within { box-shadow: 0 0 0 2px var(--blue); background: var(--layer); }
.input-unit input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--grey900); font: inherit; font-size: 16px; font-weight: 600; text-align: right; outline: none; font-variant-numeric: tabular-nums; }
.input-unit span { color: var(--grey500); font-size: 14px; margin-left: 6px; }
.stepper { display: flex; gap: 6px; min-width: 0; }
.stepper > button, .mini { flex: none; border: 0; background: var(--grey100); color: var(--grey700); font: inherit; font-weight: 700; border-radius: 12px; cursor: pointer; }
.stepper > button { width: 40px; height: 44px; font-size: 18px; }
.mini { height: 44px; padding: 0 12px; font-size: 13px; }
.stepper > button:hover, .mini:hover { background: var(--grey200); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pair .input-unit input { font-size: 14px; }
.pair .input-unit input::placeholder, .input-unit input::placeholder { color: var(--grey400); font-weight: 500; font-size: 12px; }
.oco-help { margin: 0; }
.date { height: 44px; border: 0; border-radius: 12px; background: var(--grey100); color: var(--grey900); font: inherit; font-weight: 600; padding: 0 12px; }
.pct { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pct button { border: 0; background: var(--grey50); color: var(--grey700); font: inherit; font-size: 13px; font-weight: 600; padding: 8px 0; border-radius: 10px; cursor: pointer; }
.pct button:hover { background: var(--grey100); }
.ord-summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; padding: 12px 2px 0; border-top: 1px solid var(--grey100); }
.ord-summary b { text-align: right; }
.cta { width: 100%; height: 52px; border: 0; border-radius: 14px; color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.cta.buy { background: var(--up); }
.cta.sell { background: var(--down); }
.cta:disabled { opacity: 0.5; cursor: progress; }
.cta:focus-visible, .ghost:focus-visible { outline: 3px solid var(--grey900); outline-offset: 2px; }
.ghost { height: 52px; border: 0; border-radius: 14px; background: var(--grey100); color: var(--grey800); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.confirm { margin-top: 16px; }
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.confirm-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 12px; font-size: 14px; }
.confirm-list dt { color: var(--grey600); }
.confirm-list dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.confirm-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 8px; }
.hv { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; color: var(--up); margin-bottom: 6px; }

/* 주문 내역: 취소 버튼 */
.x-btn { border: 0; background: var(--grey100); color: var(--grey700); font: inherit; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 8px; cursor: pointer; margin-top: 4px; }
.x-btn:hover { background: var(--grey200); }
.x-btn.armed { background: var(--up); color: #fff; }
.x-btn:disabled { opacity: 0.5; }

/* 알림 */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); background: var(--grey900); color: var(--layer); padding: 13px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
.toast.err { background: var(--up); color: #fff; }

.pair-cap { font-size: 11px; color: var(--grey500); }
@media (max-width: 720px) {
  .ohlc { order: 3; flex-basis: 100%; }
}

/* ── 호가창 ── */
.ob-head, .ob-row { display: grid; grid-template-columns: 1fr minmax(118px, 0.75fr) 1fr; align-items: center; }
.ob-head { font-size: 12px; color: var(--grey500); padding: 0 0 6px; border-bottom: 1px solid var(--grey100); margin-bottom: 4px; }
.ob-head span:nth-child(1) { text-align: right; padding-right: 10px; }
.ob-head span:nth-child(2) { text-align: center; }
.ob-head span:nth-child(3) { padding-left: 10px; }
.ob { display: flex; flex-direction: column; gap: 2px; }
.ob-row { border: 0; padding: 0; height: 36px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: inherit; border-radius: 8px; }
.ob-row:hover { background: var(--grey50); }
.ob-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.ob-cell { position: relative; height: 100%; display: flex; align-items: center; padding: 0 10px; overflow: hidden; }
.ob-l { justify-content: flex-end; }
.ob-r { justify-content: flex-start; }
.ob-bar { position: absolute; top: 5px; bottom: 5px; border-radius: 4px; }
.ob-l .ob-bar { right: 0; background: color-mix(in srgb, var(--down) 20%, transparent); }
.ob-r .ob-bar { left: 0; background: color-mix(in srgb, var(--up) 20%, transparent); }
.ob-vol { position: relative; font-size: 13px; font-weight: 600; color: var(--grey800); }
.ob-price { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; line-height: 1.15; border-radius: 6px; }
.ob-price small { font-size: 11px; font-weight: 500; }
.ob-row.ask .ob-price { background: color-mix(in srgb, var(--down) 7%, transparent); }
.ob-row.bid .ob-price { background: color-mix(in srgb, var(--up) 7%, transparent); }
.ob-row.cur .ob-price { box-shadow: inset 0 0 0 2px var(--grey900); }
.ob-mid { height: 1px; background: var(--grey200); margin: 3px 0; }
.ob-sum { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; font-size: 13px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--grey100); }
.ob-sum:empty { display: none; }
.ob-ratio { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; }
.ob-ra { background: var(--down); border-radius: 4px 0 0 4px; }
.ob-rb { flex: 1; background: var(--up); border-radius: 0 4px 4px 0; }
.ob-note { margin: 10px 0 0; }
@media (max-width: 720px) {
  .ob-head, .ob-row { grid-template-columns: 1fr 100px 1fr; }
}
.sd-live:empty { display: none; }
.pill.err { background: var(--up-weak); color: var(--up); }
.pill.err::before { background: var(--up); }

/* ── 투자 계획 ── */
.nav { display: flex; gap: 18px; }
.plans-view { display: flex; flex-direction: column; gap: 16px; }
.sd-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sd-top .back { margin-bottom: 0; }
a.x-btn { text-decoration: none; display: inline-block; }
.plan-form { display: flex; flex-direction: column; gap: 12px; }
.pf-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.pf-row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pf-search { position: relative; }
.text-in { width: 100%; height: 44px; border: 0; border-radius: 12px; background: var(--grey100); color: var(--grey900); font: inherit; font-size: 15px; padding: 0 12px; outline: none; }
.text-in:focus { box-shadow: 0 0 0 2px var(--blue); background: var(--layer); }
.text-in:disabled { opacity: 0.6; }
.pf-picked { min-height: 18px; color: var(--grey700); }
.pf-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.pf-actions .cta:only-child, #pf-cancel-edit[hidden] + .cta { grid-column: 1 / -1; }
.plans-list { display: flex; flex-direction: column; gap: 10px; }
.plans-note { margin: 12px 0 0; }
.plan { border: 1px solid var(--grey100); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.plan-off { opacity: 0.72; }
.plan-head { display: flex; gap: 12px; align-items: center; }
.plan-title { flex: 1; min-width: 0; }
.plan-sub { color: var(--grey600); font-size: 13px; margin-top: 2px; }
.plan-sub .chip { margin-right: 4px; }
.plan-state { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 8px; white-space: nowrap; background: var(--grey100); color: var(--grey600); }
.plan-state.s-IN_PROGRESS { background: var(--blue-weak); color: var(--blue); }
.plan-state.s-DONE { background: var(--green-weak); color: var(--green); }
.plan-state.s-CANCELED { text-decoration: line-through; }
.plan-bar { display: flex; height: 10px; border-radius: 5px; background: var(--grey100); overflow: hidden; }
.pb-fill { background: var(--blue); }
.pb-pend { background: color-mix(in srgb, var(--blue) 35%, transparent); }
.plan-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--grey600); }
.plan-stats b { color: var(--grey900); }
.plan-price { font-size: 13px; color: var(--grey600); }
.plan-price b { color: var(--grey900); }
.badge-ok { font-size: 11px; font-weight: 700; color: var(--green); background: var(--green-weak); padding: 2px 7px; border-radius: 6px; margin-left: 4px; }
.plan-note { font-size: 13px; color: var(--grey700); background: var(--grey50); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; }
.plan-fills summary { cursor: pointer; font-size: 13px; color: var(--grey700); font-weight: 600; }
.pf-fill { display: grid; grid-template-columns: 90px 1fr auto auto; gap: 10px; font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--grey100); }
.plan-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.plan-actions > .muted { margin-right: auto; }
@media (max-width: 720px) {
  /* 좁은 화면: 탭(내 계좌·투자 계획)은 상단 바 아래 줄로 */
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px 0; row-gap: 4px; }
  .nav { display: flex; gap: 18px; order: 9; width: 100%; }
  .search { flex: 1 1 0; min-width: 0; }
  .top-right { flex: none; gap: 2px; }
  .nav a { font-size: 14px; white-space: nowrap; padding: 6px 0 10px; border-bottom: 2px solid transparent; }
  .nav a.active { border-bottom-color: var(--grey900); }
  .pf-row, .pf-row3 { grid-template-columns: minmax(0, 1fr); }
  .pf-fill { grid-template-columns: 1fr auto; }
}

/* ── 전략 ── */
.seg.stype { flex-wrap: wrap; gap: 2px; }
.seg.stype button { flex: 1 0 auto; padding: 9px 10px; }
.stype-hint { margin-top: 6px; }
.stype-chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--grey100); color: var(--grey700); vertical-align: 1px; margin-right: 4px; }
.pf-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.pf-title:empty { display: none; }
select.text-in { appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--grey500) 50%), linear-gradient(135deg, var(--grey500) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.cta.group-cta { background: var(--blue); }
.pgroup { border: 1px solid var(--grey200); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.pgroup-loose { border-style: dashed; }
.pg-head { display: flex; gap: 12px; align-items: flex-start; }
.pg-title { flex: 1; min-width: 0; font-size: 16px; }
.pg-note { font-size: 13px; color: var(--grey600); margin-top: 3px; white-space: pre-wrap; }
.pg-bar { height: 12px; border-radius: 6px; }
.pg-kids { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.plan-nested { background: var(--grey50); border-color: transparent; }
.pg-confirm { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; font-size: 13px; font-weight: 600; background: var(--up-weak); color: var(--up); border-radius: 12px; padding: 10px 12px; }
.pg-confirm span { margin-right: auto; }
.badge-warn { font-size: 11px; font-weight: 700; color: var(--up); background: var(--up-weak); padding: 2px 7px; border-radius: 6px; margin-left: 2px; }
b.over { color: var(--up); }
.plan-state.s-EMPTY { background: var(--grey100); color: var(--grey500); }
.plan-state.s-EXPIRED { background: var(--grey100); color: var(--grey600); }
#pf-mode button { padding: 8px 14px; font-size: 14px; }
.pf-actions > [hidden] + .cta { grid-column: 1 / -1; }
.plan-nested .plan-note { background: var(--layer); }
@media (max-width: 720px) {
  .pgroup { padding: 14px 10px; }
  .plan-nested { padding: 12px 10px; }
}
/* 가상 계좌 상자 (기본 계좌 · 전략 계좌) */
.acct { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 2px; padding: 10px 12px; border-radius: 10px; background: var(--grey100); }
.acct-none { color: var(--grey600); font-size: 13px; }
.acct-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.acct-stats b.up { color: var(--up); }
.acct-stats b.down { color: var(--blue); }
.acct-actions { display: flex; gap: 6px; }
.acct-form { flex-wrap: wrap; gap: 6px; }
.input-unit.sm, .text-in.sm { max-width: 150px; }
.acct-default { margin-bottom: 12px; }
/* 주문 이력 (투자 계획) */
.plan-hist .st.ok { color: var(--green); }
.plan-hist .st.bad { color: var(--up); }
.plan-hist .st.off { color: var(--grey500); }
/* 연동 표시 (실계좌와 연동되지 않음) */
.acct-linked { box-shadow: inset 3px 0 0 var(--blue); background: var(--blue-weak); }
.link-on { color: var(--blue); font-weight: 700; }
.link-off { color: var(--grey500); }
.real-placed { color: var(--blue); font-weight: 600; }
.real-rejected { color: var(--up); }
.real-skipped { color: var(--grey500); }
/* 긴 설명 접기 */
.note-fold summary { cursor: pointer; color: var(--grey600); list-style: none; }
.note-fold summary::-webkit-details-marker { display: none; }
.note-fold summary::after { content: " 펼치기"; color: var(--blue); font-size: 12px; }
.note-fold[open] summary::after { content: " 접기"; }
.note-fold .note-body { margin-top: 6px; white-space: pre-wrap; line-height: 1.5; color: var(--grey700); }

/* ── 로그인 · 계정 설정 · 토큰 관리 ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { display: flex; flex-direction: column; gap: 12px; }
.auth-card[hidden] { display: none; }
.code-in { font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.acct-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--grey800); }
.auth-title { margin: 4px 0 0; font-size: 22px; color: var(--grey900); }
.auth-id { margin: 0; word-break: break-all; }
.auth-label { font-size: 14px; font-weight: 600; color: var(--grey700); }
.auth-input { width: 100%; box-sizing: border-box; border: 1px solid var(--grey200); background: var(--grey50); color: var(--grey900); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 15px; }
.auth-input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.auth-btn { border: 0; border-radius: 12px; padding: 13px 16px; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; background: var(--grey100); color: var(--grey800); }
.auth-btn.primary { background: var(--blue); color: #fff; }
.auth-btn:disabled { opacity: 0.5; cursor: default; }
.auth-sep { display: flex; align-items: center; gap: 10px; color: var(--grey500); font-size: 13px; margin-top: 4px; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--grey200); }
.auth-help { margin: 0; line-height: 1.6; }
.auth-msg { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--grey700); line-height: 1.5; }
.auth-msg.err { color: var(--up); }
.tokens-layout { max-width: 880px; margin: 24px auto; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; }
.tokens-layout h2 { margin: 0; font-size: 18px; }
.tok-form { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.tok-form .auth-input { flex: 1; min-width: 180px; }
.tok-new { background: var(--blue-weak); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.tok-new p { margin: 0 0 8px; }
.tok-copy { display: flex; gap: 8px; align-items: center; }
.tok-copy code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; background: var(--layer); padding: 8px 10px; border-radius: 8px; }
.tok-list { display: flex; flex-direction: column; }
.tok-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--grey100); }
.tok-row.off { opacity: 0.55; }
.tok-usage { margin-top: 12px; }
.tok-usage summary { cursor: pointer; font-weight: 600; color: var(--grey700); }
.tok-usage pre { overflow-x: auto; background: var(--grey50); border-radius: 12px; padding: 12px; font-size: 12px; line-height: 1.5; }

/* ── 투자 계획: 전략 목록 + 상세 ── */
.plans-head h2 { margin: 0; }
.plans-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tool-btn { height: 36px; border: 0; border-radius: 10px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; background: var(--grey100); color: var(--grey800); }
.tool-btn:hover { background: var(--grey200); }
.tool-btn.primary { background: var(--blue); color: #fff; }
.tool-btn.primary:hover { filter: brightness(1.05); }
.tool-btn:focus-visible { outline: 3px solid var(--grey900); outline-offset: 2px; }
.plans-md { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.sg-list { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 2px; }
.sg-row { width: 100%; text-align: left; border: 1px solid transparent; background: var(--grey50); border-radius: 14px; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--grey900); display: flex; flex-direction: column; gap: 7px; }
.sg-row:hover { background: var(--grey100); }
.sg-row:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.sg-row.on { border-color: var(--blue); background: var(--blue-weak); }
.sg-row.off { opacity: 0.6; }
.sg-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.sg-title { font-weight: 700; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-title .stype-chip { margin-right: 6px; }
.sg-mini { display: block; height: 4px; border-radius: 2px; background: var(--grey200); overflow: hidden; }
.sg-mini i { display: block; height: 100%; background: var(--blue); border-radius: 2px; }
.sg-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--grey600); }
.sg-special .sg-title { font-weight: 600; color: var(--grey700); }
.sg-sep { height: 1px; background: var(--grey200); margin: 6px 2px; }
.sg-list .empty { padding: 24px 8px; }
.sg-detail { min-width: 0; }
@media (max-width: 860px) {
  .plans-md { grid-template-columns: minmax(0, 1fr); }
  .sg-list { position: static; max-height: none; overflow: visible; }
}

/* ── 대화상자 (전략 마법사 · 종목 계획) ── */
.pdlg { border: 0; padding: 0; border-radius: 20px; background: var(--layer); color: var(--grey900); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3); }
.pdlg::backdrop { background: rgba(0, 0, 0, 0.5); }
.pdlg form { padding: 18px 22px 22px; }
.pdlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pdlg-head h3 { margin: 0; font-size: 19px; }
.wz-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 2px 0 6px; }
.wz-steps li { flex: 1; font-size: 12px; font-weight: 600; color: var(--grey500); padding-top: 8px; border-top: 3px solid var(--grey200); }
.wz-steps li span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--grey200); color: var(--grey700); font-size: 11px; margin-right: 5px; }
.wz-steps li.done { color: var(--grey700); border-color: var(--blue); }
.wz-steps li.done span { background: var(--blue-weak); color: var(--blue); }
.wz-steps li.on { color: var(--blue); border-color: var(--blue); }
.wz-steps li.on span { background: var(--blue); color: #fff; }
.wz-step { display: flex; flex-direction: column; gap: 12px; }
.wz-lead { margin: 4px 0 0; font-weight: 600; color: var(--grey800); }
.stype-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.stype-cards button { text-align: left; border: 1px solid var(--grey200); background: var(--grey50); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; color: var(--grey900); font: inherit; }
.stype-cards button b { font-size: 15px; }
.stype-cards button span { font-size: 12px; color: var(--grey600); }
.stype-cards button:hover { background: var(--grey100); }
.stype-cards button.on { border-color: var(--blue); background: var(--blue-weak); box-shadow: inset 0 0 0 1px var(--blue); }
.stype-cards button:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
textarea.text-in { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.wz-summary { background: var(--grey50); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.wz-summary dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0 0; }
.wz-summary dt { color: var(--grey600); }
.wz-summary dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.wz-summary p { margin: 8px 0 0; }
.wz-nav { display: flex; gap: 8px; }
.wz-nav .ghost { flex: 1; }
.wz-nav .cta { flex: 2; }
.wz-nav [hidden] { display: none; }
@media (max-width: 560px) {
  .pdlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: auto; border-radius: 20px 20px 0 0; margin: auto 0 0; }
  .pdlg .pf-row, .pdlg .pf-row3 { grid-template-columns: minmax(0, 1fr); }
}
/* 세로로 쌓이는 입력 칸(.field) 안에서는 flex:1 이 높이를 줄여 버려서 고정 */
.field > .input-unit { flex: 0 0 auto; }
.tok-scope { flex: 0 0 auto; width: auto; min-width: 150px; }
.scope-chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--grey100); color: var(--grey700); vertical-align: 1px; }
.scope-chip.mcp { background: var(--blue-weak); color: var(--blue); }
.scope-chip.runner { background: var(--green-weak); color: var(--green); }
.pair-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 15px; letter-spacing: 1px; padding: 2px 8px; border-radius: 6px; background: var(--blue-weak); color: var(--blue); }

/* ── 전략 목록 페이지 · 상세 페이지 · 대화 ── */
.sg-list { position: static; max-height: none; overflow: visible; }
.sg-detail-wrap { display: flex; flex-direction: column; gap: 12px; }
.back-link { align-self: flex-start; font-weight: 700; font-size: 14px; color: var(--grey700); text-decoration: none; padding: 7px 12px; border-radius: 10px; background: var(--grey100); }
.back-link:hover { background: var(--grey200); }
.back-link:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.chat-box { gap: 12px; }
.chat-log { max-height: 480px; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.chat-log .empty { padding: 24px 0; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; }
.bubble { padding: 10px 13px; border-radius: 16px; line-height: 1.55; font-size: 14px; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 6px; }
.msg.them .bubble { background: var(--grey100); color: var(--grey900); border-bottom-left-radius: 6px; }
.msg.them.bad .bubble { background: var(--up-weak); color: var(--up); }
.bubble code { background: rgba(127, 127, 127, 0.18); padding: 0 4px; border-radius: 4px; font-size: 13px; }
.msg .meta { font-size: 11px; color: var(--grey500); margin-top: 3px; }
.chat-opts { display: flex; gap: 6px 8px; align-items: center; flex-wrap: wrap; }
.chat-opts select { padding: 6px 10px; }
.chat-opts label + select { margin-right: 8px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { flex: 1; height: auto; min-height: 46px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.chat-form .tool-btn { height: 46px; }

/* ── 전략 문서 ── */
.doc-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }
.file-btn input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
textarea.doc-in { min-height: 140px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.doc-box { border: 1px solid var(--grey200); border-radius: 12px; padding: 10px 14px; }
.files-box { border: 1px solid var(--grey200); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.files-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.files-head .file-btn { margin-left: auto; }
.files-head .file-btn ~ .file-btn { margin-left: 0; }
.session-box .files-head button:first-of-type { margin-left: auto; }
.pkg-ask { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--grey100); }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; overflow-wrap: anywhere; }
.file-list li .x-btn { margin-left: auto; }
.doc-box summary { cursor: pointer; font-weight: 700; color: var(--grey800); }
.md-body { margin-top: 8px; font-size: 14px; line-height: 1.65; color: var(--grey800); overflow-wrap: anywhere; }
.md-body h3, .md-body h4, .md-body h5, .md-body h6 { margin: 14px 0 6px; color: var(--grey900); }
.md-body h3 { font-size: 17px; } .md-body h4 { font-size: 15px; } .md-body h5, .md-body h6 { font-size: 14px; }
.md-body p { margin: 6px 0; } .md-body ul, .md-body ol { margin: 6px 0; padding-left: 22px; }
.md-body code { background: var(--grey100); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md-body pre { background: var(--grey100); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.md-body pre code { background: none; padding: 0; }

/* ── 휴대폰 (아이폰·갤럭시) ── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.auth-page { min-height: 100dvh; } /* iOS 주소창 높이를 뺀 실제 화면 (지원 안 하면 위의 100vh) */
/* 글자 중간에서 줄이 바뀌면 안 되는 작은 버튼·표시 */
.x-btn, .tool-btn, .chip, .st, .scope-chip, .pair-code, .stype-chip, .pill { white-space: nowrap; }
.tok-row > button, .tok-row > span:last-child { flex-shrink: 0; }
.md-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.md-body th, .md-body td { border: 1px solid var(--grey200); padding: 4px 8px; white-space: nowrap; }
/* iOS Safari 는 글자가 16px 보다 작은 입력칸을 누르면 화면을 확대하고 그대로 둔다 → 터치 기기에서는 입력칸 글자 16px */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea { font-size: 16px !important; }
}
@media (max-width: 560px) {
  .layout { padding: 12px; gap: 12px; }
  .card { padding: 18px 14px; }
  /* 보유 주식: 오른쪽 한 칸에 평가금(위)과 수익(아래) — 숫자가 줄바꿈되지 않게 */
  .thead, .row { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; }
  .thead > span:last-child { display: none; }
  .thead > span:nth-last-child(2)::after { content: " · 수익"; }
  .row { padding: 12px 4px; }
  .row > .stock { grid-row: 1 / span 2; }
  .row > .r:nth-last-child(2) .cell-sub { display: none; }
  .row > .r:last-child { display: flex; gap: 6px; justify-content: flex-end; align-items: baseline; }
  .row > .r:last-child .cell-main, .row > .r:last-child .cell-sub { font-size: 12.5px; font-weight: 600; }
  .row .cell-main, .row .cell-sub { white-space: nowrap; }
  .logo { width: 36px; height: 36px; font-size: 14px; }
  .stock { gap: 10px; }
  .stock-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* 전략 상세: 겹친 상자의 안쪽 여백을 줄여 내용 폭 확보 */
  .pgroup { padding: 14px 12px; border-radius: 16px; }
  .plan { padding: 12px; border-radius: 14px; }
  .plan-actions { justify-content: flex-start; }
  .plan-actions > .muted { flex-basis: 100%; margin-right: 0; }
  .files-box, .doc-box { padding: 10px 12px; }
  /* 대화: 제목 줄의 상태 글은 다음 줄로, 보내기 버튼은 입력칸 옆에 그대로 */
  .chat-box .pg-head { flex-wrap: wrap; }
  .chat-box #chat-state { flex-basis: 100%; }
  .chat-log { max-height: 60dvh; }
  /* 토큰 화면 */
  .tok-row { align-items: flex-start; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ── 전략 상세 요약 (전체 수익·투자 원금·현재 잔고·실현 손익) ── */
.sg-summary:empty { display: none; }
.sum-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sum-tile { background: var(--grey50); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.sum-tile .k { font-size: 13px; color: var(--grey600); }
.sum-tile .v { font-size: 19px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-tile .s { font-size: 12px; color: var(--grey500); margin-top: 2px; }
.sum-per { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--grey700); }
@media (max-width: 860px) { .sum-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .sum-tile .v { font-size: 17px; }
  .chat-opts { flex-wrap: nowrap; }
  .chat-opts select { flex: 1 1 0; min-width: 0; margin-right: 0 !important; }
}

