<Ui xmlns="http://www.blizzard.com/wow/ui/">
  <!-- Reusable list row template (must be defined before use) -->
  <Button name="CMJ_ListRowTemplate" virtual="true" inherits="BackdropTemplate">
    <Size y="41"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="ARTWORK">
        <!-- Selected indicator bar inset to align with the new hover/sel insets -->
        <Texture parentKey="sel" hidden="true">
          <Color r="1" g="1" b="0" a="0.9"/>
          <Anchors>
            <Anchor point="TOPLEFT" x="5" y="0"/>
            <Anchor point="BOTTOMLEFT" x="5" y="0"/>
          </Anchors>
          <Size x="3"/>
        </Texture>
        <!-- Selected background (low-key) with a 5px left inset so it doesn't sit under the name column -->
        <Texture parentKey="selBG" hidden="true">
          <Anchors>
            <Anchor point="TOPLEFT" x="5" y="0"/>
            <Anchor point="BOTTOMRIGHT" x="0" y="0"/>
          </Anchors>
          <Color r="0" g="0" b="0" a="0.18"/>
        </Texture>
        <!-- Hover background with same 5px left inset -->
        <Texture parentKey="hover" hidden="true">
          <Anchors>
            <Anchor point="TOPLEFT" x="5" y="0"/>
            <Anchor point="BOTTOMRIGHT" x="0" y="0"/>
          </Anchors>
          <Color r="1" g="1" b="1" a="0.05"/>
        </Texture>
        <!-- Portrait and badges removed for a cleaner, left-aligned list -->
      </Layer>
      <Layer level="OVERLAY">
        <FontString parentKey="name" inherits="GameFontHighlight" justifyH="LEFT">
          <Anchors>
            <Anchor point="LEFT" x="10" y="0"/>
          </Anchors>
          <Size x="220"/>
        </FontString>
        <!-- Date removed from rows; right side reserved for tier text -->
        <FontString parentKey="date" inherits="GameFontDisable" hidden="true">
          <Anchors>
            <Anchor point="RIGHT" x="-20" y="10"/>
          </Anchors>
          <Size x="1"/>
        </FontString>
        <FontString parentKey="sub" inherits="GameFontHighlightSmall" justifyH="RIGHT">
          <Anchors>
            <Anchor point="LEFT" relativeKey="$parent.name" relativePoint="RIGHT" x="12" y="0"/>
            <Anchor point="RIGHT" x="-12" y="0"/>
          </Anchors>
          <Color r="0.85" g="0.85" b="0.85"/>
        </FontString>
        <!-- Small achievements bar next to the name (defined under Frames) -->
        <Texture parentKey="badge" hidden="true" file="Interface/AchievementFrame/AchievementStar">
          <Size x="14" y="14"/>
          <Anchors>
            <Anchor point="RIGHT" x="-6" y="10"/>
          </Anchors>
        </Texture>
        <!-- Divider -->
        <Texture parentKey="divider">
          <Anchors>
            <Anchor point="BOTTOMLEFT" x="0" y="0"/>
            <Anchor point="BOTTOMRIGHT" x="0" y="0"/>
          </Anchors>
          <Size y="1"/>
          <Color r="0" g="0" b="0" a="0.12"/>
        </Texture>
      </Layer>
    </Layers>
    <!-- No child frames needed in list row template -->
    <Scripts>
      <OnLoad> self:EnableMouse(true); self:RegisterForClicks("AnyUp"); self._cmIsRow = true; </OnLoad>
      <OnClick> if self.id and CMUI and CMUI.Select then CMUI.Select(self.id) end </OnClick>
      <OnEnter> if self.hover then self.hover:Show() end </OnEnter>
      <OnLeave> if self.hover then self.hover:Hide() end </OnLeave>
    </Scripts>
  </Button>

  <!-- Category header template (gold caption + thin divider) -->
  <Frame name="CMJ_CategoryHeader" virtual="true" inherits="BackdropTemplate">
    <Size y="24"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <FontString parentKey="text" inherits="GameFontNormalLarge">
          <Anchors>
            <Anchor point="LEFT" x="0" y="0"/>
          </Anchors>
          <Color r="0.95" g="0.82" b="0.31"/>
        </FontString>
        <Texture parentKey="divider">
          <Anchors>
            <Anchor point="BOTTOMLEFT" x="0" y="0"/>
            <Anchor point="BOTTOMRIGHT" x="0" y="0"/>
          </Anchors>
          <Size y="1"/>
          <Color r="0.6" g="0.5" b="0.3" a="0.7"/>
        </Texture>
      </Layer>
    </Layers>
  </Frame>
  
  <!-- Plain header without divider line (for Settings panels) -->
  <Frame name="CMJ_CategoryHeaderPlain" virtual="true" inherits="BackdropTemplate">
    <Size y="24"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <FontString parentKey="text" inherits="GameFontNormalLarge">
          <Anchors>
            <Anchor point="LEFT" x="0" y="0"/>
          </Anchors>
          <Color r="0.95" g="0.82" b="0.31"/>
        </FontString>
      </Layer>
    </Layers>
  </Frame>
  
  <!-- Stat row template (label left, value right) -->
  <Frame name="CMJ_StatRow" virtual="true" inherits="BackdropTemplate">
    <Size y="20"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <FontString parentKey="label" inherits="GameFontDisable" maxLines="1" justifyH="LEFT">
          <Size x="110"/>
          <Anchors><Anchor point="LEFT" x="4"/></Anchors>
        </FontString>
        <FontString parentKey="value" inherits="GameFontHighlight" justifyH="LEFT" maxLines="1">
          <Anchors>
            <Anchor point="LEFT" relativeKey="$parent.label" relativePoint="RIGHT" x="12"/>
            <Anchor point="RIGHT" x="-8"/>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
  </Frame>

  <!-- Stat row template with taller height and multi-line value support -->
  <Frame name="CMJ_StatRowMulti" virtual="true" inherits="BackdropTemplate">
    <Size y="36"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <FontString parentKey="label" inherits="GameFontDisable" maxLines="1" justifyH="LEFT" justifyV="TOP">
          <Size x="110"/>
          <Anchors><Anchor point="TOPLEFT" x="4" y="0"/></Anchors>
        </FontString>
        <FontString parentKey="value" inherits="GameFontHighlight" justifyH="LEFT" justifyV="TOP" maxLines="3">
          <Anchors>
            <Anchor point="TOPLEFT" relativeKey="$parent.label" relativePoint="TOPRIGHT" x="12" y="0"/>
            <Anchor point="RIGHT" x="-8" y="0"/>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
  </Frame>

  <!-- Two-line variant for values that should wrap to at most 2 lines (e.g., Guild) -->
  <Frame name="CMJ_StatRowTwoLine" virtual="true" inherits="BackdropTemplate">
    <Size y="32"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <FontString parentKey="label" inherits="GameFontDisable" maxLines="1" justifyH="LEFT" justifyV="TOP">
          <Size x="110"/>
          <Anchors><Anchor point="TOPLEFT" x="4" y="0"/></Anchors>
        </FontString>
        <FontString parentKey="value" inherits="GameFontHighlight" justifyH="LEFT" justifyV="TOP" maxLines="2">
          <Anchors>
            <Anchor point="TOPLEFT" relativeKey="$parent.label" relativePoint="TOPRIGHT" x="12" y="0"/>
            <Anchor point="RIGHT" x="-8" y="0"/>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
  </Frame>

  <!-- Compact stat cell for grid (label left, value right) -->
  <Frame name="CMJ_StatCell" virtual="true" inherits="BackdropTemplate">
    <Size x="150" y="20"/>
    <Layers>
      <Layer level="OVERLAY">
        <FontString parentKey="label" inherits="GameFontDisableSmall" maxLines="1" justifyV="MIDDLE" justifyH="LEFT">
          <Size x="64"/>
          <Anchors><Anchor point="TOPLEFT" x="4" y="0"/></Anchors>
        </FontString>
        <FontString parentKey="value" inherits="GameFontHighlight" justifyH="LEFT" justifyV="MIDDLE" maxLines="1">
          <Anchors>
            <Anchor point="TOPLEFT" x="72" y="0"/>
            <Anchor point="TOPRIGHT" x="-4" y="0"/>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
  </Frame>

  <!-- Achievement row template (title, description, progress right, Claim button) -->
  <Frame name="CMJ_AchievementRowTemplate" virtual="true" inherits="BackdropTemplate">
    <Size y="40"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <!-- Title: brighter for readability with subtle gold tint -->
        <FontString parentKey="title" inherits="GameFontHighlight">
          <Anchors><Anchor point="TOPLEFT" x="0" y="-2"/></Anchors>
          <Color r="0.95" g="0.90" b="0.70"/>
        </FontString>
        <!-- Description: slightly brighter than disabled gray for contrast on parchment -->
        <FontString parentKey="desc" inherits="GameFontDisableSmall">
          <Anchors><Anchor point="TOPLEFT" relativeKey="$parent.title" relativePoint="BOTTOMLEFT" y="-1"/></Anchors>
          <Color r="0.85" g="0.85" b="0.85" a="0.9"/>
        </FontString>
        <!-- Progress: larger and right-aligned with strong contrast -->
        <FontString parentKey="progress" inherits="GameFontHighlight">
          <Anchors><Anchor point="RIGHT" x="-72" y="-2"/></Anchors>
        </FontString>
        <!-- Row divider for visual separation -->
        <Texture parentKey="divider">
          <Anchors>
            <Anchor point="BOTTOMLEFT" x="0" y="0"/>
            <Anchor point="BOTTOMRIGHT" x="0" y="0"/>
          </Anchors>
          <Size y="1"/>
          <Color r="0" g="0" b="0" a="0.18"/>
        </Texture>
      </Layer>
    </Layers>
    <Frames>
      <Button parentKey="claim" inherits="UIPanelButtonTemplate" text="Claim">
        <Size x="68" y="20"/>
        <Anchors><Anchor point="RIGHT" x="-4"/></Anchors>
      </Button>
    </Frames>
  </Frame>

  <!-- Title bar template (light, gold-accented) -->
  <Frame name="CMJ_TitleBar" virtual="true" inherits="BackdropTemplate">
    <Size y="22"/>
    <Anchors>
      <Anchor point="LEFT"/>
      <Anchor point="RIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="BACKGROUND">
        <Texture parentKey="bg" setAllPoints="true">
          <Color r="0" g="0" b="0" a="0"/>
        </Texture>
      </Layer>
      <Layer level="OVERLAY">
        <Texture parentKey="topLine">
          <Anchors><Anchor point="TOPLEFT"/><Anchor point="TOPRIGHT"/></Anchors>
          <Size y="1"/>
          <Color r="0.92" g="0.78" b="0.45" a="0.8"/>
        </Texture>
        <Texture parentKey="bottomLine">
          <Anchors><Anchor point="BOTTOMLEFT"/><Anchor point="BOTTOMRIGHT"/></Anchors>
          <Size y="1"/>
          <Color r="0.6" g="0.5" b="0.3" a="0.6"/>
        </Texture>
        <!-- Drop shadow under title text -->
        <FontString parentKey="shadow" inherits="GameFontNormalLarge">
          <Anchors><Anchor point="CENTER" x="1" y="-1"/></Anchors>
          <Color r="0" g="0" b="0" a="0.6"/>
        </FontString>
        <FontString parentKey="text" inherits="GameFontNormalLarge">
          <Anchors><Anchor point="CENTER"/></Anchors>
          <Color r="0.95" g="0.82" b="0.31"/>
        </FontString>
      </Layer>
    </Layers>
  </Frame>

  <!-- Reusable EditBox template for native feel and Escape-to-unfocus -->
  <EditBox name="CMJ_EditBoxTemplate" virtual="true" inherits="InputBoxTemplate" autoFocus="false">
    <Scripts>
      <OnEscapePressed> self:ClearFocus() </OnEscapePressed>
    </Scripts>
  </EditBox>
  <!-- Journal Root -->
  <Frame name="CMJ_RootXML" hidden="true" parent="UIParent" inherits="BackdropTemplate">
    <Size x="1024" y="512"/>
    <Anchors>
      <Anchor point="CENTER"/>
    </Anchors>
    <Layers>
      <Layer level="BACKGROUND">
        <Texture file="Interface/AddOns/CharacterMemory/media/cmjournal.png" setAllPoints="true"/>
      </Layer>
    </Layers>
    <Frames>
      <!-- Left and Right pages -->
      <Frame name="$parentPageL" inherits="BackdropTemplate">
        <Anchors>
          <Anchor point="TOPLEFT" x="64" y="-56"/>
          <!-- Pull in the right edge slightly to avoid binding overlap -->
          <Anchor point="BOTTOMRIGHT" x="-540" y="60"/>
        </Anchors>
        <Layers>
      <Layer level="OVERLAY">
        <FontString name="$parentHeader" inherits="GameFontNormalLarge" text="Friendships">
              <Anchors><Anchor point="TOPLEFT" y="0"/></Anchors>
            </FontString>
          </Layer>
        </Layers>
        <Frames>
          <ScrollFrame name="$parentFaux" inherits="FauxScrollFrameTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" x="0" y="-46"/>
              <Anchor point="BOTTOMRIGHT" x="-28" y="0"/>
            </Anchors>
            <Scripts>
              <OnVerticalScroll>
                FauxScrollFrame_OnVerticalScroll(self, 41, CMJ.RefreshList)
              </OnVerticalScroll>
            </Scripts>
          </ScrollFrame>
          <!-- Toolbar row under the Friendships header for controls like filter -->
          <Frame name="$parentToolbar">
            <Size y="22"/>
            <Anchors>
              <Anchor point="TOPLEFT" x="0" y="-16"/>
              <Anchor point="RIGHT" x="-120"/>
            </Anchors>
          </Frame>
          <!-- Filter dropdown placed inside the toolbar row -->
          <Frame name="$parentFilterMenu" inherits="UIDropDownMenuTemplate">
            <Anchors>
              <Anchor point="RIGHT" relativeTo="$parentToolbar" relativePoint="RIGHT" x="-12" y="0"/>
            </Anchors>
            <Scripts>
              <OnLoad> if CMUI and CMUI.InitFriendFilter then CMUI.InitFriendFilter(self) end </OnLoad>
            </Scripts>
          </Frame>
          <!-- Next page button (replaces scroll usage) -->
          <!-- Pagination: Prev / PageIndicator / Next -->
          <Button name="$parentPrev" inherits="UIPanelButtonTemplate" text="Prev">
            <Size x="56" y="20"/>
            <Anchors><Anchor point="BOTTOMLEFT" x="0" y="0"/></Anchors>
          </Button>
          <Frame name="$parentPageIndicator">
            <Size x="120" y="20"/>
            <Anchors><Anchor point="BOTTOM" x="0" y="0"/></Anchors>
            <Layers>
              <Layer level="OVERLAY">
                <FontString parentKey="text" inherits="GameFontDisableSmall" justifyH="CENTER">
                  <Anchors><Anchor point="CENTER"/></Anchors>
                </FontString>
              </Layer>
            </Layers>
          </Frame>
          <Button name="$parentNext" inherits="UIPanelButtonTemplate" text="Next">
            <Size x="56" y="20"/>
            <Anchors><Anchor point="BOTTOMRIGHT" x="0" y="0"/></Anchors>
          </Button>
          <!-- Predefined row buttons (template from CMJ_ListRowTemplate) -->
          <Button name="$parentRow1" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" x="0" y="-46"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow2" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow1" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow3" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow2" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow4" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow3" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow5" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow4" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow6" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow5" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow7" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow6" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow8" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow7" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <Button name="$parentRow9" inherits="CMJ_ListRowTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentRow8" relativePoint="BOTTOMLEFT"/>
              <Anchor point="RIGHT" x="-28"/>
            </Anchors>
          </Button>
          <!-- Hide extra rows to ensure content never clips the bottom; show 8 max -->
        </Frames>
      </Frame>
      <Frame name="$parentPageR" inherits="BackdropTemplate">
        <Anchors>
          <Anchor point="TOPLEFT" x="520" y="-56"/>
          <Anchor point="BOTTOMRIGHT" x="-64" y="60"/>
        </Anchors>
        <Frames>
          <!-- Title bar -->
          <Frame name="$parentTitleBar" inherits="CMJ_TitleBar">
            <Anchors><Anchor point="TOPLEFT"/><Anchor point="TOPRIGHT"/></Anchors>
            <Layers>
              <Layer level="OVERLAY">
                <FontString parentKey="shadow" inherits="GameFontNormalLarge" text="Character Memory"/>
                <FontString parentKey="text" inherits="GameFontNormalLarge" text="Character Memory"/>
              </Layer>
            </Layers>
          </Frame>

          <!-- Tab bar -->
          <Frame name="$parentTabBar">
            <Size y="22"/>
            <Anchors><Anchor point="TOPLEFT" y="-22"/><Anchor point="TOPRIGHT" y="-22"/></Anchors>
            <Frames>
              <Button name="$parentTabOverview" inherits="UIPanelButtonTemplate" text="Overview">
                <Size x="84" y="20"/>
                <Anchors><Anchor point="CENTER" x="-147"/></Anchors>
                <Scripts><OnClick>if CMUI and CMUI.TabSwap then CMUI.TabSwap("Overview") end</OnClick></Scripts>
              </Button>
              <Button name="$parentTabProfile" inherits="UIPanelButtonTemplate" text="Profile">
                <Size x="84" y="20"/>
                <Anchors><Anchor point="LEFT" relativeTo="$parentTabOverview" relativePoint="RIGHT" x="8"/></Anchors>
                <Scripts><OnClick>if CharacterMemory_OpenCharacterSheet then CharacterMemory_OpenCharacterSheet() end</OnClick></Scripts>
              </Button>
              <Button name="$parentTabNotes" inherits="UIPanelButtonTemplate" text="Notes">
                <Size x="84" y="20"/>
                <Anchors><Anchor point="LEFT" relativeTo="$parentTabProfile" relativePoint="RIGHT" x="8"/></Anchors>
                <Scripts><OnClick>if CMUI and CMUI.TabSwap then CMUI.TabSwap("Notes") end</OnClick></Scripts>
              </Button>
              <Button name="$parentTabAchievements" inherits="UIPanelButtonTemplate" text="Achievements">
                <Size x="110" y="20"/>
                <Anchors><Anchor point="LEFT" relativeTo="$parentTabNotes" relativePoint="RIGHT" x="8"/></Anchors>
                <Scripts><OnClick>if CMUI and CMUI.TabSwap then CMUI.TabSwap("Achievements") end</OnClick></Scripts>
              </Button>
              
            </Frames>
          </Frame>

          <!-- Right-side content container: keep parchment visible (no overlay) -->
          <Frame name="$parentInset" inherits="BackdropTemplate">
            <Anchors>
              <Anchor point="TOPLEFT" x="0" y="-26"/>
              <Anchor point="BOTTOMRIGHT" x="0" y="6"/>
            </Anchors>
          </Frame>

          <!-- Tabs content containers -->
          <Frame name="$parentOverview">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentTabBar" relativePoint="BOTTOMLEFT" x="8" y="-8"/>
              <!-- More right padding so content never clips spine -->
              <Anchor point="BOTTOMRIGHT" relativeTo="$parentInset" relativePoint="BOTTOMRIGHT" x="-16" y="8"/>
            </Anchors>
            <Layers>
              <Layer level="OVERLAY">
                <FontString name="$parentTitle" inherits="GameFontNormalLarge">
                  <Anchors><Anchor point="TOPLEFT" x="0" y="-4"/></Anchors>
                </FontString>
                <FontString name="$parentTier" inherits="GameFontHighlightSmall">
                  <Anchors><Anchor point="TOPLEFT" relativeTo="$parentTitle" relativePoint="BOTTOMLEFT" x="0" y="-4"/></Anchors>
                  <Color r="0.90" g="0.90" b="0.90"/>
                </FontString>
                <!-- Remove badges and portrait for a clean, text-only header -->
              </Layer>
            </Layers>
            <Frames>
              <!-- Achievements mini bar next to the name in Overview header -->
              <StatusBar name="$parentNameAchBar" minValue="0" maxValue="1" defaultValue="0">
                <Size x="165" y="11"/>
                <Anchors><Anchor point="TOPRIGHT" x="-8" y="-2"/></Anchors>
                <BarTexture file="Interface/TargetingFrame/UI-StatusBar"/>
                <Layers>
                  <Layer level="BACKGROUND">
                    <Texture parentKey="bg" setAllPoints="true" file="Interface/Tooltips/UI-Tooltip-Background">
                      <Color r="0" g="0" b="0" a="0.4"/>
                    </Texture>
                  </Layer>
                  <Layer level="OVERLAY">
                    <FontString parentKey="value" inherits="GameFontHighlightSmall" justifyH="CENTER">
                      <Anchors><Anchor point="CENTER"/></Anchors>
                    </FontString>
                  </Layer>
                </Layers>
              </StatusBar>
              <!-- Relation header -->
              <Frame name="$parentRelHeader" inherits="CMJ_CategoryHeader">
                <Anchors>
                  <Anchor point="TOPLEFT" x="0" y="-28"/>
                  <Anchor point="RIGHT"/>
                </Anchors>
                <Layers>
                  <Layer level="OVERLAY">
                    <FontString parentKey="text" inherits="GameFontNormalLarge" text="Relation"/>
                  </Layer>
                </Layers>
              </Frame>
              <!-- Achievements summary bar removed; mini bar by name replaces it -->
              <!-- Relation details (facts grid) -->
              <Frame name="$parentFacts">
                <Size y="108"/>
                <Anchors>
                  <Anchor point="TOPLEFT" relativeTo="$parentRelHeader" relativePoint="BOTTOMLEFT" x="0" y="-12"/>
                  <Anchor point="RIGHT" x="-16" y="0"/>
                </Anchors>
                <Layers/>
                <Frames>
                  <!-- Left half (5 rows) -->
                  <Frame name="$parentLeft">
                    <Anchors>
                      <Anchor point="TOPLEFT"/>
                      <Anchor point="RIGHT" relativePoint="CENTER" x="-8" y="0"/>
                    </Anchors>
                    <Frames>
                      <Frame name="$parentRow1" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow2" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow1" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow3" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow2" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow4" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow3" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow5" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow4" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                    </Frames>
                  </Frame>
                  <!-- Right half (5 rows) -->
                  <Frame name="$parentRight">
                    <Anchors>
                      <Anchor point="TOPRIGHT"/>
                      <Anchor point="LEFT" relativePoint="CENTER" x="8" y="0"/>
                    </Anchors>
                    <Frames>
                      <Frame name="$parentRow1" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow2" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow1" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow3" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow2" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow4" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow3" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow5" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow4" relativePoint="BOTTOMLEFT" y="-6"/><Anchor point="RIGHT"/></Anchors></Frame>
                    </Frames>
                  </Frame>
                </Frames>
              </Frame>
              <!-- Summary header -->
              <Frame name="$parentSummaryHeader" inherits="CMJ_CategoryHeader">
                <Anchors>
                  <Anchor point="TOPLEFT" relativeTo="$parentFacts" relativePoint="BOTTOMLEFT" x="0" y="-17"/>
                  <Anchor point="RIGHT"/>
                </Anchors>
                <Layers>
                  <Layer level="OVERLAY">
                    <FontString parentKey="text" inherits="GameFontNormalLarge" text="Summary"/>
                  </Layer>
                </Layers>
              </Frame>
              <Frame name="$parentSummary">
                <Size y="96"/>
                <Anchors>
                  <Anchor point="TOPLEFT" relativeTo="$parentSummaryHeader" relativePoint="BOTTOMLEFT" x="0" y="-6"/>
                  <Anchor point="RIGHT" x="-16" y="0"/>
                </Anchors>
                <Layers/>
                <Frames>
                  <!-- Left column -->
                  <Frame name="$parentLeft">
                    <Anchors>
                      <Anchor point="TOPLEFT"/>
                      <Anchor point="BOTTOMRIGHT" relativePoint="TOP" x="-8" y="0"/>
                    </Anchors>
                    <Frames>
                      <Frame name="$parentRow1" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow2" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow1" relativePoint="BOTTOMLEFT" y="-8"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow3" inherits="CMJ_StatRowTwoLine"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow2" relativePoint="BOTTOMLEFT" y="-8"/><Anchor point="RIGHT"/></Anchors></Frame>
                    </Frames>
                  </Frame>
                  <!-- Right column -->
                  <Frame name="$parentRight">
                    <Anchors>
                      <Anchor point="TOPLEFT" relativePoint="TOP" x="8" y="0"/>
                      <Anchor point="BOTTOMRIGHT"/>
                    </Anchors>
                    <Frames>
                      <Frame name="$parentRow1" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow2" inherits="CMJ_StatRow"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow1" relativePoint="BOTTOMLEFT" y="-8"/><Anchor point="RIGHT"/></Anchors></Frame>
                      <Frame name="$parentRow3" inherits="CMJ_StatRowTwoLine"><Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow2" relativePoint="BOTTOMLEFT" y="-8"/><Anchor point="RIGHT"/></Anchors></Frame>
                    </Frames>
                  </Frame>
                </Frames>
              </Frame>
              <!-- Delete button in bottom right corner -->
              <Button name="$parentDeleteBtn" inherits="UIPanelButtonTemplate" text="Delete Entry">
                <Size x="100" y="24"/>
                <Anchors>
                  <Anchor point="BOTTOMRIGHT" x="-8" y="-15"/>
                </Anchors>
                <Scripts>
                  <OnClick>
                    if CMUI and CMUI.DeleteEntry and CMUI.GetSelectedEntry then
                      local selectedId = CMUI.GetSelectedEntry()
                      if selectedId then
                        CMUI.DeleteEntry(selectedId)
                      end
                    end
                  </OnClick>
                </Scripts>
              </Button>
              <!-- Facts grid removed to reduce clutter and fix alignment -->
            </Frames>
          </Frame>
          <Frame name="$parentNotes" hidden="true">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentTabBar" relativePoint="BOTTOMLEFT" x="8" y="-8"/>
              <Anchor point="BOTTOMRIGHT" relativeTo="$parentInset" relativePoint="BOTTOMRIGHT" x="-8" y="8"/>
            </Anchors>
            <Frames>
              <ScrollFrame name="$parentScroll" inherits="UIPanelScrollFrameTemplate">
                <Anchors><Anchor point="TOPLEFT" x="4" y="-4"/><Anchor point="BOTTOMRIGHT" x="-24" y="4"/></Anchors>
              </ScrollFrame>
              <EditBox name="$parentEdit" multiLine="true" autoFocus="false" inherits="InputBoxTemplate">
                <Size x="400"/>
              </EditBox>
              <Button name="$parentShare" inherits="UIPanelButtonTemplate" text="Share">
                <Size x="84" y="24"/>
                <Anchors><Anchor point="BOTTOMRIGHT" x="-8" y="4"/></Anchors>
              </Button>
            </Frames>
          </Frame>
          <Frame name="$parentProfile" hidden="true">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentTabBar" relativePoint="BOTTOMLEFT" x="8" y="-8"/>
              <Anchor point="BOTTOMRIGHT" relativeTo="$parentInset" relativePoint="BOTTOMRIGHT" x="-8" y="8"/>
            </Anchors>
            <Frames>
              <!-- Profile functionality moved to RPBio.xml -->
              <Frame name="$parentPlaceholder">
                <Anchors>
                  <Anchor point="CENTER"/>
                </Anchors>
                <Layers>
                  <Layer level="OVERLAY">
                    <FontString inherits="GameFontNormalLarge" text="Profile functionality moved to RP Bio">
                      <Anchors><Anchor point="CENTER"/></Anchors>
                      <Color r="0.7" g="0.7" b="0.7"/>
                    </FontString>
                  </Layer>
                </Layers>
              </Frame>
            </Frames>
          </Frame>
          

          <!-- Achievements tab -->
          <Frame name="$parentAchievements" hidden="true">
            <Anchors>
              <Anchor point="TOPLEFT" relativeTo="$parentTabBar" relativePoint="BOTTOMLEFT" x="8" y="-8"/>
              <Anchor point="BOTTOMRIGHT" relativeTo="$parentInset" relativePoint="BOTTOMRIGHT" x="-16" y="8"/>
            </Anchors>
            <Frames>
              <ScrollFrame name="$parentFaux" inherits="FauxScrollFrameTemplate">
                <Anchors>
                  <Anchor point="TOPLEFT" x="0" y="0"/>
                  <Anchor point="BOTTOMRIGHT" x="-16" y="0"/>
                </Anchors>
              </ScrollFrame>
              <Frame name="$parentRow1" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" x="0" y="0"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow2" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow1" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow3" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow2" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow4" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow3" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow5" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow4" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow6" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow5" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow7" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow6" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
              <Frame name="$parentRow8" inherits="CMJ_AchievementRowTemplate">
                <Anchors><Anchor point="TOPLEFT" relativeTo="$parentRow7" relativePoint="BOTTOMLEFT" y="-4"/><Anchor point="RIGHT"/></Anchors>
              </Frame>
            </Frames>
          </Frame>
        </Frames>
      </Frame>
    </Frames>
    <Scripts>
      <OnLoad>
        if CMUI and CMUI.InitFromXML then CMUI.InitFromXML(self) end
      </OnLoad>
    </Scripts>
  </Frame>

  <!-- Options panel for Interface Options / Settings -->
  <Frame name="CM_OptionsPanel" parent="UIParent" hidden="true">
    <Anchors>
      <Anchor point="TOPLEFT"/>
      <Anchor point="BOTTOMRIGHT"/>
    </Anchors>
    <Layers>
      <Layer level="OVERLAY">
        <FontString name="$parentTitle" inherits="GameFontNormalLarge" text="Character Memory">
          <Anchors><Anchor point="TOPLEFT" x="16" y="-16"/></Anchors>
        </FontString>
        <FontString name="$parentDesc" inherits="GameFontHighlightSmall" text="Configure your profile and UI preferences.">
          <Anchors><Anchor point="TOPLEFT" relativeTo="$parentTitle" relativePoint="BOTTOMLEFT" y="-8"/></Anchors>
        </FontString>
      </Layer>
    </Layers>
    <Frames>
      <!-- Remove in-panel tabs; navigation now uses Settings subpages -->
      <!-- Identity fields row -->
      <!-- Identity moved to RP Bio page -->
      <Frame name="$parentIdentityHeader" inherits="CMJ_CategoryHeader" hidden="true"/>
      <EditBox name="$parentTitleEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentTitleLabel" hidden="true"/>
      <EditBox name="$parentPronounsEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentPronounsLabel" hidden="true"/>
      <EditBox name="$parentAlignmentEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentAlignmentLabel" hidden="true"/>
      <EditBox name="$parentTagsEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentTagsLabel" hidden="true"/>

      <!-- Appearance quick stats -->
      <!-- Appearance & Details moved to RP Bio page -->
      <Frame name="$parentTraitsHeader" inherits="CMJ_CategoryHeader" hidden="true"/>
      <EditBox name="$parentAgeEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentAgeLabel" hidden="true"/>
      <EditBox name="$parentHeightEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentHeightLabel" hidden="true"/>
      <EditBox name="$parentWeightEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentWeightLabel" hidden="true"/>
      <EditBox name="$parentEyesEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentEyesLabel" hidden="true"/>
      <EditBox name="$parentHairEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentHairLabel" hidden="true"/>
      <EditBox name="$parentAliasEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentAliasLabel" hidden="true"/>
      <EditBox name="$parentLanguagesEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentLanguagesLabel" hidden="true"/>
      <EditBox name="$parentProficienciesEdit" inherits="InputBoxTemplate" hidden="true"/>
      <Frame name="$parentProficienciesLabel" hidden="true"/>

      <!-- Narrative traits -->
      <!-- Narrative fields moved to RP Bio page; hide on main page -->
      <EditBox name="$parentPersonalityEdit" inherits="InputBoxTemplate" multiLine="true" hidden="true"/>
      <Frame name="$parentPersonalityLabel" hidden="true"/>
      <EditBox name="$parentIdealsEdit" inherits="InputBoxTemplate" multiLine="true" hidden="true"/>
      <Frame name="$parentIdealsLabel" hidden="true"/>
      <EditBox name="$parentBondsEdit" inherits="InputBoxTemplate" multiLine="true" hidden="true"/>
      <Frame name="$parentBondsLabel" hidden="true"/>
      <EditBox name="$parentFlawsEdit" inherits="InputBoxTemplate" multiLine="true" hidden="true"/>
      <Frame name="$parentFlawsLabel" hidden="true"/>
      <EditBox name="$parentHobbiesEdit" inherits="InputBoxTemplate" multiLine="true" hidden="true"/>
      <Frame name="$parentHobbiesLabel" hidden="true"/>
      <!-- Placeholder to satisfy any legacy anchors referencing $parentBioEdit on the main options panel -->
      <EditBox name="$parentBioEdit" inherits="InputBoxTemplate" hidden="true"/>

      <!-- Preferences header and toggles -->
      <Frame name="$parentPrefsHeader" inherits="CMJ_CategoryHeader">
        <Anchors><Anchor point="TOPLEFT" relativeTo="$parentDesc" relativePoint="BOTTOMLEFT" y="-16"/><Anchor point="RIGHT" x="-16"/></Anchors>
        <Layers><Layer level="OVERLAY"><FontString parentKey="text" inherits="GameFontNormalLarge" text="Preferences"/></Layer></Layers>
      </Frame>
      <!-- Ensure the General tab group is its own container for easy hide/show -->
      <Frame name="$parentGeneralGroup">
        <Anchors>
          <Anchor point="TOPLEFT" relativeTo="$parentPrefsHeader" relativePoint="BOTTOMLEFT" x="0" y="0"/>
          <!-- Anchor to the panel bottom with space for the shared footer (approx 40px) -->
          <Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT" x="-16" y="48"/>
        </Anchors>
        <Frames>
          <!-- General toggles inside the group; keep global names for Lua -->
          <CheckButton name="CM_OptionsPanelShowOnTarget" inherits="InterfaceOptionsCheckButtonTemplate">
            <Anchors><Anchor point="TOPLEFT" x="0" y="-12"/></Anchors>
            <Scripts>
              <OnLoad>_G[self:GetName().."Text"]:SetText("Show journal when targeting players")</OnLoad>
              <OnEnter> GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetText("Automatically show the journal when you target a player.") </OnEnter>
              <OnLeave> GameTooltip:Hide() </OnLeave>
            </Scripts>
          </CheckButton>
          <CheckButton name="CM_OptionsPanelShowBadges" inherits="InterfaceOptionsCheckButtonTemplate">
            <Anchors><Anchor point="TOPLEFT" relativeTo="CM_OptionsPanelShowOnTarget" relativePoint="BOTTOMLEFT" y="-8"/></Anchors>
            <Scripts>
              <OnLoad>_G[self:GetName().."Text"]:SetText("Show friend/guild badges")</OnLoad>
              <OnEnter> GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetText("Display friend and guild badges in the journal list.") </OnEnter>
              <OnLeave> GameTooltip:Hide() </OnLeave>
            </Scripts>
          </CheckButton>
          <CheckButton name="CM_OptionsPanelEnableInspect" inherits="InterfaceOptionsCheckButtonTemplate">
            <Anchors><Anchor point="TOPLEFT" relativeTo="CM_OptionsPanelShowBadges" relativePoint="BOTTOMLEFT" y="-8"/></Anchors>
            <Scripts>
              <OnLoad>_G[self:GetName().."Text"]:SetText("Allow inspecting iLvl for targets")</OnLoad>
              <OnEnter> GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetText("Capture item level where API access is permitted.") </OnEnter>
              <OnLeave> GameTooltip:Hide() </OnLeave>
            </Scripts>
          </CheckButton>
          <CheckButton name="CM_OptionsPanelEnableProximity" inherits="InterfaceOptionsCheckButtonTemplate">
            <Anchors><Anchor point="TOPLEFT" relativeTo="CM_OptionsPanelEnableInspect" relativePoint="BOTTOMLEFT" y="-8"/></Anchors>
            <Scripts>
              <OnLoad>_G[self:GetName().."Text"]:SetText("Track nearby presence (nameplates)")</OnLoad>
              <OnEnter> GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetText("Counts nameplate presence to increment 'Nearby' stats (lightweight).") </OnEnter>
              <OnLeave> GameTooltip:Hide() </OnLeave>
            </Scripts>
          </CheckButton>
          <CheckButton name="CM_OptionsPanelAutoShare" inherits="InterfaceOptionsCheckButtonTemplate">
            <Anchors><Anchor point="TOPLEFT" relativeTo="CM_OptionsPanelEnableProximity" relativePoint="BOTTOMLEFT" y="-8"/></Anchors>
            <Scripts>
              <OnLoad>_G[self:GetName().."Text"]:SetText("Auto-share first meet in chat")</OnLoad>
              <OnEnter> GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetText("When you first meet someone, post a short message to party/raid/say.") </OnEnter>
              <OnLeave> GameTooltip:Hide() </OnLeave>
            </Scripts>
          </CheckButton>
        </Frames>
      </Frame>

      <!-- Footer with actions visible on all tabs -->
      <Frame name="$parentFooter" inherits="BackdropTemplate">
        <Anchors>
          <Anchor point="LEFT" x="16" y="0"/>
          <Anchor point="RIGHT" x="-16" y="0"/>
          <Anchor point="BOTTOM" y="12"/>
        </Anchors>
        <Size y="32"/>
        <Layers>
          <Layer level="OVERLAY">
            <Texture parentKey="topLine">
              <Anchors><Anchor point="TOPLEFT"/><Anchor point="TOPRIGHT"/></Anchors>
              <Size y="1"/>
              <Color r="0.6" g="0.5" b="0.3" a="0.7"/>
            </Texture>
          </Layer>
        </Layers>
      </Frame>
      <Button name="$parentSave" inherits="UIPanelButtonTemplate" text="Save">
        <Size x="120" y="24"/>
        <Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentFooter" relativePoint="BOTTOMLEFT" x="0" y="0"/></Anchors>
        <Scripts>
          <OnClick> if CharacterMemory_OptionsSave then CharacterMemory_OptionsSave() end </OnClick>
        </Scripts>
      </Button>
      <Button name="$parentClearSelected" inherits="UIPanelButtonTemplate" text="Clear Selected">
        <Size x="140" y="24"/>
        <Anchors><Anchor point="LEFT" relativeTo="$parentSave" relativePoint="RIGHT" x="8"/></Anchors>
        <Scripts>
          <OnClick> if CharacterMemory_OptionsClearSelected then CharacterMemory_OptionsClearSelected() end </OnClick>
        </Scripts>
      </Button>
      <Button name="$parentOpenJournal" inherits="UIPanelButtonTemplate" text="Open Journal">
        <Size x="140" y="24"/>
        <Anchors><Anchor point="LEFT" relativeTo="$parentClearSelected" relativePoint="RIGHT" x="8"/></Anchors>
        <Scripts>
          <OnClick> if CharacterMemory_OpenJournal then CharacterMemory_OpenJournal() end </OnClick>
        </Scripts>
      </Button>
      <Button name="$parentOpenSheet" inherits="UIPanelButtonTemplate" text="Open Character Sheet">
        <Size x="180" y="24"/>
        <Anchors><Anchor point="LEFT" relativeTo="$parentOpenJournal" relativePoint="RIGHT" x="8"/></Anchors>
        <Scripts>
          <OnClick> if CharacterMemory_OpenCharacterSheet then CharacterMemory_OpenCharacterSheet() end </OnClick>
        </Scripts>
      </Button>
      <Button name="$parentPublish" inherits="UIPanelButtonTemplate" text="Publish to Group">
        <Size x="160" y="24"/>
        <Anchors><Anchor point="LEFT" relativeTo="$parentOpenSheet" relativePoint="RIGHT" x="8"/></Anchors>
        <Scripts>
          <OnClick> if CharacterMemory_OptionsPublish then CharacterMemory_OptionsPublish() end </OnClick>
        </Scripts>
      </Button>
    </Frames>
    <Scripts>
      <OnShow> if CharacterMemory_OptionsOnShow then CharacterMemory_OptionsOnShow() end </OnShow>
    </Scripts>
  </Frame>

  <!-- Secondary Settings page: RP Bio editor -->
  <!-- Bio content lives inside the Options panel as a tab -->
  <Frame name="CM_BioPanel" parent="UIParent" hidden="true">
    <Anchors>
      <Anchor point="TOPLEFT"/>
      <Anchor point="BOTTOMRIGHT"/>
    </Anchors>
    <Layers/>
    <Frames>
      <Frame name="$parentHeader" inherits="CMJ_CategoryHeaderPlain">
        <Anchors>
          <Anchor point="TOPLEFT" x="16" y="-8"/>
          <Anchor point="TOPRIGHT" x="-16" y="-8"/>
        </Anchors>
        <Layers><Layer level="OVERLAY"><FontString parentKey="text" inherits="GameFontNormalLarge" text="RP Bio"/></Layer></Layers>
      </Frame>
      <!-- Identity on Bio page -->
      <Frame name="$parentIdentityHeader" inherits="CMJ_CategoryHeaderPlain" hidden="true">
        <Anchors>
          <Anchor point="TOPLEFT" relativeTo="$parentHeader" relativePoint="BOTTOMLEFT" x="0" y="-12"/>
          <Anchor point="RIGHT" x="-16"/>
        </Anchors>
        <Layers><Layer level="OVERLAY"><FontString parentKey="text" inherits="GameFontNormalLarge" text="RP Identity"/></Layer></Layers>
      </Frame>
      <EditBox name="$parentTitleEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentIdentityHeader" relativePoint="BOTTOMLEFT" x="16" y="-8"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentTitleLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentTitleEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentTitleEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Title" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentPronounsEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentTitleEdit" relativePoint="BOTTOMLEFT" x="0" y="-28"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentPronounsLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentPronounsEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentPronounsEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Pronouns" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentAlignmentEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentPronounsEdit" relativePoint="BOTTOMLEFT" x="0" y="-28"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentAlignmentLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentAlignmentEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentAlignmentEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Alignment" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentTagsEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentAlignmentEdit" relativePoint="BOTTOMLEFT" x="0" y="-28"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentTagsLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentTagsEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentTagsEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Tags (comma separated)" justifyH="LEFT"/></Layer></Layers></Frame>

      <!-- Appearance & Details on Bio page -->
      <Frame name="$parentTraitsHeader" inherits="CMJ_CategoryHeaderPlain" hidden="true">
        <Anchors><Anchor point="TOPLEFT" relativeTo="$parentTagsEdit" relativePoint="BOTTOMLEFT" x="0" y="-16"/><Anchor point="RIGHT"/></Anchors>
        <Layers><Layer level="OVERLAY"><FontString parentKey="text" inherits="GameFontNormalLarge" text="Appearance &amp; Details"/></Layer></Layers>
      </Frame>
      <EditBox name="$parentAgeEdit" inherits="CMJ_EditBoxTemplate"><Size x="140" y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentTraitsHeader" relativePoint="BOTTOMLEFT" x="16" y="-16"/></Anchors></EditBox>
      <Frame name="$parentAgeLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentAgeEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentAgeEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Age" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentHeightEdit" inherits="CMJ_EditBoxTemplate"><Size x="140" y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentAgeEdit" relativePoint="TOPRIGHT" x="16" y="0"/></Anchors></EditBox>
      <Frame name="$parentHeightLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentHeightEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentHeightEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Height" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentWeightEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentHeightEdit" relativePoint="TOPRIGHT" x="16" y="0"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentWeightLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentWeightEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentWeightEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Weight" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentEyesEdit" inherits="CMJ_EditBoxTemplate"><Size x="140" y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentAgeEdit" relativePoint="BOTTOMLEFT" x="0" y="-24"/></Anchors></EditBox>
      <Frame name="$parentEyesLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentEyesEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentEyesEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Eyes" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentHairEdit" inherits="CMJ_EditBoxTemplate"><Size x="140" y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentEyesEdit" relativePoint="TOPRIGHT" x="16" y="0"/></Anchors></EditBox>
      <Frame name="$parentHairLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentHairEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentHairEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Hair" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentAliasEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentHairEdit" relativePoint="TOPRIGHT" x="16" y="0"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentAliasLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentAliasEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentAliasEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Alias/Nickname" justifyH="LEFT"/></Layer></Layers></Frame>
      <EditBox name="$parentLanguagesEdit" inherits="CMJ_EditBoxTemplate"><Size y="20"/><Anchors><Anchor point="TOPLEFT" relativeTo="$parentEyesEdit" relativePoint="BOTTOMLEFT" x="0" y="-24"/><Anchor point="RIGHT" x="-16"/></Anchors></EditBox>
      <Frame name="$parentLanguagesLabel"><Size y="16"/><Anchors><Anchor point="BOTTOMLEFT" relativeTo="$parentLanguagesEdit" relativePoint="TOPLEFT" y="2"/><Anchor point="RIGHT" relativeTo="$parentLanguagesEdit" relativePoint="RIGHT"/></Anchors><Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontNormalSmall" text="Languages" justifyH="LEFT"/></Layer></Layers></Frame>
      <Frame name="$parentBioHeader" inherits="CMJ_CategoryHeaderPlain" hidden="true">
        <Anchors><Anchor point="TOPLEFT" relativeTo="$parentLanguagesEdit" relativePoint="BOTTOMLEFT" x="0" y="-16"/><Anchor point="RIGHT" x="-16"/></Anchors>
        <Layers><Layer level="OVERLAY"><FontString parentKey="text" inherits="GameFontNormalLarge" text="Biography"/></Layer></Layers>
      </Frame>
      <Frame name="$parentBioBox">
        <Anchors>
          <Anchor point="TOPLEFT" relativeTo="$parentBioHeader" relativePoint="BOTTOMLEFT" x="16" y="-8"/>
          <Anchor point="BOTTOMRIGHT" x="-24" y="56"/>
        </Anchors>
      </Frame>
      <EditBox name="$parentBioEdit" multiLine="true" autoFocus="false" inherits="CMJ_EditBoxTemplate">
        <Size y="300"/>
        <Anchors>
          <Anchor point="TOPLEFT" relativeTo="$parentBioBox" relativePoint="TOPLEFT" x="0" y="0"/>
          <Anchor point="RIGHT" x="-16"/>
        </Anchors>
        <Scripts>
          <OnTextChanged> if CharacterMemory_OptionsOnBioChanged then CharacterMemory_OptionsOnBioChanged(self) end </OnTextChanged>
        </Scripts>
      </EditBox>
      <!-- Char count (reuse OptionsPanel counter name for shared Lua updater) -->
      <Frame name="CM_OptionsPanelBioCount">
        <Size y="16"/>
        <Anchors><Anchor point="TOPRIGHT" relativeTo="$parentBioBox" relativePoint="TOPRIGHT" x="-8" y="-2"/></Anchors>
        <Layers><Layer level="OVERLAY"><FontString parentKey="fs" inherits="GameFontDisableSmall" justifyH="RIGHT"/></Layer></Layers>
      </Frame>
      <Button name="$parentSave" inherits="UIPanelButtonTemplate" text="Save">
        <Size x="120" y="24"/>
        <Anchors><Anchor point="TOPLEFT" relativeTo="$parentBioBox" relativePoint="BOTTOMLEFT" x="0" y="8"/></Anchors>
        <Scripts>
          <OnClick> if CharacterMemory_OptionsSave then CharacterMemory_OptionsSave() end </OnClick>
        </Scripts>
      </Button>
    </Frames>
    <Scripts>
      <OnShow> if CharacterMemory_OptionsOnShow then CharacterMemory_OptionsOnShow() end </OnShow>
    </Scripts>
  </Frame>

</Ui>


