:root {
  --bg: #0e1014; --panel: #161920; --panel2: #1d212a; --line: #262b36; --grid: #1c2029;
  --text: #d8dce4; --muted: #7c8494; --accent: #f7a600; --up: #20b26c; --down: #ef454a; --rsi: #a78bfa;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.4 -apple-system, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif; }
button, select, input { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
button { cursor: pointer; }
button:hover { border-color: #3a4150; background-color: #232834; }
input:focus, select:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 65%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
/* 셀렉트: 기본 화살표 대신 얇은 꺾쇠 */
select { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' fill='none' stroke='%237c8494' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); }
.grow { flex: 1; }

#top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 10px; padding: 6px 14px; flex-wrap: wrap; }
.brand { margin-right: 8px; font-size: 15px; font-weight: 700; letter-spacing: -.2px;
  background: linear-gradient(90deg, #f7a600, #ffd166); -webkit-background-clip: text; background-clip: text; color: transparent; }
.controls label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
/* 위쪽 막대 높이 통일 */
#top .controls button, #top .controls select, #top .controls input:not([type=checkbox]), #viewMenu button, #viewMenu input { height: 30px; }
#top .seg button, #viewMenu .seg button { height: 24px; }
#search { width: 210px; padding-left: 30px; background-repeat: no-repeat; background-position: 10px center;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='13' height='13'><circle cx='5.5' cy='5.5' r='4.5' fill='none' stroke='%237c8494' stroke-width='1.5'/><path d='M9 9l3 3' stroke='%237c8494' stroke-width='1.5' stroke-linecap='round'/></svg>"); }
#count { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
#status { margin-left: auto; font-size: 12px; }

.toggle { color: var(--muted); }
.toggle.on { background: color-mix(in srgb, var(--accent) 15%, var(--panel2)); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

#tabs, #cats { display: flex; gap: 4px; flex-wrap: wrap; }
.bar.cats { padding-top: 0; padding-bottom: 2px; }
.bar.sectors { padding-top: 2px; padding-bottom: 4px; gap: 8px; }
.bar.sectors[hidden] { display: none; }
#sectors { display: flex; gap: 4px; flex-wrap: wrap; }
#sectors button { border-radius: 999px; padding: 2px 10px; font-size: 12px; background: var(--panel); border-color: transparent; color: var(--muted); }
#sectors button:hover { color: var(--text); border-color: var(--line); }
#sectors button.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
#sectors button .n { opacity: .6; margin-left: 4px; font-size: 10px; }
.ch .st { font-size: 10px; padding: 0 4px; border-radius: 3px; line-height: 15px; align-self: center; background: #ef454a33; color: #fca5a5; }
.ch .st:empty { display: none; }
#cats button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 6px 12px; color: var(--muted); }
#cats button.on { color: var(--text); border-bottom-color: var(--accent); }
#cats button .n { opacity: .6; margin-left: 5px; font-size: 11px; }
#cats + .seg button { padding: 2px 8px; font-size: 12px; }
#regionWrap[hidden], #coinSub[hidden] { display: none; }
#tabs button { border-radius: 999px; padding: 4px 13px; background: transparent; border-color: var(--line); }
#tabs button.on { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
#tabs button .n { opacity: .6; margin-left: 4px; font-size: 11px; }
#tabs .x { margin-left: 6px; opacity: .6; }

/* 묶음 버튼: 하나의 알약 안에서 고르는 모양 */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: transparent; border-radius: 8px; margin: 0; padding: 3px 10px; color: var(--muted); }
.seg button:hover { background: var(--panel2); color: var(--text); }
.seg button.on { background: var(--accent); color: #111; font-weight: 600; box-shadow: 0 1px 4px #0007; position: relative; }

#grid { display: grid; gap: 6px; padding: 8px 12px 40px; grid-auto-rows: var(--rowh, auto); }
.cell { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; transition: border-color .15s, box-shadow .15s; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.cell.active { border-color: #3a4150; }
.ch { display: flex; align-items: baseline; gap: 6px; padding: 5px 8px 0; white-space: nowrap; overflow: hidden; font-size: 12px; }
.ch .sym { font-size: 13px; cursor: pointer; }
.ch .sym:hover { color: var(--accent); }
.ch .gs { display: inline-flex; gap: 2px; align-self: center; margin-left: -1px; }
.ch .gs:empty { display: none; }
.ch .gs i { width: 3px; height: 11px; border-radius: 1px; transform: skewX(-22deg); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; flex-shrink: 0; }
#tabs .dot { cursor: pointer; }
#tabs .dot:hover { outline: 2px solid var(--text); outline-offset: 1px; }
#pop label .dot { margin: 0; align-self: center; }
.ch .tag { font-size: 10px; padding: 0 4px; border-radius: 3px; line-height: 15px; align-self: center; }
.ch .tag:empty { display: none; }
.t-stock { background: #3b82f633; color: #93c5fd; }
.t-etf { background: #14b8a633; color: #5eead4; }
.t-commodity, .t-forex { background: #eab30833; color: #fde047; }
.t-innovation { background: #a855f733; color: #d8b4fe; }
.ch .rsi { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch .rsi.hot { color: var(--down); } .ch .rsi.cold { color: var(--up); }
.rsi-l { color: var(--rsi); }
#rsiP { width: 52px; margin-left: -6px; }
.ch .meta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; }
.ch > :not(.meta) { flex-shrink: 0; }
/* 카드 머리가 좁으면 버튼(📌 ☆ −)은 그대로 두고 RSI → 등락률 → 가격 순으로 글자를 줄임 */
.ch .sym, .ch .pbtn, .ch .gbtn, .ch .hbtn { flex-shrink: 0; }
.ch .px, .ch .chg, .ch .rsi, .ch .tag { min-width: 0; overflow: hidden; }
.ch .rsi { flex-shrink: 6; } .ch .chg { flex-shrink: 3; } .ch .px { flex-shrink: 1; }
.ch .pbtn { padding: 0 2px; border: 0; background: none; font-size: 12px; filter: grayscale(1); opacity: .35; }
.ch .pbtn:hover { opacity: .8; }
.ch .pbtn.on { filter: none; opacity: 1; }
.cell:has(.pbtn.on) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cell:has(.pbtn.on) .ch { touch-action: none; user-select: none; -webkit-user-select: none; }
/* 고정 카드 크기 조절 손잡이 (오른쪽 아래 ///) */
.cell .rz { display: none; position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; z-index: 4; cursor: nwse-resize;
  background: repeating-linear-gradient(135deg, transparent 0 3px, var(--muted) 3px 4px); clip-path: polygon(100% 0, 100% 100%, 0 100%); opacity: .7; }
.cell .rz:hover { opacity: 1; }
.cell:has(.pbtn.on) .rz { display: block; }
body.selmode .cell .rz { display: none; }
#rzBox { position: fixed; z-index: 30; pointer-events: none; border: 2px dashed; border-radius: 8px; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
#rzBox.ok { border-color: #22c55e; background: #22c55e1f; color: #4ade80; }
#rzBox.no { border-color: #ef4444; background: #ef44441f; color: #f87171; }
body.rzdrag, body.rzdrag * { cursor: nwse-resize !important; user-select: none; }
#layoutAsk { position: fixed; inset: 0; z-index: 46; background: #000a; display: grid; place-items: center; }
#layoutAsk[hidden] { display: none; }
#layoutAsk .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; width: min(440px, calc(100vw - 32px)); }
#layoutAsk p { font-size: 13px; line-height: 1.5; }
#layoutAsk .warn { color: var(--down); }
#layoutAsk .btns { display: flex; gap: 8px; justify-content: flex-end; }
.cell.lifted { position: relative; z-index: 5; transform: scale(1.03); box-shadow: 0 10px 28px #000a; outline: 2px solid var(--accent); opacity: .93; }
body.pindrag, body.pindrag * { cursor: grabbing !important; user-select: none; }
.ch .gbtn { padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 14px; }
.ch .gbtn.in { color: var(--accent); }
.ch .hbtn { padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 14px; }
.ch .hbtn:hover { color: var(--text); }

.cell { position: relative; }
.selov { display: none; position: absolute; inset: 0; z-index: 3; cursor: pointer; border-radius: 8px; }
body.selmode .selov { display: block; }
body.selmode .selov:hover { background: #ffffff0a; }
.selov .ck { position: absolute; top: 6px; right: 8px; width: 18px; height: 18px; border: 1.5px solid var(--muted); border-radius: 4px; background: var(--panel2); display: grid; place-items: center; font-size: 12px; color: #111; }
.cell.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cell.sel .ck { background: var(--accent); border-color: var(--accent); }
.cell.sel .ck::after { content: '✓'; }
body.selmode .ch .gbtn, body.selmode .ch .hbtn, body.selmode .ch .pbtn { visibility: hidden; }

#selbar { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); border-top: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
#selbar .act:not(:disabled) { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
#selbar .hint { color: var(--muted); font-size: 12px; }
#selbar[hidden], #selbar button[hidden] { display: none; }
#selbar .sep { width: 1px; height: 20px; background: var(--line); }
#selbar button:disabled { opacity: .4; cursor: default; }
#pop .pick { display: flex; justify-content: space-between; gap: 12px; width: 100%; border: 0; background: none; text-align: left; }
#pop .pick:hover { background: var(--panel); }
.cv { flex: 1; min-height: 0; position: relative; }
.cv .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }

#detail { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
#detail[hidden] { display: none; }
.dhead { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: nowrap; white-space: nowrap; }
.dhead > * { flex-shrink: 0; }
#dInfo { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dchartwrap { flex: 1; min-width: 0; position: relative; display: flex; }
.dlg { position: absolute; left: 8px; top: 6px; z-index: 5; pointer-events: none; background: color-mix(in srgb, var(--bg) 70%, transparent); padding: 1px 6px; border-radius: 4px; }
.dlg:empty { display: none; }
#dSym { font-size: 16px; }
.dlg { font-variant-numeric: tabular-nums; font-size: 12px; }
.dpc { flex: 1; min-height: 0; min-width: 0; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.dlg b { margin-right: 4px; }
/* 차트 칸 나누기: 1 / 좌우 2 / 위 1 + 아래 2 / 2x2 */
#dPanes { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.dpane { position: relative; display: flex; min-width: 0; min-height: 0; }
#dPanes:not(.n1) .dpane { outline: 1px solid var(--line); }
#dPanes:not(.n1) .dpane.act { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: -1px; z-index: 1; }
.dpx { position: absolute; top: 4px; right: 70px; z-index: 7; padding: 0 6px; font-size: 12px; opacity: .7; }
.dpane:not(:hover) .dpx { opacity: 0; }
#dPanes.n1 .dpx { display: none; }
/* 새 칸: 종목 카드 고르기 */
.dpick { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.dpick-h { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); }
.dpick-h input { flex: 1; }
.dpick-l { flex: 1; overflow: auto; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; align-content: start; }
.dpick-l button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 8px; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; }
.dpick-l button:hover { border-color: var(--accent); }
.dpick-l b { font-size: 13px; }
.dpick-l span { font-size: 11px; font-variant-numeric: tabular-nums; }
.dbody { flex: 1; min-height: 0; display: flex; }
#dtools { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-right: 1px solid var(--line); }
#dtools button { width: 34px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid transparent; background: none; font-size: 16px; color: var(--muted); position: relative; }
#dtools button:hover { background: var(--panel2); color: var(--text); }
#dtools button.on { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
#helpPanel { width: 340px; flex-shrink: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
#helpPanel[hidden] { display: none; }
#helpPanel .hp-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
#helpToc { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
#helpToc button { font-size: 11px; padding: 2px 6px; }
#helpBody { flex: 1; overflow: auto; padding: 4px 14px 24px; font-size: 13px; line-height: 1.55; color: var(--text); }
#helpBody h3 { font-size: 14px; margin: 16px 0 6px; }
#helpBody ul { margin: 0; padding-left: 18px; }
#helpBody li { margin: 3px 0; }
#helpBody p { margin: 6px 0; font-size: 12px; }
#helpBody kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; background: var(--panel2); }
#helpBody section.hl { animation: hpflash 1.2s; }
@keyframes hpflash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } to { background: transparent; } }
#dtools button svg { display: block; }
#dtools button.grp::after { content: ''; position: absolute; right: 3px; bottom: 3px; border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .55; }
#pop .pk-i { display: inline-flex; align-items: center; gap: 8px; }
#pop .pk-i svg { opacity: .85; }
#dtools .sep { width: 22px; height: 1px; background: var(--line); margin: 4px 0; }
#dtools button.txt { font-size: 11px; font-weight: 600; }
#dtools .mlabel { position: absolute; right: 1px; bottom: 0; font-size: 9px; }

#pop { position: fixed; z-index: 30; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-width: 160px; box-shadow: 0 8px 24px #0008; }
#pop .phead { display: flex; align-items: center; gap: 12px; padding: 2px 2px 6px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
#pop .phead b { flex: 1; }
#pop .phead .px { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 6px; }
#pop .phead .px:hover { color: var(--text); background: var(--panel); }
#ctx { position: fixed; z-index: 35; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px; min-width: 210px; box-shadow: 0 8px 24px #0008; }
#ctx[hidden] { display: none; }
#ctx .ctx-h, #pop .ctx-h { padding: 4px 8px 6px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
#ctx button { display: flex; justify-content: space-between; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 6px 8px; }
#ctx button:hover { background: var(--panel); }
#ctx button .muted { font-size: 11px; }
/* 차트 안(가격·볼륨·RSI) 기본 커서는 십자 (트레이딩뷰처럼). 가격축·시간축은 차트 라이브러리가 자체 커서를 씀 */
.dpc, .cv { cursor: crosshair; }
#dHint { color: var(--accent); font-size: 12px; }
#me { display: flex; align-items: center; gap: 8px; font-size: 12px; }
#me[hidden] { display: none; }
#me .logout { padding: 2px 8px; font-size: 12px; }
#status { margin-left: auto; }
/* 로그인 여부는 서버가 <html data-auth> 로 먼저 정해줌 -> 메인 화면이 잠깐 보였다 사라지는 깜빡임 없음 */
#login { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: none; place-items: center; }
html[data-auth="out"] #login { display: grid; }
html[data-auth="out"] #top, html[data-auth="out"] #grid { display: none; }
#login form[hidden] { display: none; }
#login .switch { text-align: center; color: var(--muted); }
#login a { color: var(--accent); }
/* 게스트: 보기만 */
html[data-role="guest"] .gbtn, html[data-role="guest"] .hbtn, html[data-role="guest"] #selBtn,
html[data-role="guest"] #dtools, html[data-role="guest"] #dGroup, html[data-role="guest"] #tabs .add { display: none !important; }
#me .adm { position: relative; padding: 2px 10px; font-size: 12px; }
.badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 5px; border-radius: 8px; background: var(--down); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.badge[hidden] { display: none; }
#admin { position: fixed; inset: 0; z-index: 44; background: #000b; display: grid; place-items: center; }
#admin[hidden] { display: none; }
#admin .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(1100px, calc(100vw - 24px)); height: min(760px, calc(100vh - 24px)); display: flex; flex-direction: column; }
#admin .ahead { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#admin .ahead button { border: 0; background: none; font-size: 16px; color: var(--muted); }
#admTabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
#admTabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
#admTabs button.on { color: var(--text); border-bottom-color: var(--accent); }
#admBody { flex: 1; overflow: auto; padding: 12px 16px; }
#admBody table { width: 100%; border-collapse: collapse; font-size: 12px; }
#admBody th, #admBody td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
#admBody th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
#admBody td.wrap { white-space: normal; max-width: 280px; overflow-wrap: anywhere; }
#admBody td .acts { display: flex; gap: 4px; flex-wrap: wrap; }
#admBody button { padding: 2px 8px; font-size: 12px; }
#admBody button.danger { border-color: color-mix(in srgb, var(--down) 60%, transparent); color: var(--down); }
#admBody button.ok { border-color: color-mix(in srgb, var(--up) 60%, transparent); color: var(--up); }
#admBody select { padding: 1px 4px; font-size: 12px; }
#admBody .empty { color: var(--muted); padding: 30px; text-align: center; }
#admBody form { display: flex; gap: 8px; margin-bottom: 12px; }
.role { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel2); }
.role.developer { color: #c084fc; } .role.admin { color: var(--accent); } .role.user { color: var(--text); } .role.guest { color: var(--muted); }
.st-pending { color: var(--accent); } .st-banned { color: var(--down); } .st-active { color: var(--up); }
.okx { color: var(--up); } .failx { color: var(--down); }
#login .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px 32px; width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; }
#login .brand { font-size: 18px; text-align: center; margin-bottom: 6px; }
#login input, #acct input { width: 100%; padding: 8px 10px; }
#login p { margin: 0; font-size: 12px; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; padding: 8px 12px; }
.err { color: var(--down); font-size: 12px; min-height: 1em; margin: 0; }
#me .who { background: none; border: 0; padding: 2px 4px; }
#me .who:hover { color: var(--accent); }
#acct { position: fixed; inset: 0; z-index: 45; background: #000a; display: grid; place-items: center; }
#acct[hidden], #acct [hidden] { display: none !important; }
#acct .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px 20px; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
#acct .ahead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
#acct .ahead button { border: 0; background: none; font-size: 18px; color: var(--muted); }
#acct section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
#acct form { display: flex; flex-direction: column; gap: 8px; }
#acct h4 { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
#acct p { margin: 0; }
.small { font-size: 12px; }
.pill { font-size: 11px; font-weight: 400; padding: 1px 8px; border-radius: 10px; background: var(--panel2); color: var(--muted); }
.pill.on { background: color-mix(in srgb, var(--up) 25%, transparent); color: var(--up); }
#tfaQr { background: #fff; border-radius: 8px; width: fit-content; line-height: 0; }
#tfaKey { word-break: break-all; }
#tfaCodeList { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 0; font-size: 14px; letter-spacing: 1px; }
#pop .crow { display: flex; align-items: center; gap: 10px; padding: 3px 6px; cursor: pointer; }
#pop .crow input[type=color] { width: 34px; height: 22px; padding: 0; border: 1px solid var(--line); background: none; cursor: pointer; }
#pop p { margin: 6px 6px 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; max-width: 230px; }
.swatches input[type=color] { width: 22px; height: 20px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
.vcopy { display: flex; align-items: center; gap: 4px; padding: 4px 8px; font-size: 12px; white-space: nowrap; }
.vcopy input[type=number] { width: 52px; }
.vcopy button { margin-left: auto; }
.swatches i { width: 18px; height: 18px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatches i:hover, .swatches i.on { border-color: var(--text); }
#filterBar { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 70%, transparent); }
#filterBar[hidden] { display: none; }
#filterBtn.has:not(.on) { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
#viewMenu { position: fixed; z-index: 28; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 8px 24px #0008; }
#viewMenu[hidden] { display: none; }
#viewMenu .vrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#viewBtn.on { color: var(--accent); }
#rsiQ { width: 78px; }
#rsiQ.on { border-color: var(--accent); }
#rsiMode { min-width: 40px; }
#rsiMode.auto { color: var(--accent); border-style: dashed; }
/* 슬라이드 모드: 큰 차트(상세 화면) 하나를 화면 가득, 아래 바로 종목 넘김 */
body.slidemode { overflow: hidden; }
body.slidemode #grid, body.slidemode #toTop, body.slidemode .controls label:has(#cols), body.slidemode #dClose { display: none !important; }
body.slidemode #detail { top: var(--toph, 150px); bottom: 52px; z-index: 9; }
#slideBar { position: fixed; left: 0; right: 0; bottom: 0; height: 52px; z-index: 12; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
#slideBar[hidden] { display: none; }
#slideRange { flex: 1; accent-color: var(--accent); }
#slideLabel { min-width: 150px; text-align: right; font-variant-numeric: tabular-nums; }
/* 리스트 모드: 왼쪽 80% 큰 차트(상세 화면을 창 안에 고정) + 오른쪽 20% 카드 목록 */
body.listmode { overflow: hidden; }
body.listmode #toTop, body.listmode .controls label:has(#cols), body.listmode #dClose { display: none !important; }
/* 리스트 칸 폭: 큰 차트 8 : 목록 1.5 : 휠 0.5 */
body.listmode { --lw: max(15%, 200px); }
body.listmode, body.gridmode { --ww: max(2.5%, 28px); }  /* 휠 칸 폭 */
/* 그리드: 오른쪽 휠 칸만큼 비워 둠, 맨 위로 버튼은 휠 칸 왼쪽 */
body.gridmode #grid { padding-right: calc(var(--ww) + 12px); }
body.gridmode #tip { position: fixed; z-index: 40; pointer-events: none; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; white-space: nowrap; box-shadow: 0 4px 12px #0007; }
#tip[hidden] { display: none; }
#toTop { right: calc(var(--ww) + 16px); }
body.listmode #grid { position: fixed; top: var(--toph, 150px); right: var(--ww); bottom: 0; width: var(--lw); overflow-y: auto; overflow-x: hidden;
  padding: 10px 8px 40px; border-left: 1px solid var(--line); background: var(--bg); scrollbar-width: none; }
body.listmode #grid::-webkit-scrollbar { display: none; }  /* 스크롤은 오른쪽 휠 칸으로 */
/* 휠 칸: 위에서 휠 = 목록 스크롤, 잡고 끌기 = 조그(끈 만큼 카드 몇 장씩), ▲ ▼ = 한 장씩(길게 누르면 계속) */
#listWheel { display: none; }
body.listmode #listWheel, body.gridmode #listWheel { display: flex; flex-direction: column; position: fixed; top: var(--toph, 150px); right: 0; bottom: 0; width: var(--ww); z-index: 9;
  border-left: 1px solid var(--line); background: var(--panel); user-select: none; }
#listWheel button { border: 0; border-radius: 0; background: none; color: var(--muted); height: 30px; padding: 0; font-size: 11px; }
#listWheel button:hover { color: var(--accent); background: var(--panel2); }
#lwPad { flex: 1; position: relative; cursor: ns-resize; touch-action: none; margin: 0 4px; border-radius: 8px;
  background: repeating-linear-gradient(180deg, #2a303c 0 2px, transparent 2px 9px), var(--panel2); box-shadow: inset 0 0 0 1px var(--line); }
#lwPad:hover, #lwPad.on { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, var(--line)); }
#lwPos { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-90deg); white-space: nowrap; font-size: 11px; color: var(--muted);
  background: var(--panel); padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; pointer-events: none; }
body.listmode #grid .cell { grid-column: auto !important; grid-row: auto !important; cursor: pointer; }
body.listmode #grid .cell .rz { display: none !important; }
body.listmode #grid .cell:hover { border-color: #3a4150; }
body.listmode #grid .cell.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 14px color-mix(in srgb, var(--accent) 25%, transparent); }
body.listmode #detail { top: var(--toph, 150px); right: calc(var(--lw) + var(--ww)); z-index: 9; }
#toTop { position: fixed; right: 20px; bottom: 20px; z-index: 15; width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 20px; line-height: 1; background: var(--panel2); border: 1px solid var(--line); box-shadow: 0 4px 12px #0006; }
#toTop:hover { border-color: var(--accent); color: var(--accent); }
#toTop[hidden] { display: none; }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--up); border-radius: 8px; padding: 8px 14px; box-shadow: 0 8px 24px #0008;
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; white-space: nowrap; }
.toast.err { border-left-color: var(--down); }
.toast.show { opacity: 1; transform: none; }
#pop label { display: flex; gap: 6px; padding: 4px 6px; cursor: pointer; border-radius: 4px; }
#pop label:hover { background: var(--panel); }
#pop .new { width: 100%; margin-top: 4px; }

@media (max-width: 1200px) {  /* 좁은 창: 검색칸을 줄여 위쪽 막대가 덜 접히게 */
  #search { width: 150px; }
  .controls label { gap: 4px; }
}
@media (max-width: 700px) {  /* ---- 모바일: 위쪽은 스크롤과 함께 올라가고, 탭·섹터는 한 줄 가로 스크롤, 그리드 1~3열 ---- */
  #grid { padding: 6px; gap: 6px; }
  .controls label:has(#dFrom) { width: 100%; }
  #top { position: static; }
  #top .bar { padding: 4px 8px; gap: 6px; }
  #top > .bar:first-child { flex-wrap: wrap; row-gap: 4px; }
  .brand { font-size: 14px; }
  #status { display: none; }
  #me { margin-left: auto; }
  #me .who { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #tabs { order: 3; flex: 1 1 100%; }
  #tabs, #cats, #sectors { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #tabs::-webkit-scrollbar, #cats::-webkit-scrollbar, #sectors::-webkit-scrollbar { display: none; }
  #tabs button, #cats button, #sectors button { flex-shrink: 0; white-space: nowrap; }
  #tabs button { padding: 3px 10px; font-size: 13px; }
  #cats button { padding: 5px 9px; font-size: 13px; }
  .bar.cats, .bar.sectors { flex-wrap: nowrap; }
  .bar.sectors .small { display: none; }
  #sectors { flex: 1; min-width: 0; }
  #modeSeg { display: none; }
  /* 컨트롤: ① 검색 + 상세검색 + 보기 ② 봉·정렬 ③ 선택·연동·열·종목 수 */
  #search { order: -2; flex: 1 1 0; min-width: 0; width: auto; }
  #filterBtn, #viewBtn { order: -1; padding: 0 8px; }
  .controls > .grow { order: -1; flex: 0 0 100%; height: 0; }
  .controls > label:has(#sort) { font-size: 0; gap: 0; }
  #sort { font-size: 13px; max-width: 132px; }
  #tfSeg button { padding: 2px 9px; }
  #listWheel { display: none !important; }
  body.gridmode #grid { padding-right: 6px; }
  #toTop { right: 14px; }
  /* 카드 머리: 이름·가격·등락만 */
  .ch { gap: 4px; padding: 4px 6px 0; font-size: 11px; }
  .ch .meta, .ch .tag, .ch .rsi, .ch .pbtn, .ch .hbtn { display: none; }
  .cell .rz { display: none; }
  #grid[data-cols="3"] .ch .gbtn, #grid[data-cols="3"] .ch .px { display: none; }  /* 3열: 이름·등락만 */
  /* 상세 차트 */
  .dhead { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
  #dInfo, #dHint { display: none; }
  #dHint:not(:empty) { display: block; flex: 1 1 100%; order: 9; font-size: 11px; }
  #dLay, #dAdd, #dSave { display: none; }
  #dtools button { width: 30px; height: 30px; }
  #dtools { padding: 6px 2px; gap: 2px; overflow-y: auto; }
  #dtools.open { width: 140px; }
  #railTips { display: none; }
  #helpPanel { position: fixed; inset: 0; width: auto; z-index: 30; }
  #ttBar, #rpBar { gap: 6px; padding: 6px 8px; }
}
#rpBar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--line); background: var(--panel); }
#rpBar[hidden] { display: none; }
#rpRange { flex: 1; min-width: 120px; accent-color: #f59e0b; }
#rpTime { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#rpBar .rp-tag { color: #f59e0b; border: 1px solid #f59e0b; border-radius: 4px; padding: 0 4px; font-size: 11px; }
#dReplay.on { color: #f59e0b; border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 15%, transparent); }
#dRevTag { color: #f59e0b; border: 1px solid #f59e0b; border-radius: 4px; padding: 0 4px; font-size: 11px; }
#dRevTag[hidden] { display: none; }

/* 뼈대 추적 */
#ttBar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
#ttBar[hidden] { display: none; }
#ttBar .tt-tag { color: #60a5fa; border: 1px solid #60a5fa; border-radius: 4px; padding: 0 4px; font-size: 11px; }
#ttBar label { display: flex; align-items: center; gap: 4px; font-size: 12px; }
#ttBar input[type=number] { width: 52px; }
#ttBand { position: absolute; height: 12px; z-index: 6; background: color-mix(in srgb, #60a5fa 35%, transparent); border-radius: 3px; cursor: grab; touch-action: none; }
#ttBand[hidden] { display: none; }
#ttBand:active { cursor: grabbing; }
#ttBand i { position: absolute; top: -4px; width: 8px; height: 20px; background: #60a5fa; border-radius: 3px; cursor: ew-resize; }
#ttBand i[data-h=a] { left: -4px; } #ttBand i[data-h=b] { right: -4px; }
#ttBand.cutl i[data-h=a], #ttBand.cutr i[data-h=b] { display: none; }
#ttLv { width: 110px; } #ttLvN { min-width: 22px; font-variant-numeric: tabular-nums; }

/* 🤖 뼈대 가상매매 */

/* 🤖 봇 전용 차트 */

/* 아이콘 레일 이름표 */
#railTips { position: fixed; inset: 0; pointer-events: none; z-index: 60; opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s; }
#railTips.show { opacity: 1; visibility: visible; }
.rtip { position: absolute; transform-origin: left center; white-space: nowrap; padding: 3px 10px; border-radius: 999px; font-size: 12px; line-height: 18px;
  background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); color: var(--muted); box-shadow: 0 2px 10px rgb(0 0 0 / .25);
  transition: transform .12s ease-out, opacity .12s ease-out; }
.rtip i { font-style: normal; font-size: 10px; opacity: .65; margin-left: 6px; }
.rtip.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.rtip.hi { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; font-size: 13px; padding: 4px 12px; }
.rtip.hi i { opacity: .6; }

/* 레일 펼치기 (>> / <<): 아이콘 옆에 메뉴 이름 */
#dtools .rl { display: none; }
#dtools.open { align-items: stretch; width: 168px; flex-shrink: 0; overflow-y: auto; }
#dtools.open button { width: 100%; display: flex; justify-content: flex-start; align-items: center; gap: 10px; padding: 0 8px; }
#dtools.open .rl { display: inline; font-size: 12px; white-space: nowrap; }
#dtools.open .sep { width: 100%; }
#dtools.open button.grp::after { right: 6px; bottom: auto; top: 50%; transform: translateY(-50%) rotate(-45deg); }
#railTgl { color: var(--muted); opacity: .8; }
#railTgl:hover { opacity: 1; }

/* 메인 '커스텀' 탭: 저장한 차트 조합 카드 */
#grid.customs { grid-auto-rows: auto !important; align-content: start; }
.ccard { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; min-width: 0; }
.ccard:hover { border-color: var(--accent); }
.ccard .chd { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ccard .cname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard .cdel { padding: 0 6px; opacity: .6; }
.ccard .cdel:hover { opacity: 1; }
.cprev { display: flex; flex-direction: column; gap: 4px; height: 150px; }
.crow { flex: 1; display: flex; gap: 4px; min-height: 0; }
.cbox { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; font-size: 11px; overflow: hidden; }
.cbox b { font-size: 12px; white-space: nowrap; }
.cbox span { color: var(--muted); }
.cempty { grid-column: 1 / -1; padding: 60px 20px; text-align: center; line-height: 1.8; }

/* 레이아웃 모달 */
#layModal { position: fixed; inset: 0; z-index: 70; background: rgb(0 0 0 / .45); display: grid; place-items: center; }
#layModal[hidden] { display: none; }
#layModal .lay-box { width: min(560px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#layModal .lay-h { display: flex; align-items: center; gap: 10px; }
#layModal .lay-h .muted { font-size: 12px; }
#layModal .lay-g { display: flex; flex-direction: column; gap: 6px; height: 300px; }
#layModal .cbox { cursor: grab; font-size: 12px; user-select: none; }
#layModal .cbox b { font-size: 15px; }
#layModal .cbox.act { border-color: var(--accent); }
#layModal .cbox.drag { opacity: .4; }
#layModal .cbox.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel2)); }

/* ---------------- 로고 ---------------- */
.brand { letter-spacing: -.2px; }
.brand span { color: var(--accent); }

/* ---------------- 모바일 앱 화면 (≤700px): 상단바 / 컨텐츠 / 하단바 ---------------- */
#mTop, #mNav, #mSheet, #mSearchRow, #mTools { display: none; }
@media (max-width: 700px) {
  body { padding-top: calc(50px + env(safe-area-inset-top)); padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  #mTop { display: flex; align-items: center; gap: 4px; position: fixed; top: 0; left: 0; right: 0; z-index: 15;
    height: calc(50px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 6px 0 14px;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  #mTop .brand { font-size: 17px; font-weight: 800; }
  #mTop { gap: 6px; padding-right: 10px; }
  .mdd { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; max-width: 130px; }
  .mdd span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mdd i { font-style: normal; font-size: 10px; color: var(--muted); transition: transform .15s; }
  .mdd.on { border-color: var(--accent); color: var(--accent); }
  .mdd.on i { transform: rotate(180deg); color: var(--accent); }
  #mDrop:not([hidden]) { display: block; position: fixed; z-index: 70; min-width: 190px; max-width: calc(100vw - 16px); max-height: 62vh; overflow: auto; padding: 6px;
    background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .45); }
  .mdh { font-size: 11px; color: var(--muted); padding: 8px 10px 4px; }
  .mdi { display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font-size: 14px; text-align: left; }
  .mdi > span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mdi.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .mdi b { color: var(--accent); }
  .mdi .gdot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  #mSearchRow:not([hidden]) { display: flex; gap: 8px; position: fixed; left: 0; right: 0; top: calc(50px + env(safe-area-inset-top)); z-index: 14; padding: 8px 10px;
    background: var(--bg); border-bottom: 1px solid var(--line); }
  #mSearch { flex: 1; min-width: 0; height: 36px; font-size: 15px; }
  #mNav { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 15; height: 60px; padding: 0 4px;
    background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: 20px;
    box-shadow: 0 8px 28px rgb(0 0 0 / .45); }
  #mNav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 14px; margin: 5px 0; background: none; color: var(--muted); font-size: 10px; padding: 0; }
  #mNav button.on { color: var(--accent); }
  #mNav button.on svg { stroke-width: 2.1; }
  /* PC 위쪽 막대 중 로고·탭 줄과 조작 줄은 숨김 (조작은 ⚙ 시트로 옮겨짐). 분류 칩 줄은 남김 */
  #top > .bar:first-child, #top > .bar.controls:not(#filterBar) { display: none !important; }
  #top { border-bottom: 0; background: var(--bg); }
  #sectorBar { display: none !important; }
  body.mfilt #sectorBar:not([hidden]) { display: flex !important; }
  #toTop { bottom: calc(84px + env(safe-area-inset-bottom)); }
  #viewMenu { left: 8px !important; right: 8px; top: auto !important; bottom: calc(84px + env(safe-area-inset-bottom)); max-height: 60vh; overflow: auto; z-index: 80; }
  /* 아래에서 올라오는 시트 */
  #mSheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 0); transition: background .2s; }
  #mSheet.show { background: rgb(0 0 0 / .45); }
  .msh { position: absolute; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow: auto; background: var(--panel); border-radius: 16px 16px 0 0;
    padding: 6px 14px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .22s ease-out; }
  #mSheet.show .msh { transform: none; }
  .msh-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; }
  .msh-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 15px; }
  .msh-x { border: 0; background: none; font-size: 16px; }
  #mView { display: flex; flex-direction: column; gap: 12px; }
  #mView[hidden], #mDyn[hidden] { display: none; }
  #mView > label { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
  #mView > label select { height: 34px; font-size: 14px; max-width: 60%; }
  #mView > label:has(#sort) { font-size: 13px; gap: 8px; }
  #mView > button { height: 42px; font-size: 14px; text-align: left; padding: 0 12px; }
  #mView > label:has(#sort) { order: 2; } #mView > label:has(#cols) { order: 3; }
  #mView #syncBtn { order: 4; } #mView #selBtn { order: 5; } #mView #viewBtn { order: 6; font-size: 0; }
  #mView #viewBtn::before { content: '⚙  지표 · RSI · 색상 · 순서 초기화'; font-size: 14px; }
  .msh-i { display: flex; align-items: center; gap: 12px; width: 100%; height: 46px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font-size: 15px; text-align: left; }
  .msh-i > span:first-of-type { flex: 1; display: flex; align-items: center; gap: 8px; }
  .msh-i.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
  .msh-i .gdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
  .msh-empty { font-size: 13px; padding: 6px 10px; }
  .mlay { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .mlay-i { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
  .mlay-i.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--accent); }
  .mlay-i b { font-size: 13px; }
  .mlay-i span { font-size: 10px; }
  .mlay-p { display: grid; gap: 3px; width: 46px; height: 64px; margin-bottom: 4px; align-content: start; overflow: hidden; }
  .mlay-p i { background: var(--muted); opacity: .45; border-radius: 3px; aspect-ratio: 1; }
  .mlay-p.wide i { aspect-ratio: 2.1; }
  .mlay-i.on .mlay-p i { background: var(--accent); opacity: .75; }
  .msh-me { display: flex; align-items: center; gap: 12px; padding: 6px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
  .msh-me > div { display: flex; flex-direction: column; }
  /* 상세 차트: 왼쪽 레일 대신 아래 도구막대, ⋯ 를 누르면 레일이 판으로 뜸 */
  #detail { padding-top: env(safe-area-inset-top); }
  #dtools { display: none; }
  #mTools { display: flex; justify-content: space-around; align-items: center; height: calc(54px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line); background: var(--panel); flex-shrink: 0; }
  #mTools button { width: 44px; height: 40px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); }
  #mTools button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
  #detail.mmore #dtools { display: grid; position: fixed; left: 8px; right: 8px; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 25; max-height: 58vh; overflow: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .4); }
  #detail.mmore #dtools button { width: 100%; height: 40px; display: flex; justify-content: flex-start; align-items: center; gap: 10px; padding: 0 10px; }
  #detail.mmore #dtools .rl { display: inline; font-size: 13px; }
  #detail.mmore #dtools .sep, #detail.mmore #dtools #railTgl { display: none; }
  #detail.mmore #dtools button.grp::after { right: 8px; bottom: auto; top: 50%; transform: translateY(-50%) rotate(-45deg); }
  .dhead #dGroup { padding: 0 8px; }
}

/* ---- 모바일 B 스타일: 단색 상단바 + 묶음 세그먼트, 단색으로 떠 있는 아이콘 하단바 ---- */
@media (max-width: 700px) {
  #mTop { background: var(--bg); border-bottom: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; gap: 6px; padding-left: 14px; padding-right: 10px; }
  #mTop .brand { font-size: 16px; font-weight: 700; }
  .mseg { display: inline-flex; padding: 2px; gap: 2px; background: #18191d; border: 0.5px solid #2a2c32; border-radius: 10px; }
  .mseg .mdd { height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 12px; font-weight: 500; max-width: 88px; box-shadow: none; }
  .mseg .mdd.idle { color: #8b9099; }
  .mseg .mdd.on { background: #2a2c33; color: var(--text); }
  /* 하단바만 차분한 유리: 어두운 반투명 + 흐림, 얇은 밝은 테두리 (광택 그라데이션 없음) */
  #mNav { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); height: 54px; padding: 0 6px; align-items: center;
    background: rgb(22 23 27 / .58); border: 0.5px solid rgb(255 255 255 / .10); border-radius: 18px;
    -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
    box-shadow: inset 0 0.5px 0 rgb(255 255 255 / .08), 0 10px 30px rgb(0 0 0 / .4); }
  #mNav button { color: #9a9fa8; }
  #mNav button { flex: 1; height: 54px; margin: 0; display: grid; place-items: center; border: 0; border-radius: 0; background: none; color: #9a9fa8; text-shadow: none; }
  #mNav button svg { width: 21px; height: 21px; filter: none; stroke-width: 1.8; padding: 8px; box-sizing: content-box; border-radius: 12px; transition: background .15s, color .15s; }
  #mNav button.on { color: #0d0e11; background: none; box-shadow: none; }
  #mNav button.on svg { background: #eceef1; stroke-width: 2; }
  #mDrop:not([hidden]) { background: #18191d; border: 0.5px solid #2a2c32; border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .45); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .mdi.on { color: var(--text); background: #26282e; }
  .mdi b { color: var(--text); }
  .bar.cats { display: none !important; }
  body.mfilt #sectorBar:not([hidden]) { display: none !important; }
}

/* 폰: 그림 선택 바 */
#mSelBar { display: none; }
@media (max-width: 700px) {
  #mSelBar:not([hidden]) { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel); flex-shrink: 0; }
  #mSelBar .msb-n { font-size: 13px; color: var(--muted); }
  #mSelBar { gap: 4px !important; }
  #mSelBar .msb-n { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #mSelBar button { width: 40px; height: 36px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--text); flex-shrink: 0; }
  #mSelBar button[hidden] { display: none; }
  #mSelBar button.dim { opacity: .3; }
  #mSelBar .msb-del { color: #f87171; background: color-mix(in srgb, var(--down) 16%, transparent); }
}

/* 폰: 상세 차트 머리 한 줄 — [←] ‹ BTC › ··· [1H 4H 1D 1W 1M] [☆] */
@media (max-width: 700px) {
  .dhead { flex-wrap: nowrap !important; gap: 2px; padding: 6px 8px 6px 4px; height: 52px; box-sizing: border-box; background: var(--bg); border-bottom: 0.5px solid var(--line); }
  #dClose { order: -1; width: 38px; height: 38px; padding: 0; border: 0; background: none; font-size: 0; display: grid; place-items: center; }
  #dClose::before { content: ''; width: 22px; height: 22px; background: currentColor;
    -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' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%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' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E") center / contain no-repeat; }
  #dPrev, #dNext { width: 22px; height: 32px; padding: 0; border: 0; background: none; color: #7c818a; font-size: 18px; }
  #dSym { font-size: 16px; font-weight: 700; padding: 0 2px; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  #dTf { order: 5; margin-left: auto; display: inline-flex; padding: 2px; gap: 2px; background: #18191d; border: 0.5px solid #2a2c32; border-radius: 10px; }
  #dTf button { height: 28px; min-width: 0; padding: 0 7px; border: 0; border-radius: 8px; background: none; color: #8b9099; font-size: 0; box-shadow: none; }
  #dTf button::before { content: attr(data-s); font-size: 12px; font-weight: 500; }
  #dTf button.on { background: #2a2c33; color: var(--text); }
  .dhead > .grow { display: none; }
  .dhead #dGroup { order: 6; width: 36px; height: 36px; padding: 0; border: 0; background: none; font-size: 0; display: grid; place-items: center; }
  #dGroup::before { content: '☆'; font-size: 20px; color: #9a9fa8; }
  #dGroup[data-on="1"]::before { content: '★'; color: var(--accent); }
  #dRevTag { order: 4; font-size: 9px; padding: 0 3px; }
}

/* 메인 하단바: 배경보다 한 톤 밝은 단색으로 또렷하게 떠 있는 바, 선택은 흰 알약 (유리·광택 없음) */
@media (max-width: 700px) {
  #mNav { height: 58px; border-radius: 22px; background: #1d1f25; border: 1px solid transparent;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    box-shadow: 0 0 0 1px rgb(255 255 255 / .05), 0 0 18px rgb(255 255 255 / .08), 0 14px 32px rgb(0 0 0 / .6), 0 2px 6px rgb(0 0 0 / .35); }
  #mNav::before { content: none; }
  /* 빛나는 테두리: 위쪽이 가장 밝고 아래로 옅어지는 1px 링 */
  #mNav::after { content: ''; position: absolute; inset: -1px; border-radius: 23px; padding: 1px; pointer-events: none;
    background: linear-gradient(180deg, rgb(255 255 255 / .38), rgb(255 255 255 / .10) 45%, rgb(255 255 255 / .16));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
  #mNav button { position: relative; height: 58px; color: #d4d7de; }
  #mNav button svg { filter: none; padding: 8px 16px; border-radius: 16px; transition: background .15s, color .15s; }
  #mNav button.on { color: #1a1408; }
  #mNav button.on svg { background: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent); stroke-width: 2; }
  #toTop { bottom: calc(86px + env(safe-area-inset-bottom)); }
  body { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
}

/* 로고·상단바·하단바: 끌기·글자 선택·길게 누르기 메뉴 막기 */
.brand, #mTop, #mNav, #mTools, .dhead { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.brand { cursor: default; }

/* 이메일 로그인으로 전환 (예전 아이디 계정 → 파이어베이스) */
#fbLink { position: fixed; inset: 0; z-index: 46; background: #000a; display: grid; place-items: center; }
#fbLink[hidden] { display: none; }
#fbLink .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; width: min(380px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; }
#fbLink .brand { font-size: 16px; text-align: center; }
#fbLink p { margin: 0; }
#fbLink input { width: 100%; padding: 8px 10px; box-sizing: border-box; }
#fbLink .seg { display: flex; }
#fbLink .seg button { flex: 1; }
#fbLink .fl-btns { display: flex; gap: 8px; justify-content: flex-end; }
#me .fblink { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }

/* 구글 로그인 버튼 */
#login .g-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 40px; border-radius: 10px; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; font-size: 14px; }
#login .g-btn:hover { background: #f2f2f2; }
#login .g-btn:disabled { opacity: .6; }
#login .g-note { text-align: center; font-size: 11px; }
#login .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; margin: 4px 0; }
#login .or::before, #login .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
