/* Purchase Goals: gear-setup planner. Loaded only by /dashboard/purchase-goals
   (render_purchase_goals in app/pages/), not the shared myscape.css. */

.pg-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  position: relative;
}

.tracker-icon-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.tracker-icon-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

/* RuneLite CDN icons draw on a fixed canvas with padding on the right for the
   stack-count badge; the size bump and translate recenter the glyph (see
   .loot-item-box-icon in loot-tracker.css). */
.tracker-icon-btn img {
  width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated;
  transform: translate(5.5%, -1%);
}
.tracker-icon-btn.active { border-color: var(--gold); }
.tracker-icon-btn:hover { border-color: var(--gold-dim); }
/* Setup icons are draggable to reorder (wireSetupIconDrag in app/pages/). */
.tracker-icon-btn.dragging { opacity: 0.4; cursor: grabbing; }
.tracker-icon-fallback { font-size: 9px; color: var(--text-dim); text-align: center; line-height: 1.15; padding: 0 3px; }

.tracker-menu-wrap {
  position: relative;
  /* Same 44x44 cell as a setup icon so a wrapped menu button lines up in columns
     with the rows above. */
  width: 44px; height: 44px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.icon-menu-btn {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-menu-btn:hover { border-color: var(--gold); color: var(--text); }
.icon-menu-btn.active, .icon-menu-btn.active:hover { border-color: var(--gold); color: var(--gold); }

/* Drawn three-bar hamburger rather than a text glyph, so it does not depend on
   font rendering of the character. */
.hamburger-icon { display: flex; flex-direction: column; justify-content: space-between; width: 16px; height: 11px; }
.hamburger-icon span { display: block; height: 2px; background: currentColor; }

/* Opaque: floats over the gear grid/summary list, where translucency lets
   content show through. */
.tracker-menu {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--panel); border: 1px solid var(--border); min-width: 128px;
  display: flex; flex-direction: column;
}
/* Same small/gray/all-caps treatment as .sort-btn and .btn-secondary. */
.tracker-menu-item {
  background: none; border: none; text-align: center; padding: 10px 14px;
  color: var(--text-dim); font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase;
  cursor: pointer;
}
.tracker-menu-item:hover { background: var(--panel-2); color: var(--gold); }
/* Reset button.danger (myscape.css) bleed-through: it is more specific than
   .tracker-menu-item and adds width: 100%. Same as .mm-menu-item.danger in
   mindmaps.css. */
.tracker-menu-item.danger {
  width: auto;
  background: none;
  border: none;
  color: var(--red);
  padding: 10px 14px;
  font-size: 10.5px;
}
.tracker-menu-item.danger:hover { color: var(--red); }
/* Armed "Are you sure?" state of Delete setup (see closeSetupMenu in the page
   script); the hover tint is held permanently. */
.tracker-menu-item--confirm,
.tracker-menu-item--confirm:hover {
  color: var(--red);
  background: rgba(192, 90, 76, 0.12);
}

.pg-setup-form {
  display: flex; gap: 8px; justify-content: center; align-items: center; margin-bottom: 18px;
}
.pg-setup-form input[type="text"] { flex: 1 1 280px; max-width: 360px; }
/* A required-field miss is shown as a red border only. The .pg-setup-form
   ancestor + [type="text"] compound outranks this file's rule above and
   myscape.css's input[type="text"]. */
.pg-setup-form input[type="text"].invalid { border-color: var(--red); }
/* button.primary (myscape.css) defaults to width: 100%; pin it to content size
   so it sits in one row with the input and Cancel. */
/* Id selector so it outweighs button.primary's element+class selector in
   myscape.css. */
button.primary#pgNameSave, .pg-setup-form-save {
  width: auto; flex: 0 0 auto;
  padding: 0 22px; height: 25px; margin-top: 0;
  font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Bordered box button for secondary actions beside a primary one; button.link
   (myscape.css) renders as bare text. */
/* 25px is the site-wide button height (see .loot-sort-tab in loot-tracker.css).
   .gear-icon-picker's align-items: center keeps it centered against the 32px
   search box. */
.btn-secondary {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-dim); font-family: inherit;
  padding: 0 16px; height: 25px;
  font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--gold-dim); color: var(--text); }
.btn-secondary:disabled { opacity: 0.5; cursor: default; }

.overlay-card {
  border-radius: var(--radius);
  padding: 18px 22px;
  /* 18px matches the gap below .loot-chart-card in loot-tracker.css; see also
     .pg-body's gap. */
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 18px;
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  min-height: 90px;
}
.overlay-side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.overlay-side.overlay-target { flex-direction: row-reverse; }
/* Both .overlay-icon images are RuneLite CDN item icons, so the canvas-padding
   translate (see .loot-item-box-icon in loot-tracker.css) lives on the shared
   class. */
.overlay-icon {
  width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0;
  transform: translate(5.5%, -1%);
}
.overlay-amount { font-size: 23px; font-weight: normal; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.overlay-progress { flex: 1; min-width: 60px; }
.progress-track { height: 9px; background: #100e0b; border-radius: 0; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: var(--gold); border-radius: 0; transition: width 0.5s ease; }
.progress-fill.funded-fill { background: var(--green); }
.progress-track.overlay-track { height: 16px; }

.overlay-icon-wrap {
  width: 44px; height: 44px; flex-shrink: 0; cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.overlay-icon-wrap:hover { background: rgba(255,255,255,0.06); }
.overlay-icon-wrap .overlay-icon { width: 44px; height: 44px; }
.overlay-icon-placeholder {
  width: 30px; height: 30px; border-radius: 50%; border: 1px dashed var(--text-faint);
  color: var(--text-faint); display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}
.overlay-icon-wrap:hover .overlay-icon-placeholder { border-color: var(--gold-dim); color: var(--gold); }

/* 18px matches .loot-panels' gap in loot-tracker.css. */
.pg-body { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
/* Holds the gear frame and, when editing a slot, the slot picker beneath it. JS
   pins its px width to the frame's (renderContent in app/pages/); otherwise
   the picker's search box stretches it and pushes .pg-summary-col out of the
   row. max-width: 100% is the narrow-viewport fallback. */
.pg-doll-wrap { display: flex; flex-direction: column; gap: 18px; max-width: 100%; }
.pg-summary-col { flex: 1 1 320px; min-width: 280px; }

/* Translucent frame (slots stay opaque). align-items: stretch makes .gear-doll
   as tall as .inventory-grid so .gear-doll-misc can sit at the bottom via
   margin-top: auto. flex-shrink: 0 keeps the frame at content width once
   .pg-doll-wrap is pinned. */
.pg-gear-frame {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  gap: 28px;
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-sizing: border-box;
}

/* Paperdoll above the 8 misc slots. The column stretches to the inventory's
   height and .gear-doll-misc's margin-top: auto absorbs the leftover space, so
   the paperdoll sits at the top and the misc block ends level with
   .inventory-grid. */
.gear-doll { display: flex; flex-direction: column; }

.gear-doll-slots {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(5, 56px);
  grid-template-areas:
    ".      head   ."
    "cape   neck   ammo"
    "weapon body   shield"
    ".      legs   ."
    "hands  boots  ring";
  gap: 8px;
}
/* Place slots into the grid-template-areas cells above; without them the slots
   flow in document order. */
.slot-head { grid-area: head; }
.slot-cape { grid-area: cape; }
.slot-neck { grid-area: neck; }
.slot-ammo { grid-area: ammo; }
.slot-weapon { grid-area: weapon; }
.slot-body { grid-area: body; }
.slot-shield { grid-area: shield; }
.slot-legs { grid-area: legs; }
.slot-hands { grid-area: hands; }
.slot-boots { grid-area: boots; }
.slot-ring { grid-area: ring; }

/* The 8 misc slots (MISC_EQUIPMENT_SLOTS in app/schemas.py), 2 rows of 4. 184px
   = 3 normal slots + 2 gaps (3*56 + 2*8). Height is implicit (2*40 + 8).
   margin-top: auto positions it (see .gear-doll). */
.gear-doll-misc {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 40px);
  gap: 8px;
  width: 184px;
  margin-top: auto;
}
/* 40px = (184 - 3*8px gaps) / 4: 4 slots fit the width of 3 normal ones. Two
   classes (as in slotHtml) outrank .gear-slot regardless of rule order. */
.gear-slot.gear-slot-sm { width: auto; height: 40px; }
.gear-slot.gear-slot-sm .gear-slot-icon { width: 30px; height: 30px; }

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 56px);
  grid-template-rows: repeat(7, 56px);
  gap: 8px;
}
.gear-slot {
  position: relative; width: 56px; height: 56px; border-radius: 0;
  background: var(--panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
/* Hover brightens background-color, not the border (overridden by
   .owned/.not-owned/.affordable at equal specificity) and not filter (would
   light up the icon). Matches the loot tracker hover; .filled has its own rule
   since its base is #1c1a14. */
.gear-slot:hover { background-color: rgb(51, 51, 54); }
.gear-slot.filled { background: #1c1a14; }
.gear-slot.filled:hover { background-color: rgb(38, 35, 27); }
.gear-slot.picking { border-color: var(--gold); }
/* Backs up the img's draggable="false" (slotHtml in app/pages/): Safari can
   still start a native image drag otherwise. */
/* RuneLite CDN canvas padding: size bump plus recentering translate (see
   .loot-item-box-icon in loot-tracker.css). */
.gear-slot-icon {
  width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; -webkit-user-drag: none;
  transform: translate(5.5%, -1%);
}

/* Drag and drop (wireSlotClicks/moveSlotItem in app/pages/). Outline rather
   than border so the ownership border color stays visible. .dragging fades the
   source; .drag-over rings the drop target. */
.gear-slot.dragging { opacity: 0.4; }
.gear-slot.drag-over { outline: 2px dashed var(--gold); outline-offset: -2px; }

.gear-slot.owned { border-color: var(--green); }
.gear-slot.not-owned { border-color: var(--red); }
.gear-slot.affordable { border-color: var(--amber); }

/* Shift-click multi-select (toggleSlotSelected/wireSlotClicks in app/pages/).
   Solid blue outline stays visible over every border color and differs from the
   gold .picking border. */
.gear-slot.multi-selected { outline: 2px solid var(--blue); outline-offset: -2px; }

/* Hover-only remove button (destructive shortcut). */
.gear-slot-remove {
  display: none;
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; z-index: 2;
  align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--red); color: var(--red);
  border-radius: 50%; font-size: 12px; line-height: 1; padding: 0; cursor: pointer;
}
.gear-slot-remove:hover { background: var(--red); color: var(--panel-2); }
.gear-slot.filled:hover .gear-slot-remove { display: flex; }

.gear-summary {
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
/* "Still to purchase" sort buttons: GP and A-Z toggle direction, CUSTOM is
   standalone (renderSortButtons in app/pages/). */
.gear-summary-sort { display: flex; gap: 6px; margin-bottom: 12px; }
/* 25px matches the site-wide button height (.loot-sort-tab in loot-tracker.css). */
.sort-btn {
  flex: 1;
  height: 25px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-dim);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
}
.sort-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.sort-btn.active { border-color: var(--gold); color: var(--gold); }
/* Unlike .loot-sort-arrow, no vertical nudge is needed: this button's
   font-size/padding/letter-spacing already centers the fallback-font arrow glyph
   (RuneScapePlain11 lacks the arrows). */
.sort-btn-arrow { display: inline-block; }
/* One-off nudge pulse for CUSTOM when a row is clicked/dragged in another sort
   mode (glowCustomSortButton in app/pages/); same shape as mm-edit-glow in
   mindmaps.css. Finite iteration count, and the extra box-shadow keeps it
   distinct from .active. */
@keyframes sort-btn-custom-glow {
  0%, 100% { box-shadow: none; border-color: var(--border); color: var(--text-dim); }
  50% { box-shadow: 0 0 8px 2px var(--gold); border-color: var(--gold); color: var(--gold); }
}
.sort-btn.glow { animation: sort-btn-custom-glow 0.6s ease-in-out 2; }
.gear-summary-empty { font-size: 12.5px; color: var(--text-dim); }
.gear-next-purchase { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.gear-next-purchase-icon-wrap {
  width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--border);
}
/* RuneLite CDN canvas padding: size bump plus recentering translate (see
   .loot-item-box-icon in loot-tracker.css). */
.gear-next-purchase-icon {
  width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated;
  transform: translate(5.5%, -1%);
}
.gear-next-purchase-body { flex: 1; min-width: 0; }
.gear-next-purchase-label { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.gear-next-purchase-name { font-size: 13.5px; color: var(--text); margin: 1px 0 5px; }
.gear-next-purchase-amount { font-size: 11px; color: var(--text-dim); margin-top: 3px; font-variant-numeric: tabular-nums; }
.gear-summary-list { display: flex; flex-direction: column; gap: 6px; }
.gear-summary-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--border); }
.gear-summary-row.unpurchasable { opacity: 0.55; }
/* Backs up draggable="false" on the icon img (renderSummaryList in
   app/pages/); same as .gear-slot-icon. */
/* RuneLite CDN canvas padding: size bump plus recentering translate (see
   .loot-item-box-icon in loot-tracker.css). */
.gear-summary-row-icon {
  width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated; flex: none; -webkit-user-drag: none;
  transform: translate(5.5%, -1%);
}
.gear-summary-row-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gear-summary-row-cost { font-size: 12px; color: var(--gold); white-space: nowrap; }
.gear-summary-row-cost.na { color: var(--text-faint); }

/* Drag-to-reorder, custom sort mode only (wireSummaryDrag in app/pages/). No
   .drag-over ring: rows slide aside to preview the drop (animateReorder).
   user-select: none stops text selection while dragging. */
.gear-summary-row.draggable { cursor: grab; user-select: none; }
/* Background hover, not filter, so icon and text do not brighten. Only while
   draggable (custom sort mode). */
.gear-summary-row.draggable:hover { background-color: rgb(51, 51, 54); }
.gear-summary-row.draggable.dragging { opacity: 0.4; cursor: grabbing; }

.gear-icon-picker, .gear-slot-picker {
  background: var(--panel-translucent); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 22px;
  display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap;
  /* Absorbs the padding into the parent's width; .gear-slot-picker's width is
     pinned to the gear frame (see .pg-doll-wrap) and would otherwise overflow by
     2 * 16px. */
  width: 100%;
  box-sizing: border-box;
}

/* Only .gear-icon-picker centers: its 25px Clear/Cancel row would otherwise sit
   at the top beside the 32px search box. */
.gear-icon-picker { align-items: center; }

/* Clear/Cancel share one row so they are a single flex child of
   .gear-icon-picker; flex-shrink: 0 lets the search box (flex: 1 1 240px) give
   up the room. */
.gear-icon-picker-actions { display: flex; flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto; }
.gear-icon-picker-actions .btn-secondary { flex: 0 0 auto; }

.search-box { position: relative; flex: 1 1 240px; min-width: 200px; }
/* The slot picker's search box takes its whole row. */
.search-box.search-box-full { flex: 1 1 100%; width: 100%; }
/* 32px, shorter than the site-wide input height (myscape.css padding: 12px
   14px); .gear-icon-picker's align-items: center centers the 25px buttons beside
   it. Also used for the slot picker's search box so both match. */
.search-box input[type="text"] { width: 100%; height: 32px; padding: 0 14px; }
/* Opaque for a clean dropdown; a suggestion click saves immediately
   (renderSlotSuggestions in app/pages/). */
.suggestions {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 6;
  background: var(--panel); border: 1px solid var(--border); max-height: 260px; overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  /* Stops scroll chaining into the page past the list bounds (same as
     .mm-suggestions and .pm-settings-menu). */
  overscroll-behavior: contain;
}
.suggestions.show { display: block; }
.suggestion {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px;
  color: var(--text); cursor: pointer;
}
.suggestion:hover, .suggestion.active { background: var(--panel-2); }
/* RuneLite CDN canvas padding: size bump plus recentering translate (see
   .loot-item-box-icon in loot-tracker.css). */
.suggestion img {
  width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated;
  transform: translate(5.5%, -1%);
}

/* "No match" row when the search (search_items in app/purchase_goals.py) finds
   nothing; plain muted, non-clickable text. */
.suggestion-empty {
  padding: 8px 10px; font-size: 13px; color: var(--text-faint); font-style: italic; cursor: default;
}

.pg-empty { text-align: center; color: var(--text-faint); font-size: 13px; padding: 40px 10px; }

/* Between phone and full two-column layout (721-880px) the summary wraps under
   the gear box; center the box and match the list's width. */
@media (min-width: 721px) and (max-width: 879px) {
  .pg-body { justify-content: center; }
  .pg-summary-col { max-width: 502px; }
}

@media (max-width: 720px) {
  .pg-body { flex-direction: column; align-items: center; }
  /* Stacked: center the paperdoll and inventory, and keep the 8 small slots off
     the paperdoll's bottom row (margin-top: auto only helps when the column is
     stretched beside the inventory). The phone layout sets the same with its own
     rules. */
  .pg-gear-frame { flex-direction: column; align-items: center; gap: 20px; }
  .gear-doll-misc { margin-top: 16px; }
}

/* Landing page preview (render_landing_purchase_preview, app/pages/). Same
   container treatment as .landing-loot-preview in loot-tracker.css
   (viewport-capped, clipped, bottom feather). max-width matches its 900px so
   both previews are the same size. */
.landing-purchase-preview {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  /* Fixed height (not max-height) so the bottom feather stays at the same screen
     position however much content is inside; see .landing-loot-preview in
     loot-tracker.css. */
  height: calc(100vh - 80px);
  height: calc(100svh - 80px);
  overflow: hidden;
  position: relative;
}
/* Unconditional; no --clipped modifier (see .landing-loot-preview::after in
   loot-tracker.css). */
.landing-purchase-preview::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 15%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

/* Hide the reused body's heading and setup selector via CSS so
   _purchase_goals_panel_markup stays untouched; the preview shows a single
   setup. */
.landing-purchase-preview .page-title,
.landing-purchase-preview .pg-header {
  display: none;
}

/* Add/remove/move are swallowed in the preview: default cursor on empty slots
   and the remove button. Filled slots keep pointer (they open the item's wiki
   page). */
.landing-purchase-preview .gear-slot:not(.filled),
.landing-purchase-preview .gear-slot-remove {
  cursor: default;
}

/* Landing-preview hero row: character first (left), tagline wrap second (right).
   Mirrors .loot-preview-hero/-tagline-wrap/-char in loot-tracker.css with the
   order swapped; see render_landing_purchase_preview's hero_markup. */
.purchase-preview-hero {
  display: flex;
  align-items: flex-end;
}
.purchase-preview-tagline-wrap {
  flex: 1 1 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.purchase-preview-tagline {
  margin: 0;
  max-width: 100%;
  min-width: 0;
  text-align: center;
  font-size: 30px;
  line-height: 1.25;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.purchase-preview-tagline-gold { color: var(--gold); }
.purchase-preview-tagline-white { color: var(--text); }

/* Fixed height: 157px matches .loot-preview-char in loot-tracker.css so both
   preview characters render at the same height despite different source aspect
   ratios (350x292 here); width follows. */
.purchase-preview-char {
  flex: 0 0 auto;
  height: 157px;
  line-height: 0;
}
/* Two classes beat myscape.css's .landing-anchor picture img (one class, two
   elements). */
.landing-purchase-preview .purchase-preview-char img {
  display: block;
  height: 100%;
  max-height: none;
  width: auto;
  max-width: none;
}
/* Mirrored horizontally (as .loot-preview-char--flipped in loot-tracker.css) so
   the character faces the tagline on the left. */
.landing-purchase-preview .purchase-preview-char--flipped img {
  transform: scaleX(-1);
}

/* Export icon next to "Purchase Goals" (purchase_share_icon_btn in app/pages/)
   and its popup. Same 14px bare icon as .loot-share-icon-btn (duplicated per
   page stylesheet). .pg-share-wrap anchors .pg-share-card. No transform on it: a
   transform creates a stacking context that walls the popup's z-index: 5 off,
   letting later page content paint over it (see .loot-share-wrap in
   loot-tracker.css). */
.pg-share-wrap {
  position: relative; display: inline-block; vertical-align: middle; margin-left: 8px;
}
.pg-share-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  line-height: 1;
  color: var(--text-faint);
  transition: color 0.15s ease;
  position: relative;
  top: -2px;
}
.pg-share-icon-btn:hover { color: var(--text-dim); }
.pg-share-icon-btn.open { color: var(--gold); }

/* Download icon next to "Shared by <name>" on a share page (import_icon_btn in
   render_purchase_goals_share, app/pages/). Same bare 14px shape as
   .pg-share-icon-btn; toggles .pg-import-card via .open. Rendered as a <button>
   (signed-in) or an <a> (signed-out, no popup), so the rule targets the class
   alone. */
.pg-import-wrap {
  /* No transform here, for the same stacking-context reason as .pg-share-wrap
     above. */
  position: relative; display: inline-block; vertical-align: middle; margin-left: 8px;
}
.pg-import-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  line-height: 1;
  color: var(--text-faint);
  transition: color 0.15s ease;
  position: relative;
  top: -2px;
}
.pg-import-icon-btn:hover { color: var(--text-dim); }
.pg-import-icon-btn.open { color: var(--gold); }

/* Confirming popup toggled by pgImportBtn; only rendered for signed-in viewers
   (import_card_markup in render_purchase_goals_share). Opaque, with the
   box-shadow of .loot-range-menu (loot-tracker.css). top: 32px: the wrap sits
   inside .page-title, whose larger font-size makes its line box taller than the
   14px icon (see .loot-share-card in loot-tracker.css). */
.pg-import-card {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
/* author display outranks the browser's [hidden] rule (same as
   .pg-share-card[hidden]). */
.pg-import-card[hidden] { display: none; }

/* Same sizing/coloring as .pg-share-generate-btn. .action-failed covers an
   expired link or a code that lapsed between page load and click. */
.pg-import-save-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 15px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-dim);
  /* --panel-2 so the button reads as raised against the opaque --panel popup. */
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.pg-import-save-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.pg-import-save-btn:disabled { cursor: default; opacity: 0.6; }
.pg-import-save-btn.action-failed { border-color: var(--red); color: var(--red); }

.pg-import-popup-hint { margin: 0; font-size: 13px; color: var(--text-faint); text-align: center; }

/* Popup under its trigger (absolute against .pg-share-wrap); closes on re-click
   or outside click (pgShareIconBtn handler in app/pages/). Opaque, with the
   box-shadow of .loot-range-menu (loot-tracker.css). top: 32px: the wrap sits
   inside .page-title, whose larger font-size makes its line box taller than the
   14px icon (see .loot-share-card in loot-tracker.css). */
.pg-share-card {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
/* Author display outranks the browser's [hidden] rule (same as
   .loot-share-card[hidden] in loot-tracker.css). */
.pg-share-card[hidden] { display: none; }

.pg-share-generate-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 15px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-dim);
  /* --panel-2 so the button reads as raised against the opaque --panel popup. */
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
}
.pg-share-generate-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.pg-share-generate-btn:disabled { cursor: default; opacity: 0.6; }
.pg-share-generate-btn.action-failed { border-color: var(--red); color: var(--red); }

/* Replaces pgShareGenerateBtn once a link exists; clicking copies and flashes
   "COPIED". Same sizing so the card layout does not shift. */
.pg-share-link-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-dim);
  /* --panel-2, matching .pg-share-generate-btn which this replaces in place. */
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pg-share-link-btn:hover { border-color: var(--gold-dim); color: var(--text); }

.pg-share-popup-hint { margin: 0; font-size: 13px; color: var(--text-faint); text-align: center; }

/* Share-viewing page (/s/<code>; see render_purchase_goals_share in
   app/pages/). .purchase-goal-share wraps the body. */

/* Hide the setup switcher and menu rather than strip them from the markup;
   visitors only see the one frozen setup. */
.purchase-goal-share .pg-header {
  display: none;
}

/* Hide the current-GP number and progress bar so a visitor never sees a figure
   that reads as the owner's live GP. The coins icon stays. */
.purchase-goal-share #pgCoinsAmount,
.purchase-goal-share .overlay-progress {
  display: none;
}

/* Center the remaining children now that the flex: 1 .overlay-progress spacer is
   hidden. .overlay-target already renders icon-then-amount via row-reverse,
   giving [coins][total][setup icon]. */
.purchase-goal-share .overlay-card {
  justify-content: center;
}

/* Ownership border colors describe the visitor's own bank and are meaningless on
   a stranger's setup, so all fall back to the neutral border. .affordable never
   occurs (build_purchase_goal_share_snapshot freezes coins at 0); kept as a
   defensive no-op. .owned is included: the live page's always-green treatment
   (_is_always_attainable_item) does not carry over to shared links. */
.purchase-goal-share .gear-slot.owned,
.purchase-goal-share .gear-slot.not-owned,
.purchase-goal-share .gear-slot.affordable {
  border-color: var(--border);
}

/* Only a plain click on a filled slot (opens the wiki page) is live here
   (capturing-phase listener on #pgGearFrame); default cursor on empty slots, as
   in .landing-purchase-preview. */
.purchase-goal-share .gear-slot:not(.filled) {
  cursor: default;
}

/* Never draw the hover remove button; visitors cannot delete from a shared setup
   (the capturing listener also blocks the click). */
.purchase-goal-share .gear-slot.filled:hover .gear-slot-remove {
  display: none;
}

/* The setup-icon trigger is read-only here (#pgIconTrigger clone-strip in
   render_purchase_goals_share): default cursor and no hover affordance. */
.purchase-goal-share #pgIconTrigger {
  cursor: default;
}
.purchase-goal-share .overlay-icon-wrap:hover {
  background: none;
}
.purchase-goal-share .overlay-icon-wrap:hover .overlay-icon-placeholder {
  border-color: var(--text-faint);
  color: var(--text-faint);
}

/* Setup-name line above "Shared by <name>", like .loot-share-range in
   loot-tracker.css. Uppercase via CSS; the string stays natural case. */
.pg-share-label { text-align: center; margin: 0 0 4px; text-transform: uppercase; }

/* Phone layout (site breakpoint 700px). Scoped with body:not(.phone-off) so the
   homepage preview, which reuses these classes, is untouched. Sections are max
   320px wide and centered, leaving a gutter to scroll with. */
@media (max-width: 700px) {
  /* Overview card: coins left, target right, icon above amount, progress bar on
     its own row (the one-row desktop layout is ~500px wide). */
  body:not(.phone-off) .overlay-card {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 14px;
    column-gap: 8px;
    padding: 14px 12px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }
  body:not(.phone-off) .overlay-side,
  body:not(.phone-off) .overlay-side.overlay-target {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
  }
  body:not(.phone-off) .overlay-amount { font-size: 15px; }

  /* Shared setups: no coins icon on the phone (no GP figure to pair with); icon
     and total are centered. */
  body:not(.phone-off) .purchase-goal-share .overlay-source { display: none; }
  body:not(.phone-off) .purchase-goal-share .overlay-side.overlay-target { align-items: center; }
  body:not(.phone-off) .overlay-progress { order: 3; flex: 0 0 100%; min-width: 0; }

  /* One centered column. The doll column's width is pinned in px by JS on
     desktop (see .pg-doll-wrap), hence !important. */
  body:not(.phone-off) .pg-body { align-items: center; gap: 18px; }
  body:not(.phone-off) .pg-doll-wrap {
    width: 100% !important;
    max-width: 320px;
  }
  body:not(.phone-off) .pg-gear-frame {
    width: 100%;
    align-items: center;
    gap: 20px;
    padding: 16px;
  }
  body:not(.phone-off) .pg-summary-col {
    flex: none;
    width: 100%;
    max-width: 320px;
    min-width: 0;
  }
  body:not(.phone-off) .gear-summary { padding: 14px 12px; }

  /* The setup-icon picker sits outside .pg-body; give it the same width and
     centering. */
  body:not(.phone-off) .gear-icon-picker,
  body:not(.phone-off) #pgIconPicker > * {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
  }
  body:not(.phone-off) .pg-setup-form { max-width: 320px; margin-left: auto; margin-right: auto; }

  /* 16px inputs so iOS doesn't zoom the page on focus; taller buttons. */
  body:not(.phone-off) .search-box input[type="text"],
  body:not(.phone-off) .pg-setup-form input[type="text"] { font-size: 16px; height: 40px; }
  body:not(.phone-off) .sort-btn { height: 36px; font-size: 11px; }
}

@media (max-width: 700px) {
  /* Popups anchor to the title row and stay within it so they cannot run off the
     right edge. */
  body:not(.phone-off) .page-title:has(.pg-share-wrap),
  body:not(.phone-off) .page-title:has(.pg-import-wrap) { position: relative; }
  body:not(.phone-off) .pg-share-wrap,
  body:not(.phone-off) .pg-import-wrap { position: static; }
  body:not(.phone-off) .pg-share-card,
  body:not(.phone-off) .pg-import-card {
    top: calc(100% + 6px);
    width: min(280px, 100%);
    box-sizing: border-box;
  }
}

/* Touch: no hover; the slot "x" shows only on the slot armed by a first tap
   (wireSlotClicks). */
@media (hover: none) {
  body:not(.phone-off) .gear-slot.filled:hover .gear-slot-remove { display: none; }
  body:not(.phone-off) .gear-slot.filled.touch-armed .gear-slot-remove { display: flex; }
  body:not(.phone-off) .gear-slot-remove { width: 24px; height: 24px; top: -9px; right: -9px; font-size: 15px; }
  body:not(.phone-off) .gear-slot.touch-armed { outline: 2px solid var(--gold); outline-offset: -2px; }
}

/* Icons and menu button are one wrapping row, so the button follows the last
   setup. display: contents dissolves the icon row's box so its buttons and the
   menu wrap are siblings in .pg-header's flex row. */
.pg-header {
  /* Wrapping centered row; every cell is 44px (menu button included) so full
     rows align and the last is centered. */
  flex-wrap: wrap;
  gap: 8px;
}
.tracker-icon-row { display: contents; }

@media (max-width: 700px) {
  /* Same 320px as every section: at most 6 setup icons (or 5 plus the menu
     button) per row. */
  body:not(.phone-off) .pg-header { max-width: 320px; margin-left: auto; margin-right: auto; }
  /* Keep the 8 small slots off the paperdoll's bottom row (margin-top: auto only
     helps on desktop). */
  body:not(.phone-off) .gear-doll-misc { margin-top: 16px; }
}

@media (hover: none) {
  body:not(.phone-off) #pgBody [draggable="true"],
  body:not(.phone-off) #setupIconRow [draggable="true"] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

@media (hover: none) {
  body:not(.phone-off) #pgBody [draggable],
  body:not(.phone-off) #setupIconRow [draggable] { -webkit-user-drag: none; }
}

/* Phone: even 18px between stacked sections. The empty slot-picker wrapper is a
   flex item and would add a second gap; an open picker's bottom margin is also
   reset. */
@media (max-width: 700px) {
  body:not(.phone-off) #pgSlotPicker:empty { display: none; }
  body:not(.phone-off) .gear-slot-picker,
  body:not(.phone-off) .gear-icon-picker { margin-bottom: 0; }
  body:not(.phone-off) #pgIconPicker:not(:empty) { margin-bottom: 18px; }
}

/* Phone: overview icons are 1.25x the desktop 44px (55px). */
@media (max-width: 700px) {
  body:not(.phone-off) .overlay-icon,
  body:not(.phone-off) .overlay-icon-wrap .overlay-icon { width: 55px; height: 55px; }
  body:not(.phone-off) .overlay-icon-wrap { width: 55px; height: 55px; }
  body:not(.phone-off) .overlay-icon-placeholder { width: 38px; height: 38px; font-size: 20px; }
}

@media (max-width: 700px) {
  body:not(.phone-off) .gear-icon-picker-actions { width: 100%; justify-content: center; }
}


/* Share page "save to my account" icon, phone: the popup is centered on its icon
   at the right end of the title and would overflow, so anchor it to the
   full-width title instead. The 14px icon gets a thumb-sized tap area (padding
   with equal negative margin keeps the title layout unchanged). */
@media (max-width: 700px) {
  body:not(.phone-off) .page-title:has(.pg-import-wrap) { position: relative; }
  body:not(.phone-off) .pg-import-wrap { position: static; }
  body:not(.phone-off) .pg-import-card { top: calc(100% + 6px); }
  body:not(.phone-off) .pg-import-icon-btn { padding: 10px; margin: -10px; }
}

