html, body { height: 100%; overflow: hidden; }
body { font-size: 14px; line-height: 1.45; overscroll-behavior: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: var(--bg); touch-action: none; cursor: grab; outline: none; }
#view.drag { cursor: grabbing; }
#view:focus-visible { box-shadow: inset 0 0 0 2px var(--text2); }

#panel { position: fixed; z-index: 3; top: 12px; left: 12px; bottom: 12px; width: 360px; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); }
.brand { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 13px; border-bottom: 1px solid var(--line); flex: none; }
.logo b { font-weight: 500; }
.wiki-link:hover { color: var(--hover); }
.top { flex: none; border-bottom: 1px solid var(--line); }

.maps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.maps button { padding: 9px 12px; min-width: 0; background: none; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text2); text-align: left; }
.maps button:nth-child(2n) { border-right: 0; }
.maps button:nth-last-child(-n+2):nth-child(odd), .maps button:nth-last-child(-n+2):nth-child(odd) ~ button { border-bottom: 0; }
.maps b { display: block; font: 500 12px/1.3 var(--mono); }
.maps small { display: block; font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.maps button:hover { color: var(--hover); background: var(--raised); }
.maps button[aria-pressed="true"] { color: var(--bg); background: var(--text); }
.maps button[aria-pressed="true"] small { color: #3b4048; }

.find { display: flex; gap: 8px; padding: 12px; }
.search { position: relative; flex: 1; min-width: 0; }
.search input { width: 100%; height: 36px; padding: 0 30px 0 11px; background: var(--raised); border: 1px solid var(--line2); border-radius: 0; outline: none; -webkit-appearance: none; appearance: none; }
.search input:focus { border-color: var(--text2); }
.search input::placeholder { color: var(--mute); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 11px/1 var(--mono); color: var(--text3); border: 1px solid var(--line2); padding: 3px 5px; pointer-events: none; }
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }
.toggle { height: 36px; padding: 0 12px; background: none; border: 1px solid var(--line2); color: var(--text2); white-space: nowrap; flex: none; }
.toggle:hover { color: var(--hover); border-color: var(--text3); }
.toggle[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.sheet { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.grip { display: none; }
.body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.disc { flex: none; margin: 0; padding: 8px 16px 0; border-top: 1px solid var(--line); font-size: 11.5px; line-height: 1.45; color: var(--mute); }
.disc + .foot { border-top: 0; }
.foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 16px; border-top: 1px solid var(--line); min-height: 44px; }

.langs { position: relative; font: 500 11px/1 var(--mono); letter-spacing: .06em; }
.langs summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border: 1px solid var(--line2); color: var(--text2); }
.langs summary::-webkit-details-marker { display: none; }
.langs summary::after { content: ""; border: 4px solid transparent; border-bottom-color: currentColor; margin-bottom: 4px; }
.langs summary:hover { color: var(--hover); }
.langs[open] summary { background: var(--text); color: var(--bg); border-color: var(--text); }
.langs div { position: absolute; right: 0; bottom: 100%; z-index: 5; margin-bottom: 4px; min-width: 200px; padding: 6px 0; background: var(--raised); border: 1px solid var(--line2); box-shadow: 0 -12px 32px rgba(0, 0, 0, .5); }
.langs div button { display: flex; justify-content: space-between; gap: 20px; width: 100%; padding: 8px 12px; background: none; border: 0; color: var(--text2); white-space: nowrap; font: inherit; letter-spacing: inherit; }
.langs div button span:first-child { font: 14px/1.2 var(--sans); letter-spacing: 0; }
.langs div button span:last-child { color: var(--mute); }
.langs div button:hover { background: var(--surface); color: var(--hover); }
.langs div button[aria-current] { color: var(--text); box-shadow: inset 2px 0 0 var(--text); }

.sec { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sec h2 { margin: 0 0 2px; font-size: 17px; font-weight: 500; line-height: 1.3; }
.sec h2 .mono { font-size: 13px; color: var(--text2); margin-right: 8px; }
.muted { color: var(--text2); }
.dim { color: var(--mute); }
.small { font-size: 12px; }
.note { padding: 14px 16px; color: var(--mute); }
.stats { margin: 10px 0 0; }
.stats > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stats > div:last-child { border-bottom: 0; }
.stats dt { color: var(--text2); }
.stats dd { margin: 0; font: 13px/1.6 var(--mono); }
.stats button { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 4px; }
.stats button:hover { text-decoration-color: var(--text2); }
.stats button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.hints { margin: 0; padding: 14px 16px; color: var(--mute); font-size: 13px; }
.hints p { margin: 0 0 6px; }
.back { display: inline-flex; gap: 6px; background: none; border: 0; padding: 0; margin-bottom: 10px; color: var(--text2); }
.back:hover { color: var(--hover); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; gap: 8px; align-items: baseline; padding: 3px 8px; background: none; border: 1px solid var(--line2); color: var(--text2); font-size: 12.5px; }
.chip:hover { color: var(--hover); border-color: var(--text3); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip b { font: 400 11.5px var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 12px; color: var(--mute); }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 1px var(--line2); }
.legend i.in { background: var(--danger); }

.list { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 0 10px; align-items: center; width: 100%; padding: 7px 16px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.row .ico { grid-row: 1 / span 2; }
.row:hover { background: var(--raised); }
.row.at { background: var(--raised); box-shadow: inset 2px 0 0 var(--text3); }
.row.on { background: var(--surface); box-shadow: inset 2px 0 0 var(--text); }
.row .name { grid-column: 2; grid-row: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { grid-column: 2; grid-row: 2; color: var(--mute); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .qty { grid-column: 3; grid-row: 1 / span 2; font: 13px var(--mono); color: var(--text2); text-align: right; white-space: nowrap; }
.row .qty b { color: var(--text); font-weight: 500; }
.row .qty small { display: block; font-size: 11px; color: var(--mute); }
.open { background: var(--raised); border-bottom: 1px solid var(--line); padding: 10px 0 6px; }
.open .legend { padding: 0 16px 8px 58px; }
.open .links { display: flex; gap: 14px; padding: 0 16px 8px 58px; font-size: 12px; }
.places { list-style: none; margin: 0; padding: 0; }
.places button { display: flex; gap: 10px; width: 100%; padding: 6px 16px 6px 58px; background: none; border: 0; color: var(--text2); text-align: left; }
.places button:hover { color: var(--hover); background: var(--surface); }
.places button.on { color: var(--text); box-shadow: inset 2px 0 0 var(--text); }
.places .where { flex: 1; min-width: 0; }
.places .where small { display: block; color: var(--mute); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.places .n { font: 12px/1.6 var(--mono); color: var(--mute); }
a.wiki { color: var(--mute); text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 3px; font-size: 12px; }
a.wiki:hover { color: var(--hover); text-decoration-color: var(--text2); }

.others { list-style: none; margin: 8px 0 0; padding: 0; }
.others li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 0; }
.others .ico { width: 24px; height: 24px; }

.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 14px; border-left: 1px solid var(--line); margin: 2px 0 2px 11px; }
.tree li { padding: 3px 0; }
.tree .item { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.tree .ico { width: 24px; height: 24px; }
.tree .count, .tree .cash { font: 12px var(--mono); color: var(--text2); }
.tree .cash { color: var(--text); }
.tag { font: 11px var(--mono); color: var(--danger2); }

#floors { position: fixed; z-index: 2; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); }
#floors button { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 116px; padding: 9px 12px; background: none; border: 0; border-top: 1px solid var(--line); color: var(--text2); text-align: left; font-size: 13px; white-space: nowrap; }
#floors button:first-child { border-top: 0; }
#floors button:hover { color: var(--hover); background: var(--raised); }
#floors button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
#floors .badge { font: 500 11px var(--mono); color: var(--danger2); }
#floors button[aria-pressed="true"] .badge { color: #b3261e; }

.zoom { position: fixed; z-index: 2; right: 12px; bottom: 48px; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); }
.zoom button { width: 34px; height: 34px; display: grid; place-items: center; background: none; border: 0; border-top: 1px solid var(--line); color: var(--text2); font: 16px/1 var(--mono); }
.zoom button:first-child { border-top: 0; }
.zoom button:hover { color: var(--hover); background: var(--raised); }
.zoom i { width: 12px; height: 12px; border: 2px solid currentColor; }
#hud { position: fixed; z-index: 2; right: 12px; bottom: 12px; max-width: 46vw; padding: 5px 10px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
#hud:empty { display: none; }

@media (max-width: 760px) {
  #panel { display: contents; }
  .brand { display: none; }
  .top { position: fixed; z-index: 3; top: 0; left: 0; right: 0; background: var(--bg); padding-top: env(safe-area-inset-top); }
  .maps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .maps button { padding: 9px 4px; text-align: center; border-bottom: 0 !important; }
  .maps button:nth-child(2n) { border-right: 1px solid var(--line); }
  .maps button:last-child { border-right: 0; }
  .maps small { display: none; }
  .find { padding: 8px; }
  .search input { height: 40px; font-size: 16px; padding-right: 11px; }
  .search kbd { display: none; }
  .toggle { height: 40px; }
  .sheet { position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; height: 46vh; height: 46dvh; background: var(--bg); border-top: 1px solid var(--line2); padding-bottom: env(safe-area-inset-bottom); }
  .sheet.shut { height: auto; }
  .sheet.shut .body, .sheet.shut .foot { display: none; }
  .grip { display: flex; align-items: center; gap: 10px; flex: none; width: 100%; min-height: 44px; padding: 0 16px; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text2); text-align: left; }
  .sheet.shut .grip { border-bottom: 0; }
  .grip i { width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); margin: -4px 2px 0; flex: none; }
  .sheet.shut .grip i { transform: rotate(-135deg); margin-top: 4px; }
  .grip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row { padding: 9px 16px; }
  .note.count { display: none; }
  .places button { padding-top: 9px; padding-bottom: 9px; }
  #floors { top: var(--top-h, 100px); left: 0; right: 0; transform: none; flex-direction: row-reverse; border-width: 0 0 1px; overflow-x: auto; }
  #floors button { flex: 1 0 auto; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-width: 72px; min-height: 40px; padding: 2px 8px; border-top: 0; border-left: 1px solid var(--line); font-size: 12px; }
  #floors button:last-child { border-left: 0; }
  #floors .badge { font-size: 10px; line-height: 1.2; }
  .zoom, #hud { display: none; }
}
