:root {
  --kg-blue: #4B6472;
  --kg-blue-dark: #405864;
  --kg-ink: #273840;
  --kg-muted: #66777C;
  --kg-border: #D5DDDE;
  --kg-bg: #F5F6F4;
  --kg-panel: rgba(250, 251, 250, 0.97);
  --kg-154: #22777C;
  --kg-154-line: #2F775D;
  --kg-345: #C18428;
  --kg-765: #A23A50;
  --kg-hvdc: #5A4E93;
  --kg-btb: #5A4E93;
  --kg-other: #687976;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--kg-bg);
  color: var(--kg-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }

.kg-skip-target {
  position: absolute;
  top: 70px;
  left: 0;
}

.kg-shell ~ .page__footer { display: none; }

.skip-link {
  position: absolute;
  z-index: 3000;
  top: -4rem;
  left: 1rem;
  padding: .7rem 1rem;
  background: var(--kg-blue);
  color: #fff;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.site-masthead {
  position: relative;
  z-index: 1200;
  height: 70px;
  border-bottom: 1px solid var(--kg-border);
  background: rgba(250, 251, 250, .97);
  box-shadow: 0 4px 18px rgba(34, 50, 58, .045);
}
.site-nav {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  width: min(100%, 1440px);
  height: 100%;
  margin: 0 auto;
  padding: 0 2rem;
}
.site-title {
  display: flex;
  align-items: center;
  color: var(--kg-blue);
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}
.site-tabs { display: flex; align-items: stretch; overflow-x: auto; }
.site-tabs a {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 .9rem;
  color: #394c60;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.site-tabs a::after {
  position: absolute;
  right: .9rem;
  bottom: 0;
  left: .9rem;
  height: 3px;
  background: transparent;
  content: "";
}
.site-tabs a:hover, .site-tabs a.is-active { color: var(--kg-blue); }
.site-tabs a.is-active::after { background: var(--kg-blue); }

.kg-shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  height: calc(100vh - 70px);
}
.kg-sidebar {
  z-index: 900;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--kg-border);
  background: var(--kg-panel);
}
.kg-brand { padding: .95rem .9rem .62rem; }
.kg-brand h1 { margin: 0; color: var(--kg-ink); font-size: 1.38rem; font-weight: 680; letter-spacing: -.035em; }

.kg-search-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: .2rem .9rem .75rem;
}
.kg-search-section label { margin-bottom: .35rem; color: var(--kg-muted); font-size: .73rem; font-weight: 650; letter-spacing: .01em; }
#kg-search {
  min-width: 0;
  width: 100%;
  padding: .54rem .62rem;
  border: 1px solid var(--kg-border);
  border-radius: 5px;
  color: var(--kg-ink);
  background: #fff;
  box-shadow: inset 0 1px 1px rgba(34, 47, 48, .025);
}
#kg-search:focus { outline: 2px solid rgba(75, 100, 114, .18); border-color: var(--kg-blue); }
.kg-map-toolbar button {
  padding: .55rem .72rem;
  border: 1px solid var(--kg-border);
  border-radius: 5px;
  color: #36506b;
  background: #fff;
}
.kg-map-toolbar button:hover { border-color: var(--kg-blue); color: var(--kg-blue); background: #EDF2F2; }
.kg-status { margin: .5rem 0 .25rem; color: var(--kg-muted); font-size: .72rem; }
.kg-status[hidden],
.kg-site-list[hidden],
.kg-selection[hidden] { display: none !important; }
.kg-site-list {
  max-height: min(42vh, 360px);
  margin: 0;
  padding: 0 0 .6rem;
  overflow-y: auto;
  list-style: none;
}
.kg-site-list button {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: .55rem;
  align-items: center;
  width: 100%;
  padding: .48rem .4rem;
  border: 0;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  color: #34495e;
  background: transparent;
}
.kg-site-list button:hover, .kg-site-list button.is-selected { background: #EDF2F2; color: var(--kg-ink); }
.kg-site-list .kg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kg-other); }
.kg-site-list .kg-dot[data-band="154"] { background: var(--kg-154); }
.kg-site-list .kg-dot[data-band="345"] { background: var(--kg-345); }
.kg-site-list .kg-dot[data-band="765"] { background: var(--kg-765); }
.kg-site-list .kg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 600; }
.kg-site-list .kg-kv { color: var(--kg-muted); font-size: .7rem; white-space: nowrap; }

.kg-selection { border-top: 1px solid var(--kg-border); padding: .68rem .9rem; background: rgba(237, 242, 242, .44); }
.kg-selection h2 { margin: 0; font-size: .82rem; }
.kg-selection p { margin: .35rem 0 0; color: var(--kg-muted); font-size: .75rem; line-height: 1.45; }
.kg-selection p strong { color: var(--kg-ink); }

.kg-map-wrap {
  position: relative;
  display: grid;
  min-width: 0;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
}
.kg-map { width: 100%; min-height: 0; background: #DCE9ED; }
.kg-map-toolbar {
  position: absolute;
  z-index: 800;
  top: .75rem;
  left: 3.55rem;
  display: flex;
  gap: .4rem;
}
.kg-map-toolbar button { box-shadow: 0 6px 20px rgba(38, 57, 67, .10); font-size: .76rem; font-weight: 600; }
#kg-toggle-sidebar { display: none; }
.kg-attribution-footer {
  display: flex;
  min-height: 25px;
  align-items: center;
  justify-content: flex-end;
  gap: .26rem;
  padding: .28rem .65rem;
  border-top: 1px solid var(--kg-border);
  background: var(--kg-panel);
  color: #788590;
  font-size: .61rem;
  line-height: 1.25;
  white-space: nowrap;
}
.kg-attribution-footer a {
  color: #667581;
  text-decoration: none;
}
.kg-attribution-footer a:hover,
.kg-attribution-footer a:focus { color: var(--kg-blue-dark); text-decoration: underline; }

.maplibregl-ctrl-group, .maplibregl-popup-content {
  border: 1px solid var(--kg-border);
  box-shadow: 0 6px 20px rgba(38, 57, 67, .10) !important;
}
.maplibregl-ctrl-attrib { font-size: 9px; }
.maplibregl-popup { pointer-events: none; }
.maplibregl-popup-content { padding: .8rem .85rem; border-radius: 6px; background: var(--kg-panel); pointer-events: none; }
.maplibregl-popup-close-button { padding: .25rem .45rem; color: var(--kg-muted); font-size: 1rem; pointer-events: auto; }
.kg-layer-control {
  position: absolute;
  z-index: 8;
  top: .75rem;
  right: .75rem;
  display: grid;
  gap: .20rem;
  min-width: 144px;
  padding: .46rem .50rem;
  border: 1px solid var(--kg-border);
  border-radius: 5px;
  background: var(--kg-panel);
  box-shadow: 0 6px 20px rgba(38,57,67,.10);
  color: var(--kg-ink);
  font-size: .72rem;
}
.kg-layer-control label { display: flex; min-height: 20px; align-items: center; gap: .36rem; cursor: pointer; white-space: nowrap; }
.kg-layer-control input {
  appearance: none;
  width: 13px;
  height: 13px;
  margin: 0;
  border: 1px solid #A7B3B6;
  border-radius: 3px;
  background: #fff;
  box-shadow: none;
}
.kg-layer-control input:checked {
  border-color: var(--kg-blue);
  background: var(--kg-blue);
  box-shadow: inset 0 0 0 3px #fff;
}
.kg-control-swatch {
  display: inline-block;
  width: 17px;
  height: 2px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--kg-other);
  opacity: .96;
}
.kg-layer-control label[data-kg-layer="facilities"] .kg-control-swatch { width: 7px; height: 7px; margin: 0 5px; border-radius: 50%; background: var(--kg-345); }
.kg-layer-control label[data-kg-layer="154"] .kg-control-swatch { background: var(--kg-154-line); }
.kg-layer-control label[data-kg-layer="345"] .kg-control-swatch { height: 3px; background: var(--kg-345); }
.kg-layer-control label[data-kg-layer="765"] .kg-control-swatch { height: 3px; background: var(--kg-765); }
.kg-layer-control label[data-kg-layer="hvdc"] .kg-control-swatch { height: 3px; background: var(--kg-hvdc); }
.kg-popup { min-width: 205px; }
.kg-popup h3 { margin: 0 0 .45rem; color: var(--kg-ink); font-size: 1rem; }
.kg-popup dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .55rem; margin: 0; font-size: .75rem; }
.kg-popup dt { color: var(--kg-muted); }
.kg-popup dd { margin: 0; color: var(--kg-ink); font-weight: 600; overflow-wrap: anywhere; }
.kg-line-popup { font-size: .76rem; line-height: 1.4; }
.kg-line-popup strong { color: var(--kg-ink); }

@media (max-width: 920px) {
  .site-nav { padding: 0 1rem; }
  .site-title { padding-right: 1rem; }
  .site-tabs a { padding: 0 .65rem; }
  .site-tabs a::after { right: .65rem; left: .65rem; }
  .kg-shell { grid-template-columns: 1fr; }
  .kg-sidebar {
    position: absolute;
    z-index: 1050;
    top: 70px;
    bottom: 0;
    left: 0;
    width: min(280px, 90vw);
    box-shadow: 10px 0 32px rgba(31, 68, 116, .18);
    transform: translateX(-102%);
    transition: transform .2s ease;
  }
  .kg-shell.is-sidebar-open .kg-sidebar { transform: translateX(0); }
  #kg-toggle-sidebar { display: inline-block; }
}

@media (max-width: 620px) {
  .site-masthead { height: 58px; }
  .site-nav { padding: 0 .75rem; }
  .site-title { font-size: .86rem; }
  .site-tabs a { padding: 0 .5rem; font-size: .78rem; }
  .site-tabs a:nth-child(2), .site-tabs a:nth-child(3), .site-tabs a:nth-child(4), .site-tabs a:nth-child(5) { display: none; }
  .kg-shell { height: calc(100vh - 58px); }
  .kg-sidebar { top: 58px; }
  .kg-layer-control { max-width: 190px; }
  .kg-attribution-footer { justify-content: flex-start; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .kg-sidebar { transition: none; }
}
