html, body { height: 100%; }
body { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.stage { position: relative; min-height: 0; display: grid; grid-template-columns: 300px 1fr; }
#map { position: relative; height: 100%; background: #0b1a2a; }
.leaflet-container { font: inherit; background: #0b1a2a; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--cream) !important; border-color: var(--line-2) !important; }
.leaflet-control-attribution { background: rgba(0,0,0,.7) !important; color: var(--muted) !important; font-size: 11px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tooltip.lm-tip { background: var(--panel); color: var(--cream); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.5); font-size: 12px; padding: 4px 8px; }
.leaflet-tooltip.lm-tip::before { display: none; }
.adding #map { cursor: crosshair; }

/* drawer */
.drawer { background: var(--black); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; z-index: 900; }
.drawer-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.drawer-toggle { display: none; }
.drawer-body { overflow-y: auto; padding: 12px; flex: 1; }
.drawer-actions { display: grid; gap: 8px; margin-bottom: 14px; }
.check.small { font-size: 13px; }
.layer-group { margin-bottom: 16px; }
.layer-group h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 6px; font: 900 14px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.layer-group h3 button { background: none; border: 0; color: var(--muted); font: 600 12px var(--body); cursor: pointer; }
.layer-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; user-select: none; }
.layer-row:hover { background: var(--panel); }
.layer-row .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid rgba(255,255,255,.75); }
.layer-row .sw.dia { border-radius: 2px; transform: rotate(45deg); }
.layer-row .lbl { flex: 1; }
.layer-row .n { color: var(--muted); font-size: 12px; }
.layer-row.off { opacity: .4; }
.credit { color: var(--muted); font-size: 11px; line-height: 1.5; margin-top: 18px; }
.credit a { color: var(--muted); }

.results { border-bottom: 1px solid var(--line); max-height: 50vh; overflow-y: auto; padding: 6px; }
.result { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--cream); }
.result:hover, .result:focus { background: var(--panel); outline: none; }
.result small { display: block; color: var(--muted); }

/* pins */
.pin { width: 32px; height: 32px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.6); transition: transform .15s; }
.pin span { transform: rotate(45deg); font-size: 15px; line-height: 1; }
.pin:hover { transform: rotate(-45deg) scale(1.12); }
.pin.theory { border-style: dashed; }
.pin.confirmed { border-color: var(--good); box-shadow: 0 0 0 3px rgba(70,224,160,.35), 0 3px 10px rgba(0,0,0,.6); }
.pin.private { outline: 2px dotted var(--amber); outline-offset: 2px; }
.pin.spoiler span { filter: blur(3px); }
.pin.done { opacity: .45; }
.pin.draft { animation: pulse 1s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 22px rgba(255,79,163,.95); } }
.place-pin { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.place-pin i { width: 14px; height: 14px; transform: rotate(45deg); background: var(--grad); border: 2px solid #fff; box-shadow: 0 0 12px rgba(255,79,163,.8); flex: none; }
.place-pin b { font: 800 12px/1 var(--display); letter-spacing: .02em; color: #fff; text-transform: uppercase; text-shadow: 0 1px 3px #000, 0 0 8px #000; }
.zoomed-out .place-pin b { display: none; }

.hint { position: absolute; top: 12px; left: calc(50% + 150px); transform: translateX(-50%); z-index: 950; background: var(--panel); border: 1px solid var(--pink); padding: 8px 14px; border-radius: 999px; white-space: nowrap; }
.hint button { margin-left: 8px; background: none; border: 0; color: var(--pink); cursor: pointer; font-weight: 700; }

/* detail panel */
.panel { position: fixed; top: 70px; right: 12px; bottom: 12px; width: 380px; z-index: 1100; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6); overflow-y: auto; padding: 18px; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(14px); opacity: 0; } }
.panel .k-x { position: sticky; float: right; top: 0; }
.panel h2 { font: 900 28px/1.02 var(--display); letter-spacing: -.02em; text-transform: uppercase; margin: 6px 40px 6px 0; }
.panel h3 { font: 900 13px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }
.meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.desc { white-space: pre-wrap; word-wrap: break-word; margin: 12px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.spoiler-cover { background: var(--panel-2); border: 1px dashed var(--orange); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; color: var(--orange); }
.media { display: block; max-width: 100%; border-radius: 10px; margin: 8px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.comment > div { flex: 1; min-width: 0; }
.comment b { font-size: 13px; }
.comment p { margin: 3px 0 0; white-space: pre-wrap; word-wrap: break-word; }
.comments + form { margin-top: 10px; }

@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .drawer { border-right: 0; border-bottom: 1px solid var(--line); max-height: 55vh; }
  .drawer-toggle { display: inline-flex; }
  .drawer.collapsed .drawer-body { display: none; }
  .hint { left: 50%; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72vh; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation-name: rise; }
  @keyframes rise { from { transform: translateY(24px); opacity: 0; } }
}
