/* Chart Locker: rail sub-items, map chart selector, chart dialogs */
.rail-charts { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px; }
.rc-item { position: relative; display: flex; align-items: center; height: 38px; margin: 0 -4px; border-radius: 10px; }
.rc-item:hover { background: var(--surface-2); }
.rc-open, .rc-new { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 12px; padding: 0 0 0 12px;
  background: none; border: 0; color: var(--text-2); font: inherit; font-size: 13px; text-align: left; cursor: pointer; border-radius: 9px; }
.rc-item.is-current .rc-open { color: var(--primary); }
.rc-badge { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; font-size: 11px;
  border: 1px solid var(--line); background: var(--surface); color: inherit; }
.rc-badge .icon { width: 14px; height: 14px; }
.rc-item.is-current .rc-badge { border-color: var(--primary); background: var(--primary-soft); }
.rc-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s; display: flex; flex-direction: column; line-height: 1.15; }
.rc-name small { font-size: 10.5px; color: var(--text-2); }
.sections:hover .rc-name, .sections:has(:focus-visible) .rc-name { opacity: 1; }
.rc-more { flex: none; width: 28px; height: 28px; margin-right: 10px; border: 0; background: none; color: var(--text-2); border-radius: 6px; cursor: pointer; opacity: 0; }
.sections:hover .rc-item:hover .rc-more, .rc-more:focus-visible { opacity: 1; }
.rc-more:hover { background: var(--surface); color: var(--text); }

.chart-pick { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 810; }
.cp-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: var(--touch); max-width: min(70vw, 340px); padding: 0 30px; border-radius: 999px;
  font: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; cursor: pointer; text-align: center;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); border: 1px solid var(--line); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.cp-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-btn:focus-visible, .cp-menu button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cp-menu { display: none; position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); min-width: 100%; width: max-content; max-width: min(80vw, 340px);
  padding: 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.chart-pick.open .cp-menu { display: flex; flex-direction: column; gap: 2px; }
.cp-menu button { display: flex; flex-direction: column; align-items: center; padding: 7px 14px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; text-align: center; }
.cp-menu button:hover { background: var(--surface-2); }
.cp-menu button.is-current { color: var(--primary); font-weight: 600; }
.cp-menu small { font-size: 10.5px; color: var(--text-2); font-weight: 400; }
.cp-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

.mem-list { display: flex; flex-direction: column; gap: 6px; }
.mem-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.mem-row > div:first-child, .mem-open { flex: 1; min-width: 0; }
.mem-row.is-current { box-shadow: inset 0 0 0 1px var(--primary); }
.mem-open { background: none; border: 0; padding: 0; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.mem-ctl { display: flex; gap: 6px; align-items: center; flex: none; }
.mem-ctl select { font: inherit; font-size: 13px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.mem-inv-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.chart-acts .btn { justify-content: flex-start; gap: 8px; }

/* View-only chart: hide the controls that would change it */
body[data-chart-role="viewer"] .lv-more,
body[data-chart-role="viewer"] [data-act="add"],
body[data-chart-role="viewer"] [data-del],
body[data-chart-role="viewer"] [data-ren] { display: none !important; }

/* People on the open chart: overlapping avatars left of the map buttons */
.pp-stack { position: absolute; top: 12px; right: 64px; z-index: 805; display: flex; align-items: center; height: 42px; padding: 0 4px;
  background: none; border: 0; cursor: pointer; }
.pp-item { position: relative; display: block; margin-left: -10px; }
.pp-item:first-child { margin-left: 0; }
.pp-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; flex: none;
  background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 600; border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.pp-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pp-more { background: var(--surface-2); color: var(--text); }
.pp-add { background: var(--surface); color: var(--text); }
.pp-add .icon { width: 16px; height: 16px; }
.pp-lg { width: 38px; height: 38px; box-shadow: none; }
.pp-stack:hover .pp-item { z-index: 1; }
.pp-stack:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 999px; }
@media (hover: hover) {
  .pp-item:hover { z-index: 2; }
  .pp-item:hover::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0; white-space: nowrap; padding: 4px 8px;
    border-radius: 6px; font-size: 12px; background: var(--text); color: var(--bg); pointer-events: none; }
}
@media (max-width: 1023px) { .pp-stack { top: 10px; right: 60px; } }
.rail-home-row { position: relative; }
.sections:hover .rail-home-row .rail-home, .sections:has(:focus-visible) .rail-home-row .rail-home { padding-right: 40px; }
.rc-add { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--primary); cursor: pointer; opacity: 0; transition: opacity .15s; }
.rc-add .icon { width: 16px; height: 16px; }
.rc-add:hover { background: var(--surface-3, var(--surface-1)); }
.sections:hover .rc-add, .rc-add:focus-visible { opacity: 1; }
.rc-open, .rc-name, .rc-badge { font-weight: 400; }
.sections .rail-home-row a.rail-home { background: transparent; color: inherit; }
.has-charts .sections .rail-home-row a.rail-home .icon { color: var(--primary); }
.sections .rail-home-row a.rail-home { outline: none; box-shadow: none; border-color: transparent; }
/* Live pointers on shared charts (js/app/presence.js) */
.live-cursor { background: none; border: 0; transition: transform .12s linear, opacity .4s; }
.lc-zooming .live-cursor { transition: none; }
.live-cursor svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.live-cursor .lc-tag { position: absolute; left: 16px; top: 16px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; color: #161616; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.live-cursor.lc-idle { opacity: 0; }
.pp-item:has(.pp-on)::after { content: ""; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: #34C759; box-shadow: 0 0 0 2px var(--surface); }

/* notifications bell */
.bell { position: relative; display: inline-flex; }
.bell[hidden] { display: none; }
.bell > .hdr-btn { position: relative; }
.bell-n { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; }
.bell-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); width: min(320px, 90vw); max-height: 60vh; overflow: auto; z-index: 1200; background: var(--surface); border: 1px solid var(--surface-3); border-radius: 16px; padding: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.35); }
.bell.open .bell-menu { display: block; }
.bell-item { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; }
.bell-item + .bell-item { margin-top: 4px; }
.bell-item:hover { background: var(--surface-2); }
.bell-act { display: flex; gap: 8px; }
.bell-empty { padding: 10px; margin: 0; }
.lc-center{position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-9px 0 0 -9px;border-radius:50%;border:2px solid var(--accent,#E0A526);background:color-mix(in srgb,var(--accent,#E0A526) 25%,transparent);box-shadow:0 0 0 2px rgba(0,0,0,.35);pointer-events:none;z-index:640;opacity:0;transition:opacity .2s}
.lc-center.on{opacity:1}
@media (max-width: 1023px) {
  .chart-pick { top: 10px; }
  .cp-menu { min-width: min(72vw, 300px); max-width: 90vw; padding: 8px; }
  .chart-pick.open .cp-menu { gap: 6px; }
  .cp-menu button { padding: 12px 16px; min-height: 44px; justify-content: center; font-size: 15px; }
}

/* long chart names: cut off with … ; full name on hover (title) and in the open map menu */
.rc-name { flex: 1; }
.rc-label, .rc-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-btn { max-width: min(46vw, 280px); }
.cp-btn span { min-width: 0; }
.cp-menu button { max-width: 100%; }
.cp-name { display: block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: center; }
@media (max-width: 1023px) { .cp-btn { max-width: 52vw; } }

/* hotkeys: bullseye placing cursor, settings rows, new-spot facts */
.hk-placing, .hk-placing .leaflet-interactive, .hk-placing .leaflet-grab { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='11' fill='none' stroke='%23000' stroke-opacity='.5' stroke-width='4'/%3E%3Ccircle cx='16' cy='16' r='11' fill='none' stroke='%23E0A526' stroke-width='2'/%3E%3Ccircle cx='16' cy='16' r='1.6' fill='%23E0A526'/%3E%3C/svg%3E") 16 16, crosshair !important; }
.hk-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
kbd { font-family: var(--font-mono, monospace); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line-strong, var(--line)); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); }
.hk-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }

/* per-chart colour + label */
.rc-badge[style*="--chart-c"] { border-color: var(--line); color: color-mix(in srgb, var(--chart-c) 70%, var(--text-2)); background: var(--surface); }
.rc-item.is-current .rc-badge[style*="--chart-c"] { border-color: var(--chart-c); color: var(--chart-c); background: color-mix(in srgb, var(--chart-c) 26%, var(--surface)); }
.look-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.look-sw { position: relative; cursor: pointer; }
.look-sw input { position: absolute; opacity: 0; }
.look-sw span { display: block; width: 28px; height: 28px; border-radius: 8px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.look-none span { background: repeating-linear-gradient(45deg, var(--surface-2) 0 4px, var(--surface) 4px 8px); }
.look-sw input:checked + span { border-color: var(--text); }
.look-sw input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.mapwrap .mc-pop { z-index: 1050; }   /* above the chart picker (810) and Leaflet's corner controls: + button, scale, credits (1000) */

/* chart switch loading overlay */
.chart-switching { position: absolute; inset: 0; z-index: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--bg);
  color: var(--text); font-size: 13px; font-weight: 600; transition: opacity .2s; }
.chart-switching.out { opacity: 0; }
.cs-spin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: cs-rot .8s linear infinite; }
@keyframes cs-rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chart-switching { transition: none; } .cs-spin { animation: none; } }
/* someone moving their pointer on the map: avatar outlined in their cursor colour (presence.js T.presence.active/color) */
.pp-av.pp-live { border-color: var(--pp-ring); box-shadow: 0 0 0 2px var(--pp-ring), 0 0 10px 1px var(--pp-ring); transition: border-color .2s, box-shadow .2s; }
.pp-stack .pp-item:has(.pp-live) { z-index: 1; }

/* Chart list: desktop left rail; phone badges remain on the map under the profile button. */
.map-charts { position: absolute; z-index: 800; left: 12px; top: 70px; max-height: calc(100% - 170px); overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 2px; padding: 5px; width: 52px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-1); transition: width .18s ease-out; scrollbar-width: none; }
.map-charts::-webkit-scrollbar { display: none; }
.map-charts:hover, .map-charts:focus-within { width: 260px; }
.mcl-item { position: relative; display: flex; align-items: center; min-height: 40px; border-radius: 10px; flex: none; }
.mcl-item:hover { background: var(--surface-2); }
.mcl-open, .mcl-act { flex: 1; min-width: 0; height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 0 0 6px; border: 0; background: transparent;
  color: var(--text-2); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; border-radius: 10px; }
.mcl-act { width: 100%; }
.mcl-item .rc-badge { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.mcl-item.is-current .mcl-open { color: var(--primary); }
.mcl-item.is-current .rc-badge { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary-soft); }
.mcl-inv { background: var(--primary) !important; color: var(--on-primary) !important; border-color: var(--primary) !important; }
.mcl-name { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; opacity: 0; transition: opacity .15s; }
.mcl-name > span { overflow: hidden; text-overflow: ellipsis; }
.mcl-name small { font-size: 11px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.mcl-more { flex: none; width: 30px; height: 30px; margin-right: 4px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; opacity: 0; }
.mcl-more:hover { background: var(--surface-3); color: var(--text); }
.map-charts:hover .mcl-name, .map-charts:focus-within .mcl-name, .map-charts:hover .mcl-more, .map-charts:focus-within .mcl-more { opacity: 1; }
.mcl-act { border-top: 0; }
.mcl-act + .mcl-act, .mcl-item + .mcl-act { margin-top: 2px; }
/* Out of the way while plotting a route (toolbar on the left) or while search results fill the left side */
.rt-editing .mapwrap .map-charts, .mapwrap:has(.spot-search.is-full) .map-charts { display: none; }
@media (min-width: 1024px) {
  #railCharts .map-charts { position: static; width: 100%; max-height: none; padding: 0; border: 0; border-radius: 0;
    background: transparent; box-shadow: none; overflow: hidden; transition: none; }
  #railCharts .mcl-open, #railCharts .mcl-act { padding-left: 5px; min-width: 33px; }
  #railCharts .mcl-item .rc-badge { flex: none; width: 28px; height: 28px; }
  #railCharts .mcl-name { flex: 1; opacity: 0; }
  #railCharts .mcl-more { display: none; }
  .sections:hover #railCharts .mcl-name, .sections:has(:focus-visible) #railCharts .mcl-name { opacity: 1; }
  .sections:hover #railCharts .mcl-more, .sections:has(:focus-visible) #railCharts .mcl-more { display: block; opacity: 1; }
  body.rail-touch #railCharts .mcl-name, body.rail-touch #railCharts .mcl-more { opacity: 0 !important; }
  body.rail-touch #railCharts .mcl-more { display: none !important; }
  .rail-slot:has(.sections:focus-visible), .rail-slot:has(.sections :focus-visible) { width: var(--rail-open); }
}
@media (max-width: 1023px) {
  /* Phones switch charts with the dropdown only; the chart list lives in the desktop left menu. */
  .map-charts { display: none !important; }
  .map-charts:hover, .map-charts:focus-within { width: auto; }
  .mcl-name, .mcl-more { display: none; }
  .mcl-open, .mcl-act { padding: 0 6px; gap: 0; }
}

/* The chart icon is independent of search; the crew extends left from the profile. */
.mapwrap .chart-pick { position: relative; top: auto; left: auto; transform: none; flex: none; z-index: 1; }
.mapwrap .cp-btn { width: 36px; height: 36px; max-width: none; padding: 0; background: transparent; border: 0; box-shadow: none; border-radius: var(--r-sm); letter-spacing: 0; }
.mapwrap .cp-btn:hover { background: var(--surface-2); }
.mapwrap .cp-menu { left: -4px; transform: none; min-width: 220px; max-width: min(340px, calc(100vw - 24px)); border-radius: var(--r-sm); }
.mapwrap .cp-menu button { align-items: flex-start; text-align: left; }
.mapwrap .cp-name { text-align: left; }
.map-identity .pp-stack { position: relative; top: auto; right: auto; height: var(--touch); padding: 0; margin-right: 0; }
.map-identity .pp-av { width: 30px; height: 30px; box-shadow: var(--shadow-1); }
.map-identity .pp-item { margin-left: -9px; }
.map-identity .pp-item:first-child { margin-left: 0; }

/* Crew avatars and the "+" share placeholder are hidden on every layout for now (owner's call, pending); the People
   panel and live pointers still work. The rules below keep their layout for when they return. */
.map-identity .pp-stack, .map-identity .pp-plus { display: none !important; }
/* Desktop: the profile lives in the top bar, so the map shows only the crew plus a "+" share placeholder,
   whose centre lines up with the map buttons column below. */
.map-identity .pp-plus { display: none; }
@media (min-width: 1024px) {
  .map-identity .map-acct { display: none; }
  .map-identity .pp-stack { margin-right: 0; }
  .map-identity .pp-solo { display: none; }
  .map-identity .pp-plus { display: inline-flex; margin-right: 7px; }
  .map-identity .pp-plus .pp-av { border-style: dashed; }
}

.cp-label, .cp-caret { display: none; }
