:root {
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #EAEEF3;
  --line: #DCE2E9;
  --text: #10151B;
  --text-dim: #5B6472;
  --accent: #0EA5E9;
  --accent-ink: #FFFFFF;
  --accent-soft: #E0F5FE;
  --safe: #15803D;
  --caution: #A16207;
  --warning: #C2410C;
  --danger: #BE123C;
  --safe-soft: rgba(21,128,61,0.10);
  --caution-soft: rgba(161,98,7,0.10);
  --warning-soft: rgba(194,65,12,0.10);
  --danger-soft: rgba(190,18,60,0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0E13;
    --surface: #121822;
    --surface-2: #1A222E;
    --line: #262F3B;
    --text: #EEF2F6;
    --text-dim: #8B96A5;
    --accent: #4CC9F0;
    --accent-ink: #06222C;
    --accent-soft: rgba(76,201,240,0.12);
    --safe: #34D399;
    --caution: #FBBF24;
    --warning: #FB923C;
    --danger: #FB4570;
    --safe-soft: rgba(52,211,153,0.13);
    --caution-soft: rgba(251,191,36,0.13);
    --warning-soft: rgba(251,146,60,0.14);
    --danger-soft: rgba(251,69,112,0.15);
  }
}
:root[data-theme="dark"] {
  --bg: #0A0E13;
  --surface: #121822;
  --surface-2: #1A222E;
  --line: #262F3B;
  --text: #EEF2F6;
  --text-dim: #8B96A5;
  --accent: #4CC9F0;
  --accent-ink: #06222C;
  --accent-soft: rgba(76,201,240,0.12);
  --safe: #34D399;
  --caution: #FBBF24;
  --warning: #FB923C;
  --danger: #FB4570;
  --safe-soft: rgba(52,211,153,0.13);
  --caution-soft: rgba(251,191,36,0.13);
  --warning-soft: rgba(251,146,60,0.14);
  --danger-soft: rgba(251,69,112,0.15);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.app-body { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.screen-pad {
  padding: 22px 20px calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}

.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-sm { width: 14px; height: 14px; }

.greet-dim { font-size: 13px; color: var(--text-dim); }
.greet-h { font-size: 22px; font-weight: 700; margin: 4px 0 0; letter-spacing: -0.01em; line-height: 1.3; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 15px;
  border-radius: 16px; padding: 15px; border: none; cursor: pointer;
}
.btn-primary.full { width: 100%; }
.btn-outline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; color: var(--text);
  font-weight: 600; font-size: 14px;
  border-radius: 14px; padding: 13px; border: 1.3px solid var(--line);
  cursor: pointer;
}
.btn-outline.full { width: 100%; }
.btn-outline.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-row { display: flex; gap: 8px; }

.card { background: var(--surface); border-radius: 16px; padding: 16px; border: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-label { font-size: 12px; font-weight: 700; color: var(--text-dim); letter-spacing: 0.03em; }
.section-label { font-size: 12px; font-weight: 700; color: var(--text-dim); letter-spacing: 0.03em; }
.list-card { padding: 4px 16px; }

.streak { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--caution); font-weight: 600; }

.stat-row { display: flex; }
.stat-col { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stat-col + .stat-col { border-left: 1px solid var(--line); padding-left: 14px; margin-left: 14px; }
.stat-v { font-size: 19px; font-weight: 600; }
.stat-v.safe { color: var(--safe); }
.stat-v .unit { font-size: 12px; font-weight: 500; margin-left: 1px; }
.stat-l { font-size: 11px; color: var(--text-dim); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 4px 10px 4px 8px; border-radius: 100px; }
.chip .d { width: 6px; height: 6px; border-radius: 50%; }
.chip.safe { color: var(--safe); background: var(--safe-soft); }
.chip.caution { color: var(--caution); background: var(--caution-soft); }
.chip.warning { color: var(--warning); background: var(--warning-soft); }
.chip.danger { color: var(--danger); background: var(--danger-soft); }
.chip.neutral { color: var(--text-dim); background: var(--surface-2); }
.chip .d.safe { background: var(--safe); }
.chip .d.caution { background: var(--caution); }
.chip .d.warning { background: var(--warning); }
.chip .d.danger { background: var(--danger); }

.list-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-l { display: flex; flex-direction: column; gap: 3px; }
.list-l .t { font-size: 13.5px; font-weight: 600; }
.list-l .s { font-size: 11.5px; color: var(--text-dim); }

.row-between { display: flex; justify-content: space-between; align-items: center; }

.timer { font-size: 42px; font-weight: 600; letter-spacing: -0.01em; text-align: center; margin: 4px 0 0; }
.timer-l { text-align: center; font-size: 11px; color: var(--text-dim); letter-spacing: 0.06em; }

.map {
  position: relative; height: 180px; border-radius: 16px; overflow: hidden;
  background:
    radial-gradient(140px 100px at 70% 20%, var(--accent-soft), transparent 70%),
    repeating-linear-gradient(115deg, var(--surface-2) 0 26px, var(--surface) 26px 52px);
  border: 1px solid var(--line);
}
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend .li { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); }
.legend .sw { width: 9px; height: 9px; border-radius: 2px; }

.risk-banner { border-radius: 14px; padding: 13px 15px; display: flex; align-items: center; gap: 10px; transition: background-color .2s, color .2s; }
.risk-banner .icon { width: 22px; height: 22px; }
.risk-banner .t1 { font-size: 14px; font-weight: 700; }
.risk-banner .t2 { font-size: 11.5px; opacity: 0.8; margin-top: 1px; }
.risk-banner.safe { background: var(--safe-soft); color: var(--safe); }
.risk-banner.caution { background: var(--caution-soft); color: var(--caution); }
.risk-banner.warning { background: var(--warning-soft); color: var(--warning); }
.risk-banner.danger { background: var(--danger-soft); color: var(--danger); }

.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring-score { font-size: 26px; font-weight: 700; }
.ring-label { font-size: 11px; color: var(--text-dim); }
.grid2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2x2 .cell { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); }
.grid2x2 .cell .v { font-size: 17px; font-weight: 700; }
.grid2x2 .cell .l { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.sev-row { display: flex; gap: 10px; padding: 10px 0; align-items: flex-start; }
.sev-row + .sev-row { border-top: 1px solid var(--line); }
.sev-bar { width: 3px; border-radius: 2px; align-self: stretch; flex: none; min-height: 32px; }
.sev-body .time { font-size: 11px; color: var(--text-dim); }
.sev-body .desc { font-size: 13px; font-weight: 500; margin-top: 2px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.navitem { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-dim); }
.navitem.active { color: var(--accent); }
.navitem span { font-size: 10.5px; font-weight: 600; }

/* ---------- auth pages ---------- */
.auth-body { background: var(--bg); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px; display: flex; flex-direction: column; gap: 18px; }
.auth-brand { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); }
.auth-title { font-size: 20px; font-weight: 700; line-height: 1.4; margin: 0; text-wrap: balance; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-switch { font-size: 13px; color: var(--text-dim); text-align: center; }
.auth-switch a { color: var(--accent); font-weight: 600; }
.auth-error { font-size: 13px; color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 10px 12px; }

.field-label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field-label input {
  font-family: inherit; font-size: 14.5px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; outline: none;
}
.field-label input:focus { border-color: var(--accent); }
.field-with-btn { display: flex; gap: 8px; }
.field-with-btn input { flex: 1; min-width: 0; }
.btn-check { flex: none; font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  border: none; border-radius: 10px; padding: 0 14px; cursor: pointer; }
.field-hint { font-size: 11.5px; min-height: 14px; color: var(--text-dim); }
.field-hint.ok { color: var(--safe); }
.field-hint.warn { color: var(--danger); }

/* ---------- settings ---------- */
.settings-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.theme-toggle { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.theme-toggle button {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 8px; cursor: pointer;
}
.theme-toggle button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

@media (prefers-reduced-motion: no-preference) {
  .pulse-ring { animation: pulse 2.2s ease-out infinite; }
}
@keyframes pulse {
  0% { opacity: 0.55; transform: scale(0.7); }
  70% { opacity: 0; transform: scale(2.1); }
  100% { opacity: 0; transform: scale(2.1); }
}

/* ---------- 리포트: 달력 ---------- */
.calendar-nav { display: flex; align-items: center; justify-content: space-between; }
.calendar-nav .month-label { font-size: 14px; font-weight: 700; }
.calendar-nav a { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 9px; background: var(--surface-2); color: var(--text); }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 12px; }
.calendar-weekdays span { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--text-dim); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 6px; }
.calendar-day {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--text);
}
.calendar-day.empty { visibility: hidden; }
.calendar-day.today { box-shadow: inset 0 0 0 1.3px var(--accent); }
.calendar-day.selected { background: var(--accent); color: var(--accent-ink); }
.calendar-day .dot {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%;
}
.calendar-day.selected .dot { background: var(--accent-ink); opacity: 0.7; }

.day-ride-card { display: block; padding: 12px 14px; }
.day-ride-card + .day-ride-card { border-top: 1px solid var(--line); }
.day-ride-card .row-between { align-items: flex-start; }

/* ---------- 리포트 상세: 실제 지도(Leaflet) ---------- */
#route-map {
  height: 220px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line);
  background: var(--surface-2);
}
#route-map.map-dark .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.8);
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface); color: var(--text);
}
.leaflet-popup-content { font-family: 'IBM Plex Sans KR', sans-serif; font-size: 12.5px; margin: 8px 10px; }
.leaflet-control-attribution { font-size: 9.5px !important; }
