/*
 * CricketWindies User Control Panel structure
 *
 * This file is intentionally scoped to the shared User CP shell. It is not a
 * second global stylesheet and does not target the masthead, navigation,
 * footer, PM pages, reply pages, or unrelated MyBB tables.
 *
 * Add the two hooks in the shared usercp layout template:
 *   <body class="cw-usercp-page">
 *   <div class="cw-usercp-shell">
 *     <aside class="cw-usercp-nav">{$usercpnav}</aside>
 *     <main class="cw-usercp-main">{$usercp_content}</main>
 *   </div>
 *
 * Keep MyBB's existing .usercp_nav, .usercp_nav_item, and
 * .usercp_container classes inside those regions.
 */

body.cw-usercp-page .cw-usercp-shell {
  --usercp-maroon: var(--maroon, #54102b);
  --usercp-maroon-dark: var(--maroon-dark, #390a1d);
  --usercp-gold: var(--gold, #edc268);
  --usercp-ivory: var(--ivory, #fff9f0);
  --usercp-surface: var(--surface, #ffffff);
  --usercp-surface-alt: var(--surface-alt, #f7f5f2);
  --usercp-surface-hover: var(--surface-hover, #f4f1ed);
  --usercp-ink: var(--ink, #152033);
  --usercp-muted: var(--muted, #5f6877);
  --usercp-border: var(--border, #e4ddd7);
  --usercp-border-strong: var(--border-strong, #d5cdc7);
  --usercp-link: var(--blue-link, #07588c);
}

/* One reusable desktop structure for every User CP action route. 168px
   rail + 14px gap matches .pm-layout in theme.css exactly (not an
   independent choice) -- User CP and Private Messages are meant to read
   as the same inner-page pattern, not two similar-but-different ones. */
body.cw-usercp-page .cw-usercp-shell {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-width: 0;
  align-items: start;
  color: var(--usercp-ink);
}

body.cw-usercp-page .cw-usercp-nav,
body.cw-usercp-page .cw-usercp-main {
  min-width: 0;
}

body.cw-usercp-page .cw-usercp-nav {
  position: sticky;
  top: 16px;
  overflow: hidden;
  border: 1px solid var(--usercp-border);
  border-radius: 4px;
  background: var(--usercp-surface);
}

/* Matches .pm-folder-nav / .pm-folder-nav__heading exactly: ONE outer
   bordered box (the .cw-usercp-nav aside above) wrapping both the
   heading and the {$usercpnav} list -- the heading itself carries no
   border/radius of its own, it just sits inside that box with a bottom
   rule, same as PM's own folder-nav heading. */
body.cw-usercp-page .cw-usercp-nav__heading {
  padding: 12px 13px 9px;
  color: var(--usercp-muted);
  background: var(--usercp-surface-alt);
  border-bottom: 1px solid var(--usercp-border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .45px;
  line-height: 1.2;
  text-transform: uppercase;
}

/* Flat, hand-built nav for routes rebuilt off stock templates entirely
   (see windies_usercp_nav() in windies_usercp.php) -- matches
   .pm-folder-link / .pm-folder-link.is-active exactly, same component as
   PM's own folder rail, not a similar-but-different one. Not-yet-rebuilt
   routes still render {$usercpnav} (the stock table) via the
   .usercp_nav/.usercp_nav_item rules below, kept as-is until each of
   those gets the same treatment. */
body.cw-usercp-page .ucp-nav-link {
  display: block;
  min-height: 39px;
  padding: 10px 13px;
  color: var(--usercp-ink);
  border-bottom: 1px solid var(--usercp-border);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}

body.cw-usercp-page .ucp-nav-link:last-child {
  border-bottom: 0;
}

body.cw-usercp-page .ucp-nav-link:hover,
body.cw-usercp-page .ucp-nav-link:focus-visible {
  background: var(--usercp-surface-hover);
  text-decoration: none;
}

body.cw-usercp-page .ucp-nav-link.is-active {
  color: var(--usercp-maroon);
  background: rgba(84, 16, 43, .07);
  box-shadow: inset 3px 0 0 var(--usercp-maroon);
  font-weight: 700;
}

[data-theme="dark"] body.cw-usercp-page .ucp-nav-link.is-active {
  color: var(--usercp-gold);
  background: rgba(237, 194, 104, .12);
  box-shadow: inset 3px 0 0 var(--usercp-gold);
}

body.cw-usercp-page .ucp-nav__heading {
  padding: 12px 13px 6px;
  color: var(--usercp-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}

/* Collapses the whole ~20-link nav behind one button on mobile, showing
   the current page's own name so it still reads as "you are here" even
   collapsed. Hidden entirely on desktop, where the full list already
   shows -- this button only exists to save vertical space once the rail
   stacks above the actual page content instead of sitting beside it. */
body.cw-usercp-page .ucp-nav-toggle {
  display: none;
}

@media (max-width: 760px) {
  body.cw-usercp-page .ucp-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 13px;
    border: 0;
    background: var(--usercp-surface);
    color: var(--usercp-ink);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
  }

  body.cw-usercp-page .ucp-nav-toggle .icon {
    width: 16px;
    height: 16px;
    color: var(--usercp-muted);
    transition: transform .15s ease;
  }

  body.cw-usercp-page .ucp-nav-toggle[aria-expanded="true"] .icon {
    transform: rotate(180deg);
  }

  /* Collapsed by default on mobile, shown once the toggle above adds
     .is-open -- a plain class, not the [hidden] attribute, since an
     author `display` rule always beats the UA's own [hidden] default
     regardless of media query (see the maroon-dark-mode-contrast memory's
     own cascade-origin note) -- easy to get backwards here otherwise. */
  body.cw-usercp-page .ucp-nav-list {
    display: none;
  }

  body.cw-usercp-page .ucp-nav-list.is-open {
    display: block;
  }
}

@media (max-width: 760px) {
  body.cw-usercp-page .ucp-nav-link.is-active {
    box-shadow: inset 0 -3px 0 var(--usercp-maroon);
  }

  [data-theme="dark"] body.cw-usercp-page .ucp-nav-link.is-active {
    box-shadow: inset 0 -3px 0 var(--usercp-gold);
  }
}

body.cw-usercp-page .usercp_nav {
  /* Border/radius/background now live on .cw-usercp-nav (the outer box
     wrapping this list AND the heading above it) -- this element just
     fills that box. */
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* MyBB's stock usercp.css (still loaded, per this file's own doc comment)
   gives each item's icon via a `background-position` px offset into
   usercp_sprite.png applied directly to the `<a class="usercp_nav_item">`
   itself, anchored to that element's own padding-box top-left. That only
   lines up with the text when the element's total height is left at
   stock's original ~20px single-line row — any taller box (which this file
   needs, for a comfortable tap target and the card-style row spacing) and
   the icon stays pinned near the top while the text sits lower, so the
   icon renders above/detached from the label instead of beside it. A
   same-height fix here (matching line-height/padding to the icon's own
   20px slice) held up in this project's own test browser but NOT in real
   Chrome/Safari at normal desktop zoom (confirmed live, screenshots from
   both) — some combination of font metrics/DPI rounding this project
   can't fully control for produces a few extra px of drift there, enough
   to visibly separate icon from text.
   Robust fix: stop anchoring the icon to the link's own (variable-height)
   box at all. Move the sprite onto a fixed 20x20px ::before pseudo-element
   instead, laid out via flexbox — a fixed-size box can't drift regardless
   of the row's total height, font, browser, or zoom. This needs each of
   the ~20 `.usercp_nav_<action>` sprite-position rules mirrored onto the
   ::before below (kept in the same numeric order MyBB's own usercp.css
   uses, so a future MyBB update to that file's offsets is easy to diff
   against and re-apply here) — the image and its per-action offsets are
   MyBB's own, unchanged; only which element they paint onto has moved. */
body.cw-usercp-page .usercp_nav_item {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  padding: 6px 12px !important;
  background-image: none !important;
  border-bottom: 1px solid var(--usercp-border);
  background-color: var(--usercp-surface);
  color: var(--usercp-link);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}

body.cw-usercp-page .usercp_nav_item::before {
  /* usercp_sprite.png is 35x420px (21 icons stacked at 20px row height) —
     NOT 20x20 as first assumed here. A 20px-wide box hard-cropped 15px off
     every icon's right edge, which is what read as "another sprite
     peeking through" (found by checking the actual file's pixel
     dimensions rather than guessing again — 420/20 = 21, matching the 21
     .usercp_nav_<action> classes below, so this is the real, full glyph
     width, not a rounding/DPI artifact). */
  content: "";
  flex: 0 0 35px;
  width: 35px;
  height: 20px;
  overflow: hidden;
  background-image: url(../usercp_sprite.png);
  background-repeat: no-repeat;
}

body.cw-usercp-page .usercp_nav_composepm::before { background-position: 0 0; }
body.cw-usercp-page .usercp_nav_pmfolder::before { background-position: 0 -20px; }
body.cw-usercp-page .usercp_nav_sub_pmfolder::before { background-position: 0 -40px; }
body.cw-usercp-page .usercp_nav_trash_pmfolder::before { background-position: 0 -60px; }
body.cw-usercp-page .usercp_nav_pmtracking::before { background-position: 0 -80px; }
body.cw-usercp-page .usercp_nav_pmfolders::before { background-position: 0 -100px; }
body.cw-usercp-page .usercp_nav_profile::before { background-position: 0 -120px; }
body.cw-usercp-page .usercp_nav_email::before { background-position: 0 -140px; }
body.cw-usercp-page .usercp_nav_password::before { background-position: 0 -160px; }
body.cw-usercp-page .usercp_nav_username::before { background-position: 0 -180px; }
body.cw-usercp-page .usercp_nav_editsig::before { background-position: 0 -200px; }
body.cw-usercp-page .usercp_nav_avatar::before { background-position: 0 -220px; }
body.cw-usercp-page .usercp_nav_options::before { background-position: 0 -240px; }
body.cw-usercp-page .usercp_nav_usergroups::before { background-position: 0 -260px; }
body.cw-usercp-page .usercp_nav_editlists::before { background-position: 0 -280px; }
body.cw-usercp-page .usercp_nav_attachments::before { background-position: 0 -300px; }
body.cw-usercp-page .usercp_nav_drafts::before { background-position: 0 -320px; }
body.cw-usercp-page .usercp_nav_subscriptions::before { background-position: 0 -340px; }
body.cw-usercp-page .usercp_nav_fsubscriptions::before { background-position: 0 -360px; }
body.cw-usercp-page .usercp_nav_viewprofile::before { background-position: 0 -380px; }
body.cw-usercp-page .usercp_nav_home::before { background-position: 0 -400px; }

/* The old layout used a wider padding-left as an icon gutter for these
   "child" items (email/password/username/editsig/avatar and the PM
   sub/trash folder rows) — with the icon now a flex sibling instead of a
   padding-box background, that gutter has no purpose; the !important
   above already normalizes all items to the same padding. Visual grouping
   for these comes from the surrounding template markup, not this file. */

body.cw-usercp-page .usercp_nav_item:last-child {
  border-bottom: 0;
}

body.cw-usercp-page .usercp_nav_item:hover,
body.cw-usercp-page .usercp_nav_item:focus-visible {
  background-color: var(--usercp-surface-hover);
  color: var(--usercp-maroon);
  text-decoration: none;
}

/* --maroon as a hover TEXT color has no dark-mode counterpart here (found
   auditing this file for the active-state change below) -- near-invisible
   against this theme's own dark --usercp-surface-hover otherwise. Same
   fix as everywhere else this pattern shows up sitewide. */
[data-theme="dark"] body.cw-usercp-page .usercp_nav_item:hover,
[data-theme="dark"] body.cw-usercp-page .usercp_nav_item:focus-visible {
  color: var(--usercp-gold);
}

/* Matches .pm-folder-link.is-active exactly, maroon-tinted wash + inset
   left bar rather than the plain gold-left-border+flat-surface-alt this
   read as before -- User CP's active route should look like the same
   component as PM's active folder, not a similar-but-different one. */
body.cw-usercp-page .usercp_nav_item.active,
body.cw-usercp-page .usercp_nav_item.selected,
body.cw-usercp-page .usercp_nav_item[aria-current="page"] {
  border-left: 0;
  background-color: rgba(84, 16, 43, .07);
  box-shadow: inset 3px 0 0 var(--usercp-maroon);
  color: var(--usercp-maroon);
  font-weight: 700;
}

[data-theme="dark"] body.cw-usercp-page .usercp_nav_item.active,
[data-theme="dark"] body.cw-usercp-page .usercp_nav_item.selected,
[data-theme="dark"] body.cw-usercp-page .usercp_nav_item[aria-current="page"] {
  background-color: rgba(237, 194, 104, .12);
  box-shadow: inset 3px 0 0 var(--usercp-gold);
  color: var(--usercp-gold);
}

body.cw-usercp-page .usercp_nav_item + .usercp_nav_item {
  margin-top: 0;
}

body.cw-usercp-page .usercp_container {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--usercp-ink);
}

body.cw-usercp-page .cw-usercp-main > h1,
body.cw-usercp-page .cw-usercp-main > h2,
body.cw-usercp-page .usercp_container > h1,
body.cw-usercp-page .usercp_container > h2 {
  margin: 0 0 14px;
  color: var(--usercp-ink);
  font-size: 26px;
  line-height: 1.2;
}

/* Bordered warm-paper panel for route content -- used to wrap a route's
   stock table/fieldset markup (e.g. usercp_profile's own {$requiredfields}/
   {$customfields}, which MyBB core generates as raw <tr> HTML no template
   here can restructure) rather than replacing it, matching the
   handoff's own "keep the generated markup" rule extended to field HTML,
   not just nav links. */
body.cw-usercp-page .cw-usercp-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--usercp-border);
  border-radius: 4px;
  background: var(--usercp-surface);
}

body.cw-usercp-page .cw-usercp-panel + .cw-usercp-panel {
  margin-top: 14px;
}

body.cw-usercp-page .cw-usercp-panel__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--usercp-border);
  background: var(--usercp-surface-alt);
}

body.cw-usercp-page .cw-usercp-panel__heading h2 {
  margin: 0;
  color: var(--usercp-ink);
  font-size: 16px;
  line-height: 1.2;
}

body.cw-usercp-page .cw-usercp-panel__heading p {
  margin: 0;
  color: var(--usercp-muted);
  font-size: 11px;
}

body.cw-usercp-page .cw-usercp-form {
  padding: 15px 16px 16px;
}

/* Edit Options keeps its own stock table entirely as generated (not
   field-by-field rebuilt like the other routes) -- but that table still
   carries MyBB's own "Edit Options" thead bar, which now duplicates the
   real <h1> heading this route also has. Hide just that leftover bar
   rather than touch the table markup itself. */
body.cw-usercp-page .cw-usercp-form > table.tborder > tbody > tr:first-child > td.thead,
body.cw-usercp-page .cw-usercp-form > table.tborder > tr:first-child > td.thead {
  display: none;
}

body.cw-usercp-page .cw-usercp-form__intro {
  margin: 0 0 16px;
  color: var(--usercp-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Wrapping flex row, not a fixed-column grid -- a strict N-col grid forces
   every row to share the same track widths even when a given row's fields
   don't call for it (a full-width Bio next to a narrow Gender select). Each
   field instead sets its own flex-basis/order inline (see
   usercp_profile_customfield and the hand-placed fields in usercp_profile
   itself) so unrelated fields can share a row where it makes sense (Home
   Island / Location / Gender three across) and stand alone where it
   doesn't (Bio, Website), while still wrapping cleanly at any width. */
body.cw-usercp-page .cw-usercp-field-grid {
  display: flex;
  flex-flow: row wrap;
  gap: 16px;
}

body.cw-usercp-page .cw-usercp-field {
  min-width: 0;
}

/* Smilies box beside the editor rather than stacked above it. The
   smilies column sizes to its own content (that box is a fixed 170px
   regardless -- see the inline-style override below) rather than a
   hardcoded percentage, so it never carries dead space of its own; the
   editor column takes whatever's left in the row. */
body.cw-usercp-page .cw-usercp-editor-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

body.cw-usercp-page .cw-usercp-editor-row__smilies {
  flex: 0 0 auto;
  /* 225px, not 170px -- the smilie box's own inline-styled wrapper
     declares width:170px, but the table nested inside it renders wider
     than that (its own cellpadding pushes past what the outer div
     states, and divs don't clip overflowing content by default), so
     170px still let it overflow/overlap the editor column beside it.
     flex-shrink is already 0 above, but min-width:0 still let the FLEX
     ITEM's own box shrink narrower than its content whenever the row was
     tight on space -- min-width here is what actually holds the line. */
  min-width: 225px;
}

body.cw-usercp-page .cw-usercp-editor-row__editor {
  flex: 1 1 0;
  min-width: 0;
}

/* build_clickable_smilies() (core) wraps its own output in a bare
   <div style="margin:auto; width: 170px; margin-top: 20px;"> -- no class
   or id, just an inline style. margin-top assumed the box was sitting
   below other page content, not beside a column that already starts at
   the same top; margin:auto (left/right) centers the 170px box within
   this column instead of sitting flush left like the rest of the form's
   fields. :first-child targets that bare div specifically without
   touching anything else that might land in this column later;
   !important is the only way to beat an inline style at all, not a
   specificity choice. Width is left at its own 170px -- that's sized for
   its own emoji grid internally, not something to stretch. */
body.cw-usercp-page .cw-usercp-editor-row__smilies > div:first-child {
  margin: 0 !important;
}

@media (max-width: 760px) {
  body.cw-usercp-page .cw-usercp-editor-row {
    flex-direction: column;
  }

  body.cw-usercp-page .cw-usercp-editor-row__smilies {
    flex-basis: auto;
    width: 100%;
  }
}

/* A field that's alone in its own row (no sibling to naturally split the
   row width with) shouldn't stretch its input to the full row just
   because nothing else is competing for the space -- found live on
   Change Password's "Current Password" row, and the same call applies
   anywhere else a lone single-line field sits above a paired row (Change
   Email, Change Username). Not for textareas (Bio genuinely benefits from
   the full row) -- opt in per input with this class, not a blanket rule. */
body.cw-usercp-page .cw-usercp-main .cw-usercp-field--solo input.textbox {
  /* .cw-usercp-main and .textbox both added to the selector specifically
     to outweigh the shared input.textbox rule's own max-width:100% --
     without them this rule was genuinely LESS specific than that one
     (found live: max-width:100% kept winning regardless of this rule's
     position in the file). */
  max-width: calc(50% - 8px);
}

@media (max-width: 760px) {
  body.cw-usercp-page .cw-usercp-main .cw-usercp-field--solo input.textbox {
    max-width: 100%;
  }
}

body.cw-usercp-page .cw-usercp-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

body.cw-usercp-page .cw-usercp-field small {
  display: block;
  margin-top: 5px;
  color: var(--usercp-muted);
  font-size: 11px;
  line-height: 1.35;
}

body.cw-usercp-page .cw-usercp-field small:empty {
  display: none;
}

body.cw-usercp-page .cw-usercp-field p {
  margin: 0;
  color: var(--usercp-ink);
  font-weight: 700;
}

/* Day/month/year (or similar) triplets -- birthday, away return date --
   share this one row layout rather than each growing its own markup. */
body.cw-usercp-page .cw-usercp-date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.cw-usercp-page .cw-usercp-date-row select,
body.cw-usercp-page .cw-usercp-date-row input {
  flex: 1 1 100px;
  min-width: 0;
}

/* Radio/checkbox options sitting inside a .cw-usercp-field (away status,
   revert-title) -- overrides the plain field <label> above, which is
   meant for the field's own heading label, not an inline option. */
body.cw-usercp-page .cw-usercp-field label.cw-usercp-radio,
body.cw-usercp-page label.cw-usercp-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 0 0;
  color: var(--usercp-ink);
  font-size: 13px;
  font-weight: 400;
}

body.cw-usercp-page label.cw-usercp-checkbox {
  margin: 10px 0 0;
}

body.cw-usercp-page .cw-usercp-form__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  /* var(--usercp-border), not the handoff's own hardcoded #eeeae5 -- that
     literal had no dark-mode counterpart at all (same gap already fixed
     on .notice/.error above). */
  border-top: 1px solid var(--usercp-border);
}

body.cw-usercp-page .cw-usercp-main > h3,
body.cw-usercp-page .usercp_container > h3,
body.cw-usercp-page .cw-usercp-form h3 {
  margin: 28px 0 8px;
  color: var(--usercp-ink);
  font-size: 18px;
  line-height: 1.25;
}

/* Rebuilt routes (usercp_profile etc.) nest their h3s inside
   .cw-usercp-form, not directly under .cw-usercp-main -- the > selector
   above never matched them, so this section break was relying on
   whatever margin the browser's own default h3 style happened to carry,
   not this file's intended spacing (found live: "Away Information"
   looked cramped right under the field grid above it).

   :first-of-type, not :first-child -- the intro paragraph and the
   required-fields grid both sit before "Optional Fields" in the DOM, so
   it's never actually .cw-usercp-form's first child even though it's the
   first heading. :first-child silently matched nothing here (found live:
   the top margin meant for later headings was landing on this one too,
   since the reset below never applied). */
body.cw-usercp-page .cw-usercp-form h3:first-of-type {
  margin-top: 0;
}

/* Route content stays within panels without changing outside tables. */
body.cw-usercp-page .cw-usercp-main table.tborder,
body.cw-usercp-page .usercp_container table.tborder {
  width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  border-collapse: collapse;
  background: var(--usercp-surface);
  box-shadow: 0 1px 2px rgba(21, 32, 51, 0.05);
}

body.cw-usercp-page .cw-usercp-main table.tborder .thead,
body.cw-usercp-page .usercp_container table.tborder .thead {
  background: var(--usercp-maroon);
  color: var(--usercp-ivory);
  font-weight: 700;
}

body.cw-usercp-page .cw-usercp-main table.tborder .thead a:link,
body.cw-usercp-page .cw-usercp-main table.tborder .thead a:visited,
body.cw-usercp-page .usercp_container table.tborder .thead a:link,
body.cw-usercp-page .usercp_container table.tborder .thead a:visited {
  color: var(--usercp-ivory);
}

body.cw-usercp-page .cw-usercp-main table.tborder .tcat,
body.cw-usercp-page .usercp_container table.tborder .tcat {
  background: var(--usercp-surface-alt);
  color: var(--usercp-ink);
  font-weight: 700;
}

body.cw-usercp-page .cw-usercp-main table.tborder .trow1,
body.cw-usercp-page .cw-usercp-main table.tborder .trow2,
body.cw-usercp-page .usercp_container table.tborder .trow1,
body.cw-usercp-page .usercp_container table.tborder .trow2 {
  background: var(--usercp-surface);
  color: var(--usercp-ink);
}

body.cw-usercp-page .cw-usercp-main table.tborder .trow2,
body.cw-usercp-page .usercp_container table.tborder .trow2 {
  background: var(--usercp-surface-alt);
}

body.cw-usercp-page .cw-usercp-main table.tborder td,
body.cw-usercp-page .cw-usercp-main table.tborder th,
body.cw-usercp-page .usercp_container table.tborder td,
body.cw-usercp-page .usercp_container table.tborder th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--usercp-border);
  vertical-align: middle;
}

body.cw-usercp-page .cw-usercp-main table.tborder tr:last-child > td,
body.cw-usercp-page .cw-usercp-main table.tborder tr:last-child > th,
body.cw-usercp-page .usercp_container table.tborder tr:last-child > td,
body.cw-usercp-page .usercp_container table.tborder tr:last-child > th {
  border-bottom: 0;
}

/* Consistent field rows for profile, email, password, options, and lists. */
body.cw-usercp-page .cw-usercp-main label,
body.cw-usercp-page .usercp_container label {
  color: var(--usercp-ink);
  font-weight: 700;
}

body.cw-usercp-page .cw-usercp-main input.textbox,
body.cw-usercp-page .cw-usercp-main input[type="text"],
body.cw-usercp-page .cw-usercp-main input[type="email"],
body.cw-usercp-page .cw-usercp-main input[type="password"],
body.cw-usercp-page .cw-usercp-main input[type="url"],
body.cw-usercp-page .cw-usercp-main select,
body.cw-usercp-page .cw-usercp-main textarea,
body.cw-usercp-page .usercp_container input.textbox,
body.cw-usercp-page .usercp_container input[type="text"],
body.cw-usercp-page .usercp_container input[type="email"],
body.cw-usercp-page .usercp_container input[type="password"],
body.cw-usercp-page .usercp_container input[type="url"],
body.cw-usercp-page .usercp_container select,
body.cw-usercp-page .usercp_container textarea {
  /* width, not just max-width -- an <input size="4">/<select> otherwise
     renders at its intrinsic browser char-width regardless of the
     .cw-usercp-field column it's sitting in (found live on the birthday
     row's day/month/year fields, each a narrow flex column meant to be
     filled edge-to-edge by its one control). */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--usercp-border-strong);
  border-radius: 4px;
  background: var(--usercp-surface);
  color: var(--usercp-ink);
  font: inherit;
}

body.cw-usercp-page .cw-usercp-main input.textbox,
body.cw-usercp-page .cw-usercp-main input[type="text"],
body.cw-usercp-page .cw-usercp-main input[type="email"],
body.cw-usercp-page .cw-usercp-main input[type="password"],
body.cw-usercp-page .cw-usercp-main input[type="url"],
body.cw-usercp-page .cw-usercp-main select,
body.cw-usercp-page .usercp_container input.textbox,
body.cw-usercp-page .usercp_container input[type="text"],
body.cw-usercp-page .usercp_container input[type="email"],
body.cw-usercp-page .usercp_container input[type="password"],
body.cw-usercp-page .usercp_container input[type="url"],
body.cw-usercp-page .usercp_container select {
  min-height: 38px;
  padding: 8px 10px;
}

body.cw-usercp-page .cw-usercp-main textarea,
body.cw-usercp-page .usercp_container textarea {
  min-height: 110px;
  padding: 10px;
  line-height: 1.45;
  resize: vertical;
}

/* Buttons remain scoped to User CP route content. */
body.cw-usercp-page .cw-usercp-main input.button,
body.cw-usercp-page .cw-usercp-main button.button,
body.cw-usercp-page .cw-usercp-main a.button,
body.cw-usercp-page .cw-usercp-main .button,
body.cw-usercp-page .usercp_container input.button,
body.cw-usercp-page .usercp_container button.button,
body.cw-usercp-page .usercp_container a.button,
body.cw-usercp-page .usercp_container .button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px 15px;
  border: 1px solid var(--usercp-maroon);
  border-radius: 4px;
  background: var(--usercp-maroon);
  color: var(--usercp-ivory) !important;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none !important;
}

body.cw-usercp-page .cw-usercp-main input.button:hover,
body.cw-usercp-page .cw-usercp-main button.button:hover,
body.cw-usercp-page .cw-usercp-main a.button:hover,
body.cw-usercp-page .cw-usercp-main .button:hover,
body.cw-usercp-page .usercp_container input.button:hover,
body.cw-usercp-page .usercp_container button.button:hover,
body.cw-usercp-page .usercp_container a.button:hover,
body.cw-usercp-page .usercp_container .button:hover {
  border-color: var(--usercp-maroon-dark);
  background: var(--usercp-maroon-dark);
}

body.cw-usercp-page .cw-usercp-main input.button[type="button"],
body.cw-usercp-page .cw-usercp-main input.button[name="preview"],
body.cw-usercp-page .cw-usercp-main input.button[name="cancel"],
body.cw-usercp-page .usercp_container input.button[type="button"],
body.cw-usercp-page .usercp_container input.button[name="preview"],
body.cw-usercp-page .usercp_container input.button[name="cancel"] {
  border-color: var(--usercp-border-strong);
  background: var(--usercp-surface);
  color: var(--usercp-ink) !important;
}

/* Notices, PM-space meter, and small route utilities. */
body.cw-usercp-page .cw-usercp-main .notice,
body.cw-usercp-page .cw-usercp-main .error,
body.cw-usercp-page .cw-usercp-main .red_alert,
body.cw-usercp-page .usercp_container .notice,
body.cw-usercp-page .usercp_container .error,
body.cw-usercp-page .usercp_container .red_alert {
  margin: 12px 0;
  padding: 11px 13px;
  border: 1px solid var(--usercp-border);
  border-left: 4px solid var(--usercp-gold);
  border-radius: 4px;
  background: #fffaf0;
  color: var(--usercp-ink);
}

body.cw-usercp-page .cw-usercp-main .error,
body.cw-usercp-page .cw-usercp-main .red_alert,
body.cw-usercp-page .usercp_container .error,
body.cw-usercp-page .usercp_container .red_alert {
  border-left-color: #8b2731;
  background: #fff4f4;
}

/* Added on integration, not part of the original handoff file: .notice's
   background is a hardcoded light cream (#fffaf0) and .error/.red_alert a
   hardcoded light red (#fff4f4), neither with a dark-mode counterpart —
   the same gap already found and fixed on the PM banner, profile
   empty-state, and the reply/newthread preview and validation notices.
   Also covers .error/.red_alert list items, which otherwise inherit the
   near-white dark-mode body text color against these light backgrounds. */
[data-theme="dark"] body.cw-usercp-page .cw-usercp-main .notice,
[data-theme="dark"] body.cw-usercp-page .usercp_container .notice {
  background: rgba(237, 194, 104, .12);
  border-color: rgba(237, 194, 104, .35);
}

[data-theme="dark"] body.cw-usercp-page .cw-usercp-main .error,
[data-theme="dark"] body.cw-usercp-page .cw-usercp-main .red_alert,
[data-theme="dark"] body.cw-usercp-page .usercp_container .error,
[data-theme="dark"] body.cw-usercp-page .usercp_container .red_alert {
  background: rgba(139, 39, 49, .18);
  border-color: rgba(139, 39, 49, .4);
}

body.cw-usercp-page .cw-usercp-main .error li,
body.cw-usercp-page .cw-usercp-main .red_alert li,
body.cw-usercp-page .cw-usercp-main .notice li,
body.cw-usercp-page .usercp_container .error li,
body.cw-usercp-page .usercp_container .red_alert li,
body.cw-usercp-page .usercp_container .notice li {
  color: var(--usercp-ink);
}

body.cw-usercp-page .pmspace {
  float: none;
  margin: 0 0 12px;
}

body.cw-usercp-page .pmspace_container {
  width: min(100%, 260px);
  min-height: 16px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--usercp-border-strong);
  border-radius: 3px;
  background: var(--usercp-surface);
}

body.cw-usercp-page .pmspace_used {
  min-height: 16px;
  box-sizing: border-box;
  margin: 0;
  padding: 1px 5px;
  border: 0 !important;
  background: var(--usercp-maroon);
  color: var(--usercp-ivory);
  font-size: 11px;
  line-height: 14px;
}

body.cw-usercp-page .pmspace_used.medium {
  background: #b7791f;
}

body.cw-usercp-page .pmspace_used.high {
  background: #8b2731;
}

body.cw-usercp-page .new_pm {
  color: var(--usercp-maroon);
}

/* Found auditing this file for the nav active-state fix above -- same
   gap, never had a dark counterpart. */
[data-theme="dark"] body.cw-usercp-page .new_pm {
  color: var(--usercp-gold);
}

body.cw-usercp-page .cw-usercp-main a:focus-visible,
body.cw-usercp-page .cw-usercp-main button:focus-visible,
body.cw-usercp-page .cw-usercp-main input:focus-visible,
body.cw-usercp-page .cw-usercp-main select:focus-visible,
body.cw-usercp-page .cw-usercp-main textarea:focus-visible,
body.cw-usercp-page .cw-usercp-nav a:focus-visible {
  outline: 3px solid var(--usercp-gold);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  body.cw-usercp-page .cw-usercp-shell {
    display: block;
  }

  body.cw-usercp-page .cw-usercp-nav {
    position: static;
    margin-bottom: 14px;
  }

  /* Matches .pm-folder-nav__heading's own mobile treatment (hidden once
     the rail collapses to a horizontal strip) -- kept here even though
     .usercp_nav itself stays a vertical list (see below), since "Your
     Profile" reads as redundant page furniture once every other route
     is a one-tap scroll away in the same list. */
  body.cw-usercp-page .cw-usercp-nav__heading {
    display: none;
  }

  /* .usercp_nav was assumed to be a flex-friendly list when a horizontal-
     scroll-strip override (matching PM's own mobile nav) was written
     here once — it's actually a real <table>, and MyBB renders the Menu
     section, the Messenger header, and the Messenger items as THREE
     SEPARATE <tbody> elements inside it. display:flex on a table lays out
     its direct children (those three tbody elements) as flex items side
     by side, which is exactly the bug this caused live: "Menu" and
     "Messenger" rendered as two-plus horizontally squeezed columns
     instead of one stacked nav, with real content spilling off-screen.
     Converting to a real horizontal strip means rebuilding usercp_nav and
     the ~8 usercp_nav_* templates it assembles off table markup entirely
     -- multi-template surgery for a mobile-only nicety, not attempted in
     this pass. The base (desktop) .usercp_nav_item style below is already
     a normal vertical flex row (icon + text) with a bottom border between
     items -- a perfectly good mobile list on its own, kept as-is. */

  /* Bottom bar instead of the left inset bar, matching
     .pm-folder-link.is-active's own mobile treatment exactly -- a
     left-edge bar reads oddly once each row spans the full width. */
  body.cw-usercp-page .usercp_nav_item.active,
  body.cw-usercp-page .usercp_nav_item.selected,
  body.cw-usercp-page .usercp_nav_item[aria-current="page"] {
    box-shadow: inset 0 -3px 0 var(--usercp-maroon);
  }

  [data-theme="dark"] body.cw-usercp-page .usercp_nav_item.active,
  [data-theme="dark"] body.cw-usercp-page .usercp_nav_item.selected,
  [data-theme="dark"] body.cw-usercp-page .usercp_nav_item[aria-current="page"] {
    box-shadow: inset 0 -3px 0 var(--usercp-gold);
  }

  body.cw-usercp-page .cw-usercp-main table.tborder,
  body.cw-usercp-page .usercp_container table.tborder {
    display: block;
    overflow-x: auto;
  }

  body.cw-usercp-page .cw-usercp-main table.tborder > tbody,
  body.cw-usercp-page .usercp_container table.tborder > tbody {
    min-width: 560px;
  }

  /* The Signature page's Smilies box is ALSO a .tborder table (MyBB's own
     classic box-header/body/footer convention, same as any data table) --
     the horizontal-scroll rule above meant for genuinely wide data tables
     was forcing this small widget's tbody out to 560px too, spacing its
     smilie columns out far enough that the last column of each row sat
     scrolled off-screen with no visible scrollbar affordance to reveal it
     (found live: "a column of smilies is missing" on mobile). Reset both
     properties back to normal for this specific table. */
  body.cw-usercp-page .cw-usercp-editor-row__smilies table.tborder {
    display: table;
    overflow-x: visible;
  }

  body.cw-usercp-page .cw-usercp-editor-row__smilies table.tborder > tbody {
    min-width: 0;
  }

  body.cw-usercp-page .cw-usercp-panel__heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  body.cw-usercp-page .cw-usercp-field-grid {
    display: block;
  }

  body.cw-usercp-page .cw-usercp-field + .cw-usercp-field {
    margin-top: 13px;
  }
}

@media (max-width: 450px) {
  body.cw-usercp-page .cw-usercp-main input.textbox,
  body.cw-usercp-page .cw-usercp-main input[type="text"],
  body.cw-usercp-page .cw-usercp-main input[type="email"],
  body.cw-usercp-page .cw-usercp-main input[type="password"],
  body.cw-usercp-page .cw-usercp-main input[type="url"],
  body.cw-usercp-page .cw-usercp-main select,
  body.cw-usercp-page .cw-usercp-main textarea,
  body.cw-usercp-page .usercp_container input.textbox,
  body.cw-usercp-page .usercp_container input[type="text"],
  body.cw-usercp-page .usercp_container input[type="email"],
  body.cw-usercp-page .usercp_container input[type="password"],
  body.cw-usercp-page .usercp_container input[type="url"],
  body.cw-usercp-page .usercp_container select,
  body.cw-usercp-page .usercp_container textarea {
    width: 100%;
  }

  body.cw-usercp-page .cw-usercp-main input.button,
  body.cw-usercp-page .cw-usercp-main button.button,
  body.cw-usercp-page .cw-usercp-main a.button,
  body.cw-usercp-page .cw-usercp-main .button,
  body.cw-usercp-page .usercp_container input.button,
  body.cw-usercp-page .usercp_container button.button,
  body.cw-usercp-page .usercp_container a.button,
  body.cw-usercp-page .usercp_container .button {
    width: 100%;
  }

  body.cw-usercp-page .cw-usercp-form {
    padding: 13px 12px 12px;
  }

  body.cw-usercp-page .cw-usercp-form__footer {
    display: block;
    margin-top: 13px;
    padding-top: 11px;
  }
}

/*
 * Change Avatar / crop modal
 *
 * The crop modal itself (.modal/.modal__*) is styled generically in
 * modal.css -- everything here is either avatar-specific content inside
 * that shell (.cw-avatar-crop-*) or belongs to the usercp_avatar template
 * outside the modal (.cw-avatar-preview, .cw-usercp-avatar-preview).
 */

body.cw-usercp-page .cw-usercp-avatar-preview {
  display: block;
  max-width: 100px;
  max-height: 100px;
  border-radius: 8px;
  border: 1px solid var(--usercp-border, var(--border, #e4ddd7));
}

/* Cropper.js needs a fixed-height box to size itself against -- it reads
   the container's own dimensions on init, so an auto-height stage would
   collapse to 0 before the image loads. */
body.cw-usercp-page .cw-avatar-crop-stage {
  width: 100%;
  height: min(60vh, 420px);
  overflow: hidden;
  background: var(--usercp-surface-alt, var(--surface-alt, #f7f5f2));
  border-radius: 6px;
}

body.cw-usercp-page .cw-avatar-crop-stage img {
  /* Cropper.js hides the source img and builds its own canvas/preview
     layers next to it -- this only matters for the split-second before
     Cropper finishes initializing. */
  display: block;
  max-width: 100%;
}

body.cw-usercp-page .cw-avatar-crop-zoom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--usercp-muted, var(--muted, #5f6877));
}

body.cw-usercp-page .cw-avatar-crop-zoom .icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.cw-usercp-page .cw-avatar-crop-zoom input[type="range"] {
  flex: 1 1 auto;
  accent-color: var(--usercp-maroon, var(--maroon, #54102b));
}

.cw-avatar-crop-modal__container {
  max-width: 480px;
}

/* Cropped-result preview shown under the file input once "Use This
   Photo" has run -- hidden by default via the template's own [hidden]
   attribute until avatar-cropper.js clears it. */
body.cw-usercp-page .cw-avatar-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

/* .cw-avatar-preview's own "display: flex" above outranks the browser's
   default [hidden]{display:none} rule (two classes beats one attribute
   selector) -- without this, the template's [hidden] attribute (the
   preview's actual default state before any crop has run) would be
   silently ignored and the empty preview box would show on every page
   load. */
body.cw-usercp-page .cw-avatar-preview[hidden] {
  display: none;
}

body.cw-usercp-page .cw-avatar-preview img {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--usercp-border, var(--border, #e4ddd7));
  object-fit: cover;
}

@media (max-width: 600px) {
  body.cw-usercp-page .cw-avatar-crop-stage {
    height: min(50vh, 320px);
  }
}
