:root {
  --bg: #f4f5f7; --sf: #fff; --sa: #eef0f4; --bd: #dfe2e8; --bl: #eef0f3;
  --tx: #1a1d23; --t2: #5f6672; --t3: #8b919c;
  --ac: #2563eb; --al: #eff4ff; --ah: #1d4ed8;
  --gn: #059669; --gb: #ecfdf5; --rd: #dc2626; --rb: #fef2f2;
  --r: 10px; --rs: 6px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Noto Sans KR', -apple-system, sans-serif; background: var(--bg); color: var(--tx); line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* Header */
.hd { background: linear-gradient(135deg, #0f2847, #1e56a0 50%, #2563eb); color: #fff; padding: 1.3rem 1rem 1.2rem; }
.hi { max-width: 1600px; margin: 0 auto; }
.hb { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12); padding: 4px 12px; border-radius: 20px; font-size: .72rem; font-weight: 500; margin-bottom: .6rem; }
.hd h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .3rem; }
.hd p { font-size: .78rem; opacity: .75; }
.stats { display: flex; gap: 1.5rem; margin-top: 1rem; }
.stat { text-align: center; }
.stat-n { font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; font-weight: 700; }
.stat-l { font-size: .65rem; opacity: .6; margin-top: 1px; }

/* Wrap */
.wrap { max-width: 1600px; margin: 0 auto; padding: .6rem 1rem 0; }

/* Panel (details/summary) */
.panel { background: var(--sf); border: 1.5px solid var(--bd); border-radius: var(--r); overflow: hidden; }
.panel summary { padding: .8rem 1rem; font-size: .82rem; font-weight: 600; color: var(--t2); cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: '▼'; font-size: .6rem; color: var(--t3); transition: transform .2s; }
.panel[open] summary::after { transform: rotate(180deg); }
.notes { padding: 0 1rem 1rem; }
.notes li { margin-bottom: .2rem; padding-left: .3rem; font-size: .75rem; color: var(--t2); line-height: 1.7; }

/* Map */
.map-container { padding: 0 .5rem .5rem; position: relative; }
#mapSvg { width: 100%; height: auto; border-radius: 8px; background: #f0f3f7; }
#mapSvg path { stroke: #fff; stroke-width: 1.2; cursor: pointer; transition: fill .15s; }
#mapSvg text { pointer-events: none; font-family: 'Noto Sans KR', sans-serif; font-weight: 700; fill: #2d3748; }
#mapSvg text.count { font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 700; fill: var(--ac); }
.map-info { margin: .5rem .5rem 0; padding: .5rem .8rem; background: var(--al); border-radius: var(--rs); font-size: .8rem; color: var(--ac); font-weight: 500; text-align: center; }

/* Legend */
.legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: .5rem; }
.legend-item { display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: var(--rs); cursor: pointer; font-size: .72rem; transition: background .15s; }
.legend-item:active, .legend-item.active { background: var(--ac); color: #fff; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-item.active .legend-dot { background: #fff !important; }
.legend-cnt { margin-left: auto; background: var(--sa); padding: 1px 5px; border-radius: 10px; font-family: 'JetBrains Mono', monospace; font-size: .6rem; font-weight: 600; color: var(--t3); }
.legend-item.active .legend-cnt { background: rgba(255,255,255,.25); color: #fff; }

/* Search */
.search-box { position: relative; margin-bottom: .5rem; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--t3); pointer-events: none; }
.search-box input { width: 100%; padding: 10px 12px 10px 38px; border: 1.5px solid var(--bd); border-radius: var(--r); font-size: .85rem; font-family: inherit; background: var(--sf); outline: none; transition: border-color .2s; }
.search-box input:focus { border-color: var(--ac); box-shadow: 0 0 0 3px var(--al); }

/* Filter detail */
.filter-detail { margin-bottom: .5rem; }
.filter-toggle { font-size: .78rem; font-weight: 600; color: var(--t2); cursor: pointer; padding: .4rem 0; list-style: none; }
.filter-toggle::-webkit-details-marker { display: none; }
.filter-toggle::before { content: '⚙ '; }
.filter-ranges { display: flex; flex-direction: column; gap: .5rem; padding: .5rem 0; }
.range-group label { font-size: .75rem; font-weight: 500; color: var(--t2); display: block; margin-bottom: 3px; }
.range-inputs { display: flex; align-items: center; gap: 5px; }
.range-inputs input { flex: 1; padding: 7px 8px; border: 1.5px solid var(--bd); border-radius: var(--rs); font-size: .8rem; font-family: 'JetBrains Mono', monospace; background: var(--sf); outline: none; }
.range-inputs input:focus { border-color: var(--ac); }
.range-inputs span { color: var(--t3); font-size: .8rem; }

/* Chips */
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: .4rem; }
.chip { padding: 5px 10px; border: 1.5px solid var(--bd); border-radius: 18px; background: var(--sf); font-size: .72rem; font-family: inherit; font-weight: 500; color: var(--t2); cursor: pointer; transition: all .15s; }
.chip:active, .chip.active { background: var(--ac); border-color: var(--ac); color: #fff; }
.chip .cnt { font-family: 'JetBrains Mono', monospace; font-size: .62rem; opacity: .65; margin-left: 2px; }
.chip-label { font-size: .72rem; font-weight: 600; color: var(--t2); padding: 5px 4px 5px 0; }
.result-count { font-size: .78rem; color: var(--t3); padding: 2px 0; }
.result-count strong { color: var(--ac); font-weight: 600; }

/* Card list (mobile default) */
.card-list { display: flex; flex-direction: column; gap: .5rem; padding-bottom: 1rem; }
.card { background: var(--sf); border: 1.5px solid var(--bd); border-radius: var(--r); padding: .8rem; }
.card.hidden { display: none; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .4rem; }
.card-district { font-size: .68rem; font-weight: 600; color: var(--ac); background: var(--al); padding: 2px 8px; border-radius: 10px; }
.card-id { font-family: 'JetBrains Mono', monospace; font-size: .68rem; color: var(--t3); }
.card-addr { margin-bottom: .3rem; }
.card-addr a { color: var(--ac); text-decoration: none; font-weight: 500; font-size: .82rem; }
.card-addr a:hover { text-decoration: underline; }
.card-jibun { font-size: .7rem; color: var(--t3); margin-bottom: .5rem; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .3rem; }
.card-stat { text-align: center; padding: .4rem .2rem; background: var(--sa); border-radius: var(--rs); }
.card-stat-label { font-size: .62rem; color: var(--t3); }
.card-stat-value { font-family: 'JetBrains Mono', monospace; font-size: .72rem; font-weight: 600; }
.card-convert { margin-top: .4rem; padding-top: .4rem; border-top: 1px solid var(--bl); }
.card-convert-title { font-size: .62rem; color: var(--t3); margin-bottom: .3rem; }
.card-convert-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; }
.card-convert-item { text-align: center; padding: .3rem; background: var(--bl); border-radius: var(--rs); }
.card-convert-item .card-stat-label { font-size: .58rem; }
.card-convert-item .card-stat-value { font-size: .68rem; color: var(--t2); }
.elev-badge { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px; font-size: .65rem; font-weight: 700; }
.elev-y { background: var(--gb); color: var(--gn); }
.elev-n { background: var(--rb); color: var(--rd); }

/* Table (hidden on mobile) */
.table-wrap { display: none; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; background: var(--sf); border-radius: var(--r); overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,.07); font-size: .8rem; min-width: 1100px; }
thead { position: sticky; top: 0; z-index: 10; }
thead th { background: #1e293b; color: #e2e8f0; padding: 10px 8px; font-weight: 600; font-size: .72rem; text-align: center; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.07); }
thead th:last-child { border-right: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--al); }
tbody tr:nth-child(even) { background: var(--sa); }
tbody tr:nth-child(even):hover { background: var(--al); }
tbody td { padding: 8px; border-bottom: 1px solid var(--bl); vertical-align: middle; }
.td-n { text-align: center; font-family: 'JetBrains Mono', monospace; font-size: .76rem; }
.td-c { text-align: center; }
.td-m { text-align: right; font-family: 'JetBrains Mono', monospace; font-size: .76rem; white-space: nowrap; }
.td-s { color: var(--t3); font-size: .72rem; }
.td-addr { min-width: 240px; }
.td-addr a { color: var(--ac); text-decoration: none; font-weight: 500; }
.td-addr a:hover { text-decoration: underline; }
.td-addr .jb { display: block; font-size: .68rem; color: var(--t3); margin-top: 1px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #2d3a4f; }
th.sortable::after { content: ' ⇅'; font-size: .6rem; opacity: .4; }
th.sortable.asc::after { content: ' ▲'; opacity: .9; }
th.sortable.desc::after { content: ' ▼'; opacity: .9; }
tr.hidden { display: none; }

/* Station badges */
.station-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: .4rem; }
.station-item { display: inline-flex; align-items: center; gap: 3px; background: var(--sa); border-radius: 12px; padding: 2px 8px 2px 3px; font-size: .68rem; }
.line-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 9px; color: #fff; font-size: .58rem; font-weight: 700; padding: 0 4px; font-family: 'JetBrains Mono', monospace; }
.station-name { font-weight: 500; color: var(--tx); }
.station-dist { color: var(--t3); font-family: 'JetBrains Mono', monospace; font-size: .62rem; }

/* Bookmark buttons */
.bm-btn, .bm-btn-tbl { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--bd); transition: color .15s, transform .15s; padding: 0; line-height: 1; }
.bm-btn:active, .bm-btn-tbl:active { transform: scale(1.3); }
.bm-btn.active, .bm-btn-tbl.active { color: #f59e0b; }

/* Footer */
.ft { text-align: center; padding: 1.2rem 1rem; color: var(--t3); font-size: .68rem; }

/* Desktop */
@media (min-width: 769px) {
  .hd { padding: 2rem 2rem 1.6rem; }
  .hd h1 { font-size: 1.5rem; }
  .wrap { padding-left: 2rem; padding-right: 2rem; }
  .stats { gap: 2rem; }
  .stat-n { font-size: 1.6rem; }
  .legend { grid-template-columns: repeat(4, 1fr); }
  .filter-ranges { flex-direction: row; gap: 1rem; }
  .range-group { flex: 1; }
  .card-list { display: none; }
  .table-wrap { display: block; }
}
