:root {
  color-scheme: dark;
  --bg: #070b13;
  --surface: #0a0f1c;
  --surface-2: #111a2a;
  --surface-3: #182337;
  --border: #263148;
  --text: #f6f8fc;
  --muted: #8995aa;
  --lime: #c6ff4a;
  --lime-dark: #192514;
  --blue: #62d5ff;
  --orange: #ff8064;
  --amber: #ffc85b;
  --danger: #ff637e;
  --radius: 22px;
  --shadow: 0 18px 60px rgb(0 0 0 / 28%);
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 85% 0%, #17221a 0, transparent 28rem), var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.05em; }
h2 { margin-bottom: 6px; font-size: 1.35rem; letter-spacing: -.035em; }
h3 { margin-bottom: 4px; font-size: 1rem; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 12px 18px; border-radius: 12px; background: var(--lime); color: #071006; }
.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; }
.desktop-sidebar { display: none; }
.main-content { width: 100%; min-height: 100vh; padding-bottom: 96px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 12px 18px; border-bottom: 1px solid rgb(38 49 72 / 70%); background: rgb(7 11 19 / 82%); backdrop-filter: blur(18px); }
.mobile-brand, .brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--lime); color: #0a1208; font-size: .82rem; font-weight: 900; letter-spacing: -.06em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.local-badge { display: none; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; font-weight: 650; }
.local-badge span { width: 7px; height: 7px; border-radius: 999px; background: var(--lime); box-shadow: 0 0 12px var(--lime); }
.icon-button { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 14px; background: var(--lime); color: #0a1208; cursor: pointer; font-size: 1.5rem; font-weight: 500; }
.icon-button.subtle { background: var(--surface-3); color: var(--muted); }

#app { width: min(100%, 1220px); margin: 0 auto; padding: 24px 18px 40px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-header p { margin: 0; color: var(--muted); }
.eyebrow { display: block; margin-bottom: 8px; color: var(--lime); font-size: .7rem; font-weight: 800; letter-spacing: .13em; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 2px 14px; }
.section-heading h2 { margin: 0; }
.text-link { border: 0; padding: 4px; background: transparent; color: var(--lime); cursor: pointer; font-size: .82rem; font-weight: 700; }

.dashboard-grid { display: grid; gap: 16px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgb(24 35 55 / 90%), rgb(13 21 35 / 94%)); box-shadow: 0 10px 30px rgb(0 0 0 / 12%); }
.hero-card { position: relative; overflow: hidden; min-height: 260px; padding: 26px; background: linear-gradient(135deg, #1a2b33, #142019 68%, #1d281a); }
.hero-card::after { content: ""; position: absolute; right: -70px; bottom: -90px; width: 260px; height: 260px; border: 46px solid rgb(198 255 74 / 8%); border-radius: 50%; }
.hero-card > * { position: relative; z-index: 1; }
.countdown { margin: 6px 0 4px; font-size: clamp(3rem, 11vw, 5.3rem); font-weight: 850; line-height: 1; letter-spacing: -.08em; }
.hero-meta { color: var(--muted); font-weight: 600; }
.progress-track { height: 9px; margin: 28px 0 12px; overflow: hidden; border-radius: 999px; background: #273249; }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #b2ec44, #dbff7e); }
.progress-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; }

.metric-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric-card { min-height: 132px; padding: 20px; }
.metric-label { display: block; margin-bottom: 12px; color: var(--muted); font-size: .77rem; font-weight: 650; }
.metric-value { font-size: clamp(1.7rem, 7vw, 2.5rem); font-weight: 820; letter-spacing: -.06em; }
.metric-row .metric-value { white-space: nowrap; }
.metric-value small { color: var(--muted); font-size: .85rem; font-weight: 600; letter-spacing: 0; }
.metric-note { margin: 7px 0 0; color: var(--muted); font-size: .75rem; }
.status-warning { color: var(--orange); }
.status-good { color: var(--lime); }

.today-card { grid-column: 1 / -1; padding: 22px; }
.workout-heading { display: flex; align-items: flex-start; gap: 15px; }
.workout-icon { display: grid; flex: 0 0 50px; place-items: center; width: 50px; height: 50px; border-radius: 16px; background: var(--lime); color: #0a1208; font-weight: 900; }
.workout-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.chip { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: rgb(255 255 255 / 2%); font-size: .75rem; font-weight: 650; }
.chip.lime { border-color: rgb(198 255 74 / 24%); background: rgb(198 255 74 / 8%); color: var(--lime); }
.chip.orange { border-color: rgb(255 128 100 / 24%); background: rgb(255 128 100 / 8%); color: var(--orange); }
.button { min-height: 46px; padding: 0 18px; border: 1px solid transparent; border-radius: 15px; cursor: pointer; font-weight: 760; }
.button.primary { background: var(--lime); color: #0a1208; }
.button.secondary { border-color: var(--border); background: var(--surface-3); color: var(--text); }
.button.danger { border-color: rgb(255 99 126 / 35%); background: rgb(255 99 126 / 8%); color: var(--danger); }
.button.full { width: 100%; }
.button:focus-visible, .icon-button:focus-visible, .nav-link:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgb(98 213 255 / 45%); outline-offset: 2px; }

.alert-card { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 14px; padding: 18px; border-color: rgb(255 128 100 / 28%); background: linear-gradient(135deg, rgb(255 128 100 / 9%), var(--surface-2)); }
.alert-dot { flex: 0 0 12px; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 18px rgb(255 128 100 / 60%); }
.alert-card p { margin: 5px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }

.week-toolbar { display: grid; gap: 12px; margin-bottom: 16px; padding: 16px; }
.week-toolbar label { color: var(--muted); font-size: .78rem; font-weight: 650; }
select, input, textarea { width: 100%; margin-top: 7px; border: 1px solid var(--border); border-radius: 13px; background: #0e1625; color: var(--text); }
select, input { min-height: 44px; padding: 0 12px; }
textarea { padding: 12px; resize: vertical; }
.week-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.summary-cell { padding: 14px; border-radius: 16px; background: rgb(255 255 255 / 3%); }
.summary-cell span { display: block; color: var(--muted); font-size: .72rem; }
.summary-cell strong { display: block; margin-top: 7px; font-size: .92rem; }

.day-list { display: grid; gap: 10px; }
.day-card { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 82px; padding: 12px 14px; }
.day-card.key { border-color: rgb(198 255 74 / 27%); background: linear-gradient(130deg, rgb(198 255 74 / 8%), var(--surface-2)); }
.day-badge { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: #242e40; font-weight: 800; }
.day-card.key .day-badge { background: var(--lime); color: #0a1208; }
.day-detail { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.day-distance { color: var(--muted); font-size: .8rem; font-weight: 700; }

.records-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.record-card { padding: 16px 14px; }
.record-card span { color: var(--muted); font-size: .7rem; font-weight: 700; }
.record-card strong { display: block; margin: 8px 0 6px; font-size: clamp(1.15rem, 5vw, 1.7rem); letter-spacing: -.05em; }
.record-card small { color: var(--orange); }
.record-card.goal small { color: var(--lime); }

.readiness-card { display: grid; gap: 18px; padding: 22px; }
.readiness-score { --score: 46; display: grid; place-items: center; width: 122px; height: 122px; margin: auto; border-radius: 50%; background: conic-gradient(var(--lime) calc(var(--score) * 1%), #263249 0); }
.readiness-score::before { content: ""; grid-area: 1 / 1; width: 94px; height: 94px; border-radius: 50%; background: var(--surface-2); }
.readiness-score strong, .readiness-score small { position: relative; grid-area: 1 / 1; }
.readiness-score strong { margin-top: -12px; font-size: 2rem; }
.readiness-score small { margin-top: 35px; color: var(--muted); }
.readiness-copy p { color: var(--muted); line-height: 1.65; }

.checkpoint-list, .log-list { display: grid; gap: 10px; }
.checkpoint { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; padding: 16px; }
.checkpoint-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--border); }
.checkpoint:first-child .checkpoint-dot { background: var(--lime); box-shadow: 0 0 12px rgb(198 255 74 / 50%); }
.checkpoint p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.checkpoint time { color: var(--muted); font-size: .75rem; }
.log-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 16px; }
.log-item p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.log-metric { text-align: right; }
.log-metric strong { display: block; color: var(--lime); }
.empty-state { padding: 36px 20px; text-align: center; }
.empty-state p { color: var(--muted); }

.profile-layout { display: grid; gap: 16px; }
.profile-card { padding: 22px; }
.profile-card .form-grid { margin-top: 16px; }
.form-grid { display: grid; gap: 14px; }
.form-grid label { color: var(--muted); font-size: .78rem; font-weight: 650; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.data-note { padding: 18px; color: var(--muted); font-size: .82rem; line-height: 1.6; }

.mobile-nav { position: fixed; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); min-height: 68px; padding: 7px; border: 1px solid rgb(58 70 93 / 80%); border-radius: 22px; background: rgb(17 26 42 / 92%); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.nav-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border-radius: 15px; color: var(--muted); font-size: .68rem; font-weight: 700; }
.nav-link svg { width: 20px; height: 20px; }
.nav-link.active { background: rgb(198 255 74 / 10%); color: var(--lime); }

.app-dialog { width: min(92vw, 620px); padding: 0; border: 1px solid var(--border); border-radius: 26px; background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgb(2 5 11 / 75%); backdrop-filter: blur(6px); }
.dialog-card { padding: 22px; }
.dialog-header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; right: 20px; bottom: 100px; z-index: 60; max-width: 320px; padding: 13px 17px; border: 1px solid rgb(198 255 74 / 30%); border-radius: 14px; background: #192514; color: var(--text); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (min-width: 700px) {
  .local-badge { display: inline-flex; }
  #app { padding: 36px 30px 60px; }
  .dashboard-grid { grid-template-columns: 1.4fr .9fr; }
  .hero-card { grid-row: span 2; min-height: 332px; }
  .metric-row { grid-template-columns: 1fr; }
  .today-card { grid-column: auto; }
  .alert-card { grid-column: auto; }
  .week-toolbar { grid-template-columns: .75fr 1.25fr; align-items: end; }
  .week-summary { grid-template-columns: repeat(4, 1fr); }
  .readiness-card { grid-template-columns: 150px 1fr; align-items: center; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .span-2 { grid-column: span 2; }
  .profile-layout { grid-template-columns: 1.25fr .75fr; }
}

@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .desktop-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 28px 20px; border-right: 1px solid var(--border); background: rgb(10 15 28 / 82%); backdrop-filter: blur(22px); }
  .brand { padding: 0 8px; }
  .brand strong, .brand small { display: block; }
  .brand strong { font-size: 1.15rem; }
  .brand small { margin-top: 2px; color: var(--muted); font-size: .56rem; letter-spacing: .14em; }
  .side-nav { display: grid; gap: 8px; margin-top: 54px; }
  .side-nav .nav-link { flex-direction: row; justify-content: flex-start; min-height: 48px; padding: 0 14px; gap: 12px; font-size: .86rem; }
  .sidebar-race { margin-top: auto; padding: 18px; border: 1px solid rgb(198 255 74 / 18%); border-radius: 18px; background: rgb(198 255 74 / 5%); }
  .sidebar-race strong, .sidebar-race span { display: block; }
  .sidebar-race strong { font-size: .87rem; }
  .sidebar-race span { margin-top: 7px; color: var(--muted); font-size: .75rem; }
  .mobile-brand, .mobile-nav { display: none; }
  .main-content { padding-bottom: 0; }
  .topbar { justify-content: flex-end; padding-right: 32px; }
  #app { padding: 44px 40px 70px; }
  .dashboard-grid { grid-template-columns: 1.45fr .8fr .8fr; }
  .hero-card { grid-column: span 2; }
  .metric-row { grid-template-columns: 1fr 1fr; }
  .today-card { grid-column: span 2; }
  .alert-card { grid-column: auto; }
  .day-list { grid-template-columns: 1fr 1fr; }
  .day-card:last-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
