/* Ensure [hidden] is always display:none even when overridden by .btn or other display rules */
[hidden] { display: none !important; }

/* CSS Variables for consistency with execution page */
:root {
    --accent: #4facfe;
    --accent-2: #9479ff;
    --accent-warm: #f97316;
    --success: #34d399;
    --danger: #ef4444;
    --glass-bg: rgba(6, 12, 24, 0.75);
    --glass-border: rgba(79, 172, 254, 0.22);
    --shadow-lg: 0 45px 120px rgba(15, 23, 42, 0.45);
    --text-primary: #f8fafc;
    --text-muted: rgba(248, 250, 252, 0.7);
}

/* ── Phase 4 Profile Page-Head (design ref 20) ────────────────────────────── */
.profile-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.profile-page-head h1 { font-size: 32px; line-height: 1.15; margin-bottom: 6px; }
.profile-page-head p { margin: 4px 0 0; color: var(--fg-muted, rgba(248,250,252,0.7)); max-width: 540px; font-size: 14px; }
.profile-page-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* flex-shrink:0 with no width cap pushed the action row to 476px on a
       390px viewport — the Edit-profile button sat 75% off-screen, silently
       clipped by the ancestor overflow-x:hidden (QA 2026-07-16). */
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    padding-top: 4px;
}

/* User Profile Specific Styles */
.brand-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.35rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(79, 172, 254, 0.45);
    box-shadow: 0 20px 45px rgba(79, 172, 254, 0.28);
    text-decoration: none;
    color: var(--fg);
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: 1.5rem;
}

.brand-chip img {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid rgba(79, 172, 254, 0.4);
}

.brand-chip-text {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.profile-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.profile-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 2rem;
    padding: 2.5rem;
    margin-bottom: 2.5rem;
    border-radius: 32px;
    background: rgba(5, 10, 20, 0.7);
    border: 1px solid rgba(79, 172, 254, 0.25);
    box-shadow: 0 45px 110px rgba(79, 172, 254, 0.18);
}

.hero-info {
    flex: 1 1 320px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hero-info h1 {
    font-size: clamp(2.2rem, 4vw, 3rem);
    margin: 0;
    letter-spacing: -0.015em;
}

.hero-info p {
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 520px;
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.6rem;
    border-radius: 999px;
    border: none;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(5, 10, 20, 0.65);
    color: var(--fg);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 26px 58px rgba(79, 172, 254, 0.28);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #05070f;
    box-shadow: 0 24px 60px rgba(148, 121, 255, 0.35);
}

.btn-outline {
    background: rgba(5, 10, 20, 0.65);
    border: 1px solid rgba(79, 172, 254, 0.35);
}

.btn-outline:hover {
    border-color: rgba(148, 121, 255, 0.5);
    box-shadow: 0 22px 52px rgba(79, 172, 254, 0.28);
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #05070f;
    box-shadow: 0 22px 52px rgba(102, 126, 234, 0.28);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.18);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.4);
    box-shadow: 0 22px 50px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 28px 60px rgba(239, 68, 68, 0.35);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.hero-actions .btn {
    padding-inline: 1.4rem;
}

.hero-summary {
    flex: 1 1 320px;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.summary-card {
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.18), rgba(148, 121, 255, 0.22));
    border: 1px solid rgba(79, 172, 254, 0.35);
    border-radius: 20px;
    padding: 1.6rem;
    box-shadow: 0 15px 38px rgba(79, 172, 254, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.summary-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: rgba(248, 250, 252, 0.7);
}

.summary-value {
    font-family: 'Poppins', sans-serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: #f8fafc;
}

.summary-detail {
    font-size: 0.9rem;
    color: rgba(248, 250, 252, 0.75);
}

/* Tab styling lives in profile.css to centralize the !important overrides
   needed to defeat the global button{} gradient (see D-06 in eval report). */

.profile-section {
    display: none;
    background: rgba(5, 10, 20, 0.68);
    border-radius: 24px;
    padding: 2.4rem;
    margin-bottom: 2.5rem;
    box-shadow: 0 40px 120px rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(79, 172, 254, 0.18);
}

.profile-section.active {
    display: block;
    animation: slideInUp 0.5s ease-out;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid rgba(79, 172, 254, 0.18);
}

.section-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.2), rgba(148, 121, 255, 0.25));
    border: 1px solid rgba(79, 172, 254, 0.35);
    box-shadow: inset 0 0 18px rgba(79, 172, 254, 0.15);
}

.section-title {
    font-size: 1.85rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.section-description {
    color: rgba(248, 250, 252, 0.72);
    margin: 0.45rem 0 0 0;
    font-size: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--fg);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

/* Design review P1-3 — one standard input focus state across the whole
   profile: a 2px accent-cyan outline with a 2px offset. Never remove the ring. */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
    border-color: var(--accent-cyan);
    box-shadow: none;
    transform: none;
}

/* Catch-all so EVERY text input / select / textarea on the profile page gets
   the same ring, even ones without the .form-* class. */
.profile-container input:focus-visible,
.profile-container select:focus-visible,
.profile-container textarea:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.avatar-section {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* .avatar-section is a horizontal flex row, which is right for the USER avatar
   (preview beside its upload button). The AI-character block reuses the class but
   stacks a heading, a card row and help text vertically — inherited as a flex ROW
   it squeezed the card row to ~290-330px and made it scroll with ~880px free, so
   only about three of the five characters were visible. Affects BOTH modes, not
   just cozy (measured 334px standard / 289px cozy). 2026-07-30. */
.avatar-section--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}
.avatar-section--stack > #personality-avatars-grid {
    width: 100%;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    display: block;
    margin: 0 auto 1rem auto;
}

.avatar-under-label {
    margin-bottom: 0.5rem;
}

.avatar-controls {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
}

.avatar-group {
    margin-bottom: 1rem;
}

.avatar-input-group {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    align-items: center;
}

.avatar-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-solid);
    color: var(--fg);
}

.file-input {
    display: none;
}

.file-input-label {
    padding: 0.5rem 1rem;
    background: var(--border);
    color: var(--fg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.file-input-label:hover {
    background: var(--accent);
    color: white;
}

.notification-settings {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.05), rgba(134, 239, 172, 0.05));
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.notification-settings h3 {
    color: #22c55e;
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.voice-settings {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(147, 197, 253, 0.05));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.voice-settings h3 {
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.emotion-settings {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.05), rgba(196, 181, 253, 0.05));
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.emotion-settings h3 {
    color: #a855f7;
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.emotion-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.checkbox-label:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    accent-color: #a855f7;
}

.voice-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}


.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.character-card {
    background: linear-gradient(145deg, rgba(79, 172, 254, 0.15), rgba(148, 121, 255, 0.2));
    border: 1px solid rgba(79, 172, 254, 0.3);
    border-radius: 16px;
    padding: 1.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.32);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.character-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 55px rgba(79, 172, 254, 0.28);
    border-color: rgba(148, 121, 255, 0.45);
}

.character-card h4 {
    margin: 0 0 0.75rem 0;
    color: #f8fafc;
    font-size: 1.15rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.card-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: rgba(5, 10, 20, 0.55);
    border: 1px solid rgba(79, 172, 254, 0.35);
    box-shadow: inset 0 0 12px rgba(79, 172, 254, 0.15);
    font-size: 1.6rem;
}

.card-title-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-title {
    margin: 0;
    color: #f8fafc;
    font-size: 1.1rem;
    font-weight: 600;
}

.card-subtitle {
    margin: 0;
    color: rgba(248, 250, 252, 0.72);
    font-size: 0.9rem;
}

.card-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    background: rgba(5, 10, 20, 0.65);
    border: 1px solid rgba(79, 172, 254, 0.35);
    font-size: 0.85rem;
    color: rgba(248, 250, 252, 0.85);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card-fieldset {
    gap: 1.25rem;
}

.card-tip {
    font-size: 0.85rem;
    color: rgba(248, 250, 252, 0.7);
    margin: 0;
}

.preferences-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.preference-category {
    background: rgba(5, 10, 20, 0.75);
    border: 1px solid rgba(79, 172, 254, 0.2);
    border-radius: 18px;
    padding: 1.6rem;
    transition: all 0.3s ease;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.preference-category:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 50px rgba(79, 172, 254, 0.22);
}

.preference-category h4 {
    margin: 0 0 0.75rem 0;
    color: #f8fafc;
    font-size: 1.05rem;
    font-weight: 600;
}

.preference-note {
    margin: 0;
    font-size: 0.88rem;
    color: rgba(248, 250, 252, 0.7);
}

.preference-details {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.preference-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.1rem;
}


.success-message {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-weight: 600;
    animation: slideIn 0.3s ease-out;
}

.error-message {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-weight: 600;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    .profile-container {
        padding: 1rem;
    }

    .profile-hero {
        padding: 2rem 1.5rem;
        border-radius: 26px;
    }

    .hero-summary {
        grid-template-columns: 1fr;
    }

    .hero-actions {
        justify-content: flex-start;
    }

    .profile-tabs {
        flex-direction: column;
    }

    .profile-nav-btn {
        width: 100%;
        text-align: center;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .avatar-section {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        /* QA R2: reset the base align-items:center. In a column flex it sized the
           persona-avatars grid to its ~1264px content width (unscrollable, then
           clipped by body{overflow-x:hidden}); stretch constrains it to the
           viewport so the grid's own overflow-x:auto scrolls the personas. */
        align-items: stretch;
    }
    #personality-avatars-grid { min-width: 0; }

    .avatar-controls {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .character-grid,
    .preferences-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-pill {
        width: 100%;
        max-width: none;
    }

    .preference-pair {
        grid-template-columns: 1fr;
    }
}

/* How-to guide overlay */
.guide-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    background: rgba(8, 13, 24, 0.82);
    backdrop-filter: blur(18px);
    z-index: 12000;
}

.guide-overlay.active {
    display: flex;
}

.guide-modal {
    width: min(960px, 100%);
    max-height: min(85vh, 760px);
    background: linear-gradient(145deg, rgba(11, 16, 32, 0.96), rgba(14, 23, 45, 0.92));
    border-radius: 28px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 35px 90px rgba(15, 23, 42, 0.55);
    color: rgba(226, 232, 240, 0.94);
    position: relative;
    overflow-y: auto;
}

.guide-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.8);
    color: rgba(248, 250, 252, 0.85);
    border-radius: 14px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.guide-close:hover {
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.25);
}

.guide-header {
    padding: clamp(1.8rem, 3vw, 2.6rem);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.guide-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(129, 140, 248, 0.9);
    display: inline-block;
    margin-bottom: 0.6rem;
}

.guide-header h2 {
    margin: 0 0 0.6rem 0;
    font-size: clamp(1.9rem, 3vw, 2.4rem);
    font-weight: 700;
    color: #f8fafc;
}

.guide-header p {
    margin: 0;
    font-size: 1rem;
    color: rgba(203, 213, 225, 0.82);
}

.guide-body {
    padding: 0 clamp(1.8rem, 3vw, 2.6rem) clamp(2.2rem, 4vw, 2.8rem);
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
    gap: clamp(1.8rem, 4vw, 2.5rem);
}

.guide-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.guide-card {
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
    padding: clamp(1.4rem, 3vw, 1.8rem);
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
}

.guide-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.guide-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(140deg, rgba(99, 102, 241, 0.9), rgba(56, 189, 248, 0.85));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
}

.guide-card h3 {
    margin: 0 0 0.4rem 0;
    font-size: 1.2rem;
    color: #f8fafc;
}

.guide-card p {
    margin: 0 0 0.9rem 0;
    color: rgba(203, 213, 225, 0.82);
    line-height: 1.55;
}

.guide-card-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.45rem;
}

.guide-card-list li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: rgba(226, 232, 240, 0.85);
    font-size: 0.95rem;
}

.guide-card-list span {
    font-size: 1.1rem;
}

.guide-steps {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(59, 130, 246, 0.24);
    border-radius: 22px;
    padding: clamp(1.3rem, 3vw, 1.8rem);
    display: grid;
    gap: 0.9rem;
}

.guide-steps h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.guide-steps ol {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.45rem;
    color: rgba(203, 213, 225, 0.82);
    font-size: 0.95rem;
}

.guide-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.3rem;
}

.guide-stat {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(129, 140, 248, 0.22);
    border-radius: 20px;
    padding: 1.2rem 1.4rem;
    display: grid;
    gap: 0.35rem;
}

.guide-stat-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    color: rgba(148, 163, 184, 0.82);
}

.guide-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f8fafc;
}

.guide-stat-detail {
    font-size: 0.9rem;
    color: rgba(203, 213, 225, 0.8);
}

.guide-quick-actions {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 20px;
    padding: 1.1rem 1.3rem;
    display: grid;
    gap: 0.75rem;
}

.guide-quick-actions h4 {
    margin: 0;
    font-size: 1rem;
    color: #f1f5f9;
}

.guide-action-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(30, 64, 175, 0.32);
    color: #dbeafe;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.guide-action-btn:hover {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(30, 64, 175, 0.35);
}

.guide-resources {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    padding: 1.2rem 1.4rem;
    display: grid;
    gap: 0.6rem;
    font-size: 0.92rem;
    color: rgba(203, 213, 225, 0.82);
}

.guide-resources a {
    color: #93c5fd;
    text-decoration: none;
    font-weight: 600;
}

.guide-resources a:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .guide-body {
        grid-template-columns: 1fr;
    }

    .guide-sidebar {
        order: -1;
    }
}

@media (max-width: 640px) {
    .guide-modal {
        border-radius: 24px;
    }

    .guide-body {
        gap: 1.4rem;
        padding: 0 1.4rem 1.8rem;
    }

    .guide-card {
        flex-direction: column;
    }

    .guide-card-icon {
        width: 44px;
        height: 44px;
    }

    .guide-action-btn {
        font-size: 0.95rem;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-btn {
        width: 100%;
        justify-content: center;
    }

    .hero-summary {
        grid-template-columns: 1fr;
    }
}

/* F4: Sticky save button — always visible at bottom of long forms */
.form-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 1rem 0;
    background: linear-gradient(to top, rgba(11, 18, 32, 1) 60%, rgba(11, 18, 32, 0));
    margin-top: 1rem;
}

/* V5: Enlarge close/dismiss buttons for 50+ users */
.modal-close,
.panel-close,
.close-btn,
[aria-label="Close"] {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   Data Management Section — donate / delete content / delete account
   ═══════════════════════════════════════════════════════════════════════ */

/* Banner host — full-width slot at top of profile page */
.data-mgmt-banner-host {
    width: 100%;
    display: block;
}

.data-mgmt-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.5rem;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    line-height: 1.5;
}

.data-mgmt-banner.warning {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.4);
    color: #ffedd5;
}

.data-mgmt-banner.danger {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fee2e2;
}

.data-mgmt-banner-text {
    flex: 1 1 auto;
    min-width: 240px;
}

.data-mgmt-banner-action {
    flex: 0 0 auto;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    min-height: 40px;
}

.data-mgmt-banner-action:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.5);
}

.data-mgmt-banner-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Data Management section block */
.data-mgmt-section {
    background: rgba(239, 68, 68, 0.04);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 14px;
    padding: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
}

/* Quiet launcher — muted link at the very bottom of the profile page.
   Designed to be non-prominent (rarely-used destructive actions live
   behind it), but findable when users go looking. Separator above it
   visually parks it below the main content. */
.data-mgmt-footer-link {
    margin-top: 2.5rem;
    padding: 1.4rem 0 2rem;
    text-align: center;
    border-top: 1px dashed var(--border, rgba(148, 163, 184, 0.2));
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.data-mgmt-footer-link:hover {
    opacity: 1;
}

.data-mgmt-reveal-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--muted, rgba(148, 163, 184, 0.85));
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    transition: all 0.2s ease;
}

.data-mgmt-reveal-btn:hover {
    color: var(--fg, rgba(248, 250, 252, 0.95));
    border-color: var(--border, rgba(148, 163, 184, 0.3));
}

/* Keyboard focus needs a clear ring, not just the faint hover border — the
   shared hover+focus rule set outline:none with only a 30%-opacity border,
   which reads as no focus cue for keyboard users (sweep-03 B3 §98). A solid
   accent outline is visible on both the dark profile bg and cozy cream. */
.data-mgmt-reveal-btn:focus-visible {
    color: var(--fg, rgba(248, 250, 252, 0.95));
    border-color: var(--accent-purple, #9479ff);
    outline: 2px solid var(--accent-purple, #9479ff);
    outline-offset: 2px;
}

.data-mgmt-heading {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--fg, #f8fafc);
}

.data-mgmt-intro {
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    color: var(--muted, rgba(248, 250, 252, 0.7));
    line-height: 1.5;
}

/* Cards */
.data-mgmt-card {
    padding: 1.15rem 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.35);
    margin-bottom: 1rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.data-mgmt-card:last-child {
    margin-bottom: 0;
}

.data-mgmt-card.donate {
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.06);
}

.data-mgmt-card.delete-content {
    border-color: rgba(249, 115, 22, 0.35);
    background: rgba(249, 115, 22, 0.05);
}

.data-mgmt-card.delete-account {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.05);
}

.data-mgmt-card-title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--fg, #f8fafc);
}

.data-mgmt-card-body {
    margin: 0 0 1rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--muted, rgba(248, 250, 252, 0.8));
}

.data-mgmt-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.data-mgmt-card-actions .btn {
    min-height: 40px;
}

.data-mgmt-status {
    font-size: 0.85rem;
    color: var(--muted, rgba(248, 250, 252, 0.65));
}

/* Button variants */
.data-mgmt-btn-warning {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    border: 1px solid transparent;
}

.data-mgmt-btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, #ea580c, #c2410c);
}

.data-mgmt-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: 1px solid transparent;
}

.data-mgmt-btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.data-mgmt-btn-warning:disabled,
.data-mgmt-btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(148, 163, 184, 0.25);
}

/* Donate button "enabled" state — neutral outline */
#dmDonateBtn.is-enabled {
    background: transparent;
    border: 1px solid rgba(52, 211, 153, 0.5);
    color: #34d399;
}

#dmDonateBtn.is-enabled:hover:not(:disabled) {
    background: rgba(52, 211, 153, 0.08);
}

/* ─── Modals ────────────────────────────────────────────────────────── */
.data-mgmt-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
}

.data-mgmt-modal.is-open {
    display: block;
}

.data-mgmt-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 20, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: dmFadeIn 0.18s ease-out;
}

@keyframes dmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.data-mgmt-modal-content {
    max-width: 520px;
    width: 100%;
    background: var(--bg-elev, #0f172a);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    color: var(--fg, #f8fafc);
    max-height: 90vh;
    overflow-y: auto;
    animation: dmSlideUp 0.22s ease-out;
}

@keyframes dmSlideUp {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.data-mgmt-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.data-mgmt-modal-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.data-mgmt-modal-title {
    flex: 1;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--fg, #f8fafc);
}

.data-mgmt-modal-close {
    background: transparent;
    border: none;
    color: var(--muted, rgba(248, 250, 252, 0.7));
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

.data-mgmt-modal-close:hover {
    background: rgba(148, 163, 184, 0.12);
    color: var(--fg, #f8fafc);
}

.data-mgmt-modal-body {
    padding: 1.25rem 1.5rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--fg, #f8fafc);
}

.data-mgmt-modal-body p {
    margin: 0 0 1rem;
}

.data-mgmt-modal-body p:last-child {
    margin-bottom: 0;
}

.data-mgmt-confirm-field {
    margin-top: 1rem;
}

.data-mgmt-confirm-field label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--muted, rgba(248, 250, 252, 0.8));
}

.data-mgmt-confirm-field .form-input {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.data-mgmt-donate-link-wrap {
    margin-top: 0.5rem;
    text-align: center;
}

.data-mgmt-donate-link {
    font-size: 0.88rem;
    color: #34d399;
    text-decoration: none;
    border-bottom: 1px dashed rgba(52, 211, 153, 0.4);
    padding-bottom: 1px;
}

.data-mgmt-donate-link:hover {
    color: #6ee7b7;
    border-bottom-color: rgba(52, 211, 153, 0.8);
}

.data-mgmt-modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    flex-wrap: wrap;
}

.data-mgmt-modal-footer .btn {
    min-height: 42px;
    min-width: 110px;
}

/* ─── Toast fallback (if no global showToast) ──────────────────────── */
.data-mgmt-toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
    pointer-events: none;
}

.data-mgmt-toast {
    padding: 0.8rem 1.1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    animation: dmFadeIn 0.2s ease-out;
    color: #fff;
}

.data-mgmt-toast-success { background: #059669; }
.data-mgmt-toast-error   { background: #dc2626; }
.data-mgmt-toast-info    { background: #2563eb; }

.data-mgmt-toast-fadeout {
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* ─── Cozy mode overrides ──────────────────────────────────────────── */
:root[data-ux-mode="cozy"] .data-mgmt-section {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.25);
}

:root[data-ux-mode="cozy"] .data-mgmt-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(15, 23, 42, 0.12);
    color: #1e293b;
}

:root[data-ux-mode="cozy"] .data-mgmt-card-title,
:root[data-ux-mode="cozy"] .data-mgmt-heading {
    color: #0f172a;
}

:root[data-ux-mode="cozy"] .data-mgmt-card-body,
:root[data-ux-mode="cozy"] .data-mgmt-intro,
:root[data-ux-mode="cozy"] .data-mgmt-status {
    color: #475569;
}

:root[data-ux-mode="cozy"] .data-mgmt-card.donate {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.5);
}

:root[data-ux-mode="cozy"] .data-mgmt-card.delete-content {
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.45);
}

:root[data-ux-mode="cozy"] .data-mgmt-card.delete-account {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.45);
}

:root[data-ux-mode="cozy"] .data-mgmt-modal-content {
    background: #fff;
    color: #1e293b;
    border-color: rgba(15, 23, 42, 0.15);
}

:root[data-ux-mode="cozy"] .data-mgmt-modal-title,
:root[data-ux-mode="cozy"] .data-mgmt-modal-body {
    color: #0f172a;
}

:root[data-ux-mode="cozy"] .data-mgmt-modal-close {
    color: #64748b;
}

:root[data-ux-mode="cozy"] .data-mgmt-modal-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

:root[data-ux-mode="cozy"] .data-mgmt-banner.warning {
    background: #fff7ed;
    color: #7c2d12;
    border-color: #fdba74;
}

:root[data-ux-mode="cozy"] .data-mgmt-banner.danger {
    background: #fef2f2;
    color: #7f1d1d;
    border-color: #fca5a5;
}

:root[data-ux-mode="cozy"] .data-mgmt-banner-action {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.18);
    color: inherit;
}

:root[data-ux-mode="cozy"] .data-mgmt-banner-action:hover {
    background: rgba(15, 23, 42, 0.12);
}

/* Mobile tweaks */
@media (max-width: 640px) {
    .data-mgmt-section {
        padding: 1.15rem;
    }
    .data-mgmt-card {
        padding: 1rem;
    }
    .data-mgmt-modal-overlay {
        padding: 0.75rem;
    }
    .data-mgmt-modal-footer {
        justify-content: stretch;
    }
    .data-mgmt-modal-footer .btn {
        flex: 1 1 auto;
    }
}
}