.kuehn-profile-badges {
    margin: 20px 0;
    padding: 10px 0 0;
    border: 0;
}

.kuehn-profile-badges__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.kuehn-profile-badges__header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kuehn-profile-badges__streak {
    white-space: nowrap;
}

.kuehn-profile-badges__list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.kuehn-profile-badge {
    --badge-accent: var(--profile-nav-active, #667eea);
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 10px;
    padding: 14px 12px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--kuehn-site-surface, #ffffff) 90%, transparent);
    border: 1px solid color-mix(in srgb, var(--kuehn-site-border, #d8d8de) 85%, transparent);
    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

.kuehn-profile-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px color-mix(in srgb, var(--kuehn-site-border, #d8d8de) 35%, transparent);
}

.kuehn-profile-badge__icon-wrap {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--badge-accent) 17%, transparent);
    border: 1px solid color-mix(in srgb, var(--badge-accent) 30%, transparent);
}

.kuehn-profile-badge__icon {
    font-size: 2rem;
    line-height: 1;
}

.kuehn-profile-badge__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.kuehn-profile-badge__title {
    font-size: 0.92rem;
    line-height: 1.2;
    font-weight: 700;
    color: var(--kuehn-site-text, #1d2327);
}

.kuehn-profile-badge__meta {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--kuehn-site-muted, #556074);
}

.kuehn-profile-badge.is-locked {
    opacity: 0.38;
    filter: grayscale(0.8) brightness(0.9);
    border-style: dashed;
    background: color-mix(in srgb, var(--kuehn-site-surface, #ffffff) 86%, #8a96af 14%);
}

.kuehn-profile-badge.is-locked .kuehn-profile-badge__icon-wrap {
    background: color-mix(in srgb, var(--badge-accent) 10%, transparent);
}

.kuehn-profile-badge.is-locked:hover {
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.kuehn-profile-badge.is-earned {
    opacity: 1;
    border-color: color-mix(in srgb, var(--badge-accent) 42%, var(--kuehn-site-border, #d8d8de));
}

.kuehn-profile-badges__footer {
    margin-top: 12px;
    font-size: 0.83rem;
    color: var(--kuehn-site-muted, #556074);
}

.kuehn-profile-badge--common {
    --badge-accent: #667eea;
}

.kuehn-profile-badge--rare {
    --badge-accent: #10b981;
}

.kuehn-profile-badge--special {
    --badge-accent: #f59e0b;
}

[data-site-theme-resolved="dark"] .profile-page .kuehn-profile-badge {
    background: linear-gradient(
        160deg,
        color-mix(in srgb, var(--kuehn-site-surface, #1a1f28) 92%, #0d121b 8%) 0%,
        color-mix(in srgb, var(--kuehn-site-surface, #1a1f28) 70%, #05070b 30%) 100%
    );
    border-color: color-mix(in srgb, var(--kuehn-site-border, #2b3340) 88%, transparent);
    box-shadow: none;
}

[data-site-theme-resolved="dark"] .profile-page .kuehn-profile-badge__title {
    color: var(--kuehn-site-text, #e7eaf0);
}

[data-site-theme-resolved="dark"] .profile-page .kuehn-profile-badge__meta,
[data-site-theme-resolved="dark"] .profile-page .kuehn-profile-badges__footer {
    color: var(--kuehn-site-muted, #a1a8b5);
}

[data-site-theme-resolved="dark"] .profile-page .kuehn-profile-badge.is-locked {
    background: linear-gradient(
        160deg,
        color-mix(in srgb, var(--kuehn-site-surface, #1a1f28) 85%, #1c2330 15%) 0%,
        color-mix(in srgb, var(--kuehn-site-surface, #1a1f28) 70%, #0a0f16 30%) 100%
    );
}

@media (max-width: 700px) {
    .kuehn-profile-badges__list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kuehn-profile-badge__icon-wrap {
        width: 52px;
        height: 52px;
        border-radius: 14px;
    }

    .kuehn-profile-badge__icon {
        font-size: 1.75rem;
    }
}

/* ===== Toggle button ===== */

.kuehn-profile-badges__toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--kuehn-site-border, #d8d8de) 80%, transparent);
    background: color-mix(in srgb, var(--kuehn-site-surface, #fff) 90%, transparent);
    color: var(--kuehn-site-muted, #556074);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.kuehn-profile-badges__toggle:hover {
    border-color: var(--profile-nav-active, #667eea);
    color: var(--profile-nav-active, #667eea);
    background: color-mix(in srgb, var(--profile-nav-active, #667eea) 8%, transparent);
}

.kuehn-profile-badges__toggle-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.kuehn-profile-badges:not([data-badges-collapsed]) .kuehn-profile-badges__toggle-icon {
    transform: rotate(180deg);
}

/* ===== Collapsed state: compact icon strip ===== */

.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badges__list {
    grid-template-columns: repeat(auto-fill, 46px);
    gap: 8px;
    max-height: 46px;
    overflow: hidden;
}

.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badge {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
}

.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badge:hover {
    transform: none;
    box-shadow: none;
}

.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badge__content {
    display: none;
}

.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badge__icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: 10px;
}

.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badge__icon {
    font-size: 1.55rem;
}

/* ===== Badge tooltip (JS-created, appended to body) ===== */

.kuehn-badge-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 13px 10px;
    border-radius: 10px;
    background: var(--kuehn-site-surface, #1a1f28);
    border: 1px solid color-mix(in srgb, var(--kuehn-site-border, #2b3340) 80%, transparent);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    max-width: 240px;
    opacity: 0;
    transform: translateY(4px) scale(0.97);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.kuehn-badge-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.kuehn-badge-tooltip__name {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--kuehn-site-text, #e7eaf0);
    line-height: 1.25;
}

.kuehn-badge-tooltip__desc {
    display: block;
    font-size: 0.78rem;
    color: var(--kuehn-site-muted, #a1a8b5);
    line-height: 1.4;
}

.kuehn-badge-tooltip__date {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--profile-nav-active, #667eea);
    padding-top: 2px;
    border-top: 1px solid color-mix(in srgb, var(--kuehn-site-border, #2b3340) 60%, transparent);
    margin-top: 2px;
}

/* Light mode tooltip */
[data-site-theme-resolved="light"] .kuehn-badge-tooltip {
    background: #ffffff;
    border-color: #dde0ee;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

[data-site-theme-resolved="light"] .kuehn-badge-tooltip__name {
    color: #1d2127;
}

[data-site-theme-resolved="light"] .kuehn-badge-tooltip__desc {
    color: #556074;
}

[data-site-theme-resolved="light"] .kuehn-badge-tooltip__date {
    border-top-color: #dde0ee;
}

/* ==========================================================================
   SB10-01 — Rarity Visual Hierarchy
   ========================================================================== */

/* ---- Icon-wrap sizing per rarity ---- */
.kuehn-profile-badge--common .kuehn-profile-badge__icon-wrap {
    width: 54px;
    height: 54px;
}

.kuehn-profile-badge--rare .kuehn-profile-badge__icon-wrap {
    width: 62px;
    height: 62px;
}

.kuehn-profile-badge--special .kuehn-profile-badge__icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: 20px;
}

/* ---- Icon font-size per rarity ---- */
.kuehn-profile-badge--common .kuehn-profile-badge__icon {
    font-size: 1.75rem;
}

.kuehn-profile-badge--rare .kuehn-profile-badge__icon {
    font-size: 2.1rem;
}

.kuehn-profile-badge--special .kuehn-profile-badge__icon {
    font-size: 2.5rem;
}

/* ---- Per-rarity earned: border strength + shadow depth ---- */
.kuehn-profile-badge--common.is-earned {
    box-shadow: 0 2px 10px color-mix(in srgb, var(--badge-accent) 18%, transparent);
}

.kuehn-profile-badge--rare.is-earned {
    border-width: 2px;
    box-shadow: 0 4px 18px color-mix(in srgb, var(--badge-accent) 28%, transparent);
}

.kuehn-profile-badge--special.is-earned {
    border-width: 2px;
    padding: 16px 14px;
    background: linear-gradient(
        145deg,
        color-mix(in srgb, var(--badge-accent) 12%, var(--kuehn-site-surface, #ffffff)) 0%,
        color-mix(in srgb, var(--badge-accent) 5%, var(--kuehn-site-surface, #ffffff)) 100%
    );
    box-shadow:
        0 6px 24px color-mix(in srgb, var(--badge-accent) 32%, transparent),
        inset 0 0 0 1px color-mix(in srgb, var(--badge-accent) 28%, transparent);
}

/* Special icon glow — reduced-motion safe, isolated to icon-wrap to avoid hover conflict */
@media (prefers-reduced-motion: no-preference) {
    .kuehn-profile-badge--special.is-earned .kuehn-profile-badge__icon-wrap {
        animation: kuehn-special-icon-glow 3s ease-in-out infinite alternate;
    }
}

@keyframes kuehn-special-icon-glow {
    from {
        filter: drop-shadow(0 0 0px color-mix(in srgb, var(--badge-accent) 0%, transparent));
    }
    to {
        filter: drop-shadow(0 0 7px color-mix(in srgb, var(--badge-accent) 65%, transparent));
    }
}

/* Dark mode: special badge gradient — profile widget */
[data-site-theme-resolved="dark"] .profile-page .kuehn-profile-badge--special.is-earned {
    background: linear-gradient(
        145deg,
        color-mix(in srgb, var(--badge-accent) 16%, var(--kuehn-site-surface, #1a1f28)) 0%,
        color-mix(in srgb, var(--badge-accent) 7%, var(--kuehn-site-surface, #1a1f28)) 100%
    );
}

/* Dark mode: special badge gradient — achievements catalog page */
[data-site-theme-resolved="dark"] .kuehn-achievements-catalog .kuehn-profile-badge--special.is-earned {
    background: linear-gradient(
        145deg,
        color-mix(in srgb, var(--badge-accent) 16%, var(--kuehn-site-surface, #1a1f28)) 0%,
        color-mix(in srgb, var(--badge-accent) 7%, var(--kuehn-site-surface, #1a1f28)) 100%
    );
}

/* ---- Locked state: opacity bump (was 0.38 — nearly invisible) ---- */
.kuehn-profile-badge.is-locked {
    opacity: 0.55;
}

/* ---- Lock icon overlay: positioned badge bottom-right of icon-wrap ---- */
.kuehn-profile-badge__icon-wrap {
    position: relative;
}

.kuehn-profile-badge.is-locked .kuehn-profile-badge__icon-wrap::after {
    content: '\1F512';
    position: absolute;
    bottom: -5px;
    right: -5px;
    font-size: 0.7rem;
    line-height: 1;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kuehn-site-surface, #ffffff);
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--kuehn-site-border, #e9e9ec) 90%, transparent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

/* Hidden in collapsed strip view */
.kuehn-profile-badges[data-badges-collapsed] .kuehn-profile-badge.is-locked .kuehn-profile-badge__icon-wrap::after {
    display: none;
}

/* Dark mode: lock overlay surface */
[data-site-theme-resolved="dark"] .kuehn-profile-badge.is-locked .kuehn-profile-badge__icon-wrap::after {
    background: var(--kuehn-site-surface, #1a1f28);
    border-color: color-mix(in srgb, var(--kuehn-site-border, #2b3340) 80%, transparent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ---- Mobile: scale down special/rare to stay clean at ≤700px ---- */
@media (max-width: 700px) {
    .kuehn-profile-badge--special .kuehn-profile-badge__icon-wrap {
        width: 58px;
        height: 58px;
        border-radius: 16px;
    }

    .kuehn-profile-badge--special .kuehn-profile-badge__icon {
        font-size: 2rem;
    }

    .kuehn-profile-badge--rare .kuehn-profile-badge__icon-wrap {
        width: 54px;
        height: 54px;
    }

    .kuehn-profile-badge--rare .kuehn-profile-badge__icon {
        font-size: 1.85rem;
    }
}

/* ==========================================================================
   Showcase badge picker (profile settings)
   ========================================================================== */

.kuehn-showcase-picker__list {
    list-style: none;
    margin: var(--space-compact, 16px) 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.kuehn-showcase-picker__badge {
    position: relative;
    cursor: pointer;
    text-align: center;
    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.kuehn-showcase-picker__badge.is-selected {
    border-color: color-mix(in srgb, var(--badge-accent) 65%, var(--kuehn-site-border, #d8d8de));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--badge-accent) 28%, transparent);
}

.kuehn-showcase-picker__check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--badge-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.kuehn-showcase-picker__badge.is-selected .kuehn-showcase-picker__check {
    display: flex;
}

.kuehn-showcase-picker__footer {
    display: flex;
    align-items: center;
    gap: var(--space-compact, 16px);
    margin-top: var(--space-compact, 16px);
    flex-wrap: wrap;
}

.kuehn-showcase-picker__count {
    font-size: 0.875rem;
    color: var(--kuehn-site-muted, #556074);
}

.kuehn-showcase-picker__save {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    background: var(--profile-nav-active, #667eea);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm, 8px);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.kuehn-showcase-picker__save:hover {
    background: color-mix(in srgb, var(--profile-nav-active, #667eea) 83%, #000);
}

.kuehn-showcase-picker__save:disabled {
    opacity: 0.55;
    cursor: default;
}

.kuehn-showcase-picker__status {
    font-size: 0.875rem;
}

.kuehn-showcase-picker__status.is-success {
    color: #10b981;
}

.kuehn-showcase-picker__status.is-error {
    color: #ef4444;
}
