/* ============================================================
   Profile (#home-tab-profile, js/profile.js): who you are, your avatars,
   your products, and personalization. Opened from your name in the rail.
   ============================================================ */

.pf-page {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: 40px 32px 48px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pf-head { display: flex; align-items: center; gap: 16px; }

.pf-me {
    width: 56px;
    height: 56px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sl-accent-tint);
    color: var(--sl-accent-text);
    font-size: 20px;
    font-weight: 700;
}

.pf-head-text { flex: 1; min-width: 0; }
.pf-name { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-email { margin-top: 2px; font-size: 12.5px; color: var(--sl-text-3); }
.pf-setup-link { flex: none; }

.pf-tabs { align-self: flex-start; }
.pf-tabs .sl-seg-btn { gap: 6px; }

.pf-intro { margin: 0 0 14px; max-width: 640px; font-size: 13px; line-height: 1.5; color: var(--sl-text-2); }

/* Avatars and products: square photo cards, "New" first. */
.pf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px 14px;
    align-items: start;
}

.pf-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    outline: none;
}

.pf-card-photo {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: var(--sl-r-10);
    background: var(--sl-card);
    color: var(--sl-text-3);
    box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.07);
    transition: box-shadow 0.15s ease;
}

.pf-card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pf-card:hover .pf-card-photo { box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.18), var(--sl-shadow-card); }
.pf-card:focus-visible .pf-card-photo { box-shadow: 0 0 0 2px var(--sl-focus); }

.pf-card-name {
    padding: 0 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--sl-text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pf-card-meta { display: flex; align-items: center; gap: 5px; padding: 0 2px; font-size: 11.5px; color: var(--sl-text-3); }

.pf-card-add {
    aspect-ratio: 1;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    text-align: center;
    border: 1px dashed var(--sl-border-strong);
    border-radius: var(--sl-r-10);
    transition: background 0.12s ease, border-color 0.12s ease;
}

.pf-card-add:hover { background: var(--sl-wash); border-color: var(--sl-accent-line); }
.pf-card-add:focus-visible { border-color: var(--sl-focus); }

.pf-card-add-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sl-quiet);
    color: var(--sl-link);
}

.pf-card-add-label { font-size: 13px; font-weight: 600; color: var(--sl-text-1); }
.pf-card-add-sub { font-size: 11.5px; line-height: 1.35; color: var(--sl-text-3); }

.pf-card-initials { font-size: 26px; font-weight: 700; color: var(--sl-text-2); letter-spacing: 0.02em; }
.pf-card-brands { color: var(--sl-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-md-btn { flex: none; gap: 6px; }

/* One brand / platform: name, context and guidelines, avatars, products. */
.pf-brand { display: flex; flex-direction: column; gap: 18px; }
.pf-back { align-self: flex-start; gap: 4px; margin-left: -6px; }
.pf-brand-top { display: flex; align-items: center; gap: 12px; }
.pf-brand-name {
    flex: 1;
    min-width: 0;
    height: 44px;
    font-size: 20px;
    font-weight: 700;
    background: transparent;
    border-color: transparent;
}
.pf-brand-name:hover { border-color: var(--sl-border); }
.pf-brand-name:focus { background: var(--sl-panel); }
.pf-sub-title { margin: 6px 0 0; font-size: 15px; }
.pf-brand-foot { display: flex; justify-content: flex-start; padding-top: 8px; border-top: 1px solid var(--sl-hairline); }

/* Avatar chips on a brand; brand toggles on an avatar. */
.pf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.pf-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 6px 0 4px;
    border-radius: 16px;
    background: var(--sl-quiet);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--sl-text-1);
}

.pf-chip img,
.pf-chip-initials {
    width: 24px;
    height: 24px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
}

.pf-chip-initials { display: grid; place-items: center; background: var(--sl-accent-tint); color: var(--sl-accent-text); font-size: 10px; }

.pf-chip-x {
    width: 20px;
    height: 20px;
    padding: 0;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--sl-text-3);
    cursor: pointer;
}

.pf-chip-x:hover { background: var(--sl-danger-wash); color: var(--sl-danger-text); }

.pf-toggle {
    height: 30px;
    padding: 0 12px;
    border-radius: 15px;
    border: 1px solid var(--sl-border);
    background: none;
    color: var(--sl-text-2);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.pf-toggle:hover { border-color: var(--sl-border-strong); color: var(--sl-text-1); }
.pf-toggle.is-on { background: var(--sl-accent-tint); border-color: var(--sl-accent-line); color: var(--sl-accent-text); }

/* The agent file (Markdown) viewer. */
.pf-dialog.pf-dialog-wide { width: min(760px, calc(100vw - 32px)); }
.pf-md-where { margin: 0; word-break: break-all; }

.pf-md {
    margin: 0;
    max-height: 60vh;
    overflow: auto;
    padding: 12px 14px;
    border-radius: var(--sl-r-8);
    background: var(--sl-panel);
    border: 1px solid var(--sl-hairline);
    font-family: var(--sl-font-mono);
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--sl-text-1);
    white-space: pre-wrap;
    word-break: break-word;
}

/* The avatar / product editor: above #home-screen (9999) and the home mark (10150),
   below the app's confirm (10300), which Delete asks through. */
.pf-scrim { z-index: 10200; }

.pf-dialog {
    width: min(540px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.pf-dialog-body { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.pf-dialog-note { font-size: 12px; line-height: 1.4; color: var(--sl-warning); }
.pf-dialog-note:empty { display: none; }
.pf-flex { flex: 1; }

.pf-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pf-field-label { font-size: 12px; font-weight: 600; color: var(--sl-text-2); }
.pf-field-hint { font-size: 11.5px; line-height: 1.4; color: var(--sl-text-3); }
.pf-field-input { width: 100%; }

.pf-photos { display: flex; flex-wrap: wrap; gap: 12px; }

.pf-photo {
    position: relative;
    width: 76px;
    height: 76px;
    flex: none;
    border-radius: var(--sl-r-8);
    background: var(--sl-quiet);
    box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.1);
}

.pf-photo img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.pf-photo.is-loading { display: grid; place-items: center; }

.pf-photo-x {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 18px;
    height: 18px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid oklch(1 0 0 / 0.22);
    background: oklch(0.32 0.008 250);
    color: var(--sl-text-1);
    cursor: pointer;
}

.pf-photo-x:hover { background: var(--sl-danger-wash); color: var(--sl-danger-text); }

.pf-photo-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px dashed var(--sl-border-strong);
    background: none;
    box-shadow: none;
    color: var(--sl-text-2);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.pf-photo-add:hover { border-color: var(--sl-accent-line); color: var(--sl-text-1); }

.pf-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid oklch(1 0 0 / 0.15);
    border-top-color: var(--sl-link);
    animation: pf-spin 0.8s linear infinite;
}

@keyframes pf-spin { to { transform: rotate(360deg); } }

.pf-voice { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }

/* Personalization: four groups, saved as you type. */
.pf-personal { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.pf-personal .pf-intro { margin-bottom: 0; }
.pf-group { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
.pf-group-title { margin: 0; font-size: 15px; }
.pf-format { align-self: flex-start; }
.pf-personal-foot { min-height: 18px; }
.pf-saved { font-size: 12px; color: var(--sl-success); }

@container home-main (max-width: 599px) {
    .pf-page { padding: 24px 16px 32px; }
    .pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pf-head { flex-wrap: wrap; }
}

body.pw-mobile .pf-page { padding: 18px 14px 32px; }
.pw-desktop:not(.pw-desktop-mac) .pf-page { padding-top: 54px; }
