/* Character Overview page (render_character_overview in app/pages/), in its
   own file because none of it applies elsewhere. */

.co-summary-row {
  /* Eight equal columns while there's room, four below 840px: never a lopsided
     7+1 or 6+2 wrap. */
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 8px 12px;
  /* 18px: the site-wide gap between top-level cards (see .dash-grid in
     myscape.css). */
  margin-bottom: 18px;
}

@media (max-width: 839px) {
  .co-summary-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 10px; }
}

.co-stat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

/* Wiki icons have varying native sizes; each is scaled into this fixed box. No
   RuneLite padding-compensation transform (compare .dash-card-icon img in
   myscape.css), which only applies to RuneLite item icons. */
.co-stat-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.co-stat-value {
  font-size: 15px;
  color: var(--gold);
  white-space: nowrap;
}

/* Main row: .co-left-col beside .clog-card. flex-start pins both to the same top
   edge (their heights differ a lot); nowrap keeps them side by side at every
   width. */
.co-main-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 18px;
  margin-bottom: 18px;
}

.co-left-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 1 290px;
  min-width: 0;
}

/* Four cards on one row at any width: each list has a fixed height + overflow,
   so a narrow width squeezes columns rather than scrolling the row. */
.co-quad-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 18px;
}

/* flex: 1 1 0 splits the row evenly whatever the content; min-width: 0 lets a
   card shrink below its content. */
.skills-card,
.quests-card,
.diaries-card,
.ca-card {
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  flex: 1 1 0;
  min-width: 0;
}

/* The row stretches these cards to match their 272px siblings; centering the
   content splits the leftover space evenly above and below. */
.skills-card,
.ca-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* minmax(0, 1fr), not a bare 1fr: a bare track's automatic minimum is its items'
   min-content width, which let the third column overflow the card. No scrollbar:
   this card never scrolls. */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

/* Each cell is a link (see skill_cells in app/pages/): the site-wide a/a:hover
   color and underline are reset, including under :hover since a:hover outweighs
   a single class. title is the tooltip (setSkillTooltip). Tight padding and no
   min-width let three cells fit in narrow windows; overflow: hidden + nowrap
   clip rather than bleed past the card border. */
.skill-cell,
.skill-cell:hover {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 3px 4px;
  overflow: hidden;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
.skill-cell:hover { background-color: rgb(51, 51, 54); }
.skill-cell:hover .skill-cell-level { color: var(--text); text-decoration: none; }

/* Smaller than .co-stat-icon (28px) so the card reads compact next to the 15px
   level text. */
.skill-cell-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
  flex: none;
}

/* 3ch fits the highest virtual level (126, see levelForXp). inline-block because
   an inline <span> ignores min-width. */
.skill-cell-level {
  display: inline-block;
  min-width: 3ch;
  font-size: 15px;
  color: var(--text);
}

/* 3D model viewer card (render_character_overview in app/pages/). No width
   rule: .co-left-col's flex-basis sets it. */
.model-viewer-card {
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

/* Sized by this wrapper (2:3 portrait), not the canvas attributes: the module
   script reads clientWidth/clientHeight for renderer.setSize. */
.model-viewer-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
}
/* Backdrop behind the alpha:true canvas (see applyBackground/modelViewerBg).
   z-index 0, one below the canvas. */
.model-viewer-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
  /* Filter on the backdrop only, so it does not affect the canvas or buttons. */
  filter: saturate(0.75) brightness(0.8);
}
/* Default cursor: the camera takes no pointer input. Explicit position/z-index 1
   paints it over .model-viewer-bg regardless of DOM order. */
.model-viewer-canvas-wrap canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  /* Materials are unlit (KHR_materials_unlit, see the GLB export in
     app/main.py), so there is no scene light to raise; brighten the canvas
     itself. */
  filter: brightness(1.15);
  /* OrbitControls sets touch-action: none, which would block page scrolling from
     the model on touch screens; the camera takes no pointer input. !important
     beats the library's inline style. */
  touch-action: auto !important;
}

/* Button row overlaid on the viewport; the camera fit
   (CAMERA_DISTANCE_MULTIPLIER/applyVerticalFramePan) leaves this strip clear.
   z-index 2, above backdrop and canvas. */
.model-viewer-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
/* Like .clog-sync-btn but 26px, with a translucent dark scrim so the icon stays
   legible over any backdrop photo. */
.model-viewer-btn {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(20, 18, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
}
.model-viewer-btn:hover { border-color: var(--gold); color: var(--gold); }
.model-viewer-btn svg { display: block; }
/* Author `display` outranks the UA [hidden] rule; restores it for the play/pause
   SVG pair (see setPlayPauseIcon). */
.model-viewer-btn svg[hidden] { display: none; }


/* Shown instead of the canvas wrap (see showEmpty) when no model was exported or
   the fetch fails. */
.model-viewer-empty {
  display: none;
  padding: 40px 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* Collection Log card, right of .co-left-col. Data: GET
   /api/players/me/collection-log (GameAccount.collection_log_items,
   app/models.py). flex-basis 572px + .co-left-col's 290px + 18px gap = the 880px
   page width, so the columns land flush. */
.clog-card {
  flex: 1 1 572px;
  min-width: 0;
  background: var(--panel-translucent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px 12px;
}

/* Shown instead of .clog-body (see showClogEmpty) until the collection log has
   been synced. */
.clog-empty {
  display: none;
  padding: 32px 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.clog-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.clog-tabs-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
}
.clog-tabs {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 3px;
}

/* Manual hiscores refresh for renderClogItemsHeader's counts (backfills stats
   added after linking). Icon-only to fit beside three tabs; 29px click target. */
.clog-sync-btn {
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
}
.clog-sync-btn:hover { border-color: var(--gold-dim); }
.clog-sync-btn:disabled { cursor: default; }
.clog-sync-btn svg { display: block; }
/* Sync in flight: gold border and icon. Declared after :hover so it wins the
   equal-specificity tie while the pointer is over the button. */
.clog-sync-btn.syncing { border-color: var(--gold); color: var(--gold); }
.clog-sync-btn.syncing svg { animation: clog-sync-spin 0.8s linear infinite; }
@keyframes clog-sync-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* Brief red flash on a failed sync, cleared by the click handler. */
.clog-sync-btn.sync-failed { border-color: var(--red); color: var(--red); }
.clog-tab {
  flex: 1;
  padding: 8px 6px;
  font-size: 15px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.clog-tab:hover { border-color: var(--gold-dim); color: var(--text); }
.clog-tab.active { border-color: var(--gold); color: var(--gold); }

.clog-panes {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
/* Fixed-width rail so the grid starts at the same x on every tab; min-width
   keeps a long page name from widening it. The 361px height is a fallback until
   syncClogHeight (app/pages/) matches .model-viewer-card. overscroll-behavior:
   contain stops scroll chaining to the page. */
.clog-pages {
  flex: 0 0 226px;
  min-width: 0;
  height: 361px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}
.clog-page-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  font-size: 15px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Keeps rows at natural height; otherwise the flex column shrinks rows when a
     long tab (Bosses) overflows. */
  flex-shrink: 0;
}
.clog-page-btn:hover { color: var(--text); background: var(--panel-2); }
.clog-page-btn.active {
  color: var(--gold);
  background: var(--panel-2);
  border-color: var(--gold-dim);
}
.clog-page-count {
  flex: none;
  font-size: 15px;
}
/* Red/yellow/green for zero, partial or complete (progressState in
   renderClogPages); same status vocabulary as mindmaps.css. */
.clog-page-btn.zero .clog-page-count { color: var(--red); }
.clog-page-btn.started .clog-page-count { color: var(--yellow); }
.clog-page-btn.complete .clog-page-count { color: var(--green); }

/* Item grid, a fixed 6 columns. padding-right leaves the scrollbar track clear
   of the tiles (scrollbar-gutter: stable reserves the track itself). Height
   synced with .clog-pages by syncClogHeight. */
/* Column wrapper so the header sits above the grid without affecting .clog-pages
   (see syncClogHeight). */
.clog-items-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.clog-items-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 15px;
}
/* min-width: 0 lets a long page name ellipsis instead of crowding the count. */
.clog-items-header-name {
  min-width: 0;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* Rendered only when clogKillCounts has an entry (see renderClogItemsHeader);
   multiple numbers are joined with a middot, not summed. */
.clog-items-header-kc {
  flex: none;
  color: var(--gold);
  white-space: nowrap;
}
.clog-items {
  height: 361px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 8px;
  display: grid;
  /* As many columns as fit with tiles of at least 40px, stretched to fill: six
     at normal width. The phone layout sets five. */
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  align-content: flex-start;
  gap: 6px;
}
.clog-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.clog-item:hover {
  background-color: rgb(51, 51, 54);
}
.clog-item.obtained { border-color: var(--gold-dim); }
.clog-item-icon {
  width: 78%;
  height: 78%;
  object-fit: contain;
  image-rendering: pixelated;
  /* RuneLite item-icon CDN (item_icon_url in app/purchase_goals.py) with the
     same nudge as .loot-item-box-icon for the CDN's baked-in sprite padding;
     copied since this page does not load loot-tracker.css. */
  transform: translate(5.5%, -1%);
}
.clog-item:not(.obtained) .clog-item-icon {
  filter: grayscale(1) brightness(0.55);
  opacity: 0.75;
}
/* Obtained quantity; omitted for 1 since the tile's border already says
   'obtained'. */
.clog-item-qty {
  position: absolute;
  /* Digits have no descender, so line-height: 1 leaves space below the glyph;
     nudged left so the badge looks equally inset from the right and bottom. */
  right: 2.5px;
  bottom: 0px;
  font-size: 15px;
  color: var(--gold);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
  line-height: 1;
}

/* Quests card: list grouped Free / Members' as in-game
   (app.character_progress_data.get_quest_list), names colored green completed,
   yellow started, red not started. Fixed height + own scrollbar instead of
   growing the row for ~196 rows; 272px matches .skills-grid's content height. */
.quests-list {
  height: 272px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 6px;
}
.quests-group-title {
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: normal;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}
.quests-group-title:first-child { margin-top: 0; }
/* Rows are links to the quest's wiki page (see renderQuests). display: block
   keeps div-like layout and ellipsis; color: inherit + text-decoration: none
   undo the site-wide a/a:hover reset. */
.quest-row {
  display: block;
  font-size: 13px;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
  text-decoration: none;
  padding: 1px 4px;
  margin: 0 -4px;
  border-radius: var(--radius);
}
.quest-row--completed { color: var(--green); }
.quest-row--in_progress { color: var(--yellow); }
.quest-row--not_started { color: var(--red); }
/* Hover shows a --panel-2 box instead of an underline, cancelling a:hover's
   underline and gold. The status-color rules below stay separate so hover still
   shows each quest's state. */
.quest-row:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.quest-row--completed:hover { color: var(--green); }
.quest-row--in_progress:hover { color: var(--yellow); }
.quest-row--not_started:hover { color: var(--red); }
.quests-empty {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Achievement Diaries card: one .diary-row per area
   (app.character_progress_data.get_diary_tier_totals, areas from DIARY_AREAS in
   app/mindmaps.py) with a completed/total count and a four-segment tier bar:
   green up to the area's highest completed tier (GameAccount.diary_tiers), no
   partial fill (see /api/character-overview/progress in app/main.py).
   Rows are links (see renderDiaries/diaryWikiUrl); :hover repeats
   color/text-decoration because a:hover outweighs a single class. .diaries-list
   has the same fixed 272px height + scrollbar as .quests-list. */
.diaries-list {
  height: 272px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 6px;
}
.diary-row {
  display: block;
  color: inherit;
  text-decoration: none;
  padding: 4px;
  margin: 0 -4px 2px -4px;
  border-radius: var(--radius);
}
.diary-row:last-child { margin-bottom: 0; }
.diary-row:hover {
  background: var(--panel-2);
  color: inherit;
  text-decoration: none;
}
.diary-row-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.diary-row-label {
  font-size: 13px;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.diary-row-count {
  font-size: 12px;
  color: var(--text-muted);
  flex: none;
}
.diary-row-bar {
  display: flex;
  gap: 2px;
  height: 6px;
}
/* var(--bg) for unfilled segments: an incomplete tier reads as empty, not red.
   Opaque, since translucent black would barely show. */
.diary-tier-seg {
  flex: 1 1 0;
  background: var(--bg);
  /* Same border as .ca-tile-bar, but border-box so it eats into the bar's 6px
     height instead of adding to it. */
  box-sizing: border-box;
  border: 1px solid var(--border);
}
.diary-tier-seg--completed {
  background: var(--green);
}
/* Partly finished tier: gold fills the segment from the left by tasks done
   (width set inline in renderDiaries); green only once the tier is completed. */
.diary-tier-seg-fill {
  height: 100%;
  background: #ff981f;
}

/* Combat Achievements card: one .ca-tile per tier
   (app.character_progress_data.get_ca_tier_totals) in a 2-column grid like the
   in-game tab; CA_TIER_ORDER is row-major so no reordering is needed. Unlike
   .diary-tier-seg the bar is real within-tier progress
   (COMBAT_ACHIEVEMENT_COMPLETED_VARBITS are live per-tier counts); a null count
   renders as an em dash and an empty bar. Tiles link to the wiki (see
   renderCombatAchievements). Always six tiles, so no scrollbar; padding/gap are
   tuned to land near the 272px of .quests-list. */
.ca-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.ca-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 6px;
  color: inherit;
  text-decoration: none;
}
/* rgb(51, 51, 54), not --panel-2: the tile's resting background already is
   --panel-2. Same shade as .skill-cell/.clog-item; text-decoration: none cancels
   a:hover's underline. */
.ca-tile:hover {
  background-color: rgb(51, 51, 54);
  text-decoration: none;
}
.ca-tile-label {
  font-size: 13px;
  color: var(--text);
}
.ca-tile-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}
.ca-tile-count {
  font-size: 12px;
  color: var(--text-muted);
}
.ca-tile-bar {
  width: 100%;
  height: 6px;
  /* var(--bg): the tile is --panel-2, so the track needs the darkest color to
     read as recessed. */
  background: var(--bg);
  border: 1px solid var(--border);
}
.ca-tile-bar-fill {
  height: 100%;
  background: var(--gold-dim);
}

/* Landing page preview (render_landing_character_overview_preview in
   app/pages/): the real page reused unmodified in one scroll-snap panel. Only
   these rules are preview-specific. */

/* Same fixed-height, clipped, feathered treatment as .landing-loot-preview
   (loot-tracker.css). 900px matches the ~880px page width (290 + 572 + 18). */
.landing-character-overview-preview {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  height: calc(100vh - 80px);
  height: calc(100svh - 80px);
  overflow: hidden;
  position: relative;
}
.landing-character-overview-preview::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 15%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
  /* Above the model viewer's canvas (z-index 1) and buttons (z-index 2), which
     would otherwise paint over this fade. */
  z-index: 10;
}

.landing-character-overview-preview .page-title { display: none; }

/* Landing-preview hero row: tagline + character, bottom-aligned like the other
   previews (see hero_markup in render_landing_character_overview_preview). */
.co-preview-hero {
  display: flex;
  align-items: flex-end;
}
.co-preview-tagline-wrap {
  flex: 1 1 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.co-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;
}
.co-preview-tagline-gold { color: var(--gold); }
.co-preview-tagline-white { color: var(--text); }

.co-preview-char {
  flex: 0 0 auto;
  height: 157px;
  line-height: 0;
}
.landing-character-overview-preview .co-preview-char img {
  display: block;
  height: 100%;
  max-height: none;
  width: auto;
  max-width: none;
}


/* Public profile settings cog + card. #publicProfileCard is absent on the
   landing preview and on visitors' views (see public_profile_settings_btn in
   app/pages/). Collapsed and floating so it does not push .co-summary-row
   down. */

/* Bare cog icon inline in the page title (same glyph as .pm-settings-btn,
   possessions.css). .co-settings-wrap is the position: relative anchor of
   .public-profile-card. No transform here: it would create a stacking context
   and wall the popup's z-index: 5 off from the page, letting later content paint
   over it (see .loot-share-wrap in loot-tracker.css). */
.co-settings-wrap {
  position: relative; display: inline-block; vertical-align: middle; margin-left: 8px;
}
.co-settings-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; margin: 0;
  color: var(--text-faint); cursor: pointer; line-height: 1;
  transition: color 0.15s ease;
  /* Nudged up 2px: the SVG glyph sits low against the title text. */
  position: relative;
  top: -2px;
}
.co-settings-btn:hover { color: var(--text-dim); }
.co-settings-btn.active { color: var(--gold); }

/* Floats under its trigger; closes on re-click or outside click (see
   publicProfileSettingsBtn in app/pages/). Opaque --panel (as .tracker-menu)
   since it floats over content; box-shadow matches .loot-range-menu. top: 32px,
   not icon height + gap: the wrap inherits .page-title's larger font-size, so
   its line box is taller than the 15px icon (see .loot-share-card in
   loot-tracker.css). */
.public-profile-card {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  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 UA [hidden] rule; same fix as .model-viewer-btn
   svg[hidden]. */
.public-profile-card[hidden] { display: none; }

/* Segmented control as .mm-segment-group/.mm-segment-btn (mindmaps.css),
   duplicated to keep this file self-contained. flex: 0 0 auto since it shares a
   row with the link field. */
.public-profile-seg-group {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.public-profile-seg-btn {
  /* 23px + the group's own 1px top/bottom border = the site-wide 25px. */
  height: 23px;
  background: #100e0b;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 0 10px;
  cursor: pointer;
  text-align: center;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
}
.public-profile-seg-btn:last-child { border-right: none; }
.public-profile-seg-btn:hover { color: var(--text); }
.public-profile-seg-btn.active { background: var(--panel-2); color: var(--gold); }
.public-profile-seg-btn:disabled { cursor: default; opacity: 0.7; }

/* Same convention as .loot-range-btn (25px, uppercase, --panel-2/--border),
   except font-size 15px to match this card. */
.public-profile-link-btn {
  flex: 0 0 auto;
  height: 25px;
  padding: 0 10px;
  font-size: 15px;
  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;
  white-space: nowrap;
}
/* :not(:disabled): no hover highlight in the Private (disabled) state or during
   a regenerate request. */
.public-profile-link-btn:hover:not(:disabled) {
  border-color: var(--gold-dim);
  color: var(--text);
}
.public-profile-link-btn:disabled {
  cursor: default;
  opacity: 0.6;
}
/* The link display (publicProfileLinkBtn): 190px fits a full
   myscape.io/c/<code>; text-transform: none overrides the uppercase;
   overflow/ellipsis is a safety net. */
.public-profile-link-display {
  width: 190px;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Red flash when 'Generate new link' hits its once-a-day throttle (429, see
   regenerate_public_profile_code in app/main.py); cleared after 2.5s. */
.public-profile-link-btn.action-failed { border-color: var(--red); color: var(--red); }


/* Friend-request button beside a public profile's character name
   (render_public_character_overview); styled like .co-settings-btn. */
.co-friend-wrap {
  position: relative; display: inline-block; vertical-align: middle; margin-left: 8px;
}
.co-friend-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; margin: 0;
  color: var(--text-faint); cursor: pointer; line-height: 1;
  transition: color 0.15s ease;
  position: relative;
  top: -2px;
}
.co-friend-btn[hidden] { display: none; }
.co-friend-btn:hover { color: var(--gold); }
.co-friend-btn--done, .co-friend-btn--done:hover { color: var(--gold-dim); cursor: default; }


/* Phone-only scroll cue (see the phone block below); hidden everywhere
   else. */
.clog-tabs-arrow { display: none; }

/* Desktop scrollbars on the four scrolling lists. myscape.css sets
   scrollbar-color/scrollbar-width globally, and Chrome then ignores
   ::-webkit-scrollbar and draws a rounded thumb; resetting both to auto lets the
   site's square thumb through. @supports keeps Firefox on its thin themed
   scrollbar. */
@supports selector(::-webkit-scrollbar) {
  .clog-pages,
  .clog-items,
  .quests-list,
  .diaries-list {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
  .clog-pages::-webkit-scrollbar,
  .clog-items::-webkit-scrollbar,
  .quests-list::-webkit-scrollbar,
  .diaries-list::-webkit-scrollbar {
    width: 6px;
  }
  .clog-pages::-webkit-scrollbar-track,
  .clog-items::-webkit-scrollbar-track,
  .quests-list::-webkit-scrollbar-track,
  .diaries-list::-webkit-scrollbar-track {
    background: transparent;
  }
}
@supports not selector(::-webkit-scrollbar) {
  .clog-pages,
  .clog-items,
  .quests-list,
  .diaries-list {
    scrollbar-color: var(--gold-dim) transparent;
  }
}

/* The drawn scrollbars (see the phone block) are phone-only too. */
.co-sb { display: none; }
@media (max-width: 700px) {
  body:not(.phone-off) .co-sb { display: block; }
}

/* Registered so the tab strip's fade widths can transition; without @property
   support the fade switches instantly. */
@property --clog-fade-l { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --clog-fade-r { syntax: '<length>'; inherits: false; initial-value: 0px; }


/* Phone layout. The first @media block on this page: the desktop layout never
   wraps and is too wide for a phone, so everything stacks in one column here.
   700px is the site-wide phone breakpoint; keep it identical on every page.
   Scoped to body:not(.phone-off) so the homepage preview is unaffected. */
@media (max-width: 700px) {
  /* Sections are 320px wide (or screen minus gutters), centered, leaving plain
     page strips beside scrollable lists to scroll the page with a thumb. */
  body:not(.phone-off) .co-summary-row,
  body:not(.phone-off) .co-main-row,
  body:not(.phone-off) .co-quad-row {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }

  /* Summary row: a tidy 4x2 grid instead of a 3-3-2 wrap. */
  body:not(.phone-off) .co-summary-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 4px;
    padding: 12px 6px;
  }
  body:not(.phone-off) .co-stat {
    min-width: 0;
    gap: 6px;
  }
  body:not(.phone-off) .co-stat-value {
    font-size: 13px;
  }

  /* One column: model viewer, Collection Log, then the four cards. */
  body:not(.phone-off) .co-main-row,
  body:not(.phone-off) .co-quad-row {
    flex-direction: column;
    align-items: stretch;
  }
  body:not(.phone-off) .co-left-col,
  body:not(.phone-off) .clog-card,
  body:not(.phone-off) .skills-card,
  body:not(.phone-off) .quests-card,
  body:not(.phone-off) .diaries-card,
  body:not(.phone-off) .ca-card {
    flex: none;
    width: 100%;
    box-sizing: border-box;
  }
  /* Every section except the summary row is a 2:3 portrait box; content fills
     the remaining room and scrolls, and overflow: hidden keeps it in the box. */
  body:not(.phone-off) .model-viewer-card,
  body:not(.phone-off) .clog-card,
  body:not(.phone-off) .skills-card,
  body:not(.phone-off) .quests-card,
  body:not(.phone-off) .diaries-card,
  body:not(.phone-off) .ca-card {
    aspect-ratio: 2 / 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
  }
  body:not(.phone-off) .model-viewer-card {
    width: 100%;
    box-sizing: border-box;
  }
  body:not(.phone-off) .model-viewer-canvas-wrap {
    aspect-ratio: auto;
    flex: 1 1 0;
    min-height: 0;
  }
  body:not(.phone-off) .clog-body {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body:not(.phone-off) .clog-panes {
    flex: 1 1 0;
    min-height: 0;
  }
  body:not(.phone-off) .clog-items-col {
    flex: 1 1 0;
    min-height: 0;
  }
  body:not(.phone-off) .quests-list,
  body:not(.phone-off) .diaries-list {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
  }
  body:not(.phone-off) .skills-grid {
    flex: 1 1 0;
    min-height: 0;
    grid-template-rows: repeat(8, minmax(0, 1fr));
  }
  body:not(.phone-off) .ca-list {
    flex: 1 1 0;
    min-height: 0;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }

  /* Drawn scrollbars: phone browsers use fading overlay scrollbars (iOS cannot
     disable this), so the real one is hidden and the page draws its own (.co-sb,
     built by the 'drawn scrollbars' script in app/pages/) in a strip reserved
     by padding-right. Positioned against each list's parent, hence position:
     relative. */
  body:not(.phone-off) .clog-panes,
  body:not(.phone-off) .clog-items-col,
  body:not(.phone-off) .quests-card,
  body:not(.phone-off) .diaries-card {
    position: relative;
  }
  body:not(.phone-off) .clog-pages,
  body:not(.phone-off) .clog-items,
  body:not(.phone-off) .quests-list,
  body:not(.phone-off) .diaries-list {
    scrollbar-width: none;
    overflow-y: auto;
    padding-right: 16px;
  }
  body:not(.phone-off) .clog-pages::-webkit-scrollbar,
  body:not(.phone-off) .clog-items::-webkit-scrollbar,
  body:not(.phone-off) .quests-list::-webkit-scrollbar,
  body:not(.phone-off) .diaries-list::-webkit-scrollbar {
    display: none;
  }
  body:not(.phone-off) .co-sb {
    position: absolute;
    width: 14px;
    background: transparent;
    z-index: 1;
    touch-action: none;
    visibility: hidden;
  }
  body:not(.phone-off) .co-sb--on { visibility: visible; }
  body:not(.phone-off) .co-sb-thumb {
    width: 6px;
    margin-left: 8px;
    background: var(--gold-dim);
    border-radius: var(--radius);
    touch-action: none;
    cursor: grab;
  }
  body:not(.phone-off) .co-sb-thumb.dragging { background: var(--gold); }
  body:not(.phone-off) .model-viewer-btn {
    width: 36px;
    height: 36px;
  }

  body:not(.phone-off) .clog-tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  body:not(.phone-off) .clog-tabs::-webkit-scrollbar { display: none; }

  /* Scroll cue: the strip fades at whichever edge has more tabs (can-scroll-left
     / can-scroll-right, set by updateClogTabsFade). The fade widths are
     registered custom properties (see @property) so the mask can transition; a
     mask rather than an overlay gradient works over the translucent card
     background. */
  body:not(.phone-off) .clog-tabs {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--clog-fade-l), #000 calc(100% - var(--clog-fade-r)), transparent);
    mask-image: linear-gradient(to right, transparent, #000 var(--clog-fade-l), #000 calc(100% - var(--clog-fade-r)), transparent);
    transition: --clog-fade-l 0.25s ease, --clog-fade-r 0.25s ease;
  }
  body:not(.phone-off) .clog-tabs-wrap.can-scroll-left .clog-tabs { --clog-fade-l: 44px; }
  body:not(.phone-off) .clog-tabs-wrap.can-scroll-right .clog-tabs { --clog-fade-r: 44px; }
  body:not(.phone-off) .clog-tabs-arrow {
    display: block;
    position: absolute;
    top: 50%;
    width: 9px;
    height: 9px;
    margin-top: -5px;
    border-top: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  body:not(.phone-off) .clog-tabs-arrow--right {
    right: 6px;
    transform: rotate(45deg);
  }
  body:not(.phone-off) .clog-tabs-arrow--left {
    left: 6px;
    transform: rotate(-135deg);
  }
  body:not(.phone-off) .clog-tabs-wrap.can-scroll-right .clog-tabs-arrow--right,
  body:not(.phone-off) .clog-tabs-wrap.can-scroll-left .clog-tabs-arrow--left {
    opacity: 1;
  }
  body:not(.phone-off) .clog-tab {
    flex: 0 0 auto;
    padding: 9px 12px;
    font-size: 14px;
  }
  body:not(.phone-off) .clog-sync-btn {
    width: 36px;
    height: 36px;
  }
  body:not(.phone-off) .clog-panes {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  body:not(.phone-off) .clog-pages {
    flex: none;
    height: 160px;
  }
  body:not(.phone-off) .clog-page-btn {
    padding: 9px 8px;
  }
  body:not(.phone-off) .clog-items {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: auto;
    flex: 1 1 0;
    min-height: 0;
    align-content: start;
  }

  body:not(.phone-off) .page-title:has(.co-settings-wrap) {
    position: relative;
  }
  body:not(.phone-off) .co-settings-wrap {
    position: static;
  }
  body:not(.phone-off) .public-profile-card {
    top: calc(100% + 6px);
    /* 2/3 of a page section (320px), centered under the title. */
    width: 213px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
  }
  body:not(.phone-off) .public-profile-seg-group {
    width: 100%;
  }
  body:not(.phone-off) .public-profile-seg-btn {
    flex: 1 1 0;
    height: 36px;
  }
  body:not(.phone-off) .public-profile-link-btn {
    height: 36px;
    width: 100%;
    font-size: 15px;
  }

  /* Tier icons are 24px sprites; 48px is an exact 2x so they stay crisp
     (image-rendering: pixelated above). */
  body:not(.phone-off) .ca-tile {
    gap: 6px;
  }
  body:not(.phone-off) .ca-tile-icon {
    width: 48px;
    height: 48px;
  }

  /* Roomier tap targets in the four cards. */
  body:not(.phone-off) .skill-cell,
  body:not(.phone-off) .skill-cell:hover {
    padding: 4px;
    gap: 8px;
  }
  body:not(.phone-off) .skill-cell-icon {
    width: 26px;
    height: 26px;
  }
  body:not(.phone-off) .skill-cell-level {
    font-size: 17px;
  }
  body:not(.phone-off) .quest-row {
    padding: 5px 4px;
  }
  body:not(.phone-off) .diary-row {
    padding: 6px 4px;
  }
}
