/* ========== Reset & Base ========== */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Noto Sans KR',-apple-system,BlinkMacSystemFont,sans-serif;background:#F9FAFB;color:#111827;-webkit-font-smoothing:antialiased;overflow:hidden;height:100dvh}

/* ========== Layout (mobile-first) ========== */
.app{display:flex;flex-direction:column;height:100dvh}

/* ── Header ── */
.header{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.08);z-index:30;flex-shrink:0}
.header-inner{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;max-width:1280px;margin:0 auto}
.header-left{display:flex;align-items:center;gap:8px;min-width:0}
.back-btn{display:none;width:36px;height:36px;border:none;border-radius:50%;background:transparent;cursor:pointer;font-size:18px;color:#374151;flex-shrink:0;align-items:center;justify-content:center}
.back-btn:hover{background:#F3F4F6}
.back-btn.visible{display:flex}
.header-title{font-size:17px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.badge{display:flex;align-items:center;gap:6px;background:linear-gradient(135deg,#3B82F6,#8B5CF6);color:#fff;padding:5px 12px;border-radius:999px;font-size:13px;font-weight:600;flex-shrink:0}
.badge-bar{width:40px;height:6px;background:rgba(255,255,255,.3);border-radius:999px;overflow:hidden}
.badge-bar-fill{height:100%;background:#fff;border-radius:999px;transition:width .4s}

/* ── Map ── */
.map-wrap{position:relative;flex:1;min-height:0}
#map{width:100%;height:100%}

/* ── Bottom Panel ── */
.panel{background:#fff;border-top:1px solid #E5E7EB;flex-shrink:0;overflow-y:auto;max-height:45dvh;transition:max-height .3s}
.panel.collapsed{max-height:0;border-top:none}

/* ── Route List (overview) ── */
.route-list{padding:8px}
.route-card{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;cursor:pointer;transition:background .15s}
.route-card:hover{background:#F3F4F6}
.route-card:active{background:#E5E7EB}
.route-emoji{width:42px;height:42px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:22px;flex-shrink:0}
.route-info{flex:1;min-width:0}
.route-name{font-size:14px;font-weight:600;margin-bottom:2px}
.route-meta{font-size:11px;color:#9CA3AF}
.route-progress{width:60px;text-align:right;flex-shrink:0}
.route-progress .pct{font-size:14px;font-weight:700}
.route-pbar{height:4px;background:#E5E7EB;border-radius:999px;margin-top:4px;overflow:hidden}
.route-pbar-fill{height:100%;border-radius:999px;transition:width .4s}

/* ── Site List (detail) ── */
.site-header{padding:12px 16px;border-bottom:1px solid #F3F4F6;position:sticky;top:0;background:#fff;z-index:5}
.site-header h3{font-size:15px;font-weight:700;margin-bottom:6px}
.site-pbar{height:5px;background:#E5E7EB;border-radius:999px;overflow:hidden}
.site-pbar-fill{height:100%;border-radius:999px;transition:width .4s}
.site-pinfo{display:flex;justify-content:space-between;font-size:11px;margin-bottom:4px;color:#6B7280}
.site-pinfo .val{font-weight:700}

.site-list{padding:4px 8px 8px}
.site-item{display:flex;align-items:center;gap:10px;padding:10px;border-radius:10px;cursor:pointer;transition:background .12s}
.site-item:hover{background:#F9FAFB}
.site-item.active{background:#EFF6FF}
.site-num{width:26px;height:26px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;color:#fff;flex-shrink:0}
.site-num.pending{background:#EF4444}
.site-num.done{background:#D1D5DB}
.site-body{flex:1;min-width:0}
.site-name{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.site-item.visited .site-name{color:#9CA3AF;text-decoration:line-through}
.site-region{font-size:11px;color:#9CA3AF;margin-top:1px}
.site-actions{display:flex;gap:4px;flex-shrink:0}
.btn{padding:5px 10px;border:none;border-radius:8px;font-size:11px;font-weight:600;cursor:pointer;transition:all .12s;white-space:nowrap}
.btn-primary{background:#3B82F6;color:#fff}
.btn-primary:hover{background:#2563EB}
.btn-ghost{background:#F3F4F6;color:#6B7280}
.btn-ghost:hover{background:#E5E7EB}
.btn-green{background:#F0FDF4;color:#16A34A}
.btn-green:hover{background:#DCFCE7}

/* ── Map overlays ── */
.map-legend{position:absolute;bottom:12px;left:12px;background:rgba(255,255,255,.92);backdrop-filter:blur(6px);border-radius:10px;padding:8px 12px;box-shadow:0 1px 8px rgba(0,0,0,.1);z-index:10;font-size:11px;display:flex;gap:10px;color:#6B7280}
.legend-dot{width:10px;height:10px;border-radius:50%;display:inline-block;vertical-align:middle;margin-right:3px}

/* ── Loading / Error ── */
.overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;z-index:15}
.overlay-loading{background:rgba(255,255,255,.85)}
.overlay-error{background:#FEF2F2}
.spinner{width:28px;height:28px;border:3px solid #3B82F6;border-top-color:transparent;border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ========== Desktop (≥768px) ========== */
@media(min-width:768px){
  .map-wrap{flex:1}
  .panel{position:absolute;top:12px;right:12px;bottom:12px;width:340px;max-height:none;border-top:none;border-radius:16px;box-shadow:0 4px 20px rgba(0,0,0,.12);z-index:12;overflow-y:auto}
  .panel.collapsed{display:none}
  .map-wrap{position:relative;flex:1}
}
