/* 휴대폰(폭 640px 이하) 전용 화면. designbookmark.com 참고: 무채색 바탕 · 큰 둥근 카드 · 알약 칩 · 화면 아래 떠 있는 알약 메뉴.
   색은 터미널과 같은 규칙(상승 빨강 · 하락 파랑, 공포 파랑 · 탐욕 빨강). */

#m, .m-back { display: none; }
@media (max-width: 640px) {
  html:not(.m-full) .app, html:not(.m-full) .tabbar { display: none !important; }
  html:not(.m-full) #m { display: block; }
  html.m-full .m-back { display: inline-flex; }
}

#m {
  --m-bg: #f2f3f5; --m-card: #ffffff; --m-card2: #f0f1f4; --m-line: #e6e8ec; --m-ink: #0e0f12; --m-sub: #6b7180;
  --m-active: #0e0f12; --m-active-ink: #ffffff; --m-nav: rgb(255 255 255 / 0.82);
  min-height: 100vh; padding: 0 16px calc(104px + env(safe-area-inset-bottom));
  background: var(--m-bg); color: var(--m-ink);
  font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #m { --m-bg: #0b0b0c; --m-card: #161618; --m-card2: #202023; --m-line: #26262a; --m-ink: #f2f2f3; --m-sub: #9a9aa2;
    --m-active: #f2f2f3; --m-active-ink: #0b0b0c; --m-nav: rgb(28 28 31 / 0.82); }
}
:root[data-theme="dark"] #m { --m-bg: #0b0b0c; --m-card: #161618; --m-card2: #202023; --m-line: #26262a; --m-ink: #f2f2f3; --m-sub: #9a9aa2;
  --m-active: #f2f2f3; --m-active-ink: #0b0b0c; --m-nav: rgb(28 28 31 / 0.82); }
#m a { color: inherit; text-decoration: none; }
#m button { font: inherit; color: inherit; }
#m .ic { width: 18px; height: 18px; }
#m .up { color: var(--up); } #m .down { color: var(--down); } #m .flat { color: var(--m-sub); }

/* 머리 */
.m-top { display: flex; align-items: center; gap: 10px; height: 56px; }
.m-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.m-brand .logo { width: 28px; height: 28px; }
.m-clock { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--m-sub); font-size: 13px; }
.m-live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.m-icon { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: var(--m-card); cursor: pointer; }
.m-hello { padding: 10px 2px 14px; }
.m-hello h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.m-hello p { margin: 4px 0 0; color: var(--m-sub); font-size: 14px; }
.m-body { display: grid; gap: 12px; }

/* 카드 */
.m-card { display: block; padding: 18px; border-radius: 24px; background: var(--m-card); }
.m-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.m-h h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.m-more { display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; border: 0; border-radius: 999px; background: var(--m-card2); color: var(--m-sub) !important; font-size: 13px; font-weight: 600; cursor: pointer; }
.m-more .ic { width: 15px; height: 15px; }
.m-band { display: inline-flex; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; background: color-mix(in srgb, currentColor 15%, transparent); }
.m-chg { font-weight: 700; white-space: nowrap; }

/* 브리핑 */
.m-hero { padding: 20px; }
.m-temp { display: flex; align-items: center; gap: 14px; }
.m-num { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -0.05em; }
.m-temp div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.m-temp small { color: var(--m-sub); font-size: 12.5px; }
.m-bar { position: relative; height: 6px; margin: 16px 0 14px; border-radius: 3px; background: linear-gradient(90deg, var(--down), var(--flat) 50%, var(--up)); }
.m-bar span { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--m-card); border: 3px solid var(--m-ink); }
.m-lines { list-style: none; counter-reset: l; display: grid; gap: 10px; margin: 0; padding: 0; }
.m-lines li { counter-increment: l; display: grid; grid-template-columns: 24px 1fr; gap: 10px; font-size: 16px; line-height: 1.5; }
.m-lines li::before { content: counter(l); display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 8px; background: var(--m-card2); font-size: 12px; font-weight: 800; }
.m-us { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--m-line); color: var(--m-sub); font-size: 14px; }
.m-us b { color: var(--m-ink); }

/* 핵심 지수 */
.m-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.m-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 10px; border-radius: 20px; background: var(--m-card); }
.m-tn { display: flex; align-items: center; gap: 6px; color: var(--m-sub); font-size: 13px; font-weight: 600; }
.m-tv { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.m-tile .m-chg { font-size: 14px; }
.m-tile .spark { height: 26px; margin-top: 6px; }
.m-pills { display: flex; gap: 8px; margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.m-pills::-webkit-scrollbar { display: none; }
.m-pill { display: inline-flex; align-items: baseline; gap: 6px; flex: none; padding: 9px 14px; border-radius: 999px; background: var(--m-card); font-size: 13.5px; white-space: nowrap; }
.m-pill span { color: var(--m-sub); }
.m-pill b { font-weight: 800; }

/* 심리 */
.m-gauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.m-g { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 16px; background: var(--m-card2); }
.m-gn { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.m-g .m-band { font-size: 11.5px; padding: 1px 8px; }
.m-g small { color: var(--m-sub); font-size: 11.5px; line-height: 1.3; }
.m-g small b { display: block; color: var(--m-ink); font-size: 12px; }

/* 목록 */
.m-list { display: grid; }
.m-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 76px; align-items: center; gap: 10px; min-height: 50px; border-top: 1px solid var(--m-line); }
.m-list > :first-child { border-top: 0; }
.m-rn { display: flex; flex-direction: column; min-width: 0; }
.m-rn b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-rn small { color: var(--m-sub); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-rv { font-weight: 700; white-space: nowrap; }
.m-row > :last-child { text-align: right; }
.m-row > .m-band { justify-self: end; }
.m-favrow { display: grid; grid-template-columns: minmax(0, 1fr) 36px; align-items: center; gap: 6px; border-top: 1px solid var(--m-line); }
.m-list > .m-favrow:first-child { border-top: 0; }
.m-favrow .m-row { border-top: 0; }
.m-star { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--m-sub) !important; cursor: pointer; }
.m-star .ic { width: 18px; height: 18px; }
.m-star.on { color: #f5a524 !important; }
.m-star.on .ic { fill: currentColor; }
.m-indchips { display: grid; gap: 8px; padding: 2px 2px 4px; }
.m-indchips small { color: var(--m-sub); font-size: 12.5px; font-weight: 600; }
.m-indchips div { display: flex; flex-wrap: wrap; gap: 8px; }
#m .ind-chip { height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--m-card); color: var(--m-ink) !important; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.m-cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px; border: 0; border-radius: 16px; background: var(--m-card2); font-weight: 700; cursor: pointer; }
.m-issues { list-style: none; counter-reset: i; display: grid; margin: 0; padding: 0; }
.m-issues li { counter-increment: i; display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 11px 0; border-top: 1px solid var(--m-line); font-size: 15.5px; font-weight: 600; line-height: 1.45; }
.m-issues li:first-child { border-top: 0; padding-top: 2px; }
.m-issues li::before { content: counter(i); color: var(--m-sub); font-weight: 800; }
.m-next { display: flex; align-items: center; gap: 14px; }
.m-dday { display: grid; place-items: center; min-width: 58px; height: 36px; padding: 0 10px; border-radius: 12px; background: var(--m-card2); font-weight: 800; }
.m-dday.soon { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.m-nt { display: flex; flex-direction: column; }
.m-nt small { color: var(--m-sub); font-size: 13px; }
/* 버튼 이름은 m-fullbtn. html의 m-full(전체 보기 상태)과 겹치면 페이지 전체가 이 버튼 모양이 돼 위로 밀려났다 */
.m-fullbtn { display: flex; align-items: center; justify-content: center; gap: 4px; height: 48px; margin-top: 4px; border: 1px solid var(--m-line); border-radius: 999px; background: none; color: var(--m-sub) !important; font-weight: 600; cursor: pointer; }
.m-empty { margin: 8px 4px; color: var(--m-sub); font-size: 14px; }

/* 관심 탭 */
.m-search { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 18px; border-radius: 999px; background: var(--m-card); color: var(--m-sub); }
.m-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--m-ink); font: 16px var(--font); outline: none; }
.m-results { list-style: none; margin: 0; padding: 6px; border-radius: 20px; background: var(--m-card); }
.m-results button { display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 12px 12px; border: 0; border-radius: 14px; background: none; text-align: left; font-size: 15px; cursor: pointer; }
.m-results button:active { background: var(--m-card2); }
.m-results small { color: var(--m-sub); font-size: 12.5px; }
.m-results .empty { padding: 10px 12px; color: var(--m-sub); }
.m-wrow { display: grid; grid-template-columns: minmax(0, 1fr) 64px auto 30px; align-items: center; gap: 10px; min-height: 58px; border-top: 1px solid var(--m-line); }
.m-wrow .spark { height: 26px; margin: 0; }
.m-wv { display: flex; flex-direction: column; align-items: flex-end; }
.m-wv .m-chg { font-size: 13px; }
.m-del { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: var(--m-card2); color: var(--m-sub) !important; cursor: pointer; }
.m-del .ic { width: 14px; height: 14px; }

/* 시장·뉴스 탭: 알약 칩 */
.m-chips { display: flex; gap: 8px; margin: 0 -16px 2px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.m-chips::-webkit-scrollbar { display: none; }
.m-chips button { flex: none; height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--m-card); color: var(--m-sub) !important; font-size: 14px; font-weight: 600; cursor: pointer; }
.m-chips button[aria-selected="true"] { background: var(--m-active); color: var(--m-active-ink) !important; }
.m-story { display: flex; flex-direction: column; gap: 6px; }
.m-story b { font-size: 16px; font-weight: 700; line-height: 1.45; letter-spacing: -0.01em; }
.m-story p { margin: 0; color: var(--m-sub); font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--m-sub); font-size: 12.5px; }
.m-meta i { font-style: normal; padding: 1px 8px; border-radius: 999px; background: var(--m-card2); color: var(--m-ink); font-weight: 600; }

/* 떠 있는 알약 메뉴 */
.m-nav { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: min(calc(100% - 32px), 420px); padding: 6px; border-radius: 999px;
  background: var(--m-nav); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.18), 0 0 0 1px var(--m-line); }
.m-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: 52px; border: 0; border-radius: 999px; background: none; color: var(--m-sub) !important; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.m-nav button .ic { width: 20px; height: 20px; }
.m-nav button.on { background: var(--m-active); color: var(--m-active-ink) !important; }

/* 전체 터미널에서 돌아오는 버튼 */
.m-back { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 45; transform: translateX(-50%); align-items: center; gap: 4px;
  height: 44px; padding: 0 18px 0 12px; border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 14px var(--font); box-shadow: 0 6px 20px rgb(0 0 0 / 0.25); cursor: pointer; }
.m-back .ic { width: 18px; height: 18px; }

/* 투자 권유 아님 안내(모든 탭 맨 아래) */
.m-note { margin: 18px 4px 0; font-size: 11.5px; line-height: 1.5; color: var(--m-sub); text-align: center; }

/* ---------- 토스 미니앱(html.toss, toss/가 묶을 때 toss-config.js가 켬)
   휴대폰 화면만 보인다. 이름·로고·뒤로가기는 토스 내비게이션 바가 맡아서 우리 머리줄·전체 보기·간단히 보기 버튼은 숨긴다.
   토스 미니앱은 밝은 화면 기준이고, 아래 여백은 토스가 알려 주는 안전 영역(--toss-bottom)을 쓴다. */
html.toss .app, html.toss .tabbar, html.toss .m-back, html.toss .m-fullbtn, html.toss .m-top, html.toss #disguise { display: none !important; }
html.toss #m { display: block !important; max-width: 560px; margin: 0 auto; padding-top: 8px;
  padding-bottom: calc(104px + max(env(safe-area-inset-bottom), var(--toss-bottom, 0px))); }
html.toss .m-nav { bottom: calc(14px + max(env(safe-area-inset-bottom), var(--toss-bottom, 0px))); }

