/* qimen3ai · Compass V3 — Map-first mobile (kimontonko-style) */

* { box-sizing: border-box }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}
.cmp-body {
  background: #0a0e1a;
  color: #f8fafc;
  font-family: 'Inter', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* === Header === */
.cmp-topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(10,14,26,0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(200,164,92,0.25);
}
.cmp-back {
  color: #c8a45c; font-size: 22px; text-decoration: none;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.cmp-back:hover { background: rgba(200,164,92,0.12) }
.cmp-topbar-title {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.cmp-topbar-title strong { font-size: 15px; color: #f8fafc; font-weight: 700 }
.cmp-topbar-title small { font-size: 11px; color: #c8a45c }
.cmp-icon-btn {
  background: transparent; color: #c8a45c;
  border: 1px solid rgba(200,164,92,0.35);
  width: 36px; height: 36px; border-radius: 6px;
  font-size: 16px; cursor: pointer;
}
.cmp-icon-btn:hover { background: rgba(200,164,92,0.12) }

/* === Tab + meta === */
.cmp-subbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: rgba(15,23,41,0.5);
  border-bottom: 1px solid rgba(200,164,92,0.12);
  gap: 10px;
}
.cmp-tabs { display: flex; gap: 4px }
.cmp-tab {
  background: transparent;
  border: 1px solid rgba(148,163,184,0.18);
  color: #94a3b8;
  padding: 5px 12px; border-radius: 6px;
  font-size: 12px; cursor: pointer;
}
.cmp-tab.active {
  background: rgba(200,164,92,0.18);
  border-color: #c8a45c;
  color: #c8a45c;
}
.cmp-meta-time {
  font-size: 11px; color: #c8a45c;
}

/* === Filter === */
.cmp-controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 14px;
  background: rgba(10,14,26,0.5);
  border-bottom: 1px solid rgba(200,164,92,0.1);
}
.cmp-ctrl { display: flex; flex-direction: column; gap: 3px }
.cmp-ctrl span {
  font-size: 10px; color: #c8a45c; font-weight: 600; letter-spacing: 0.5px;
}
.cmp-ctrl select {
  background: rgba(10,14,26,0.7); color: #f8fafc;
  border: 1px solid rgba(200,164,92,0.3);
  border-radius: 6px; padding: 7px 9px; font-size: 13px;
  width: 100%;
}

/* === Views === */
.cmp-view { display: none; flex: 1 }
.cmp-view.active { display: block }

/* === Map === */
.cmp-map-wrap {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 560px;
  background: #e8eaed;
}
@media (min-width: 768px) {
  .cmp-map-wrap { height: 72vh }
}
.cmp-map {
  width: 100%; height: 100%;
  background: #e8eaed;
}
.leaflet-container {
  background: #e8eaed !important;
  font-family: 'Inter', sans-serif !important;
}
.leaflet-control-attribution {
  font-size: 9px;
  background: rgba(255,255,255,0.85) !important;
}

/* User pin */
.cmp-user-pin { background: transparent !important; border: none !important; }
.cmp-user-pin-inner {
  width: 16px; height: 16px;
  background: #0ea5e9;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(14,165,233,0.3), 0 2px 8px rgba(0,0,0,0.4);
  margin: 1px;
}

/* Floating right buttons */
.cmp-map-floats {
  position: absolute; right: 12px; top: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}
.cmp-float-btn {
  width: 44px; height: 44px;
  background: #fff; color: #1a2440;
  border: none; border-radius: 12px;
  font-size: 20px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  display: flex; align-items: center; justify-content: center;
}
.cmp-float-btn:hover { background: #c8a45c; color: #050816 }
.cmp-float-btn.active { background: #c8a45c; color: #050816 }

/* Bottom overlay (hint + legend) */
.cmp-bottom-overlay {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.cmp-hint-card {
  background: rgba(255,255,255,0.95);
  color: #1a2440;
  padding: 8px 14px;
  border-radius: 10px;
  text-align: center;
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

/* Recommend card (best/worst) */
.cmp-rec-card {
  display: flex; align-items: stretch;
  background: rgba(255,255,255,0.96);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  font-size: 12px;
}
.cmp-rec-best, .cmp-rec-worst {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
}
.cmp-rec-tag {
  font-size: 10px; color: #64748b; letter-spacing: 0.5px;
}
.cmp-rec-val {
  font-weight: 700; color: #1a2440;
  font-size: 13px;
}
.cmp-rec-divider {
  width: 1px; background: rgba(0,0,0,0.08);
  margin: 0 12px;
}

/* Score badge floating on map at sector center */
.cmp-score-badge {
  background: transparent !important;
  border: none !important;
}
.cmp-score-badge-inner {
  background: rgba(15,23,41,0.85);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.cmp-score-badge-inner.has-personal::after {
  content: '⭐';
  margin-left: 2px;
  font-size: 9px;
}
/* v2.1 — 6 levels (L1-L6) */
.cmp-score-badge-inner.tier-l1 { background: #22c55e }
.cmp-score-badge-inner.tier-l2 { background: #38bdf8 }
.cmp-score-badge-inner.tier-l3 { background: #ca8a04 }
.cmp-score-badge-inner.tier-l4 { background: #ea580c }
.cmp-score-badge-inner.tier-l5 { background: #dc2626 }
.cmp-score-badge-inner.tier-l6 { background: #991b1b }
/* legacy compat */
.cmp-score-badge-inner.tier-great { background: #22c55e }
.cmp-score-badge-inner.tier-good  { background: #38bdf8 }
.cmp-score-badge-inner.tier-fair  { background: #ca8a04 }
.cmp-score-badge-inner.tier-risk  { background: #ea580c }
.cmp-score-badge-inner.tier-avoid { background: #dc2626 }

/* Loading */
.cmp-loading {
  position: absolute; inset: 0;
  background: rgba(232,234,237,0.85);
  z-index: 999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
}
.cmp-loading[hidden] { display: none !important }
[hidden] { display: none !important }
.cmp-loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(200,164,92,0.3);
  border-top-color: #c8a45c;
  border-radius: 50%;
  animation: cmp-spin 0.8s linear infinite;
}
@keyframes cmp-spin {
  to { transform: rotate(360deg) }
}
.cmp-loading-text {
  font-size: 12px; color: #1a2440; font-weight: 600;
}
.cmp-legend {
  background: rgba(255,255,255,0.95);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: center;
  font-size: 11px;
  color: #1a2440;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.cmp-legend-item { display: flex; align-items: center; gap: 4px }
.cmp-legend-dot {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

/* === SVG Compass tab === */
.cmp-svg-wrap {
  display: flex; justify-content: center; padding: 20px 14px;
}
.cmp-svg {
  width: 100%; max-width: 360px; height: auto;
  filter: drop-shadow(0 4px 24px rgba(0,0,0,0.4));
}
.cmp-ring-outer { fill: rgba(15,23,41,0.55); stroke: rgba(200,164,92,0.35); stroke-width: 1.5 }
.cmp-ring-inner { fill: rgba(10,14,26,0.7); stroke: rgba(200,164,92,0.18); stroke-width: 1 }
.cmp-center { fill: #c8a45c; stroke: #050816; stroke-width: 2 }
.cmp-center-text { fill: #050816; font-size: 14px; font-weight: 700 }
.cmp-n-mark { fill: #c8a45c; font-size: 10px; font-weight: 700; letter-spacing: 1px }
.cmp-sector { cursor: pointer; transition: opacity .15s; stroke: rgba(10,14,26,0.85); stroke-width: 2 }
.cmp-sector:hover { opacity: 0.85; stroke-width: 3 }
.cmp-sector-personal { stroke: #c8a45c; stroke-width: 3 }
.cmp-dir-label { fill: #f8fafc; font-size: 11px; font-weight: 600; pointer-events: none }
.cmp-dir-label-cn { fill: #c8a45c; font-size: 13px; font-weight: 600; pointer-events: none }
.cmp-score-label { fill: #f8fafc; font-size: 13px; font-weight: 700; pointer-events: none }
.cmp-arrow { pointer-events: none; transform-origin: 0 0; transition: transform 0.3s ease-out }
.cmp-arrow polygon { fill: #c8a45c; stroke: #050816; stroke-width: 1 }
.cmp-helper { font-size: 12px; color: #94a3b8; text-align: center; margin: 8px 14px 24px }

/* === Bottom Sheet === */
.cmp-sheet-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 99998;
}
.cmp-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-height: 85vh; overflow-y: auto;
  background: linear-gradient(180deg, #0f1729, #0a0e1a);
  border-radius: 16px 16px 0 0;
  padding: 16px 20px 30px;
  z-index: 99999;
  animation: cmp-sheet-up .25s ease-out;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
  isolation: isolate;
}
.cmp-sheet * { position: relative; z-index: 1 }
@media (min-width: 768px) {
  .cmp-sheet {
    left: 50%; right: auto; bottom: 20px;
    transform: translateX(-50%);
    max-width: 480px;
    border-radius: 16px;
  }
  @keyframes cmp-sheet-up {
    from { transform: translate(-50%, 100%) }
    to { transform: translate(-50%, 0) }
  }
}
@keyframes cmp-sheet-up {
  from { transform: translateY(100%) }
  to { transform: translateY(0) }
}
.cmp-sheet-handle {
  width: 40px; height: 4px;
  background: rgba(200,164,92,0.5);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.cmp-sheet-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; color: #94a3b8;
  border: 1px solid rgba(148,163,184,0.3);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 14px; cursor: pointer;
}
.cmp-d-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; gap: 8px;
}
.cmp-d-name { font-size: 18px; font-weight: 700; color: #f8fafc }
.cmp-d-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px; font-weight: 700;
  padding: 4px 14px; border-radius: 10px;
}
.cmp-d-tier { font-size: 11px; color: #94a3b8; margin-bottom: 12px }
.cmp-d-summary {
  background: rgba(200,164,92,0.08);
  border-left: 3px solid #c8a45c;
  padding: 10px 12px; border-radius: 0 6px 6px 0;
  font-size: 13px; color: #f8fafc; line-height: 1.55;
  margin-bottom: 14px;
}
.cmp-d-section-title {
  font-size: 11px; color: #c8a45c; letter-spacing: 1px;
  text-transform: uppercase; font-weight: 700;
  margin: 14px 0 6px;
}
.cmp-d-row {
  display: grid; grid-template-columns: 28px 1fr auto;
  gap: 10px; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(148,163,184,0.08);
  font-size: 13px;
}
.cmp-d-row:last-child { border-bottom: 0 }
.cmp-d-row-icon { font-size: 16px; text-align: center }
.cmp-d-row-text { color: #f8fafc }
.cmp-d-row-text small { display: block; color: #94a3b8; font-size: 11px; margin-top: 2px }
.cmp-d-row-score {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 13px;
}
.cmp-d-row-score.pos { color: #34d399 }
.cmp-d-row-score.neg { color: #f87171 }
.cmp-d-row-score.zero { color: #94a3b8 }
.cmp-d-use {
  margin-top: 14px;
  background: rgba(15,23,41,0.6);
  padding: 10px 12px; border-radius: 8px;
  font-size: 12px; color: #94a3b8;
}
.cmp-d-use b { color: #f8fafc; display: block; margin-bottom: 4px }
.cmp-d-warn {
  margin-top: 10px;
  font-size: 11px; color: #64748b; line-height: 1.5;
  padding: 8px 10px;
  background: rgba(239,68,68,0.06);
  border-left: 2px solid rgba(239,68,68,0.4);
  border-radius: 0 4px 4px 0;
}

/* === Help modal === */
.cmp-help-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 99996;
}
.cmp-help {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #0f1729, #0a0e1a);
  border: 1px solid rgba(200,164,92,0.3);
  border-radius: 14px;
  width: 92%; max-width: 420px; max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px;
  z-index: 99997;
  isolation: isolate;
}
.cmp-help h3 {
  font-size: 16px; color: #c8a45c;
  margin: 0 0 12px; padding-right: 30px;
}
.cmp-help-list {
  list-style: none; padding: 0; margin: 0 0 14px;
}
.cmp-help-list li {
  padding: 6px 0;
  font-size: 13px;
  color: #f8fafc;
  display: flex; align-items: baseline; gap: 8px;
}
.cmp-help-list li b { color: #f8fafc }
.cmp-help-note {
  font-size: 11px; color: #94a3b8; line-height: 1.6;
  margin: 12px 0;
  padding: 10px;
  background: rgba(15,23,41,0.6);
  border-radius: 8px;
}
.cmp-help-details {
  margin-top: 12px;
  background: rgba(15,23,41,0.5);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.cmp-help-details summary {
  cursor: pointer; color: #c8a45c; font-weight: 600;
}
.cmp-privacy-note {
  margin: 8px 0 0; font-size: 10px; color: #64748b; line-height: 1.5;
}

/* Location picker (compact) */
#cmpLocation .loc-row { gap:6px; flex-wrap:wrap; margin-top: 8px; display: flex }
#cmpLocation .loc-row .loc-search-wrap { flex:1; min-width:160px; position: relative }
#cmpLocation .loc-row .loc-city { flex:1; min-width:140px; font-size:12px; padding:6px 8px; background: rgba(10,14,26,0.7); color: #f8fafc; border: 1px solid rgba(200,164,92,0.3); border-radius: 6px }
#cmpLocation .loc-row .loc-search { font-size:12px; padding:6px 8px; width:100%; background: rgba(10,14,26,0.7); color: #f8fafc; border: 1px solid rgba(200,164,92,0.3); border-radius: 6px }
#cmpLocation .small-btn { padding:5px 8px; font-size:11px; background: transparent; color: #c8a45c; border: 1px solid rgba(200,164,92,0.35); border-radius: 6px; cursor: pointer }
#cmpLocation .loc-geo { display:none }
#cmpLocation .loc-correction { font-size:11px; padding:4px 6px; margin-top:6px; color: #94a3b8 }
#cmpLocation .loc-border-warn { font-size:11px; padding:4px 8px; margin-top:4px; color: #fb923c; background: rgba(251,146,60,0.1); border-radius: 4px }
#cmpLocation .loc-custom-row { gap:6px; margin-top:4px; display: flex }
#cmpLocation .loc-custom-row input { font-size:12px; padding:6px 8px; flex: 1; background: rgba(10,14,26,0.7); color: #f8fafc; border: 1px solid rgba(200,164,92,0.3); border-radius: 6px }
#cmpLocation .loc-suggest { position:absolute; top:100%; left:0; right:0; background: #0f1729; border:1px solid rgba(200,164,92,0.4); border-radius:6px; max-height:200px; overflow-y:auto; z-index:1100; margin-top:2px }
#cmpLocation .loc-suggest-item { font-size:11px; padding:6px 8px; color: #f8fafc; border-bottom: 1px solid rgba(148,163,184,0.1); cursor: pointer }
#cmpLocation .loc-suggest-item:hover { background: rgba(200,164,92,0.1) }
