*, *::before, *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      height: 100vh;
      height: 100dvh;
      display: flex;
      align-items: center;
      justify-content: center;
      background: radial-gradient(ellipse at center, #27221c 0%, #080810 75%);
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      overflow-x: hidden;
      padding-left: calc(56px + var(--tut-w));
      padding-right: 56px;
    }

    #bgCanvas {
      position: fixed;
      inset: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      z-index: 0;
    }



    .maps-page-wrap {
      position: relative;
      z-index: 2;
      display: flex;
      flex-direction: column;
      gap: 8px;
      box-sizing: border-box;
      width: min(520px, calc(100vw - 112px));
      max-height: calc(100dvh - 80px);
      padding: 16px 0;
    }

    .maps-container {
      display: flex;
      flex-direction: column;
      gap: 6px;
      box-sizing: border-box;
      flex: 1;
      min-height: 0;
      overflow-y: auto;
    }

    .maps-container::-webkit-scrollbar       { width: 4px; }
    .maps-container::-webkit-scrollbar-track  { background: transparent; }
    .maps-container::-webkit-scrollbar-thumb  { background: rgba(255,255,255,0.2); border-radius: 2px; }

    /* ── Toolbar row (filter dropdown + Add New Map) ── */
    .map-toolbar-row {
      display: flex; align-items: center; justify-content: space-between; gap: 10px;
      flex-shrink: 0;
    }

    /* ── Category filter dropdown (multi-select) ── */
    .map-filter-dd { position: relative; }
    .map-filter-dd-btn {
      display: flex; align-items: center; gap: 8px;
      padding: 7px 12px; border-radius: 8px; cursor: pointer;
      border: 1px solid rgba(255,255,255,0.15);
      background: rgba(255,255,255,0.05);
      font-size: 12px; color: rgba(255,255,255,0.6);
      font-family: inherit;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .map-filter-dd-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.85); }
    .map-filter-dd-btn.active {
      background: rgba(216,170,93,0.22); border-color: rgba(216,170,93,0.5);
      color: var(--accent);
    }
    /* FA-icon experiment: icons are <i class="fa-...">; the FA webfont kit draws them
       to svg (these rules still match). No stroke/fill — FA glyphs are filled
       paths colored by currentColor. */
    .map-filter-dd-btn svg, .map-filter-dd-btn i { width: 13px; height: 13px; flex-shrink: 0; transition: transform 0.15s; font-size: 13px; }
    .map-filter-dd.open .map-filter-dd-btn svg, .map-filter-dd.open .map-filter-dd-btn i { transform: rotate(180deg); }
    /* Menu is detached to <body> at runtime (see maps-panel.js) so a scrolling
       ancestor like stories.html's .stories-wrapper can never clip it. */
    .map-filter-dd-menu.map-filter-dd-menu--floating {
      display: none;
      position: fixed; z-index: 1000;
      min-width: 180px; max-height: 240px; overflow-y: auto;
      background: var(--panel-bg-solid, rgba(29,33,39,0.98));
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 8px; box-shadow: 0 12px 30px rgba(0,0,0,0.4);
      padding: 6px;
    }
    .map-filter-dd-menu.map-filter-dd-menu--floating.open { display: block; }
    .map-filter-dd-item {
      display: flex; align-items: center; gap: 8px;
      padding: 6px 8px; border-radius: 6px; cursor: pointer;
      font-size: 12px; color: rgba(255,255,255,0.75);
      -webkit-user-select: none;
      user-select: none;
    }
    .map-filter-dd-item:hover { background: rgba(255,255,255,0.08); }
    .map-filter-dd-item input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

    /* ── Row category badge ── */
    .map-row-cat-badge {
      font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
      padding: 2px 7px; border-radius: 8px; flex-shrink: 0;
      background: rgba(216,170,93,0.15); color: var(--accent);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      max-width: 90px;
    }

    /* ── Row timeline-anchor subtitle (local-milestone maps with a Start/End
       Date set — informational only, see PLAN-milestones.md Step 8) ── */
    .map-row-anchor {
      font-size: 10px; color: rgba(255,255,255,0.32); flex-shrink: 0;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
      max-width: 140px;
    }

    /* ── Modal category picker ── */
    .map-cat-picker {
      display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    }
    .map-cat-chip-sel {
      display: inline-flex; align-items: center; gap: 6px;
      background: rgba(216,170,93,0.15); border: 1px solid rgba(216,170,93,0.35);
      border-radius: 14px; padding: 5px 8px 5px 12px;
      font-size: 12px; color: white;
    }
    .map-cat-chip-sel button {
      background: none; border: none; cursor: pointer; flex-shrink: 0;
      color: rgba(255,255,255,0.45); font-size: 13px; line-height: 1; padding: 0 2px;
      font-family: inherit;
    }
    .map-cat-chip-sel button:hover { color: rgba(255,255,255,0.85); }
    .map-cat-add-btn {
      padding: 5px 12px; border-radius: 14px;
      border: 1px dashed rgba(255,255,255,0.25);
      background: transparent; font-size: 12px; color: rgba(255,255,255,0.45);
      cursor: pointer; font-family: inherit;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }
    .map-cat-add-btn:hover {
      background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.4);
      color: rgba(255,255,255,0.75);
    }
    .map-cat-search-wrap { position: relative; flex: 1; min-width: 160px; }
    .map-cat-search {
      background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
      border-radius: 10px; padding: 6px 10px; color: white; width: 100%;
      font-family: inherit; font-size: 12px; outline: none;
      transition: border-color 0.2s ease, background 0.2s ease;
    }
    .map-cat-search:focus { border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.12); }
    .map-cat-search::placeholder { color: rgba(255,255,255,0.3); }
    .map-cat-dropdown {
      position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 220;
      background: var(--panel-bg-solid, rgba(29,33,39,0.98));
      border: 1px solid rgba(255,255,255,0.14); border-radius: 10px;
      overflow-y: auto; max-height: 180px; display: none;
    }
    .map-cat-dropdown-item {
      padding: 8px 12px; font-size: 12px; color: white; cursor: pointer;
    }
    .map-cat-dropdown-item:hover { background: rgba(255,255,255,0.1); }
    .map-cat-dropdown-item--create {
      color: var(--accent); border-top: 1px solid rgba(255,255,255,0.08);
    }
    .map-cat-dropdown-item--create:hover { background: rgba(216,170,93,0.1); }

    /* ── Map rows (tree-view style) ── */
    .map-row {
      display: flex; align-items: center; gap: 8px;
      padding: 6px 14px; border-radius: 8px; cursor: pointer;
      -webkit-user-select: none;
      user-select: none; -webkit-touch-callout: none;
      -webkit-tap-highlight-color: transparent;
      border: 1px solid transparent;
      transition: background 0.15s;
    }
    .map-row.map-parent {
      background: rgba(216,170,93,0.08);
      border-color: rgba(216,170,93,0.18);
    }
    @media (hover: hover) { .map-row.map-parent:hover { background: rgba(216,170,93,0.14); } }
    .map-row.map-leaf {
      background: rgba(255,255,255,0.04);
      border-color: rgba(255,255,255,0.07);
    }
    @media (hover: hover) { .map-row.map-leaf:hover { background: rgba(255,255,255,0.08); } }
    .map-row.map-sub {
      background: rgba(255,255,255,0.03);
      padding: 5px 12px;
    }
    @media (hover: hover) { .map-row.map-sub:hover { background: rgba(255,255,255,0.06); } }

    /* FA-icon experiment: <i class="map-row-icon fa-solid fa-map"> — the FA kit
       converts it to svg carrying the same class. Fixed 15px column, glyph
       height via font-size; color replaces the old stroke color. */
    .map-row-icon {
      width: 15px; flex-shrink: 0;
      font-size: 13px; text-align: center;
      color: rgba(255,255,255,0.5);
    }
    .map-row.map-parent .map-row-icon { color: rgba(216,170,93,0.7); }

    .map-row-name {
      flex: 1; min-width: 0;
      font-size: 13px; font-weight: 600;
      color: rgba(255,255,255,0.85);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .map-row.map-parent .map-row-name { color: var(--accent); }
    .map-row.map-sub .map-row-name    { font-weight: 500; color: rgba(255,255,255,0.7); }

    .map-row-star {
      width: 26px; height: 26px; flex-shrink: 0;
      display: flex; align-items: center; justify-content: center;
      border-radius: 6px; border: none; background: transparent;
      cursor: pointer; color: rgba(255,255,255,0.2);
      transition: background 0.15s, color 0.15s;
      opacity: 0;
    }
    /* Hover reveal is desktop-only — on touch (hover: none), iOS eats the
       first tap as hover when :hover reveals content, forcing a second tap
       (see codex.html's matching comment). */
    @media (hover: hover) { .map-row:hover .map-row-star { opacity: 1; } }
    @media (hover: none) { .map-row-star { opacity: 0.55; } }
    .map-row-star.active { color: var(--accent); opacity: 1; }
    .map-row-star:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.6); }
    .map-row-star.active:hover { background: rgba(216,170,93,0.15); }
    /* FA-icon experiment: rest = fa-regular fa-star, active = fa-solid fa-star
       (chosen at row-build time); color comes from the button's own rules. */
    .map-row-star svg, .map-row-star i { width: 13px; height: 13px; font-size: 13px; }

    .map-expand-btn {
      display: flex; align-items: center; justify-content: center;
      width: 22px; height: 22px; flex-shrink: 0;
      background: transparent; border: none; cursor: pointer;
      padding: 0; border-radius: 4px;
      transition: background 0.15s;
    }
    .map-expand-btn:hover { background: rgba(255,255,255,0.1); }

    /* FA-icon experiment: <i class="map-chevron fa-solid fa-chevron-right"> —
       the class (and this rotation transition) stays on the FA-generated svg. */
    .map-chevron {
      width: 13px; height: 13px; flex-shrink: 0;
      color: rgba(216,170,93,0.5);
      transition: transform 0.18s;
    }
    .map-group:not(.collapsed) .map-chevron { transform: rotate(90deg); }

    .map-add-btn {
      display: flex; align-items: center; gap: 8px;
      padding: 7px 14px; border-radius: 8px; cursor: pointer;
      border: 1px dashed rgba(255,255,255,0.18);
      background: transparent; font-family: inherit;
      font-size: 13px; color: rgba(255,255,255,0.6);
      transition: background 0.15s, border-color 0.15s, color 0.15s;
      white-space: nowrap; flex-shrink: 0;
      margin-left: auto;
    }
    .map-add-btn:hover {
      background: rgba(255,255,255,0.05);
      border-color: rgba(255,255,255,0.3);
      color: rgba(255,255,255,0.85);
    }
    .map-add-btn svg, .map-add-btn i { width: 13px; height: 13px; flex-shrink: 0; font-size: 13px; }

    /* ── Map edit mode ── */
    .map-modal-overlay {
      display: none; position: fixed; inset: 0; z-index: 100;
      background: rgba(0,0,0,0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
      align-items: center; justify-content: center; padding: 20px;
    left: var(--tut-w, 0px); }
    .map-modal-overlay.open { display: flex; }
    .map-modal-panel {
      background: var(--panel-bg); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
      border: 1px solid rgba(255,255,255,0.14); border-radius: 20px;
      width: min(480px, calc(100vw - 40px)); color: white; padding: 28px 28px 24px;
    }
    .map-modal-top {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 20px;
    }
    .map-modal-title { font-size: 18px; font-weight: 700; }
    .map-modal-close {
      width: 34px; height: 34px; border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.1);
      color: white; font-size: 16px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.2s ease;
    }
    .map-modal-close:hover { background: rgba(255,255,255,0.22); }
    .map-edit-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
    .map-edit-field:last-of-type { margin-bottom: 0; }
    .map-edit-label {
      font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
      text-transform: uppercase; color: rgba(255,255,255,0.45);
    }
    .map-edit-input, textarea.map-edit-input {
      background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
      border-radius: 10px; padding: 8px 12px; color: white;
      font-family: inherit; font-size: 14px; outline: none; width: 100%; resize: vertical;
      transition: border-color 0.2s ease, background 0.2s ease;
    }
    .map-edit-input:focus, textarea.map-edit-input:focus {
      border-color: rgba(255,255,255,0.4); background: rgba(255,255,255,0.12);
    }
    .map-edit-input::placeholder, textarea.map-edit-input::placeholder { color: rgba(255,255,255,0.3); }
    textarea.map-edit-input { min-height: 80px; }
    .map-modal-footer { display: flex; gap: 10px; margin-top: 20px; }
    .map-modal-btn {
      flex: 1; padding: 11px; border-radius: 12px;
      border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.1);
      color: white; font-family: inherit; font-size: 12px; font-weight: 700;
      letter-spacing: 1px; text-transform: uppercase; cursor: pointer;
      transition: background 0.2s ease;
    }
    .map-modal-btn:hover                      { background: rgba(255,255,255,0.2); }
    .map-modal-btn:disabled                   { opacity: 0.5; cursor: not-allowed; }
    .map-modal-btn--save                      { background: rgba(216,170,93,0.25); border-color: rgba(216,170,93,0.4); }
    .map-modal-btn--save:hover:not(:disabled) { background: rgba(216,170,93,0.4); }

    /* ── Tree: parent groups + sub-maps ── */
    .map-group { display: flex; flex-direction: column; gap: 0; }

    .map-children {
      padding: 3px 0 3px 14px;
      display: flex; flex-direction: column; gap: 3px;
      border-left: 1px solid rgba(255,255,255,0.1);
      margin-left: 21px; margin-top: 3px;
    }
    .map-group.collapsed > .map-children { display: none; }

    /* ── Context menu: base look now from theme.css; just the wider min-width here ── */
    .ctx-menu.open { min-width: 200px; }

    /* ── World picker modal ── */
    .wp-overlay {
      display: none; position: fixed; inset: 0; z-index: 300;
      background: rgba(0,0,0,0.65); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
      align-items: center; justify-content: center; padding: 20px;
    left: var(--tut-w, 0px); }
    .wp-overlay.open { display: flex; }
    .wp-panel {
      background: var(--panel-bg); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
      border: 1px solid rgba(255,255,255,0.14); border-radius: 20px;
      width: min(460px,calc(100vw - 40px)); max-height: calc(100vh - 80px);
      display: flex; flex-direction: column; color: white; overflow: hidden;
    }
    .wp-top { display: flex; align-items: center; justify-content: space-between; padding: 24px 24px 16px; flex-shrink: 0; }
    .wp-title { font-size: 18px; font-weight: 700; }
    .wp-close {
      width: 34px; height: 34px; border-radius: 10px;
      border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.1);
      color: white; font-size: 16px; cursor: pointer;
      display: flex; align-items: center; justify-content: center; transition: background 0.2s ease;
    }
    .wp-close:hover { background: rgba(255,255,255,0.22); }
    .wp-list { flex: 1; overflow-y: auto; padding: 0 16px 8px; display: flex; flex-direction: column; gap: 8px; }
    .wp-list::-webkit-scrollbar { width: 4px; }
    .wp-list::-webkit-scrollbar-track { background: transparent; }
    .wp-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
    .wp-item {
      display: flex; align-items: center; gap: 14px;
      padding: 12px 14px; border-radius: 12px;
      border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05);
      cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; -webkit-user-select: none; user-select: none;
    }
    .wp-item:hover    { background: rgba(255,255,255,0.1); }
    .wp-item.selected { background: rgba(216,170,93,0.2); border-color: rgba(216,170,93,0.6); }
    .wp-icon  { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
    .wp-name  { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }
    .wp-footer { display: flex; gap: 10px; padding: 16px 24px 24px; flex-shrink: 0; }
    .wp-btn {
      flex: 1; padding: 11px; border-radius: 12px;
      border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.1);
      color: white; font-family: inherit; font-size: 12px; font-weight: 700;
      letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: background 0.2s ease;
    }
    .wp-btn:hover                      { background: rgba(255,255,255,0.2); }
    .wp-btn:disabled                   { opacity: 0.4; cursor: not-allowed; }
    .wp-btn--copy                      { background: rgba(216,170,93,0.25); border-color: rgba(216,170,93,0.4); }
    .wp-btn--copy:hover:not(:disabled) { background: rgba(216,170,93,0.4); }

    /* ── Feature toast ── */
    .feature-toast {
      position: fixed;
      bottom: 40px;
      left: calc(50% + var(--tut-w, 0px) / 2);
      transform: translateX(-50%) translateY(10px);
      background: var(--panel-bg-solid);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 12px;
      padding: 12px 20px;
      color: white;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      font-size: 13px;
      font-weight: 600;
      white-space: nowrap;
      z-index: 1000;
      opacity: 0;
      transition: opacity 0.3s ease, transform 0.3s ease;
      pointer-events: none;
    }
    .feature-toast.show {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }

    @media (max-width: 600px) {
      input, select, textarea { font-size: 16px; }
    }

/* Whole-map GM marker (PLAN-ttrpg.md Phase 5). */
/* Shared with named players. Gold rather than the GM badge's amber: amber
   reads as "withheld from everyone", and this is the softer case. */
.map-row-shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #d8aa5d);
  background: rgba(216, 170, 93, 0.12);
  border: 1px solid rgba(216, 170, 93, 0.3);
  border-radius: 5px;
  padding: 1px 6px;
}
.map-row-gm-badge {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  background: rgba(216, 170, 93, 0.16);
  border: 1px solid rgba(216, 170, 93, 0.42);
  color: var(--accent, #d8aa5d); font-size: 9.5px; letter-spacing: 0.03em;
  text-transform: uppercase; white-space: nowrap;
}
.map-row-gm-badge i { font-size: 8.5px; }
