/* Phone skin for TV Lab (Android build only: android/prepare-web.js links it after apple.css). Everything is scoped
   under html.mobile (set by mobile.js), so the desktop never sees a rule of it even if the file were loaded.
   Layout: compact header + one-line info strip + full-width chart, a bottom tab bar (차트 · 목록 · 거래 · AI · 더보기)
   whose panels (aside, #dock, #ai, #mMore) open as full-screen sheets, modals as sheets, menus as action sheets.
   mobile-ui.js builds the tab bar, the 더보기 sheet and the floating ✏︎ toolbar and keeps body classes in sync. */

html.mobile {
  --tab-h: 56px; --safe-b: env(safe-area-inset-bottom, 0px); --tabs: calc(var(--tab-h) + var(--safe-b));
  --hdr-h: 48px; --info-h: 30px; --ctl-sm: 32px; --ctl: 40px; --ctl-lg: 50px; --row: 44px;
  --fs-meta: 12px; --fs-ctl: 14px; --fs-body: 14px; --fs-title: 17px;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
/* grouped sheets (iOS Settings look): darker canvas, lighter cells */
html.mobile body { --m-bg: #0d0d0e; --m-cell: #1c1c1e; --m-sep: rgba(255, 255, 255, .08); }
html.mobile body.light { --m-bg: #f2f2f7; --m-cell: #ffffff; --m-sep: rgba(60, 60, 67, .14); }
html.mobile, html.mobile body { overscroll-behavior: none; }
html.mobile body { height: 100%; font-size: var(--fs-body); user-select: none; -webkit-user-select: none; }
html.mobile :is(input, textarea, #aiLog, .ai-pop, #modal .body) { user-select: text; -webkit-user-select: text; }
html.mobile button, html.mobile select { touch-action: manipulation; }
html.mobile .gutter { display: none !important; }   /* no hover-resize handles on touch */
html.mobile #zoomBtn, html.mobile #shotBtn { display: none !important; }

/* ---------- layout grid: header / info / chart / tab bar ---------- */
html.mobile body, html.mobile body.ai-open {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--hdr-h) var(--info-h) minmax(0, 1fr) var(--tabs);
}
html.mobile header, html.mobile #info, html.mobile body.ai-open #info { grid-column: 1; }
html.mobile #charts { grid-column: 1; grid-row: 3; }
html.mobile #mTabs { grid-column: 1; grid-row: 4; }
html.mobile body.m-kb { grid-template-rows: var(--hdr-h) var(--info-h) minmax(0, 1fr) 0; }   /* soft keyboard up: no tab bar */
html.mobile body.m-kb #mTabs, html.mobile body.m-kb #mPen, html.mobile body.m-kb #rail { display: none !important; }

/* ---------- header: symbol · status dot · interval · chart type ……… ⋯ ---------- */
html.mobile header { padding: 0 6px 0 4px; gap: 2px; }
html.mobile header > *, html.mobile header .grp, html.mobile header .hsep { display: none; }
html.mobile header > :is(#symBtn, #ivAll, #ctype, .sp, #moreBtn, #status) { display: inline-flex; }
html.mobile #symBtn { order: 1; height: 40px; padding: 0 8px; font-size: 17px; letter-spacing: -0.03em; min-width: 0; }
html.mobile #symBtn #symName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.mobile #symBtn small { display: none; }
html.mobile #symBtn::after { content: ""; width: 12px; height: 12px; margin-left: 3px; flex: none; background: var(--muted); -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat;
  --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9.5l6 6 6-6'/></svg>"); }
html.mobile #status { order: 2; width: 18px; height: 40px; margin: 0 2px 0 -6px; padding: 0; justify-content: center; font-size: 0; background: none; color: var(--muted); }
html.mobile #status::before { margin: 0; font-size: 9px; }
html.mobile #ivAll { order: 3; margin-left: 2px; }
html.mobile #ctype { order: 4; }
html.mobile :is(#ivAll, #ctype) { height: 34px; padding: 0 24px 0 11px; border-radius: 99px; font-size: 13.5px; font-weight: 650; background-position: right 8px center; max-width: 34vw; text-overflow: ellipsis; }
html.mobile header .sp { order: 5; min-width: 4px; }
html.mobile #moreBtn { order: 6; width: 40px; height: 40px; border-radius: 99px; }
html.mobile #moreBtn .ic { width: 20px; height: 20px; color: var(--text); }
/* PC-sync "changes waiting" chip floats under the header instead of squeezing it */
html.mobile #syncChip { display: inline-flex; align-items: center; position: fixed; z-index: 26; top: calc(var(--hdr-h) + var(--info-h) + 10px); left: 50%; transform: translateX(-50%); height: 36px; padding: 0 16px; box-shadow: var(--shadow); background: var(--accent); color: #fff; }
html.mobile #syncChip[hidden] { display: none; }

/* ---------- info strip: one quiet line, scrolls sideways ---------- */
html.mobile #info { font-size: 11.5px; }
html.mobile #info .ticks { gap: 14px; padding: 0 12px; }
html.mobile #info .k { margin-right: 4px; }
html.mobile #info .calnext { margin: 0 8px 0 2px; padding: 3px 9px; font-size: 11px; white-space: nowrap; }
@media (max-width: 380px) { html.mobile #info .calnext:not(:has(.down)) { display: none; } }   /* narrow phones: only when it is under an hour away */

/* ---------- chart: full width, shorter indicator panes ---------- */
html.mobile .pane, html.mobile #charts:not(.l1) .pane { flex: 0 1 72px; }
html.mobile #charts.l6 .pane, html.mobile #charts.l8 .pane { flex-basis: 44px; }
html.mobile .legend { font-size: 11.5px; left: 8px; top: 4px; }
html.mobile .legend b { font-size: 13px; }
html.mobile .replay { top: 10px; max-width: calc(100% - 16px); overflow-x: auto; }
html.mobile .replay button { height: 34px; }

/* ---------- drawing tools: ✏︎ button + floating toolbar (the rail) ---------- */
html.mobile #mPen, html.mobile #rail {
  position: fixed; z-index: 22; bottom: calc(var(--tabs) + 12px);
  background: var(--menu); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); box-shadow: var(--shadow);
}
html.mobile #mPen { right: 12px; width: 46px; height: 46px; padding: 0; border-radius: 99px; display: grid; place-items: center; color: var(--text); }
html.mobile #mPen .ic { width: 20px; height: 20px; }
html.mobile body.m-rail #mPen { background: var(--accent); color: #fff; }
html.mobile body.picking #mPen { box-shadow: var(--shadow), 0 0 0 3px var(--tint); }
html.mobile #rail { display: none; right: 66px; height: 46px; padding: 3px; gap: 1px; flex-direction: row; align-items: center; border: 0; border-radius: 99px; overflow: visible; max-width: calc(100vw - 80px); }
html.mobile body.m-rail #rail { display: flex; animation: m-pop .16s ease-out; }
html.mobile #rail button { width: 40px; height: 40px; border-radius: 99px; flex: none; }
html.mobile #rail .sep { width: 1px; height: 20px; margin: 0 3px; flex: none; }
html.mobile #rail .ic { width: 19px; height: 19px; }
@media (max-width: 380px) { html.mobile #rail button { width: 36px; height: 36px; } html.mobile #rail .sep { margin: 0 2px; } }
html.mobile body:not(.picking) #railCursor { background: none; color: var(--muted); }
html.mobile body.picking #railCursor { color: var(--text); }
/* the drawing the finger picked: what can be done with it */
html.mobile #mSel { position: fixed; z-index: 24; bottom: calc(var(--tabs) + 70px); left: 50%; transform: translateX(-50%); --tx: -50%; display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 14px; border-radius: 99px;
  background: var(--menu); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); box-shadow: var(--shadow); font-weight: 650; white-space: nowrap; animation: m-pop .16s ease-out; }
html.mobile #mSel[hidden] { display: none; }
html.mobile #mSel button { height: 36px; padding: 0 13px; border-radius: 99px; background: var(--hover); font-weight: 600; }
html.mobile #mSel button.danger { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }

/* ---------- bottom tab bar ---------- */
html.mobile #mTabs { display: grid; grid-template-columns: repeat(5, 1fr); align-items: start; padding: 0 4px var(--safe-b); z-index: 38; position: relative;
  background: var(--panel); box-shadow: 0 -0.5px 0 var(--line); }
html.mobile #mTabs button { position: relative; height: var(--tab-h); padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: -0.01em; }
html.mobile #mTabs button .ic { width: 24px; height: 24px; }
html.mobile #mTabs button.on { color: var(--accent); }
html.mobile #mTabs button:active .ic { transform: scale(.9); }
html.mobile #mTabs .badge { position: absolute; top: 4px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff;
  font: 700 10.5px/17px var(--font); text-align: center; box-shadow: 0 0 0 2px var(--panel); }
html.mobile #mTabs .badge:empty { display: none; }
html.mobile #mTabs .badge.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; top: 7px; left: calc(50% + 9px); }

/* ---------- sheets: the tab panels, full screen above the tab bar ---------- */
html.mobile :is(aside, #dock, #ai, #mMore) {
  position: fixed; left: 0; right: 0; top: 0; bottom: var(--tabs); width: auto; height: auto; max-height: none; z-index: 35;
  margin: 0; border: 0; box-shadow: none; flex-direction: column; min-height: 0;
}
html.mobile body.m-kb :is(aside, #dock, #ai, #mMore) { bottom: 0; }
html.mobile aside, html.mobile body.ai-open aside, html.mobile #mMore[hidden] { display: none; }   /* #dock / #ai keep their own [hidden] rule */
html.mobile body.side-open aside, html.mobile #mMore:not([hidden]) { display: flex; }
html.mobile body.side-open aside, html.mobile #dock:not([hidden]), html.mobile #ai:not([hidden]), html.mobile #mMore:not([hidden]) { animation: m-in .18s ease-out; }
html.mobile .m-head { flex: none; display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px 0 18px; }
html.mobile .m-head h2 { margin: 0; flex: 1; min-width: 0; font-size: 24px; font-weight: 750; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.mobile .m-head .m-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
@keyframes m-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes m-up { from { transform: translateY(100%); } }
@keyframes m-pop { from { opacity: 0; transform: translateX(var(--tx, 0)) scale(.94); } }

/* ---------- 목록 (sidebar) ---------- */
html.mobile aside { background: var(--panel); }
html.mobile aside .tabs { margin: 2px 14px 8px; padding: 2px; flex: none; }
html.mobile aside .tabs button { height: 34px; font-size: 13px; gap: 4px; }
html.mobile aside .tabs .ic { width: 14px; height: 14px; }
html.mobile aside .lists { padding: 0 14px 2px; gap: 6px; }
html.mobile aside .filter { padding: 6px 14px 6px; }
html.mobile aside .filter input { height: 40px; font-size: 15px; border-radius: 11px; padding-left: 34px; background-position: 11px center; background-size: 16px; }
html.mobile .colhead, html.mobile #list li { grid-template-columns: 22px minmax(0, 1fr) 92px 74px 46px; column-gap: 8px; }
html.mobile .colhead { padding: 0 16px; scrollbar-gutter: auto; }
html.mobile .colhead button { height: 30px; font-size: 12px; }
html.mobile #list { padding: 2px 0 8px; scrollbar-gutter: auto; }
html.mobile #list li { margin: 0 8px; padding: 0 8px; min-height: 54px; border-radius: 12px; }
html.mobile #list .star { font-size: 17px; width: 22px; height: 44px; }
html.mobile #list .name { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
html.mobile #list .px { font-size: 15px; font-weight: 550; }
html.mobile #list .chg { justify-self: end; min-width: 70px; padding: 4px 7px; border-radius: 7px; color: #fff; font-size: 13.5px; font-weight: 650; text-align: right; background: var(--seg); }
html.mobile #list .chg.up { background: var(--up); }
html.mobile #list .chg.down { background: var(--down); }
html.mobile #list .vol { font-size: 12px; }
@media (hover: none) { html.mobile :is(#list li, #alerts li, .scan-list li, #cal .cal-ev, #news .news-it, .srow):hover { background: none; } }
html.mobile :is(#list li, #alerts li, .scan-list li, #news .news-it, .srow):active { background: var(--hover); }
html.mobile #list li.cur { background: var(--tint); }
@media (max-width: 380px) {   /* 360-px phones: the volume column gives its room to the name */
  html.mobile .colhead, html.mobile #list li { grid-template-columns: 22px minmax(0, 1fr) 90px 72px; }
  html.mobile :is(.colhead button[data-sort="vol"], #list .vol) { display: none; }
}
html.mobile aside h3 { padding: 12px 18px 6px; font-size: 13px; }
html.mobile aside h3 button { height: 30px; font-size: 12px; }
html.mobile aside form { padding: 0 14px 8px; gap: 6px; }
html.mobile aside > form input { font-size: 15px; }
html.mobile #alerts { max-height: 24%; }
html.mobile #alerts li { min-height: 44px; margin: 0 8px; padding: 0 10px; }
html.mobile #alerts .empty .ic { width: 13px; height: 13px; vertical-align: -2px; }
html.mobile #alerts li button { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; color: var(--muted); }
html.mobile #cal, html.mobile #news, html.mobile #scan { font-size: 13.5px; }
html.mobile #cal .cal-f, html.mobile #news .cal-f { padding: 4px 14px 10px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
html.mobile #cal .cal-f button, html.mobile #news .cal-f button { flex: none; height: 32px; padding: 0 12px; font-size: 12.5px; }
html.mobile #cal .cal-f label { flex: none; white-space: nowrap; }
html.mobile #cal .cal-day { padding: 14px 18px 6px; font-size: 13px; }
html.mobile #cal .cal-ev { margin: 0 8px; padding: 8px 10px; grid-template-columns: 44px 10px minmax(0, 1fr) auto; }
html.mobile #news .news-it { margin: 2px 8px; padding: 11px 12px; font-size: 14.5px; line-height: 1.45; }
html.mobile #news > .cal-note:last-child { display: none; }   /* desktop reader-window instructions */
html.mobile .scan-cfg { padding: 4px 18px 6px; font-size: 12.5px; line-height: 2.4; }
html.mobile .scan-cfg :is(input, select) { height: 32px; font-size: 13px; }
html.mobile .scan-cfg input[type=checkbox] { width: 18px; height: 18px; margin: 0 4px 0 0; vertical-align: -4px; }
html.mobile .scan-list li { margin: 0 8px; padding: 10px 12px; }

/* ---------- 거래 (dock): 주문 | 포지션 | 미체결 | … segmented, one view at a time ---------- */
html.mobile #dock { background: var(--m-bg); }
html.mobile #dock .dock-head { flex: none; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; border: 0; }
html.mobile #dock #dockSum { order: 1; flex: 1 1 100%; padding: 0 18px; font-size: 12.5px; line-height: 1.5; white-space: normal; overflow: visible; }
html.mobile #dock .dock-tabs { order: 2; flex: 1 1 100%; display: flex; margin: 0 14px; overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); }
html.mobile #dock .dock-tabs button { flex: 1 0 auto; height: 34px; padding: 0 12px; font-size: 13px; white-space: nowrap; }
html.mobile #dock .sp, html.mobile #dockClose { display: none; }
html.mobile body.m-tk #dock .dock-tabs button.on { background: transparent; color: var(--muted); box-shadow: none; }
html.mobile body.m-tk #dock .dock-tabs #mTkTab, html.mobile #dock .dock-tabs #mTkTab.on { background: var(--seg); color: var(--text); box-shadow: var(--seg-shadow); }
html.mobile body:not(.m-tk) #dock .dock-tabs #mTkTab { background: transparent; color: var(--muted); box-shadow: none; }
html.mobile #dock .dock-main { flex: 1 1 auto; height: auto; min-height: 0; flex-direction: column; }
html.mobile body.m-tk #dockBody, html.mobile body:not(.m-tk) #ticket { display: none; }
html.mobile #dockBody { flex: 1; min-height: 0; font-size: 13.5px; }
/* ticket: one column, ≥ 40 px controls, buy / sell pinned at the bottom for the thumb */
html.mobile #ticket { width: auto; flex: 1; min-height: 0; padding: 4px 14px 0; border: 0; background: none; font-size: 14px; overscroll-behavior: contain; }
html.mobile #ticket .tk { gap: 10px; max-width: 640px; margin: 0 auto; padding: 14px; border-radius: 16px; background: var(--m-cell); }
html.mobile #ticket .tk-l { gap: 8px; }
html.mobile #ticket .tk-l > b { font-size: 17px; letter-spacing: -0.02em; }
html.mobile #ticket .tk-l :is(input[type=number], input:not([type]), input[type=password], select, button) { height: var(--ctl); font-size: 15px; border-radius: 10px; }
html.mobile #ticket .tk-l .fld { height: var(--ctl); border-radius: 10px; padding: 0 12px; }
html.mobile #ticket .tk-l .fld > span { font-size: 12.5px; }
html.mobile #ticket .tk-l .fld input[type=number] { font-size: 16px; font-weight: 600; }
html.mobile #ticket .tk-l .lev { width: 64px; text-align: center; }
html.mobile #ticket .tk-l .unit { width: auto; max-width: 58%; flex: none; field-sizing: content; }
html.mobile #ticket .tk-l:has(.typ) { flex-wrap: wrap; }
html.mobile #ticket .tk-l .typ { flex: 1 1 100%; width: auto; }
html.mobile #ticket #tkLast { padding: 0 14px; }
html.mobile #ticket input[type=range] { height: var(--ctl); }
html.mobile #ticket .tk-side { height: 44px; border-radius: 12px; }
html.mobile #ticket .tk-side button { height: 40px; font-size: 15px; border-radius: 10px; }
html.mobile #ticket .tk-l.small { flex-wrap: wrap; row-gap: 4px; font-size: 13px; }
html.mobile #ticket .tk-l.small label { min-height: 36px; gap: 8px; padding-right: 10px; }
html.mobile #ticket .tk-l.small input[type=checkbox] { width: 20px; height: 20px; margin: 0; }
html.mobile #ticket .tk-sum { flex: 1 1 100%; margin: 0; white-space: normal; }
html.mobile #ticket .tk-risk { font-size: 13px; line-height: 1.5; }
html.mobile #ticket .tk-go { position: sticky; bottom: 0; z-index: 2; margin: 10px -14px 0; padding: 10px 14px 12px; gap: 10px; border-radius: 0;
  background: color-mix(in srgb, var(--m-cell) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 -0.5px 0 var(--line); }
html.mobile #ticket .tk-go button { height: var(--ctl-lg); border-radius: 14px; font-size: 16px; }
html.mobile #ticket .tk > .muted.small { font-size: 12.5px; }
/* positions / open orders as cards (labels come from the column they replace) */
html.mobile #dockBody :is(table.pos, table.ord) { display: block; width: auto; min-width: 0; }
html.mobile #dockBody :is(table.pos, table.ord) :is(tbody, thead) { display: block; }
html.mobile #dockBody :is(table.pos, table.ord) tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin: 0 14px 10px; padding: 12px 14px 14px; border-radius: 16px; background: var(--m-cell); }
html.mobile #dockBody :is(table.pos, table.ord) tr:first-child { display: flex; justify-content: flex-end; margin: 0 14px 8px; padding: 0; background: none; }
html.mobile #dockBody :is(table.pos, table.ord) tr:first-child th:not(:last-child) { display: none; }
html.mobile #dockBody :is(table.pos, table.ord) :is(td, th) { position: static; height: auto; padding: 0; border: 0; background: none; box-shadow: none; text-align: left; white-space: normal; min-width: 0; }
html.mobile #dockBody :is(table.pos, table.ord) tr:hover > td { background: none; }
html.mobile #dockBody :is(table.pos, table.ord) th button { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 99px; }
html.mobile #dockBody :is(table.pos, table.ord) td { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.35; }
html.mobile #dockBody :is(table.pos, table.ord) td::before { display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
html.mobile #dockBody :is(table.pos, table.ord) td .muted { font-size: 12px; font-weight: 500; }
html.mobile #dockBody :is(table.pos, table.ord) td:first-child { grid-column: 1 / 3; grid-row: 1; flex-direction: row; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
html.mobile #dockBody :is(table.pos, table.ord) td:first-child a { color: var(--text); }
html.mobile #dockBody table.pos td:nth-child(2)::before { content: "수량"; }
html.mobile #dockBody table.pos td:nth-child(3)::before { content: "진입가"; }
html.mobile #dockBody table.pos td:nth-child(4)::before { content: "마크가"; }
html.mobile #dockBody table.pos td:nth-child(5)::before { content: "청산가"; }
html.mobile #dockBody table.pos td:nth-child(6) { grid-column: 2 / 4; grid-row: 1; font-size: 15px; text-align: right; white-space: nowrap; }
html.mobile #dockBody table.pos td:nth-child(5) { grid-column: 1 / 3; }
html.mobile #dockBody table.pos td:nth-child(6)::before { content: "미실현 (ROE)"; }
html.mobile #dockBody table.pos td:nth-child(2) { grid-row: 2; }
html.mobile #dockBody table.pos td.c-mark { display: block; }
html.mobile #dockBody table.pos td.guards { grid-column: 1 / -1; font-size: 13.5px; word-spacing: 4px; }
html.mobile #dockBody table.pos td.guards::before { content: "손절 · 익절"; word-spacing: normal; }
html.mobile #dockBody :is(table.pos, table.ord) td.acts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
html.mobile #dockBody :is(table.pos, table.ord) td.acts button { height: 38px; margin: 0; padding: 0 4px; font-size: 13.5px; border-radius: 10px; }
html.mobile #dockBody table.ord td:nth-child(2)::before { content: "종류"; }
html.mobile #dockBody table.ord td:nth-child(3)::before { content: "방향"; }
html.mobile #dockBody table.ord td:nth-child(4)::before { content: "가격 · 발동가"; }
html.mobile #dockBody table.ord td:nth-child(5)::before { content: "수량"; }
html.mobile #dockBody table.ord td:nth-child(6)::before { content: "체결"; }
html.mobile #dockBody table.ord td.acts { grid-column: 3; grid-row: 1; display: flex; justify-content: flex-end; }
html.mobile #dockBody table.ord td.acts button { width: 72px; height: 34px; }
html.mobile #dockBody table.kv { width: calc(100% - 28px); min-width: 0; margin: 0 14px; border-radius: 16px; overflow: hidden; background: var(--m-cell); }
html.mobile #dockBody table.kv :is(td, th) { height: 44px; padding: 0 14px; background: var(--m-cell); }
html.mobile #dockBody table.kv tr:first-child { display: none; }
html.mobile #dockBody > .cal-note { margin: 0 14px; }
html.mobile #dockBody > .cal-note:only-child { padding: 40px 20px; font-size: 14px; }
html.mobile #dockBody .set { padding: 4px 18px 18px; gap: 14px; font-size: 14px; }
html.mobile #dockBody .set input:not([type=checkbox]) { height: var(--ctl); font-size: 15px; }
html.mobile #dockBody .set button { height: var(--ctl); }
html.mobile #dockBody .jr { padding: 0 14px; }
/* 호가·체결: ladder | tape side by side, the flow summary only where there is room */
html.mobile #dockBody .book { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 10px; padding: 0 10px; }
html.mobile #dockBody .book .flow { display: none; }
html.mobile #dockBody .book .hd { font-size: 10.5px; }
html.mobile #dockBody .book .r { font-size: 11.5px; }
html.mobile #dockBody .book .hd > span:first-child { white-space: nowrap; }
html.mobile #dockBody .book .hd select { height: 17px; font-size: 10.5px; padding: 0 14px 0 4px; background-position: right 2px center; }
@media (max-width: 440px) {   /* portrait phones: the tape keeps price and size, the clock goes */
  html.mobile #dockBody .book .hd { font-size: 10px; }
  html.mobile #dockBody .book .tape :is(.r, .hd) { grid-template-columns: 1.1fr 1fr; }
  html.mobile #dockBody .book .tape :is(.r, .hd) > :nth-child(3) { display: none; }
}
html.mobile #dockBody .book .lad .mid { gap: 8px; }
html.mobile #dockBody .book .lad .mid b { flex: none; font-size: 15px; white-space: nowrap; }
html.mobile #dockBody .book .lad .mid span { min-width: 0; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 700px) {
  html.mobile #dockBody .book { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.2fr); }
  html.mobile #dockBody .book .flow { display: flex; }
}

/* ---------- AI ---------- */
html.mobile #ai { background: var(--panel); }
html.mobile #ai .ai-head { flex: none; flex-wrap: wrap; height: auto; gap: 8px; padding: 0 12px 10px; border: 0; }
html.mobile #ai .ai-head h2 { order: 1; margin: 0; padding-left: 6px; font-size: 24px; font-weight: 750; letter-spacing: -0.03em; line-height: 52px; }
html.mobile #ai .ai-head .sp { order: 2; }
html.mobile #ai .ai-head #aiNew { order: 3; height: 34px; padding: 0 14px; border-radius: 99px; background: var(--hover); font-size: 13px; font-weight: 650; }
html.mobile #ai .ai-head .m-br { order: 4; flex: 1 1 100%; height: 0; }
html.mobile #ai .ai-head :is(#aiPersona, #aiHist) { order: 5; flex: 1 1 0; min-width: 0; max-width: none; height: 36px; border-radius: 10px; font-size: 13.5px; text-overflow: ellipsis; }
html.mobile #ai #aiClose { display: none; }
html.mobile #aiLog { padding: 6px 14px 14px; font-size: 15px; line-height: 1.55; scrollbar-gutter: auto; overscroll-behavior: contain; }
html.mobile #aiLog .msg { padding: 10px 14px; border-radius: 20px; flex-shrink: 0; }   /* index.html's generic .err min-height lets a long failed/stopped answer collapse and draw over the next ones */
html.mobile #aiLog .msg.u { max-width: 86%; }
html.mobile #aiLog .empty { margin-top: 48px; padding: 0 24px; line-height: 1.7; font-size: 14px; }
html.mobile #aiLog .ord-card .btns button { height: 42px; font-size: 14px; }
html.mobile #aiLog .code .bar button { height: 30px; }
html.mobile #aiQuick { padding: 2px 14px 8px; gap: 8px; }
html.mobile #aiQuick button { height: 34px; padding: 0 14px; font-size: 13px; }
html.mobile #ai .ai-in { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px 8px; padding: 8px 12px 10px; }
html.mobile #ai .ai-btns { display: contents; }
html.mobile #ai #aiLogin, html.mobile #ai #aiStat { grid-column: 1 / -1; grid-row: 1; }
html.mobile #ai .ai-btns .sp { display: none; }
html.mobile #ai .ai-ctl { grid-column: 1 / -1; grid-row: 2; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
html.mobile #ai .ai-ctl .pill { flex: none; height: 32px; padding: 0 12px; font-size: 13px; background: var(--hover); }
html.mobile #ai .ai-ctl .ring { display: none; }   /* plan usage lives on the PC that answers */
html.mobile #ai textarea { grid-column: 1; grid-row: 3; min-height: 42px; max-height: 28vh; padding: 10px 16px; border-radius: 21px; font-size: 15px; line-height: 1.4; }
html.mobile #ai :is(#aiSend, #aiStop) { grid-column: 2; grid-row: 3; width: 42px; height: 42px; padding: 0; border-radius: 99px; font-size: 0; display: grid; place-items: center; }
html.mobile #ai :is(#aiSend, #aiStop)[hidden] { display: none; }
html.mobile #ai #aiSend::before, html.mobile #ai #aiStop::before { content: ""; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
html.mobile #ai #aiSend { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5.5 11.5L12 5l6.5 6.5'/></svg>"); }
html.mobile #ai #aiStop { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><rect x='6' y='6' width='12' height='12' rx='2.5'/></svg>"); background: var(--text); color: var(--bg); }
html.mobile .ai-pop { position: fixed; left: 10px !important; right: 10px; top: auto !important; bottom: calc(var(--tabs) + 10px); width: auto; max-width: none; z-index: 82; font-size: 14px; animation: m-in .18s ease-out; }
html.mobile .ai-pop button { height: 36px; }
html.mobile .pop-eff { width: auto; }
html.mobile .eff button { height: 30px; }

/* ---------- 더보기 ---------- */
html.mobile #mMore { background: var(--m-bg); }
html.mobile .m-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 28px; }
html.mobile .m-group { max-width: 680px; margin: 0 auto 22px; }
html.mobile .m-gh { padding: 0 16px 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
html.mobile .m-cells { border-radius: 14px; overflow: hidden; background: var(--m-cell); }
html.mobile .m-cell { width: 100%; display: flex; align-items: center; gap: 13px; min-height: 52px; padding: 0 14px; border-radius: 0; background: none; text-align: left; font-size: 16px; font-weight: 500; letter-spacing: -0.015em; }
html.mobile .m-cell + .m-cell > .m-lbl { box-shadow: 0 -0.5px 0 var(--m-sep); }
html.mobile .m-cell:active:not(.static) { background: var(--hover); }
html.mobile .m-cell .m-lbl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; align-self: stretch; }
html.mobile .m-cell .m-lbl > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.mobile .m-cell small { flex: none; max-width: 46%; font-size: 15px; font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.mobile .m-cell .chev { width: 13px; height: 13px; color: var(--muted); opacity: .7; }
html.mobile .m-cell .m-ico { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--c, #8e8e93); color: #fff; }
html.mobile .m-cell .m-ico .ic { width: 18px; height: 18px; }
html.mobile .m-cell[disabled] { opacity: .45; }
html.mobile .m-seg { flex: none; display: inline-flex; padding: 2px; border-radius: 9px; background: var(--hover); }
html.mobile .m-seg button { height: 30px; padding: 0 14px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
html.mobile .m-seg button.on { background: var(--seg); color: var(--text); box-shadow: var(--seg-shadow); }
html.mobile .m-foot { max-width: 680px; margin: -8px auto 0; padding: 0 16px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
html.mobile .m-foot a { color: var(--accent); }

/* ---------- menus → action sheets ---------- */
html.mobile #mScrim { position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, .38); opacity: 0; transition: opacity .2s; pointer-events: none; }
html.mobile #mScrim.on { opacity: 1; pointer-events: auto; }
html.mobile #menu { position: fixed; left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + var(--safe-b)); min-width: 0; max-height: min(78vh, 640px); z-index: 80;
  padding: 6px; border-radius: 16px; background: var(--raised); -webkit-backdrop-filter: none; backdrop-filter: none; animation: m-up .22s cubic-bezier(.2, .9, .3, 1); overscroll-behavior: contain; }
html.mobile #menu .item { grid-template-columns: 22px minmax(0, 1fr); gap: 8px; min-height: 46px; align-items: center; padding: 0 12px 0 8px; border-radius: 10px; font-size: 15.5px; line-height: 1.3; }
html.mobile #menu .item > span:first-child { color: var(--accent); font-weight: 700; text-align: center; }
html.mobile #menu .item:hover { background: none; color: inherit; }
html.mobile #menu .item.danger, html.mobile #menu .item.danger:hover { color: var(--down); }
html.mobile #menu .item.disabled, html.mobile #menu .item.disabled:hover { color: var(--muted); }
html.mobile #menu .item:not(.disabled):active { background: var(--hover); }
html.mobile #menu .key { display: none; }
html.mobile #menu .m-cancel { position: sticky; bottom: -6px; margin: 6px -6px -6px; padding: 6px; background: var(--raised); box-shadow: 0 -0.5px 0 var(--line); }
html.mobile #menu .m-cancel button { width: 100%; height: 48px; border-radius: 12px; background: var(--hover); font-size: 16px; font-weight: 700; }
@media (min-width: 600px) { html.mobile #menu { left: 50% !important; right: auto; width: 420px; margin-left: -210px; } }
@media (min-width: 700px) {   /* tablets: sheets and cards keep a readable width */
  html.mobile #modal { padding: 24px 24px 0; }
  html.mobile #modal .box, html.mobile #modal .box.wide { max-width: 820px; margin: 0 auto; }
  html.mobile #dockBody :is(table.pos, table.ord), html.mobile #dockBody table.kv { max-width: 760px; margin-left: auto; margin-right: auto; }
}

/* ---------- modals → sheets, confirm dialogs, toast ---------- */
html.mobile #modal { z-index: 60; padding: 10px 0 0; align-items: stretch; background: rgba(0, 0, 0, .45); }
html.mobile #modal .box, html.mobile #modal .box.wide { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 16px 16px 0 0; background: var(--panel); -webkit-backdrop-filter: none; backdrop-filter: none; animation: m-up .28s cubic-bezier(.2, .9, .3, 1); }
html.mobile #modal .head { flex: none; gap: 10px; height: 54px; padding: 0 10px 0 18px; font-size: 17px; }
html.mobile #modal .head .title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.mobile #modal .head .close { flex: none; width: 34px; height: 34px; padding: 0; border-radius: 99px; background: var(--hover); color: var(--muted); font-size: 15px; font-weight: 700; }
html.mobile #modal .body { flex: 1; min-height: 0; padding: 14px 16px calc(24px + var(--safe-b)); overflow-x: auto; font-size: 14px; }
html.mobile #modal .body :is(input:not([type=checkbox]):not([type=color]), select) { font-size: 15px; }
html.mobile #modal .body input[type=checkbox] { width: 20px; height: 20px; }
html.mobile #modal .body button:not(.on):not(.star), html.mobile #modal .body button.on { border-radius: 10px; }
html.mobile #modal .q { height: 44px; font-size: 16px; border-radius: 12px; margin-bottom: 10px; }
html.mobile .srow { grid-template-columns: 32px minmax(0, 1fr) 92px 70px; min-height: 52px; padding: 0 8px 0 0; gap: 8px; font-size: 15px; }
html.mobile .srow > span:last-child { display: none; }
html.mobile .srow .star { height: 44px; font-size: 18px; }
html.mobile .srow > span:nth-child(2) .muted { display: none; }   /* every symbol is a USDT perpetual */
html.mobile .setrow { gap: 8px 10px; padding: 10px 0; }
html.mobile .setrow label { min-width: 0; flex: 1 1 140px; }
html.mobile .pm, html.mobile .sync-pane { min-width: 0; }
html.mobile .pm-sum { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 10px; }
html.mobile #modal .jr-stats .chip { font-size: 15px; }
html.mobile .sync-pane .kv { grid-template-columns: 72px 1fr; }
html.mobile .sync-pane .paste input { min-width: 0; font-size: 13px; }
html.mobile .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
html.mobile .code { height: 46vh; font-size: 13px; }
html.mobile .scr-row { min-height: 44px; }
html.mobile .eng-ctl { gap: 8px; }
html.mobile .ask { z-index: 70; padding: 16px; }
html.mobile .ask .box { width: min(440px, 100%); padding: 20px 18px 16px; border-radius: 18px; }
html.mobile .ask .t { font-size: 17px; }
html.mobile .ask input { height: 44px; font-size: 16px; }
html.mobile .ask .b { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
html.mobile .ask .b button { height: 46px; min-width: 0; font-size: 15px; border-radius: 12px; }
html.mobile #toast { z-index: 90; bottom: calc(var(--tabs) + 14px); max-width: calc(100vw - 32px); width: max-content; white-space: normal; text-align: center; line-height: 1.4; }
html.mobile body.m-kb #toast { bottom: 14px; }
html.mobile body.m-rail[data-mtab="chart"] #toast { bottom: auto; top: calc(var(--hdr-h) + var(--info-h) + 12px); }   /* the drawing toolbar owns the bottom */
html.mobile .empty-state { padding: 40px 18px; }

/* ---------- landscape phones: every pixel to the chart ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  html.mobile { --tab-h: 46px; --hdr-h: 42px; --info-h: 0px; }
  html.mobile #info { display: none; }
  html.mobile .pane, html.mobile #charts:not(.l1) .pane { flex-basis: 54px; }
  html.mobile #mTabs button { flex-direction: row; gap: 6px; font-size: 12px; padding: 0; }
  html.mobile #mTabs button .ic { width: 20px; height: 20px; }
  html.mobile #mTabs .badge, html.mobile #mTabs .badge.dot { position: static; margin-left: -2px; }   /* after the label: the icon sits beside it here */
  html.mobile .m-head { height: 44px; }
  html.mobile .m-head h2, html.mobile #ai .ai-head h2 { font-size: 19px; line-height: 44px; }
  html.mobile #modal { padding-top: 0; }
  html.mobile #modal .box { border-radius: 0; }
  html.mobile #modal .head { height: 46px; }
  /* 목록: the whole sheet scrolls (list, then alerts) instead of two cramped scrollers */
  html.mobile aside { overflow-y: auto; overscroll-behavior: contain; }
  html.mobile aside > * { flex: none; }
  html.mobile aside :is(#list, #cal, #news, #scan, #alerts) { flex: none; min-height: auto; max-height: none; overflow: visible; }
  /* 거래: the account line moves up beside the title */
  html.mobile #dock #dockSum { position: absolute; top: 0; left: 84px; right: 180px; height: 44px; padding: 0; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
  html.mobile #dock .dock-head { padding-bottom: 6px; }
  /* AI: one header row, no prompt chips, pills beside the field */
  html.mobile #ai .ai-head { flex-wrap: nowrap; padding-bottom: 6px; }
  html.mobile #ai .ai-head .m-br { display: none; }
  html.mobile #ai .ai-head :is(#aiPersona, #aiHist) { order: 2; flex: 0 1 220px; }
  html.mobile #ai .ai-head .sp { order: 3; }
  html.mobile #ai .ai-head #aiNew { order: 4; }
  html.mobile #aiQuick { display: none; }
  html.mobile #ai .ai-in { grid-template-columns: auto minmax(0, 1fr) auto; padding-top: 6px; padding-bottom: 6px; }
  html.mobile #ai .ai-ctl { grid-column: 1; grid-row: 3; align-self: center; }
  html.mobile #ai textarea { grid-column: 2; }
  html.mobile #ai :is(#aiSend, #aiStop) { grid-column: 3; }
}

/* ---------- icons used only here ---------- */
html.mobile .i-candle { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M7.5 3v3.5M7.5 17v4M16.5 5v4M16.5 17.5V21'/><rect x='4.8' y='6.5' width='5.4' height='10.5' rx='1.4'/><rect x='13.8' y='9' width='5.4' height='8.5' rx='1.4'/></svg>"); }
html.mobile .i-up { --i: url("data:image/svg+xml;utf8,<svg 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'><path d='M12 15V4M7.5 8.5L12 4l4.5 4.5M5 13.5V19h14v-5.5'/></svg>"); }
html.mobile .i-down { --i: url("data:image/svg+xml;utf8,<svg 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'><path d='M12 4v11M7.5 10.5L12 15l4.5-4.5M5 13.5V19h14v-5.5'/></svg>"); }
html.mobile .i-info { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='12' cy='12' r='8.5'/><path d='M12 11v5.5'/><circle cx='12' cy='7.8' r='1.1' fill='black' stroke='none'/></svg>"); }
html.mobile .i-chevr { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 5l7 7-7 7'/></svg>"); }
html.mobile .i-x { --i: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'><path d='M6 6l12 12M18 6L6 18'/></svg>"); }
