/* ============================================================
   Auth, Registration & Profile
   ============================================================ */

/* --- Auth forms --- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    margin: 0 auto;
}

.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="number"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-base);
    transition: border-color var(--duration);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--c-basic);
}

.auth-form input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-btn {
    padding: 13px;
    border-radius: var(--radius-sm);
    background: var(--c-basic);
    color: #fff;
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-size: var(--fs-lg);
    margin-top: 8px;
    transition: opacity var(--duration);
}

.auth-btn:hover {
    opacity: 0.9;
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    margin-top: 12px;
    color: var(--c-basic);
    cursor: pointer;
    font-weight: 600;
    font-size: var(--fs-sm);
    transition: opacity var(--duration);
}

.auth-switch.is-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.auth-switch:hover {
    text-decoration: underline;
}

.recovery-tabs {
    display: flex;
    gap: 6px;
    margin: -4px 0 16px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.recovery-tab {
    flex: 1;
    min-width: 0;
    padding: 9px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 700;
    line-height: 1.2;
}

.recovery-tab.is-active {
    background: color-mix(in srgb, var(--c-basic) 20%, var(--surface-3));
    color: var(--text);
}

.recovery-tab:focus-visible {
    outline: 2px solid var(--c-basic);
    outline-offset: 2px;
}

.recovery-username-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 2px 2px;
    color: var(--text-2);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.recovery-username-panel.is-hidden {
    display: none;
}

.recovery-username-panel p,
.recovery-username-panel ol {
    margin: 0;
}

.recovery-username-panel ol {
    padding-left: 20px;
}

.recovery-username-panel a,
.recovery-username-panel code {
    color: var(--c-basic);
    font-weight: 700;
}

.recovery-username-note {
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.field-error {
    color: #ef4444;
    font-size: var(--fs-xs);
    font-weight: 600;
    min-height: 0;
}

.agreement-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    color: var(--text-2);
}

.agreement-link {
    background: none;
    border: none;
    color: var(--c-basic);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    text-decoration: underline;
    padding: 0;
}

.auth-section-title {
    text-align: center;
    margin-bottom: 20px;
}

.password-toggle {
    color: #94a3b8;
    font-size: var(--fs-sm);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    margin-bottom: 10px;
}

.password-toggle input[type="checkbox"],
.agreement-row input[type="checkbox"],
.profile-checkbox-label input[type="checkbox"] {
    display: inline-block;
    appearance: auto;
    -webkit-appearance: auto;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--c-basic);
    cursor: pointer;
}

.auth-error-msg {
    color: #ef4444;
    font-size: var(--fs-sm);
    margin-bottom: 10px;
    text-align: center;
}

/* --- Registration fields --- */
.gender-toggle-row {
    display: flex;
    gap: 8px;
}

.reg-gender-label {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
}

.registration-age-column {
    flex: 1;
}

.age-stepper {
    position: relative;
    display: flex;
    align-items: stretch;
}

.auth-form .age-stepper .age-field-input {
    padding-right: 44px;
    -moz-appearance: textfield;
    appearance: textfield;
}

.auth-form .age-stepper .age-field-input::-webkit-outer-spin-button,
.auth-form .age-stepper .age-field-input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.age-stepper-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    bottom: 6px;
    width: 28px;
    display: grid;
    grid-template-rows: 1fr 1fr;
    overflow: hidden;
    border: 1px solid var(--border-2);
    border-radius: 6px;
    background: var(--surface-3);
}

.age-stepper-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--duration), color var(--duration);
}

.age-stepper-btn::before {
    content: "";
    width: 0;
    height: 0;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

.age-stepper-up::before {
    border-bottom: 5px solid currentColor;
}

.age-stepper-down {
    border-top: 1px solid var(--border);
}

.age-stepper-down::before {
    border-top: 5px solid currentColor;
}

.age-stepper-btn:hover,
.age-stepper-btn:focus-visible {
    background: color-mix(in srgb, var(--accent-color) 18%, transparent);
    color: var(--accent-color);
    outline: none;
}

.age-stepper-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

body.light .age-stepper-controls {
    background: var(--surface);
}

.registration-error-row {
    display: flex;
    gap: 10px;
    margin-top: -8px;
    margin-bottom: 8px;
}

.registration-error-cell {
    flex: 1;
    margin-bottom: 0;
}

.registration-warning {
    font-size: 12px;
    color: var(--text-3);
    text-align: center;
    margin-top: 15px;
}

.warning-label {
    color: #ef4444;
    font-weight: 700;
}

/* --- Profile card --- */
.profile-card {
    max-width: 500px;
    margin: 20px auto;
    background:
        var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: box-shadow var(--duration) ease, border-color var(--duration) ease;
}

.profile-card::before {
    content: none;
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    min-height: 0;
    padding: 0 0 2px;
}

.profile-avatar-wrap {
    --katomu-avatar-size: 68px;
    position: relative;
    width: 68px;
    height: 68px;
    flex-shrink: 0;
    user-select: none;
}

.profile-hero-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-hero-nick,
.profile-hero-name {
    font-size: var(--fs-xl);
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0;
    background: linear-gradient(90deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.profile-hero-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: var(--fs-xs);
    color: var(--text-3);
    margin-top: 2px;
}

.profile-hero-sub > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-2);
}

#profile-top-badges-container {
    justify-content: flex-start !important;
    margin: -6px 0 0 !important;
    padding-bottom: 0;
    border-bottom: 0;
}

#profile-top-badges-container .pp-top-badge {
    border-radius: var(--radius-pill);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.profile-gender-badge.male {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
    border-color: rgba(96, 165, 250, 0.2);
}

.profile-gender-badge.female {
    color: #f472b6;
    background: rgba(244, 114, 182, 0.08);
    border-color: rgba(244, 114, 182, 0.2);
}

.profile-stats-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: 0;
}

.profile-stat-box {
    --profile-stat-accent: var(--c-basic);
    padding: 18px 18px 16px 20px;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: 14px;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform var(--duration) cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow var(--duration) ease, border-color var(--duration) ease, background var(--duration) ease;
}

.profile-stat-box:first-child:not(.profile-katy-panel),
.profile-stat-box.profile-stat-box--reputation {
    --profile-stat-accent: #eab308;
}

.profile-stat-box#mastery-box {
    --profile-stat-accent: #a78bfa;
}

.profile-stat-box:hover {
    transform: translateY(-2px);
    border-color: var(--border-2);
    background: var(--surface-3);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.profile-stat-box::before {
    content: none;
}

.profile-stat-label {
    font-size: 11px;
    color: var(--profile-stat-accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    align-self: flex-start;
    margin-bottom: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

/* Color coding for Reputation and Mastery boxes */
.profile-stat-box:first-child:not(.profile-katy-panel) .profile-stat-label,
.profile-stat-box.profile-stat-box--reputation .profile-stat-label {
    color: #eab308;
}
.profile-stat-box:first-child:not(.profile-katy-panel) .profile-stat-label i,
.profile-stat-box.profile-stat-box--reputation .profile-stat-label i {
    color: #eab308;
}

.profile-stat-box#mastery-box .profile-stat-label {
    color: #a78bfa;
}
.profile-stat-box#mastery-box .profile-stat-label i {
    color: #a78bfa;
}

.profile-stat-val {
    font-size: 34px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    align-self: flex-start;
    background: linear-gradient(180deg, var(--text) 0%, var(--text-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.profile-stat-box .rank-badge,
.profile-stat-box .writing-class-badge,
#profile-rank-badge,
#profile-mastery-rank-badge,
#profile-writing-class-badge {
    align-self: flex-start;
}

.profile-age-value {
    font-size: 32px;
}

.profile-stat-box.profile-katy-panel {
    --profile-stat-accent: #facc15;
}

.profile-stat-box.profile-katy-panel .profile-stat-label,
.profile-stat-box.profile-katy-panel .profile-stat-label i {
    color: var(--profile-stat-accent);
}

.profile-katy-value-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
}

.profile-katy-unit {
    color: var(--profile-stat-accent);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 3px;
    white-space: nowrap;
}

.profile-katy-hint {
    color: var(--text-3);
}

.profile-katy-warning {
    margin: 0;
    color: #f59e0b;
    font-size: 12px;
    line-height: 1.45;
}

.profile-katy-bot-link {
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid rgba(34, 197, 94, 0.32);
    border-radius: 8px;
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    align-self: flex-start;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--duration) ease, border-color var(--duration) ease, color var(--duration) ease;
}

.profile-katy-bot-link:hover,
.profile-katy-bot-link:focus-visible {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.16);
    color: #86efac;
    outline: none;
}

.profile-stat-box.profile-katy-panel.is-attention {
    border-color: rgba(234, 179, 8, 0.55);
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.12);
}

.profile-edit-section {
    margin: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-edit-label {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0;
    margin-bottom: 4px;
}

.profile-field {
    margin-bottom: 4px;
}

.profile-field-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.profile-age-field {
    flex: 1;
}

.profile-age-note {
    opacity: 0.55;
    font-weight: 500;
    font-size: 11px;
}

.profile-age-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.profile-field-label {
    font-size: 12px;
    color: var(--text-2);
    font-weight: 700;
    margin-bottom: 6px;
    display: block;
}

.profile-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    margin-top: 10px;
    user-select: none;
    line-height: 1.4;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.profile-checkbox-label:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.profile-checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(15, 23, 42, 0.4);
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
    margin-top: 1px;
}

.profile-checkbox-label input[type="checkbox"]:checked {
    background: var(--c-basic);
    border-color: var(--c-basic);
}

.profile-checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.profile-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.profile-input:focus {
    outline: none;
    border-color: var(--c-basic);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15), inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

#profile-age-input {
    width: 90px;
    text-align: center;
}

.profile-save-mini-btn {
    padding: 11px 18px;
    border-radius: 12px;
    background: var(--c-basic);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.22);
}

.profile-save-mini-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.profile-actions {
    display: flex;
    gap: 14px;
    width: 100%;
    margin-top: 10px;
}

.profile-save-btn {
    flex: 1.5;
    padding: 14px 20px;
    border-radius: 14px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.01em;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, opacity 0.25s ease;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(16, 185, 129, 0.36);
}

.profile-save-btn:active {
    transform: translateY(0);
}

.profile-logout-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ef4444;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-logout-btn:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.45);
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.12);
}

.profile-logout-btn:active {
    transform: translateY(0);
}

/* NOTE: .help-btn base styles are defined in components.css.
   Only profile-specific hover override stays here. */
.help-btn:hover {
    background: color-mix(in srgb, var(--c-basic) 30%, transparent);
    border-color: color-mix(in srgb, var(--c-basic) 65%, transparent);
    color: var(--c-basic);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}


/* Light Theme Overrides */
body.light .profile-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(241, 245, 249, 0.72) 100%);
    border: 1px solid var(--border-2);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

body.light .profile-card::before {
    content: none;
}

body.light .profile-hero-nick,
body.light .profile-hero-name {
    background: linear-gradient(90deg, #1e293b 0%, #475569 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light .profile-hero-sub > span {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
    color: var(--text-2);
}

body.light .profile-stat-box {
    background: var(--surface-2);
    border-color: var(--border-2);
}

body.light .profile-stat-box:hover {
    background: var(--surface-3);
    border-color: var(--border-2);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
}

body.light .profile-stat-label {
    background: transparent;
    border-color: transparent;
}

/* KatomuFic fanfic count badge in profile stats row */
a.fic-works-badge {
    text-decoration: none;
    border-color: rgba(168, 85, 247, 0.2);
}
a.fic-works-badge:hover {
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 8px 24px rgba(168, 85, 247, 0.15), inset 0 0 0 1px rgba(168, 85, 247, 0.1);
}

body.light .profile-stat-val {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light .profile-edit-section {
    background: rgba(255, 255, 255, 0.52);
    border-color: var(--border);
}

body.light .profile-input {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.12);
    color: #0f172a;
}

body.light .profile-input:focus {
    background: #fff;
}

body.light .profile-checkbox-label {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.03);
}

body.light .profile-checkbox-label:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.05);
}

body.light .profile-checkbox-label input[type="checkbox"] {
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.8);
}

body.light .profile-checkbox-label input[type="checkbox"]:checked {
    background: var(--c-basic);
    border-color: var(--c-basic);
}

body.light .profile-stat-desc,
body.light .profile-stat-label {
    color: var(--text-2);
}

body.light .profile-logout-btn {
    background: rgba(239, 68, 68, 0.04);
    border-color: rgba(239, 68, 68, 0.15);
}

body.light .profile-logout-btn:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
}

body.light .help-btn {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.03);
}

@media (max-width: 768px) {
    .gender-age-row {
        flex-direction: column;
        gap: 10px;
    }

    .gender-toggle-group,
    .gender-age-row>div {
        width: 100%;
    }

    .gender-pills {
        width: 100%;
    }

    .gender-pill {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    /* ── Profile card: tighter padding, full-width ── */
    .profile-card {
        padding: 16px 14px;
        margin: 0;
        width: 100%;
        border-radius: 16px;
        gap: 16px;
    }

    .profile-card::before {
        content: none;
    }

    /* ── Hero: keep horizontal row like the screenshot ── */
    .profile-hero {
        flex-direction: row;
        align-items: center;
        gap: 14px;
        text-align: left;
        min-height: 0;
        padding: 0;
    }

    .profile-avatar-wrap {
        --katomu-avatar-size: 58px;
        width: var(--katomu-avatar-size);
        height: var(--katomu-avatar-size);
        flex-shrink: 0;
    }

    .profile-hero-info {
        flex: 1;
        min-width: 0;
        text-align: left;
    }

    .profile-hero-nick,
    .profile-hero-name {
        font-size: 18px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .profile-hero-sub {
        justify-content: flex-start;
        margin-top: 4px;
    }

    #profile-top-badges-container {
        margin: -4px 0 0 !important;
        padding-bottom: 0;
    }

    /* ── Stats: vertical and compact ── */
    .profile-stats-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0;
    }

    #mastery-box {
        grid-column: auto;
    }

    .profile-stat-box {
        min-width: 0;
        padding: 14px 12px 14px 16px;
        border-radius: 16px;
        gap: 8px;
    }

    .profile-stat-box::before {
        top: 14px;
        bottom: 14px;
    }

    .profile-stat-val {
        font-size: 30px;
    }

    .profile-stat-label {
        justify-content: flex-start;
        text-align: left;
        overflow-wrap: anywhere;
        font-size: 10px;
    }

    .profile-stat-desc {
        font-size: 10.5px;
        max-width: 100%;
        text-align: left;
    }

    .profile-katy-bot-link {
        width: 100%;
    }

    /* ── Edit section: tighter ── */
    .profile-edit-section {
        margin: 0;
        padding: 14px 12px;
        gap: 12px;
        border-radius: 16px;
    }

    .profile-edit-label {
        font-size: 14px;
    }

    .profile-input {
        padding: 11px 14px;
        font-size: 14px;
    }

    #profile-age-input {
        width: 80px;
    }

    .profile-save-mini-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .profile-checkbox-label {
        font-size: 12px;
        padding: 10px;
    }

    /* ── Actions: stacked column ── */
    .profile-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 4px;
    }

    .profile-save-btn,
    .profile-logout-btn {
        width: 100%;
        min-width: 0;
        padding: 13px 16px;
        font-size: 14px;
    }
}

/* --- Gender icon coloring for navigation ease --- */
.lucide-mars,
[data-icon="mars"],
.profile-gender-badge.male svg,
.profile-gender-icon.profile-gender-icon[class*="mars"],
label[for="reg_gender_m"] svg {
    color: #60a5fa !important;
}

.lucide-venus,
[data-icon="venus"],
.profile-gender-badge.female svg,
.profile-gender-icon.profile-gender-icon[class*="venus"],
label[for="reg_gender_f"] svg {
    color: #f472b6 !important;
}

/* Custom active/checked states for registration gender buttons */
#tab-account input[id="reg_gender_m"]:checked + .reg-gender-label {
    border-color: #60a5fa !important;
    background: rgba(96, 165, 250, 0.12) !important;
    color: #60a5fa !important;
}

#tab-account input[id="reg_gender_f"]:checked + .reg-gender-label {
    border-color: #f472b6 !important;
    background: rgba(244, 114, 182, 0.12) !important;
    color: #f472b6 !important;
}

/* --- Daily Mastery Cap Progress Bar Styles (ROADMAP §4.1) --- */
.mastery-daily-limit {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px !important;
}

.profile-stat-box .reputation-daily-limit,
.profile-stat-box .mastery-class-limit,
.profile-stat-box .mastery-daily-limit {
    margin-top: 4px !important;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

body.light .profile-stat-box .reputation-daily-limit,
body.light .profile-stat-box .mastery-class-limit,
body.light .profile-stat-box .mastery-daily-limit {
    border-color: transparent;
    background: transparent;
}

body.light #profile-mastery-daily-fill {
    box-shadow: 0 0 6px rgba(109, 40, 217, 0.4) !important;
}

.profile-limit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 750;
    width: 100%;
}

.reputation-streak {
    width: 100%;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.reputation-streak-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.25;
}

.reputation-streak-header span {
    min-width: 0;
}

#profile-reputation-streak-next {
    color: var(--c-basic);
    text-align: right;
    white-space: nowrap;
}

.reputation-streak-days {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    margin-top: 7px;
    width: 100%;
}

.reputation-streak-day {
    height: 6px;
    min-width: 0;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border);
}

.reputation-streak-day.is-filled {
    background: var(--c-basic);
    border-color: color-mix(in srgb, var(--c-basic) 70%, transparent);
    box-shadow: 0 0 6px color-mix(in srgb, var(--c-basic) 45%, transparent);
}

.reputation-streak-day.is-today {
    background: linear-gradient(90deg, var(--c-basic), #facc15);
    border-color: rgba(250, 204, 21, 0.65);
    box-shadow: 0 0 7px rgba(250, 204, 21, 0.35);
}

.reputation-streak-note {
    margin-top: 7px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.3;
}

.reputation-history-panel {
    width: 100%;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}

.reputation-history-title {
    margin-bottom: 6px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.reputation-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 2px;
}

.reputation-history-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-height: 28px;
    font-size: 12px;
}

.reputation-history-delta {
    font-weight: 900;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.reputation-history-delta.is-positive {
    color: #4ade80;
}

.reputation-history-delta.is-negative {
    color: #f87171;
}

.reputation-history-delta.is-neutral {
    color: var(--text-3);
}

.reputation-history-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reputation-history-reason {
    color: var(--text);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reputation-history-meta,
.reputation-history-empty {
    color: var(--text-3);
    font-size: 11px;
}

.reputation-history-empty.is-error {
    color: #f87171;
}

@media (max-width: 768px) {
    .profile-limit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .reputation-streak-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    #profile-reputation-streak-next {
        text-align: left;
        white-space: normal;
    }
}


/* --- Writing Style Class Badge & Gate Styles --- */
.writing-class-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid currentColor;
    user-select: none;
    line-height: 1.2;
}

.class-badge--one-liner {
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.3);
    background: rgba(148, 163, 184, 0.08);
}
.class-badge--medium {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}
.class-badge--multi-paragraph {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.08);
}
.class-badge--novelist {
    color: #a78bfa;
    border-color: rgba(167, 139, 250, 0.4);
    background: rgba(167, 139, 250, 0.1);
    box-shadow: 0 0 6px rgba(167, 139, 250, 0.2);
}

body.light .class-badge--one-liner {
    color: #64748b;
    border-color: rgba(100, 116, 139, 0.4);
    background: rgba(100, 116, 139, 0.06);
}
body.light .class-badge--medium {
    color: #059669;
    border-color: rgba(5, 150, 105, 0.4);
    background: rgba(5, 150, 105, 0.06);
}
body.light .class-badge--multi-paragraph {
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.4);
    background: rgba(37, 99, 235, 0.06);
}
body.light .class-badge--novelist {
    color: #7c3aed;
    border-color: rgba(124, 58, 237, 0.4);
    background: rgba(124, 58, 237, 0.06);
}

.profile-mastery-badge {
    color: #a78bfa !important;
    background: rgba(167, 139, 250, 0.08) !important;
    border-color: rgba(167, 139, 250, 0.2) !important;
}

body.light .profile-mastery-badge {
    color: #7c3aed !important;
    background: rgba(124, 58, 237, 0.06) !important;
    border-color: rgba(124, 58, 237, 0.2) !important;
}

.profile-stat-desc {
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.45;
    margin-top: 2px;
    padding-top: 10px;
    max-width: none;
    text-align: left;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    font-weight: 500;
}

body.light .profile-stat-desc {
    border-top-color: rgba(15, 23, 42, 0.08);
}

@media (max-width: 768px) {
    .profile-stat-desc {
        font-size: 10.5px;
        max-width: 100%;
        text-align: left;
    }
}

.info-help-btn:hover {
    opacity: 1 !important;
    color: var(--c-basic) !important;
    border-color: var(--c-basic) !important;
}

/* ── Avatar Upload Zone ─────────────────────────────────────── */

.profile-avatar-wrap.avatar-uploadable {
    cursor: pointer;
}

/* ── Friends Sidebar Avatar Thumbnail ───────────────────────── */
.friends-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--c-basic) 0%, #7c3aed 100%);
    overflow: hidden;
    position: relative;
}

.friends-item-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ── Chat Header Partner Avatar ─────────────────────────────── */
.chat-header-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
