:root {
  color-scheme: light;
  --ground: #e9eef0;
  --surface: #ffffff;
  --ink: #15272d;
  --soft: #4c6067;
  --line: #cbd6da;
  --pole: #0f3f4a;
  --pole-deep: #082a32;
  --lamp: #ffc53d;
  --link: #0b6075;
  --up: #b3261e;
  --down: #1f5fbf;
  --sign-font: 'Do Hyeon', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 16px/1.6 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--link); }
h1, h2, .logo, .sign-title, .fuel-name { font-family: var(--sign-font); font-weight: 400; line-height: 1.2; }
h1 { font-size: 2rem; margin: 0 0 1rem; }
h2 { font-size: 1.35rem; margin: 0 0 .75rem; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
main:focus { outline: none; }
.skip { position: absolute; left: 1rem; top: -4rem; background: var(--surface); padding: .5rem 1rem; z-index: 2000; }
.skip:focus { top: .5rem; }

/* 위쪽 메뉴 */
.top { display: flex; align-items: center; gap: 2rem; padding: 0 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { font-size: 1.6rem; color: var(--pole); text-decoration: none; white-space: nowrap; }
nav { display: flex; overflow-x: auto; scrollbar-width: none; }
nav a { padding: 1rem .9rem; color: var(--soft); text-decoration: none; white-space: nowrap; border-bottom: 4px solid transparent; }
nav a:hover { color: var(--ink); }
nav a[aria-current] { color: var(--ink); font-weight: 700; border-bottom-color: var(--lamp); }
nav a:focus-visible { outline-offset: -3px; }

.page { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 2rem; max-width: 1360px; margin: 0 auto; padding: 1.5rem; align-items: start; }

/* 가격판: 유종 선택 버튼을 겸한다 */
.sign { position: sticky; top: 1.5rem; background: var(--pole); color: #fff; border-radius: 10px 10px 0 0; padding: 1rem .75rem; }
.sign-title { font-size: 1.5rem; text-align: center; margin: 0 0 .75rem; }
.sign-note { font-size: .85rem; margin: .75rem .25rem 0; color: #d8e6e9; }
#sign { display: grid; gap: .5rem; }
.fuel {
  --c: #666; --t: #fff;
  display: grid; grid-template-columns: 1fr 116px; align-items: stretch; width: 100%; padding: 0; overflow: hidden;
  border: 3px solid transparent; border-radius: 4px; background: var(--pole-deep); cursor: pointer; font: inherit; color: var(--ink);
}
.fuel.B027 { --c: #f2b705; --t: #15272d; }
.fuel.D047 { --c: #1b7f4b; }
.fuel.K015 { --c: #6b4fa0; }
.fuel.B034 { --c: #b3261e; }
.fuel.C004 { --c: #2563b8; }
.fuel-name { display: grid; place-items: center; padding: .5rem .25rem; font-size: 1.3rem; background: #eef3f4; border-left: 8px solid var(--c); }
.fuel[aria-pressed=true] { border-color: #fff; }
.fuel[aria-pressed=true] .fuel-name { background: var(--c); color: var(--t); }
.fuel:focus-visible { outline-color: var(--lamp); }
.led { display: block; width: 100%; align-self: center; padding: .55rem .6rem; }
.led path { fill: none; stroke-width: 2; }
.led .off { stroke: #12404b; }
.led .on { stroke: #9aa8ad; }
.fuel[aria-pressed=true] .led .on { stroke: var(--lamp); }

/* 본문 */
section { background: var(--surface); padding: 1.25rem; margin: 0 0 1rem; border-radius: 6px; }
.note, .meta { color: var(--soft); font-size: .9rem; }
.note { margin: .5rem 0; }
.warn { color: #7a4b00; }
.error { color: var(--up); margin: .5rem 0; }
.empty { margin: .5rem 0; }
.up { color: var(--up); }
.down { color: var(--down); }
.now { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; margin: 0; }
.now strong { font-size: 2rem; line-height: 1.2; }

.controls { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin-bottom: .75rem; }
.controls .error { flex-basis: 100%; }
label { display: grid; gap: .2rem; font-size: .9rem; color: var(--soft); }
label.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; color: var(--ink); }
label.check input { width: 20px; height: 20px; }
select, input:not([type=checkbox]), main button, dialog button, .small {
  font: inherit; color: var(--ink); min-height: 44px; padding: .4rem .8rem; border: 1px solid #7b8d94; border-radius: 4px; background: var(--surface);
}
main button, dialog button, .small { cursor: pointer; }
main button:hover, dialog button:hover, .small:hover { background: #eef3f4; }
main button:disabled { opacity: .6; cursor: default; }
main .primary { background: var(--pole); border-color: var(--pole); color: #fff; font-weight: 700; }
main .primary:hover { background: var(--pole-deep); }
.small { display: inline-flex; align-items: center; font-size: .9rem; text-decoration: none; }
.actions { display: inline-flex; gap: .4rem; }
.badge { justify-self: start; background: var(--lamp); color: var(--ink); font-weight: 700; font-size: .85rem; padding: .1rem .5rem; border-radius: 3px; }
.tel { justify-self: start; padding: .2rem 0; }

/* 내 주변 */
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; background: var(--surface); border-left: 8px solid var(--lamp); padding: .75rem 1rem; margin-bottom: 1rem; }
.summary:empty { display: none; }
.summary-price { font-size: 1.9rem; line-height: 1.1; }
.summary .actions { margin-left: auto; }
.near-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.near-body:has(.stations) { grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); }
.map { height: min(68vh, 640px); min-height: 360px; border-radius: 6px; z-index: 0; }
.near-list { max-height: min(68vh, 640px); overflow-y: auto; }
.near-list:has(.stations) { background: var(--surface); border-radius: 6px; padding: 0 1rem; }
.loading .near-body, .loading .summary { opacity: .5; }
.range { stroke: var(--link); stroke-width: 2; fill: var(--link); fill-opacity: .06; }
.here { stroke: #fff; stroke-width: 3; fill: var(--down); fill-opacity: 1; }
.tag {
  position: absolute; left: 0; bottom: 7px; transform: translateX(-50%); display: grid; justify-items: center; width: max-content;
  padding: 2px 7px; background: #fff; color: var(--ink); border: 1px solid var(--pole); border-radius: 4px; line-height: 1.25; cursor: pointer;
}
.tag::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--pole); border-bottom: 0; }
.tag span { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.tag strong { font-size: 15px; }
.tag-best { background: var(--lamp); border: 2px solid var(--pole-deep); padding: 4px 10px; }
.tag-best b { font-size: 12px; }
.tag-best span { max-width: 120px; font-size: 12px; }
.tag-best strong { font-size: 20px; }
.leaflet-marker-icon:focus-visible { outline: none; }
.leaflet-marker-icon:focus-visible .tag { outline: 3px solid var(--link); }
.leaflet-container { font: inherit; }
.leaflet-container a.small { color: var(--ink); }
.leaflet-container .leaflet-control-attribution { font-size: 12px; }
.popup { display: grid; gap: .3rem; font-size: 15px; }
.popup-price { font-size: 1.1rem; font-weight: 700; }

/* 주유소 목록 */
.stations { list-style: none; margin: 0; padding: 0; }
.stations li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.stations li:last-child { border-bottom: 0; }
.stations .best { border-left: 8px solid var(--lamp); padding-left: .75rem; }
.station-text { display: grid; }
.station-name { font-weight: 700; }
main button.station-name { justify-self: start; border: 0; padding: .3rem 0; min-height: 32px; text-align: left; text-decoration: underline; text-underline-offset: 3px; background: none; }
.station-price { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.best .station-price { font-size: 1.6rem; }
.stations .actions { grid-column: 1 / -1; }

/* 차트와 표 */
.figure { max-width: 760px; }
.readout { margin: 0; color: var(--soft); }
.readout strong { font-size: 1.3rem; color: var(--ink); }
.chart { height: 210px; overflow: hidden; }
.chart svg { display: block; touch-action: pan-y; }
.chart svg:focus-visible { outline-offset: -3px; }
.grid { stroke: var(--line); }
.cross { stroke: var(--soft); }
.line { fill: none; stroke: var(--link); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--link); stroke: var(--surface); stroke-width: 2; }
.tick { font-size: 12px; fill: var(--soft); font-variant-numeric: tabular-nums; }
summary { cursor: pointer; padding: .6rem 0; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child { text-align: left; }
thead th { color: var(--soft); font-weight: 400; font-size: .9rem; }

.key { display: flex; align-items: center; gap: .5rem; }
.base-key { width: 2px; height: 1rem; background: var(--soft); }
.dots { list-style: none; margin: 0; padding: 0; max-width: 760px; }
.dots li > * { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 6.5rem; gap: 1rem; align-items: center; width: 100%; min-height: 36px; }
.dots li > button { min-height: 44px; border: 0; padding: 0 .4rem; text-align: left; background: none; }
.dots li > button[aria-pressed=true] { background: #dcebef; font-weight: 700; }
.track { position: relative; align-self: stretch; margin: 0 6px; background: linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat; }
.mark { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px; border-radius: 50%; background: var(--link); box-shadow: 0 0 0 2px var(--surface); }
.base { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--soft); }
.dots-price { text-align: right; font-variant-numeric: tabular-nums; }

/* 상세정보 */
dialog { width: min(520px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); border: 0; border-top: 8px solid var(--lamp); border-radius: 6px; padding: 1.25rem; color: var(--ink); }
dialog::backdrop { background: rgb(8 42 50 / .6); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.dialog-head .small { flex: none; }
dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; }
dt { color: var(--soft); }
dd { margin: 0; }

footer { max-width: 1360px; margin: 0 auto; padding: 0 1.5rem 2rem; font-size: .85rem; color: var(--soft); }
footer p { max-width: 78ch; margin: .4rem 0; }

@media (max-width: 1100px) {
  .near-body:has(.stations) { grid-template-columns: minmax(0, 1fr); }
  .near-list { max-height: none; }
}

/* 좁은 화면에서는 가격판을 가로로 눕혀 지도가 바로 보이게 한다 */
@media (max-width: 820px) {
  .top { display: block; padding: .6rem 0 0; }
  .logo { padding: 0 1rem; }
  nav { padding: 0 .4rem; }
  nav a { padding: .6rem .5rem; font-size: .95rem; }
  .page { display: block; padding: 0; }
  .sign { position: static; border-radius: 0; padding: .5rem; }
  .sign-title { font-size: 1rem; margin: 0 0 .35rem; }
  .sign-note { font-size: .8rem; margin: .4rem 0 0; text-align: center; }
  #sign { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .3rem; }
  .fuel { grid-template-columns: 1fr; }
  .fuel-name { font-size: 1.05rem; padding: .3rem 0; border-left: 0; border-top: 5px solid var(--c); }
  .led { padding: .35rem .25rem; }
  main { padding: 1rem; }
  h1 { font-size: 1.6rem; margin-bottom: .75rem; }
  .near-controls { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
  .near-controls button { padding: .4rem; }
  .near-controls label { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .5rem; white-space: nowrap; }
  .summary { padding: .6rem .75rem; margin-bottom: .75rem; }
  .map { height: 56vh; }
  .summary .actions { margin-left: 0; }
  .dots li > * { grid-template-columns: 6.2rem minmax(0, 1fr) 5.8rem; gap: .5rem; font-size: .9rem; }
  footer { padding: 0 1rem 2rem; }
}
