/* Compare layouts panel (layout-compare.js), the shortcut sheet and the first-visit tour (help-tour.js) */
:root { --c-cmp-moved: #f0c060; --c-cmp-changed: #6fd3e0; }

/* ---------- Compare panel, over the bottom left of the map ---------- */
.cmp-panel {
  position: absolute; z-index: 3; left: 12px; bottom: 12px; width: min(340px, calc(100% - 24px)); max-height: 48%;
  display: flex; flex-direction: column; gap: var(--sp-3); overflow: auto; padding: var(--sp-4) var(--sp-5);
  background: var(--c-float); border: 1px solid var(--c-line-strong);
  box-shadow: 0 0 0 3px var(--c-float-ring), 0 10px 24px rgba(0, 0, 0, .6); font-size: var(--fs-sm);
}
.cmp-panel[hidden] { display: none; }
.cmp-head { display: flex; align-items: baseline; gap: var(--sp-4); }
.cmp-head h2 { margin: 0; font: 700 var(--fs-lg)/1.2 var(--font-display); text-transform: var(--display-case); letter-spacing: var(--tracking-display); color: var(--c-heading); overflow: hidden; text-overflow: ellipsis; }
.cmp-head h2::after { display: none; }
.cmp-head button { margin-left: auto; min-height: 22px; padding: 0 var(--sp-3); }
.cmp-panel .help { margin: 0; color: var(--c-owned); }
.cmp-panel .help:empty { display: none; }
.cmp-sum { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.cmp-chip { min-height: 26px; padding: 0 var(--sp-4); font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: var(--sp-3); }
.cmp-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cmp-dot.cmp-added { background: var(--c-ok); }
.cmp-dot.cmp-removed { background: var(--c-danger); }
.cmp-dot.cmp-moved { background: var(--c-cmp-moved); }
.cmp-dot.cmp-changed { background: var(--c-cmp-changed); }
.cmp-same { font-size: var(--fs-xs); }
.cmp-types-wrap summary { cursor: pointer; color: var(--c-text-muted); }
.cmp-types { list-style: none; margin: var(--sp-2) 0 0; padding: 0; max-height: 180px; overflow: auto; }
.cmp-type {
  display: flex; width: 100%; gap: var(--sp-4); align-items: center; min-height: 24px; padding: 0 var(--sp-3);
  border: 0; border-bottom: 1px dotted var(--c-line); background: none; box-shadow: none; text-align: left; font-size: var(--fs-sm);
}
.cmp-type:hover { background: var(--c-hover); }
.cmp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-text); }
.cmp-bits { display: flex; gap: var(--sp-3); font-variant-numeric: tabular-nums; }
.cmp-added-t { color: var(--c-ok); }
.cmp-removed-t { color: var(--c-danger); }
.cmp-moved-t { color: var(--c-cmp-moved); }
.cmp-changed-t { color: var(--c-cmp-changed); }
.cmp-with { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-5); }
.cmp-with select { width: 100%; }
@media (max-width: 720px) {
  .cmp-panel { top: 8px; bottom: auto; left: 8px; right: 52px; width: auto; max-height: 42%; }
}

/* ---------- Controls dialog (? button, ? key) ---------- */
dialog.keys-dlg { width: min(880px, 94vw); max-height: 88vh; overflow: auto; }
.keys-ctl { margin-top: var(--sp-4); }
.keys-ctl .ctl { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-5) var(--sp-7); align-items: start; }
.keys-ctl .ctl-touch { display: none; }
@media (any-pointer: coarse) {
  .keys-ctl .ctl-touch { display: grid; }
  @media not all and (any-pointer: fine) { .keys-ctl .ctl-mouse { display: none; } }
}
.keys-ctl .ctl + .ctl { margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px dotted var(--c-line); }
.keys-ctl .ctl-touch:not(:first-child) { margin-top: var(--sp-6); }
.keys-ctl h3 { margin: 0 0 var(--sp-3); font: 600 var(--fs-lg)/1.2 var(--font-caps); text-transform: var(--display-case); letter-spacing: var(--tracking-display); color: var(--c-heading); }
.keys-ctl dl { margin: 0; }
.keys-ctl .help { grid-column: 1 / -1; margin: 0; }
.keys-more { margin-top: var(--sp-6); border-top: 1px dotted var(--c-line); padding-top: var(--sp-4); }
.keys-more > summary { cursor: pointer; list-style: none; }
.keys-more > summary::-webkit-details-marker { display: none; }
.keys-more > summary h2 { display: inline; margin: 0; font: 600 var(--fs-lg)/1.2 var(--font-caps); text-transform: var(--display-case); letter-spacing: var(--tracking-display); color: var(--c-text-muted); }
.keys-more > summary::before { content: "▸ "; color: var(--c-text-faint); }
.keys-more[open] > summary::before { content: "▾ "; }
.keys-more .help { margin-top: var(--sp-3); line-height: 1.5; }
.keys-foot { margin-top: var(--sp-5); align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-3); }
.keys-foot .help { margin-right: auto; }

/* The ? button at the bottom right of the map */
.help-fab {
  position: absolute; z-index: 3; right: 12px; bottom: 12px; width: 32px; height: 32px; min-height: 0; padding: 0;
  font: 700 18px/1 var(--font-display); text-transform: var(--display-case); letter-spacing: var(--tracking-display); color: var(--c-text-muted);
  background: var(--c-float); border: 1px solid var(--c-line-strong); box-shadow: 0 0 0 3px var(--c-float-ring);
}
.help-fab:hover, .help-fab:focus-visible { color: var(--c-heading); border-color: var(--c-accent-strong); }
@media (max-width: 720px) {
  .help-fab { bottom: auto; top: 8px; right: 8px; width: 36px; height: 36px; }
}

/* ---------- First-visit tour ---------- */
.tour-ring {
  position: fixed; z-index: 50; pointer-events: none;
  border: 2px solid var(--c-select); box-shadow: 0 0 0 4px rgba(167, 139, 250, .2), 0 0 24px rgba(167, 139, 250, .28);
  transition: left .18s, top .18s, width .18s, height .18s;
}
.tour-card {
  position: fixed; z-index: 51; width: min(320px, calc(100vw - 32px)); padding: var(--sp-5) var(--sp-6);
  background: var(--c-raised); color: var(--c-text); border: 1px solid var(--c-line-strong);
  box-shadow: 0 0 0 4px var(--c-raised), 0 0 0 5px var(--c-line-strong), var(--shadow-pop);
}
.tour-card h2 { margin: 0 0 var(--sp-3); font: 700 var(--fs-xl)/1.2 var(--font-display); text-transform: var(--display-case); letter-spacing: var(--tracking-display); color: var(--c-heading); }
.tour-card h2::after { display: none; }
.tour-card p { margin: 0; line-height: 1.5; }
.tour-foot { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-5); }
.tour-foot .muted { font-size: var(--fs-xs); margin-right: auto; }
@media (prefers-reduced-motion: reduce) { .tour-ring { transition: none; } }

/* The one-line tour offer over the map, first visit only (help-tour.js) */
.tour-offer {
  position: absolute; z-index: 3; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: calc(100% - 120px);
  display: flex; align-items: stretch;
  background: var(--c-float); border: 1px solid var(--c-accent-strong); box-shadow: 0 0 0 3px var(--c-float-ring), var(--shadow-pop);
}
.tour-offer button { border: 0; background: none; box-shadow: none; min-height: 36px; }
.tour-offer-take { padding: 0 var(--sp-5); color: var(--c-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tour-offer-take:hover, .tour-offer-take:focus-visible { color: var(--c-accent-strong); text-decoration: underline; }
.tour-offer-x { padding: 0 var(--sp-4); color: var(--c-text-muted); border-left: 1px solid var(--c-line) !important; }
.tour-offer-x:hover, .tour-offer-x:focus-visible { color: var(--c-heading); }
@media (max-width: 720px) {
  /* the map tools run along the bottom on phones, so the offer sits at the top, clear of the ? button */
  .tour-offer { bottom: auto; top: 8px; left: 8px; transform: none; max-width: calc(100% - 64px); }
  .tour-offer button { min-height: 44px; }
}
/* Controls scrolls: keep its title and ✕ on screen (one dialog pattern, dialogs.js) */
dialog.keys-dlg > .lib-head { position: sticky; top: calc(-1 * var(--sp-6)); z-index: 2; margin: calc(-1 * var(--sp-6)) calc(-1 * var(--sp-6)) 0; padding: var(--sp-6) var(--sp-6) var(--sp-3); background: var(--c-raised); }
