/* The profile editor: a sectioned form beside a live profile card preview, an unsaved-changes bar, and the crop step as an overlay. */

.modal.profile-edit { max-width: 980px; height: min(780px, calc(100vh - 32px)); height: min(780px, calc(100dvh - 32px)); display: flex; flex-direction: column; position: relative; overflow: hidden; }
.profile-edit .pe-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 10px; flex: none; }
.profile-edit .pe-head h2 { font-size: 1.3125rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; flex: 1; }
.pe-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; flex: 1; min-height: 0; }
.pe-form { padding: 6px 26px 90px 22px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; scroll-padding-bottom: 90px; }
.pe-pvbar { display: none; }

/* sections and fields */
.pe-sec { padding: 12px 0 4px; border-top: 1px solid var(--line); }
.pe-sec:first-child { border-top: 0; padding-top: 4px; }
.pe-title { font-size: 0.71875rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.pe-title-row { display: flex; justify-content: space-between; align-items: baseline; }
.pe-title-row .pe-count { text-transform: none; letter-spacing: 0; }
.pe-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.profile-edit .field { margin-bottom: 10px; }
.profile-edit .field > .pe-lbl { display: flex; align-items: baseline; justify-content: space-between; }
.pe-count { font-size: 0.75rem; color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }
.pe-count.warn { color: var(--away); }
.pe-count.max { color: var(--danger); }
.pe-hint { display: block; margin-top: 5px; font-size: 0.78125rem; color: var(--faint); }
.pe-note { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bg); color: var(--muted); font-size: 0.78125rem; }
.pe-note svg { flex: none; }

/* pictures: one control each, with a Change overlay on hover and a pencil badge */
.pe-imgs { display: flex; gap: 22px; align-items: flex-start; }
.pe-imgcol { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.pe-imgcol.grow { flex: 1; }
.pe-remove { font-size: 0.78125rem; font-weight: 600; color: var(--muted); }
.pe-remove:hover { color: var(--danger); }
.pe-slot { position: relative; display: block; background-size: cover; background-position: center; background-repeat: no-repeat; background-clip: padding-box; }
.pe-slot .pe-ov {
  position: absolute; inset: 0; display: grid; place-content: center; background: rgba(6, 10, 22, 0.62); color: #fff;
  font-size: 0.75rem; font-weight: 700; opacity: 0; transition: opacity .15s; border-radius: inherit;
}
.pe-slot:hover .pe-ov, .pe-slot:focus-visible .pe-ov { opacity: 1; }
.pe-editdot {
  position: absolute; right: -5px; bottom: -5px; width: 24px; height: 24px; border-radius: 50%; background: var(--raised-2); color: var(--text);
  display: grid; place-items: center; border: 3px solid var(--panel); box-sizing: content-box;
}
.slot-bn { width: 100%; max-width: 250px; aspect-ratio: 315 / 96; border-radius: 10px; border: 1px solid var(--line-strong); }
.slot-av { display: grid; place-items: center; font-weight: 700; font-size: 1.625rem; color: #0d1326; width: 76px; height: 76px; border-radius: 22px; flex: none; }
.slot-av::before { content: attr(data-init); }

/* colours: three rows under one heading, each with a one-line caption */
.pe-crow { display: grid; grid-template-columns: 170px 1fr; gap: 4px 12px; align-items: center; padding: 7px 0; }
.pe-crow + .pe-crow { border-top: 1px dashed var(--line); }
.pe-ct b { display: block; font-size: 0.84375rem; }
.pe-ct small { display: block; color: var(--faint); font-size: 0.75rem; line-height: 1.3; }
.pe-sw { gap: 6px; }
.profile-edit .pe-sw button { transition: transform .1s; }
.profile-edit .pe-sw button:hover:not([aria-pressed="true"]) { transform: scale(1.08); }
.profile-edit .pe-sw .none { background: var(--raised); color: var(--muted); display: grid; place-items: center; font-size: 0.875rem; border: 2px dashed var(--line-strong); }
.profile-edit .pe-sw .none[aria-pressed="true"] { border: 2.5px solid var(--text); }
@media (hover: hover) and (pointer: fine) {
  .profile-edit .pe-sw button { width: 28px; height: 28px; border-radius: 9px; border-width: 2.5px; }
  .profile-edit .pe-sw .none { border-width: 2px; }
}

/* badges */
.pe-btiles { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-btile { position: relative; width: 50px; height: 50px; border-radius: 13px; background: var(--bg); border: 1.5px solid var(--line-strong); display: grid; place-items: center; transition: border-color .1s, background .1s; }
.pe-btile img { width: 34px; height: 34px; }
.pe-btile:hover { border-color: var(--accent); }
.pe-btile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pe-n {
  position: absolute; top: -6px; right: -6px; width: 19px; height: 19px; border-radius: 50%; background: var(--accent-strong); color: #fff;
  font-size: 0.6875rem; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--panel);
}
.pe-n[hidden] { display: none; }
.pe-bcap { font-size: 0.78125rem; color: var(--muted); min-height: 20px; margin-top: 8px; }
.pe-bcap b { color: var(--text); }

/* the preview: the real profile card and list row, drawn from the draft */
.pe-prev {
  background: var(--bg); border-left: 1px solid var(--line); padding: 8px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  overflow-y: auto; min-height: 0; background-image: radial-gradient(rgba(160, 180, 255, .07) 1px, transparent 1px); background-size: 14px 14px;
}
.pe-cap { align-self: stretch; display: flex; justify-content: space-between; font-size: 0.71875rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 12px; }
.pe-cap span:last-child:not(:first-child) { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--faint); }
.pe-rowbox { align-self: stretch; background: var(--panel); border-radius: var(--r-md); padding: 8px; border: 1px solid var(--line); }
.pe-card { border: 1px solid var(--line-strong); border-radius: var(--r-md); text-align: left; }
.pe-card:not(.has-accent) { background: var(--panel); box-shadow: var(--shadow); }
.pe-card .btn { cursor: default; }

/* the unsaved-changes bar */
.pe-savebar {
  position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 9px 9px 9px 16px;
  border-radius: var(--r-md); background: var(--raised); border: 1px solid var(--line-strong); box-shadow: 0 10px 30px rgba(2, 5, 15, .6);
  transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; transition: transform .22s cubic-bezier(.2, .9, .3, 1.2), opacity .15s;
}
.pe-savebar.show { transform: none; opacity: 1; pointer-events: auto; }
.pe-msg { flex: 1; min-width: 0; font-size: 0.875rem; font-weight: 600; }
.pe-msg.err { color: var(--danger); }

/* the crop step, over the whole editor */
.crop-overlay {
  position: absolute; inset: 0; z-index: 50; background: rgba(4, 7, 18, .78); backdrop-filter: blur(2px); display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  animation: fade .12s;
}
.crop-box { width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); }
.crop-box .cropper { flex-direction: column; align-items: stretch; gap: 14px; padding: 0; margin: 0; border: 0; background: none; }
.crop-box .crop-view { align-self: center; }
.crop-box .crop-view:focus-visible { outline-offset: 4px; }
.crop-box .crop-side { min-width: 0; }

@media (max-width: 900px) {
  .pe-body { grid-template-columns: minmax(0, 1fr) 300px; }
  .pe-crow { grid-template-columns: 130px 1fr; }
}

/* phones: full screen (the height of the padless scrim, which is pinned to the window), with the preview as a slim sticky bar that opens */
@media (max-width: 760px) {
  .scrim.profile-scrim { padding: 0; }
  .modal.profile-edit { max-width: none; height: 100%; max-height: none; border-radius: 0; border: 0; }
  .profile-edit .pe-head { padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(18px, env(safe-area-inset-left)); }
  .profile-edit .pe-head h2 { font-size: 1.125rem; }
  .pe-body { display: block; overflow-y: auto; overscroll-behavior: contain; scroll-padding: 64px 0 calc(90px + env(safe-area-inset-bottom)); }
  .pe-form { overflow: visible; padding: 4px max(16px, env(safe-area-inset-right)) calc(100px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .pe-prev { display: none; }
  .pe-savebar { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); }
  .pe-pvbar { display: block; position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
  .pe-bar { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); text-align: left; }
  .pe-bar .who { flex: 1; min-width: 0; font-weight: 700; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pe-bar .who small { display: block; color: var(--faint); font-weight: 500; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; }
  .pe-bar .tog { display: flex; align-items: center; gap: 4px; color: var(--accent-2); font-size: 0.8125rem; font-weight: 700; }
  .pe-bar .tog svg { transition: rotate .2s; }
  .pe-pvbar.open .tog svg { rotate: 180deg; }
  .pe-drop {
    display: none; flex-direction: column; align-items: center; gap: 10px; padding: 4px 16px 16px; max-height: 60vh; max-height: 60dvh; overflow-y: auto;
    background: var(--bg); background-image: radial-gradient(rgba(160, 180, 255, .07) 1px, transparent 1px); background-size: 14px 14px;
  }
  .pe-pvbar.open .pe-drop { display: flex; }
  .pe-drop > [data-pv="drop"] { width: 100%; }
  .pe-drop .pe-card { width: 100%; }
  .pe-two { grid-template-columns: 1fr; }
  .pe-imgs { gap: 14px; }
  .slot-av { width: 64px; height: 64px; }
  .pe-crow { grid-template-columns: 1fr; padding: 10px 0; }
  .pe-ct { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .pe-ct small { display: inline; }
  .profile-edit .pe-sw { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
  .profile-edit .pe-sw button { width: 100%; height: auto; aspect-ratio: 1; border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .pe-savebar { transition: none; }
}

/* the live preview under the crop slider (custom user tab designer): the framed picture at its saved shape, with the row's text over it */
.crop-live { display: grid; gap: 6px; }
.crop-live > small { color: var(--muted); }
.crop-live-box { position: relative; width: 100%; max-width: 268px; border-radius: var(--r-sm); overflow: hidden; background: var(--bg); border: 1px solid var(--line); isolation: isolate; }
.crop-live-box img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.crop-live-box::after { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(90deg, rgba(8, 12, 26, .62), rgba(8, 12, 26, .18) 70%); }
.crop-live-over { position: absolute; inset: 0; z-index: 2; }
.crop-live-over .member { height: 100%; }
.crop-live-over .member .who small { color: #cbd3ee; } .crop-live-over .member .who small.on { color: #6fe3ae; }
