/* m.mystock.se - 모바일 우선. 브레이크포인트 하나(720px)로 태블릿/데스크톱까지 커버합니다. */

:root {
    --bg:         #0b1220;
    --bg-2:       #111c31;
    --surface:    rgba(255, 255, 255, 0.045);
    --surface-2:  rgba(255, 255, 255, 0.08);
    --line:       rgba(255, 255, 255, 0.10);
    --text:       #e2e8f0;
    --muted:      #94a3b8;
    --dim:        #64748b;
    --accent:     #3b82f6;
    --accent-2:   #8b5cf6;
    --buy:        #22c55e;
    --sell:       #ef4444;
    --hold:       #94a3b8;
    --warn:       #f59e0b;

    --topbar-h:   56px;
    --tabbar-h:   58px;
    --radius:     14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', Roboto, sans-serif;
    background: linear-gradient(175deg, #0f172a 0%, #0b1220 60%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- 레이아웃 ---------- */

.topbar {
    position: sticky; top: 0; z-index: 50;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 1rem 0;
    display: flex; align-items: center; gap: .75rem;
    background: rgba(11, 18, 32, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
}

.topbar__title {
    font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__title--brand {
    background: linear-gradient(120deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar__spacer { margin-left: auto; }

.iconbtn {
    width: 36px; height: 36px; flex: none;
    display: grid; place-items: center;
    border-radius: 10px; color: var(--muted);
}
.iconbtn:active { background: var(--surface-2); }
.iconbtn--on { color: var(--warn); }

.view {
    max-width: 720px; margin: 0 auto;
    padding: 1rem 1rem calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1.5rem);
}

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    background: rgba(11, 18, 32, 0.9);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
}
.tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: .68rem; color: var(--dim); font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar svg { width: 21px; height: 21px; }

/* ---------- 공통 조각 ---------- */

.section-title {
    font-size: .78rem; font-weight: 700; color: var(--dim);
    letter-spacing: .06em; text-transform: uppercase;
    margin: 1.5rem .25rem .6rem;
}
.section-title:first-child { margin-top: .25rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
}

.muted { color: var(--muted); }
.dim   { color: var(--dim); }
.num   { font-variant-numeric: tabular-nums; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge--buy   { background: rgba(34, 197, 94, .15);  color: #4ade80; }
.badge--sell  { background: rgba(239, 68, 68, .15);  color: #f87171; }
.badge--hold  { background: rgba(148, 163, 184, .14); color: var(--muted); }
.badge--warn  { background: rgba(245, 158, 11, .14); color: #fbbf24; }

.empty {
    text-align: center; color: var(--dim);
    padding: 3rem 1rem; font-size: .9rem; line-height: 1.7;
}

.spinner {
    width: 22px; height: 22px; margin: 3rem auto;
    border: 2px solid var(--line); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.errorbox {
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    border-radius: var(--radius);
    padding: 1rem; font-size: .88rem; line-height: 1.6;
}
.errorbox code { color: #fca5a5; font-size: .8rem; }

/* ---------- 시장 요약 ---------- */

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.summary__cell {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: .7rem .5rem; text-align: center;
    transition: border-color .15s, background .15s;
}
.summary__cell[aria-pressed="true"] { border-color: var(--accent); background: rgba(59, 130, 246, .12); }
.summary__n { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.summary__l { font-size: .7rem; color: var(--muted); margin-top: 2px; }

.stamp { font-size: .72rem; color: var(--dim); text-align: center; margin-top: .75rem; }

/* ---------- 검색 / 정렬 ---------- */

.search {
    display: flex; align-items: center; gap: .5rem;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 0 .75rem; margin-top: .75rem;
}
.search input {
    flex: 1; background: none; border: none; outline: none;
    padding: .7rem 0; font-size: .95rem;
}
.search input::placeholder { color: var(--dim); }
.search svg { width: 17px; height: 17px; color: var(--dim); flex: none; }

.chips { display: flex; gap: .4rem; overflow-x: auto; margin-top: .6rem; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none; padding: .35rem .75rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: .78rem; color: var(--muted); font-weight: 600;
}
.chip[aria-pressed="true"] { background: rgba(59, 130, 246, .16); border-color: var(--accent); color: #93c5fd; }

/* ---------- 종목 행 ---------- */

.rows { display: flex; flex-direction: column; gap: .4rem; }

.row {
    display: flex; align-items: center; gap: .75rem;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: .7rem .85rem;
    transition: background .12s;
}
.row:active { background: var(--surface-2); }
.row__main { flex: 1; min-width: 0; }
.row__sym { font-weight: 700; font-size: .92rem; letter-spacing: -.01em; }
.row__name {
    font-size: .76rem; color: var(--muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row__right { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row__price { font-weight: 600; font-size: .9rem; }
.row__win { font-size: .7rem; color: var(--dim); }

.more {
    display: block; width: 100%; margin-top: .75rem; padding: .8rem;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; color: var(--muted); font-size: .85rem; font-weight: 600;
}

/* ---------- 상세 ---------- */

.hero { padding: .25rem 0 1rem; }
.hero__name { font-size: 1.05rem; font-weight: 600; color: var(--muted); }
.hero__price { font-size: 2.1rem; font-weight: 700; letter-spacing: -.03em; margin-top: .35rem; }
.hero__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .6rem; }
.hero__tag { font-size: .72rem; color: var(--dim); background: var(--surface); border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px; }

.notice {
    display: flex; gap: .6rem; align-items: flex-start;
    background: rgba(245, 158, 11, .09); border: 1px solid rgba(245, 158, 11, .25);
    border-radius: var(--radius); padding: .8rem .9rem; margin-bottom: 1rem;
    font-size: .8rem; line-height: 1.6; color: #fcd34d;
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }

.chartcard { padding: 1rem .5rem .75rem; }
.chartcard__head { display: flex; align-items: center; justify-content: space-between; padding: 0 .5rem .5rem; }
.chartcard__title { font-size: .82rem; font-weight: 700; color: var(--muted); }
.chartcard__note { font-size: .72rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.chartbox { position: relative; touch-action: pan-y; }
.chartbox svg { display: block; width: 100%; }

.readout {
    position: absolute; top: 0; left: 0; pointer-events: none;
    background: rgba(15, 23, 42, .95); border: 1px solid var(--line);
    border-radius: 8px; padding: .35rem .55rem; font-size: .72rem;
    font-variant-numeric: tabular-nums; white-space: nowrap;
    opacity: 0; transition: opacity .1s;
}
.readout--on { opacity: 1; }
.readout b { display: block; font-size: .8rem; }

.ranges { display: flex; gap: .3rem; padding: 0 .5rem; margin-top: .5rem; }
.ranges button {
    flex: 1; padding: .4rem 0; border-radius: 8px;
    font-size: .76rem; font-weight: 600; color: var(--dim);
}
.ranges button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .85rem; }
.stat__l { font-size: .7rem; color: var(--dim); font-weight: 600; }
.stat__v { font-size: 1.05rem; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat__s { font-size: .7rem; color: var(--muted); margin-top: 2px; }

.tf { width: 100%; border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums; }
.tf th, .tf td { padding: .55rem .4rem; text-align: right; border-bottom: 1px solid var(--line); }
.tf th { font-size: .7rem; color: var(--dim); font-weight: 600; }
.tf th:first-child, .tf td:first-child { text-align: left; }
.tf tr:last-child td { border-bottom: none; }

.recbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin: .1rem 0 .5rem; }
.recbar span { display: block; }
.reclegend { display: flex; flex-wrap: wrap; gap: .5rem .9rem; font-size: .72rem; color: var(--muted); }
.reclegend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

.linklist { display: flex; flex-direction: column; }
.linklist > * {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .8rem .25rem; border-bottom: 1px solid var(--line);
    font-size: .88rem; text-align: left; width: 100%;
}
.linklist > *:last-child { border-bottom: none; }
.linklist code { font-size: .78rem; color: var(--muted); }

@media (min-width: 720px) {
    .stats { grid-template-columns: repeat(4, 1fr); }
}

/* 문서 화면(지원 / 방침) - 읽는 글이라 목록 화면보다 행간을 넓게 잡습니다. */
.prose { font-size: .87rem; line-height: 1.8; color: #cbd5e1; }
.prose b { color: var(--text); }
.prose ul { margin: .4rem 0 .4rem 1.1rem; }
.prose li { margin: .15rem 0; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
