.xp-header {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 120px;
    flex-shrink: 0;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.72rem;
    white-space: nowrap;
}
.xp-header-text {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}
.xp-badge {
    font-size: 0.9em;
    line-height: 1;
}
[data-xp-progress] {
    appearance: none;
    border: 0;
    border-radius: 8px;
    width: 100%;
    height: 6px;
    overflow: hidden;
    background: var(--border-color);
}
[data-xp-progress]::-webkit-progress-bar { background: var(--border-color); }
[data-xp-progress]::-webkit-progress-value { background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); }
[data-xp-progress]::-moz-progress-bar { background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); }
.xp-profile { padding: 20px; }
.xp-profile h2 { margin: 0 0 12px; font-size: 1.1rem; }
.xp-profile p, .xp-profile li { font-size: 0.85rem; line-height: 1.6; }
.xp-profile ul { padding-left: 20px; margin-bottom: 0; }
.xp-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11000;
    padding: 10px 18px;
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    background: var(--card-color);
    color: var(--text-color);
    box-shadow: 0 4px 16px var(--shadow);
    pointer-events: none;
}
.xp-toast[hidden] { display: none; }

/* ── Floating XP Particle & Pulse Animations ── */
.xp-float-particle {
    position: fixed;
    z-index: 12000;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.95rem;
    font-weight: 800;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    box-shadow: 0 4px 18px rgba(124, 58, 237, 0.45);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    transform: translate(-50%, -50%);
    animation: xp-float-up 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes xp-float-up {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.7);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -16px) scale(1.1);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -46px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -70px) scale(0.9);
    }
}
.xp-widget-bump {
    animation: xp-widget-pulse 0.5s ease-out;
}
@keyframes xp-widget-pulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.08); filter: brightness(1.25); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* ── Study Mastery Tiers & Badges ── */
.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.tier-bronze   { background: rgba(205, 127, 50, 0.16); color: #cd7f32; border: 1px solid rgba(205, 127, 50, 0.4); }
.tier-silver   { background: rgba(148, 163, 184, 0.16); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.4); }
.tier-gold     { background: rgba(245, 158, 11, 0.16); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.4); }
.tier-platinum { background: rgba(56, 189, 248, 0.16); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.tier-diamond  { background: rgba(168, 85, 247, 0.16); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); }
.tier-master   { background: rgba(234, 179, 8, 0.16); color: #eab308; border: 1px solid rgba(234, 179, 8, 0.4); }

/* ── Profile Tier Hero Card ── */
.rank-hero, .tier-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 8%, var(--card-color)), var(--card-color));
}
.rank-hero-icon, .tier-hero-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 2rem;
    background: var(--card-color-alt);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow);
    flex-shrink: 0;
}
.rank-hero-details h3, .tier-hero-details h3 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-color);
}
.rank-target-box, .tier-target-box {
    margin: 14px 0 16px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--card-color-alt);
    border: 1px solid var(--border-color);
    font-size: 0.84rem;
    color: var(--text-color);
    line-height: 1.5;
}

/* ── Study Mastery Ladder Stepper ── */
.rank-ladder, .tier-ladder {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin: 16px 0;
}
.rank-ladder-step, .tier-ladder-step {
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--card-color-alt);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.55;
    transition: all 0.2s;
}
.rank-ladder-step.active, .tier-ladder-step.active {
    opacity: 1;
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, var(--card-color));
    box-shadow: 0 0 12px rgba(187, 134, 252, 0.2);
    transform: translateY(-2px);
}
.rank-ladder-step.unlocked, .tier-ladder-step.unlocked {
    opacity: 0.9;
    border-color: var(--secondary-color);
}
.rank-step-badge, .tier-step-badge {
    font-size: 1.4rem;
}
.rank-step-title, .tier-step-title {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.3;
}
.rank-step-levels, .tier-step-levels {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ── Dashboard Tier Badge ── */
.habit-rank {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 99px;
    background: var(--card-color-alt);
    border: 1px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Header layout on desktop & mobile with desktop navigation support */
#app-header[data-authenticated] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
#app-header[data-authenticated] .header-logo {
    flex-shrink: 0;
    min-width: 0;
}
#app-header[data-authenticated] .header-logo h1 {
    white-space: nowrap;
}
#app-header[data-authenticated] .header-desktop-nav {
    display: none;
}
@media (min-width: 768px) {
    #app-header[data-authenticated] .header-desktop-nav {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-left: 12px;
    }
}
#app-header[data-authenticated] .xp-header {
    margin-left: auto;
    flex-shrink: 0;
}
#app-header[data-authenticated] .header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-end;
}
@media (max-width: 600px) {
    #app-header[data-authenticated] {
        display: grid;
        grid-template-areas: "brand actions" "xp xp";
        grid-template-columns: minmax(0, 1fr) auto;
        height: auto;
        min-height: 54px;
        gap: 6px 8px;
        padding: 6px 8px;
    }
    #app-header[data-authenticated] .header-logo {
        grid-area: brand;
        min-width: 0;
    }
    #app-header[data-authenticated] .xp-header {
        grid-area: xp;
        width: 100%;
        margin-left: 0;
        justify-self: stretch;
        font-size: 0.72rem;
    }
    #app-header[data-authenticated] .header-actions {
        grid-area: actions;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }
}
@media (max-width: 360px) {
    #app-header[data-authenticated] .header-actions { gap: 2px; }
    #app-header[data-authenticated] .hdr-btn { width: 32px; height: 32px; }
    #app-header[data-authenticated] .font-size-controls { height: 32px; }
    #app-header[data-authenticated] .font-size-btn { height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
    .xp-float-particle { animation: none; opacity: 1; }
    .xp-widget-bump { animation: none; }
    .rank-ladder-step.active, .tier-ladder-step.active { transform: none; }
    .combo-counter-pill { animation: none; }
}

/* ── Streak Flame Evolution ── */
.habit-streak.streak-blaze {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.08);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
}
.habit-streak.streak-amethyst {
    color: #c084fc;
    border-color: rgba(192, 132, 252, 0.4);
    background: rgba(192, 132, 252, 0.1);
    box-shadow: 0 0 12px rgba(187, 134, 252, 0.25);
}
.habit-streak.streak-celestial {
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.5);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(168, 85, 247, 0.12));
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
}

/* ── In-Session Combo Counter Pill ── */
.combo-counter-pill {
    position: fixed;
    top: 72px;
    right: 18px;
    z-index: 2500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: combo-bounce 0.35s ease-out;
    pointer-events: none;
}
@keyframes combo-bounce {
    0% { transform: scale(0.6); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Session End Accuracy Ring ── */
.accuracy-dial-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 12px 0 18px;
}
.accuracy-dial-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.accuracy-dial-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}
.accuracy-dial-bar {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}

/* ── Trophy Cabinet & Badges ── */
.trophy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
    padding: 16px;
}
.trophy-card {
    background: var(--card-color-alt);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.trophy-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px var(--shadow);
}
.trophy-card.unlocked.tier-bronze {
    border-color: rgba(205, 127, 50, 0.45);
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.08), var(--card-color-alt));
}
.trophy-card.unlocked.tier-silver {
    border-color: rgba(148, 163, 184, 0.45);
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.08), var(--card-color-alt));
}
.trophy-card.unlocked.tier-gold {
    border-color: rgba(245, 158, 11, 0.45);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.09), var(--card-color-alt));
}
.trophy-card.locked {
    opacity: 0.72;
    border-style: dashed;
}
.trophy-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.trophy-icon-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--card-color);
    border: 1px solid var(--border-color);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.trophy-tier-pip {
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 0.75rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.trophy-title-wrap {
    min-width: 0;
}
.trophy-category {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.trophy-title {
    margin: 1px 0 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.trophy-desc {
    margin: 0 0 10px;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.35;
    flex: 1;
}
.trophy-progress-wrap {
    margin-top: auto;
}
.trophy-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.trophy-status-max {
    color: #f59e0b;
    font-weight: 700;
}
.trophy-progress-track {
    height: 6px;
    border-radius: 999px;
    background: var(--border-color);
    overflow: hidden;
}
.trophy-progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
    background: var(--primary-color);
}
.trophy-progress-bar.tier-fill-gold {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}
.trophy-progress-bar.tier-fill-silver {
    background: linear-gradient(90deg, #94a3b8, #64748b);
}
.trophy-progress-bar.tier-fill-bronze {
    background: linear-gradient(90deg, #cd7f32, #b45309);
}
.trophy-progress-bar.tier-fill-locked {
    background: var(--text-muted);
    opacity: 0.5;
}

