/* ════════════════════════════════════════════════════════════
   AI Running Planner — Global CSS
   Design Tokens + Layout + Components + Utilities
   ════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root,
:root[data-theme="light"] {
    --bg:        #FAFAFA;
    --surface:   #FFFFFF;
    --surface-2: #F4F4F6;
    --border:    #ECECEF;

    --text:      #1D1D1F;
    --muted:     #6E6E73;
    --faint:     #B8B8BD;

    --accent:    #4D8DFF;
    --accent-ink:#0A56D6;

    --coach-bg:   #DFF6F1;  --coach-ink:   #1F8E7D;
    --plan-bg:    #E3EEFF;  --plan-ink:    #2F6FE0;
    --tt-bg:      #FFE7DA;  --tt-ink:      #E06A36;
    --profile-bg: #ECE3FF;  --profile-ink: #7A56F0;

    --good:    #1FA34A;
    --warn:    #B8780C;
    --danger:  #E0413B;
    --lime:    #1FA34A;

    --nav-bg: rgba(255,255,255,.78);
    --shadow-sm: 0 1px 2px rgba(20,20,30,.04), 0 1px 8px rgba(20,20,30,.03);
    --shadow-md: 0 4px 20px rgba(20,20,30,.06);
    --shadow-lift: 0 8px 30px rgba(20,20,30,.10);
}

:root[data-theme="dark"] {
    --bg:        #0E0E11;
    --surface:   #1A1A1E;
    --surface-2: #232328;
    --border:    #2E2E34;

    --text:      #F5F5F7;
    --muted:     #A1A1A8;
    --faint:     #5C5C63;

    --accent:    #6FA3FF;
    --accent-ink:#9EC1FF;

    --coach-bg:   #143430;  --coach-ink:   #5FE0CB;
    --plan-bg:    #16263F;  --plan-ink:    #7FB0FF;
    --tt-bg:      #3A2418;  --tt-ink:      #FFAB7E;
    --profile-bg: #251B40;  --profile-ink: #C2A8FF;

    --good:    #4ADE80;
    --warn:    #FBBF24;
    --danger:  #FF6B6B;
    --lime:    #4ADE80;

    --nav-bg: rgba(20,20,24,.78);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 1px 8px rgba(0,0,0,.2);
    --shadow-md: 0 4px 20px rgba(0,0,0,.35);
    --shadow-lift: 0 8px 30px rgba(0,0,0,.45);
}

:root {
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 24px;
    --r:    20px;
    --font-display: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-mono:    'DM Mono', monospace;
    --nav-h: 64px;

    /* ── 타이포그래피 스케일 (여기서 한번에 조절) ── */
    --fs-page-title:   30px;   /* 페이지 h1 */
    --fs-section-title:20px;   /* 섹션 타이틀 ("이번 주 80/20 분석") */
    --fs-card-title:   18px;   /* 카드 타이틀 */
    --fs-body:         16px;   /* 본문 기본 */
    --fs-body-sm:      15px;   /* 보조 텍스트 ("목표 80%") */
    --fs-label:        14px;   /* 라벨 ("이번 주 거리") */
    --fs-stat:         38px;   /* stat-val 큰 숫자 ("12km") */
    --fs-stat-sm:      22px;   /* 작은 stat ("100%") */
    --fs-item-title:   18px;   /* 목록 아이템 제목 */
    --fs-item-sub:     15px;   /* 목록 아이템 부제목 */
    --fs-meta:         14px;   /* 날짜/작성자 등 메타 */
    --fs-nav:          17px;   /* 상단 nav */
    --fs-btn:          15px;   /* 버튼 */
    --fs-badge:        13px;   /* 뱃지/pill */
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; color-scheme: light dark; }

body {
    font-family: var(--font-display);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-top: var(--nav-h);
    letter-spacing: -0.01em;
    font-size: var(--fs-body);
    line-height: 1.6;
    transition: background .25s ease, color .25s ease;
}

/* ── Top Nav ── */
.top-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 8px;
    transition: background .25s ease, border-color .25s ease;
    overflow: visible;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 18px;
    color: var(--text);
    text-decoration: none;
    margin-right: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}
.nav-logo .nav-logo-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent) 0%, #8C6CFF 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow: visible;
    scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 100px;
    font-size: var(--fs-nav);
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    transition: all .18s cubic-bezier(.4,0,.2,1);
    flex-shrink: 0;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface-2); }

.nav-link.nav-coach.active   { color: var(--coach-ink);   background: var(--coach-bg); }
.nav-link.nav-plan.active    { color: var(--plan-ink);    background: var(--plan-bg); }
.nav-link.nav-tt.active      { color: var(--tt-ink);      background: var(--tt-bg); }
.nav-link.nav-profile.active { color: var(--profile-ink); background: var(--profile-bg); }

/* ── Nav 드롭다운 ── */
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
    background: none; border: none; font-family: var(--font-display);
    font-size: var(--fs-nav); font-weight: 600;
    color: var(--muted); padding: 8px 14px; border-radius: 10px;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.nav-dropdown-btn:hover,
.nav-dropdown-btn.active { background: var(--surface-2); color: var(--text); }
.nav-dropdown-panel {
    display: none;
    position: absolute; top: calc(100% + 8px); left: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 6px;
    min-width: 280px; z-index: 1100;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.nav-dropdown-panel.open { display: block; }
.nav-dropdown-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-radius: 10px; font-size: 16px; font-weight: 600;
    color: var(--muted); text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.nav-dropdown-item:hover, .nav-dropdown-item.active {
    background: var(--surface-2); color: var(--text);
}
.nav-icon { font-size: 21px; line-height: 1; }

.nav-right {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-badge {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}
.nav-badge strong { color: var(--accent); font-weight: 500; }

/* ── Theme toggle ── */
.theme-toggle {
    width: 40px; height: 40px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 17px;
    color: var(--text);
    transition: all .18s;
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-2); transform: scale(1.05); }

/* ── Page wrapper ── */
.page-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 72px;
}

/* ── 페이지 제목 ── */
.page-title {
    font-size: var(--fs-page-title);
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: background .25s ease, border-color .25s ease;
}
.card-title {
    font-size: var(--fs-card-title);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Stat cards ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: background .25s ease, border-color .25s ease;
}
.stat-label {
    font-size: var(--fs-label);
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.stat-val {
    font-size: var(--fs-stat);
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-mono);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.stat-val.accent  { color: var(--accent); }
.stat-val.good    { color: var(--good); }
.stat-val.warn    { color: var(--warn); }
.stat-val.danger  { color: var(--danger); }
.stat-val.tt      { color: var(--tt-ink); }
.stat-val.profile { color: var(--profile-ink); }
.stat-diff {
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}
.stat-diff.up   { color: var(--good); }
.stat-diff.down { color: var(--danger); }

/* ── Section header ── */
.section-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.section-title {
    font-size: var(--fs-section-title);
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-link {
    font-size: var(--fs-body-sm);
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}
.section-link:hover { color: var(--accent-ink); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 24px;
    border-radius: 100px;
    font-size: var(--fs-btn);
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all .18s cubic-bezier(.4,0,.2,1);
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font-display);
}
.btn-primary   { background: var(--text);         color: var(--bg); }
.btn-secondary { background: var(--surface-2);    color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm   { padding: 9px 18px; font-size: 14px; }
.btn-lg   { padding: 18px 44px; font-size: 18px; }
.btn-coach   { background: var(--coach-ink);   color: #fff; }
.btn-plan    { background: var(--plan-ink);    color: #fff; }
.btn-tt      { background: var(--tt-ink);      color: #fff; }
.btn-profile { background: var(--profile-ink); color: #fff; }
.btn-lime    { background: var(--lime);        color: #fff; }
.btn:hover { filter: brightness(1.05); }
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); box-shadow: var(--shadow-lift); }

/* ── Pills / badges ── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border-radius: 100px;
    font-size: var(--fs-badge);
    font-weight: 700;
}
.pill-good   { background: rgba(31,163,74,.14);  color: var(--good); }
.pill-warn   { background: rgba(184,120,12,.14); color: var(--warn); }
.pill-danger { background: rgba(224,65,59,.14);  color: var(--danger); }
.pill-muted  { background: var(--surface-2);     color: var(--muted); }

/* ── Utils ── */
.hidden { display: none !important; }
.mt4  { margin-top: 4px; }
.mt8  { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mt24 { margin-top: 24px; }
.mt32 { margin-top: 32px; }
.mb8  { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; }
.gap8  { gap: 8px; }
.gap12 { gap: 12px; }
.gap16 { gap: 16px; }
.text-muted { color: var(--muted); font-size: var(--fs-meta); }
.text-mono  { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.good   { color: var(--good); }
.warn   { color: var(--warn); }
.danger { color: var(--danger); }
.accent { color: var(--accent); }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Responsive ── */
@media (max-width: 720px) {
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .page-wrap { padding: 20px 16px 56px; }
    .nav-badge { display: none; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-val  { font-size: 28px; }
    .card { padding: 20px; border-radius: var(--r-md); }
    .top-nav { padding: 0 14px; }
    body { font-size: 16px; }
    .nav-links { display: none; }
}

/* ── 햄버거 버튼 ── */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px; height: 36px;
    background: none; border: none;
    cursor: pointer; padding: 4px;
    border-radius: var(--r-sm);
}
.hamburger span {
    display: block; height: 2px; width: 22px;
    background: var(--text); border-radius: 2px;
    transition: all .25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media (max-width: 600px) {
    .hamburger { display: flex; }
}

/* ── 모바일 풀스크린 메뉴 ── */
.mobile-menu {
    display: none;
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
}
.mobile-menu.open { display: block; }
.mobile-menu-inner {
    position: absolute; top: 0; right: 0;
    width: min(320px, 85vw); height: 100%;
    background: var(--surface);
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0,0,0,.2);
    padding-bottom: 40px;
}
.mobile-menu-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    background: var(--surface);
}
.mobile-menu-item {
    display: flex; align-items: center;
    padding: 16px 20px;
    font-size: 16px; font-weight: 600;
    color: var(--text); text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.mobile-menu-item:hover { background: var(--surface-2); }
.mobile-menu-sub {
    padding-left: 32px;
    font-size: 15px; font-weight: 500;
    color: var(--muted);
}
.mobile-menu-divider {
    padding: 10px 20px 6px;
    font-size: 12px; font-weight: 700;
    color: var(--muted); letter-spacing: .05em;
    text-transform: uppercase;
    background: var(--surface-2);
}
