/* ==========================================================================
   VoiceIQ — Account (profile) page layout. Loaded last, after voiceiq-minimal.css.
   Two-column layout: sticky identity rail on the left, open settings cards on the
   right. Tokens only; scoped to body[data-page="profile"]. No DOM contracts change.
   ========================================================================== */

body[data-page="profile"] {
  --pp-rail: 320px;
  --pp-gap: 24px;
  --pp-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l4 4 10-10'/%3E%3C/svg%3E");
  --pp-icon-spark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l2.4 5.6L20 10l-4.5 4 1.3 6L12 17l-4.8 3 1.3-6L4 10l5.6-1.4z'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   Shell + page header
   -------------------------------------------------------------------------- */
body[data-page="profile"] .profile-shell { max-width: 1240px; padding-top: 32px; padding-bottom: 64px; }
body[data-page="profile"] .profile-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0; padding: 0 0 24px; }
body[data-page="profile"] .profile-heading .ph-copy { min-width: 0; }
body[data-page="profile"] .profile-heading .ph-kicker { display: block; margin: 0; font-size: 12.5px; font-weight: 450; letter-spacing: 0; text-transform: none; color: var(--muted); }
body[data-page="profile"] .profile-heading h1 { margin: 4px 0 6px; max-width: 24ch; font-size: clamp(24px, 2.6vw, 30px); letter-spacing: -.03em; line-height: 1.12; font-weight: 600; }
body[data-page="profile"] .profile-heading p { margin: 0; max-width: 520px; font-size: 14px; line-height: 1.55; color: var(--muted); }
body[data-page="profile"] .profile-heading .ph-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 0 0 auto; }
body[data-page="profile"] .profile-billing-link { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 6px !important; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; }
body[data-page="profile"] .profile-billing-link svg { width: 16px; height: 16px; color: var(--muted); transition: color var(--t) var(--ease); }
body[data-page="profile"] .profile-billing-link:hover { background: var(--surface-2); color: var(--text); }
body[data-page="profile"] .profile-billing-link:hover svg { color: var(--text); }

/* --------------------------------------------------------------------------
   Two-column layout
   -------------------------------------------------------------------------- */
body[data-page="profile"] .profile-layout { display: grid; grid-template-columns: var(--pp-rail) minmax(0, 1fr); gap: var(--pp-gap); align-items: start; }
body[data-page="profile"] .profile-rail { position: sticky; top: 24px; display: grid; gap: 12px; min-width: 0; }
body[data-page="profile"] .profile-main { display: grid; gap: 12px; min-width: 0; }

/* --------------------------------------------------------------------------
   Identity card (rail)
   -------------------------------------------------------------------------- */
body[data-page="profile"] .profile-shell .member-card { position: relative; min-height: 0; max-width: none; width: 100%; margin: 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-l) !important; background: var(--surface); box-shadow: none; overflow: visible; }
body[data-page="profile"] .profile-shell .profile-identity { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 32px 24px 24px; text-align: center; overflow: hidden; }
body[data-page="profile"] .profile-identity::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 84px; background: linear-gradient(180deg, var(--surface-2), transparent); pointer-events: none; }
body[data-page="profile"] .profile-identity > * { position: relative; }
body[data-page="profile"] .profile-avatar-preview { width: 104px !important; height: 104px !important; font-size: 38px !important; margin: 0; border: 1px solid var(--line); background: var(--surface-2) !important; color: var(--text) !important; font-family: var(--font-body) !important; font-weight: 600 !important; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line); }
body[data-page="profile"] .profile-details { width: 100%; min-width: 0; margin-top: 18px; }
body[data-page="profile"] .profile-name-row { display: flex; flex-direction: column; align-items: center; gap: 8px; }
body[data-page="profile"] .profile-name-row #profileUsername { margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 1.1; letter-spacing: -.03em; font-weight: 600; overflow-wrap: anywhere; }
body[data-page="profile"] .profile-name-row .profile-special-tag { margin: 0; }
body[data-page="profile"] .profile-shell #credentialStatus { margin: 8px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
body[data-page="profile"] .profile-user-id { display: inline-flex; align-items: center; gap: 8px; margin: 12px auto 0; min-height: 30px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; transition: border-color .15s ease, color .15s ease; }
body[data-page="profile"] .profile-user-id:hover { border-color: var(--line-strong); color: var(--text); }
body[data-page="profile"] .profile-user-id code { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: var(--text); }
body[data-page="profile"] .profile-user-id svg { width: 13px; height: 13px; opacity: .7; }
body[data-page="profile"] .profile-avatar-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: 20px 0 0; padding-top: 20px; border-top: 1px solid var(--line); }
body[data-page="profile"] .profile-avatar-actions button { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; border-radius: 6px !important; font-size: 13px; font-weight: 500; }
body[data-page="profile"] .profile-avatar-actions button svg { width: 15px; height: 15px; }
body[data-page="profile"] .profile-photo-hint { width: 100%; margin: 4px 0 0; font-size: 12px; color: var(--faint); }

/* --------------------------------------------------------------------------
   Membership card (rail, condensed)
   -------------------------------------------------------------------------- */
body[data-page="profile"] .profile-plus-focus { margin: 0; }
body[data-page="profile"] .profile-membership { padding: 20px; }
body[data-page="profile"] .profile-membership .profile-plus-label { position: relative; display: inline-flex; align-items: center; gap: 10px; margin: 0; font-size: 12.5px; font-weight: 450; letter-spacing: 0; text-transform: none; color: var(--muted); }
body[data-page="profile"] .profile-membership .profile-plus-label::before { content: ""; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); }
body[data-page="profile"] .profile-membership .profile-plus-label::after { content: ""; position: absolute; left: 6px; top: 50%; width: 16px; height: 16px; margin-top: -8px; background: var(--text); -webkit-mask: var(--pp-icon-spark) center / contain no-repeat; mask: var(--pp-icon-spark) center / contain no-repeat; }
body[data-page="profile"] .profile-plus-focus .profile-membership h2 { margin: 14px 0 0; font-size: 17px; letter-spacing: -.025em; font-weight: 600; }
body[data-page="profile"] .profile-plus-focus .profile-membership p { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
body[data-page="profile"] .profile-plus-focus .profile-membership > p[data-plus-state]:empty { display: none; }
body[data-page="profile"] .profile-membership ul { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.45; color: var(--text); }
body[data-page="profile"] .profile-plus-focus .profile-membership ul { grid-template-columns: 1fr; gap: 8px; }
body[data-page="profile"] .profile-membership li { position: relative; padding-left: 26px; }
body[data-page="profile"] .profile-membership li::before { content: ""; position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border-radius: 999px; background: var(--surface-2); }
body[data-page="profile"] .profile-membership li::after { content: ""; position: absolute; left: 4px; top: 5px; width: 10px; height: 10px; background: var(--text); -webkit-mask: var(--pp-icon-check) center / contain no-repeat; mask: var(--pp-icon-check) center / contain no-repeat; }
body[data-page="profile"] .membership-comparison { margin: 14px 0 0; border-radius: 10px; }
body[data-page="profile"] .membership-comparison table { min-width: 440px; font-size: 12px; }
body[data-page="profile"] .membership-comparison th, body[data-page="profile"] .membership-comparison td { padding: 8px 10px; }
body[data-page="profile"] .profile-plus-focus .profile-membership-actions { display: grid; gap: 8px; max-width: none; margin-top: 16px; }
body[data-page="profile"] .profile-shell .profile-membership-actions a, body[data-page="profile"] .profile-membership-actions button { min-height: 36px; padding: 0 14px; border-radius: 6px !important; font-size: 13px; font-weight: 500; }
body[data-page="profile"] .profile-membership [role=status] { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
body[data-page="profile"] .profile-membership [role=status]:empty { display: none; }

/* --------------------------------------------------------------------------
   Settings cards (right column) — each <details> is an open card
   -------------------------------------------------------------------------- */
body[data-page="profile"] .profile-quiet-settings { display: grid; gap: 12px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
body[data-page="profile"] .profile-quiet-settings details { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
body[data-page="profile"] .profile-quiet-settings details:last-child { border-bottom: 1px solid var(--line); }
body[data-page="profile"] .profile-quiet-settings details:hover { border-color: var(--line-strong); }
body[data-page="profile"] .profile-quiet-settings details:focus-within { border-color: var(--line-strong); box-shadow: var(--shadow-1); }

body[data-page="profile"] .profile-quiet-settings summary {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px; min-height: 58px; padding: 12px 14px 12px 16px; margin: 0;
  border-radius: var(--radius-l); background: transparent; color: var(--text); font-size: 14.5px; font-weight: 600; letter-spacing: -.01em;
  list-style: none; cursor: pointer; user-select: none; transition: background var(--t) var(--ease);
}
body[data-page="profile"] .profile-quiet-settings summary::-webkit-details-marker { display: none; }
body[data-page="profile"] .profile-quiet-settings summary::before, body[data-page="profile"] .profile-quiet-settings summary::after { content: none; display: none; }
body[data-page="profile"] .profile-quiet-settings summary:hover { background: var(--surface-2); }
body[data-page="profile"] .profile-quiet-settings details[open] summary { background: transparent; border-bottom: 1px solid var(--line); border-radius: var(--radius-l) var(--radius-l) 0 0; }
body[data-page="profile"] .profile-quiet-settings details[open] summary:hover { background: var(--surface-2); }
body[data-page="profile"] .profile-quiet-settings summary:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; border-radius: var(--radius-l); }

/* Leading icon tile + trailing chevron (inline SVG injected by page-profile.js) */
body[data-page="profile"] i.pp-ico { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; margin: 0; padding: 0; border-radius: 8px; background: var(--surface-2); color: var(--text); font-style: normal; }
body[data-page="profile"] i.pp-ico svg { width: 16px; height: 16px; display: block; }
body[data-page="profile"] i.pp-chev { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; margin: 0 0 0 auto; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font-style: normal; transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease); }
body[data-page="profile"] i.pp-chev svg { width: 15px; height: 15px; display: block; }
body[data-page="profile"] .profile-quiet-settings details[open] i.pp-chev { transform: rotate(180deg); }
body[data-page="profile"] .profile-quiet-settings summary:hover i.pp-chev { border-color: var(--line-strong); color: var(--text); }

/* Badges inside summaries (Recovery: Not verified / Verified; Invite: Give 50 · Get 50) */
body[data-page="profile"] .profile-quiet-settings summary #recoveryEmailBadge,
body[data-page="profile"] .profile-quiet-settings .invite-friends summary span {
  margin-left: auto; margin-right: 0; display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 6px; font-family: var(--font-body); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; white-space: nowrap;
}
body[data-page="profile"] .profile-quiet-settings summary #recoveryEmailBadge:not([hidden]) + i.pp-chev,
body[data-page="profile"] .profile-quiet-settings .invite-friends summary span:not([hidden]) + i.pp-chev { margin-left: 4px; }
body[data-page="profile"] .profile-quiet-settings summary #recoveryEmailBadge { background: var(--warn-soft); color: var(--warn); }
body[data-page="profile"] .profile-quiet-settings summary #recoveryEmailBadge.verified { background: var(--success-soft); color: var(--success); }
body[data-page="profile"] .profile-quiet-settings .invite-friends summary span { background: var(--signal-soft); color: var(--signal-text); }

/* Card body */
body[data-page="profile"] .profile-settings-content { max-width: none; padding: 18px 20px 22px; }
body[data-page="profile"] .profile-settings-content > p { max-width: 560px; margin: 0 0 14px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
body[data-page="profile"] .profile-settings-content > p#recoveryEmailStatus,
body[data-page="profile"] .profile-settings-content #inviteStatus {
  display: flex; align-items: flex-start; gap: 10px; max-width: 560px; margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 13px; line-height: 1.5;
}
body[data-page="profile"] .profile-settings-content > p#recoveryEmailStatus::before,
body[data-page="profile"] .profile-settings-content #inviteStatus::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--signal); }
body[data-page="profile"] .profile-settings-content > p#recoveryEmailStatus::before { background: var(--warn); }
body[data-page="profile"] details:has(#recoveryEmailBadge.verified) .profile-settings-content > p#recoveryEmailStatus::before { background: var(--success); }
body[data-page="profile"] .profile-settings-content #inviteStatus { margin: 16px 0 0; }
body[data-page="profile"] .profile-settings-content #inviteStatus:empty { display: none; }

body[data-page="profile"] .profile-security form { display: grid; gap: 0; width: 100%; max-width: 560px; }
body[data-page="profile"] .profile-security .field-label { display: block; margin: 14px 0 6px; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
body[data-page="profile"] .profile-security form .field-label:first-child { margin-top: 0; }
body[data-page="profile"] .profile-security .creator-name { width: 100%; min-height: 40px; border-radius: 6px !important; }
body[data-page="profile"] .profile-security .create-model-button { width: auto; justify-self: start; min-height: 38px !important; min-width: 148px; margin-top: 18px; padding: 0 16px; border-radius: 6px !important; font-size: 13px !important; }
body[data-page="profile"] .profile-security .recovery-change { display: inline-flex; align-items: center; min-height: 34px; margin: 0 0 14px; padding: 0 12px; border-radius: 6px !important; font-size: 13px; font-weight: 500; }
body[data-page="profile"] .profile-security .recovery-refresh { margin: 14px 16px 0 0; padding: 0; font-size: 13px; color: var(--muted); text-decoration-color: var(--line-strong); }

/* Invite friends internals */
body[data-page="profile"] .invite-warning { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 560px; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--warn-soft); color: var(--text); font-size: 13px; line-height: 1.5; }
body[data-page="profile"] .invite-warning a { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
body[data-page="profile"] .invite-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; max-width: 560px; }
body[data-page="profile"] .invite-copy .creator-name { font-family: var(--font-body); font-size: 13px; }
body[data-page="profile"] .invite-copy .create-model-button { margin: 0; min-width: 0; }
body[data-page="profile"] .invite-code { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
body[data-page="profile"] .invite-code strong { margin-left: 6px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--text); font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: .08em; }
body[data-page="profile"] .invite-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 560px; margin-top: 16px; }
body[data-page="profile"] .invite-stats span { padding: 14px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; color: var(--muted); font-size: 12px; line-height: 1.4; }
body[data-page="profile"] .invite-stats strong { display: block; margin-bottom: 4px; font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.03em; line-height: 1; color: var(--text); }

/* --------------------------------------------------------------------------
   Footer row (right column)
   -------------------------------------------------------------------------- */
body[data-page="profile"] .profile-shell .profile-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px 0 0; padding: 14px 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: transparent; }
body[data-page="profile"] .profile-footer p { flex: 1; min-width: 0; margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
body[data-page="profile"] .profile-footer p:empty::before { content: "Signed in on this device. Sign out to end this session."; color: var(--faint); }
body[data-page="profile"] .profile-shell .profile-footer button { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px !important; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; }
body[data-page="profile"] .profile-shell .profile-footer button svg { width: 15px; height: 15px; color: var(--muted); transition: color var(--t) var(--ease); }
body[data-page="profile"] .profile-shell .profile-footer button:hover { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
body[data-page="profile"] .profile-shell .profile-footer button:hover svg { color: var(--danger); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1000px) {
  body[data-page="profile"] .profile-rail { top: 84px; }
}
@media (max-width: 860px) {
  body[data-page="profile"] .profile-layout { grid-template-columns: 1fr; }
  body[data-page="profile"] .profile-rail { position: static; }
  body[data-page="profile"] .profile-shell .profile-identity { flex-direction: row; align-items: center; gap: 20px; padding: 22px; text-align: left; }
  body[data-page="profile"] .profile-identity::before { display: none; }
  body[data-page="profile"] .profile-avatar-preview { width: 80px !important; height: 80px !important; font-size: 30px !important; box-shadow: none; }
  body[data-page="profile"] .profile-details { margin-top: 0; }
  body[data-page="profile"] .profile-name-row { flex-direction: row; flex-wrap: wrap; align-items: center; }
  body[data-page="profile"] .profile-avatar-actions { justify-content: flex-start; margin-top: 14px; padding-top: 14px; }
  body[data-page="profile"] .profile-photo-hint { margin: 0 0 0 4px; width: auto; }
}
@media (max-width: 640px) {
  body[data-page="profile"] .profile-shell { padding-top: 24px; padding-bottom: 48px; }
  body[data-page="profile"] .profile-heading { flex-direction: column; align-items: flex-start; gap: 14px; padding-bottom: 20px; }
  body[data-page="profile"] .profile-heading .ph-actions { width: 100%; }
  body[data-page="profile"] .profile-billing-link { width: 100%; justify-content: center; }
  body[data-page="profile"] .profile-shell .profile-identity { flex-direction: column; align-items: flex-start; padding: 20px; }
  body[data-page="profile"] .profile-avatar-preview { width: 72px !important; height: 72px !important; font-size: 28px !important; }
  body[data-page="profile"] .profile-details { margin-top: 14px; }
  body[data-page="profile"] .profile-avatar-actions button { flex: 1 1 auto; justify-content: center; }
  body[data-page="profile"] .profile-photo-hint { width: 100%; margin: 4px 0 0; }
  body[data-page="profile"] .profile-shell .member-card { padding: 20px; }
  body[data-page="profile"] .profile-quiet-settings summary { min-height: 54px; padding: 10px 12px 10px 14px; font-size: 14px; }
  body[data-page="profile"] .profile-settings-content { padding: 16px 16px 18px; }
  body[data-page="profile"] .profile-security .create-model-button { width: 100%; }
  body[data-page="profile"] .invite-copy { grid-template-columns: 1fr; }
  body[data-page="profile"] .invite-stats { grid-template-columns: 1fr; }
  body[data-page="profile"] .profile-shell .profile-footer { flex-direction: column; align-items: stretch; }
  body[data-page="profile"] .profile-shell .profile-footer button { justify-content: center; }
}
@media (max-width: 420px) {
  body[data-page="profile"] .profile-quiet-settings summary #recoveryEmailBadge,
  body[data-page="profile"] .profile-quiet-settings .invite-friends summary span { display: none; }
  body[data-page="profile"] .profile-quiet-settings summary #recoveryEmailBadge:not([hidden]) + i.pp-chev,
  body[data-page="profile"] .profile-quiet-settings .invite-friends summary span:not([hidden]) + i.pp-chev { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  body[data-page="profile"] .profile-quiet-settings summary,
  body[data-page="profile"] i.pp-chev,
  body[data-page="profile"] .profile-quiet-settings details,
  body[data-page="profile"] .profile-billing-link { transition: none; }
}
