/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0e0e12;
    --surface:     #18181f;
    --surface2:    #1f1f2a;
    --border:      #2a2a38;
    --accent:      #7c6ff7;
    --accent-soft: #9d95f8;
    --accent-glow: rgba(124, 111, 247, 0.25);
    --green:       #4ade80;
    --text:        #e8e8f0;
    --text-muted:  #7a7a9a;
    --text-dim:    #4a4a6a;
    --radius:      14px;
    --radius-sm:   8px;
    --radius-lg:   20px;
    --shadow:      0 4px 24px rgba(0,0,0,0.5);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.4);
    --font:        'Nunito', system-ui, sans-serif;
    --transition:  0.18s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

img { display: block; max-width: 100%; }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(14, 14, 18, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.logo-icon { width: 32px; height: 32px; }
.logo-text {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.3px;
}

.header-nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition), background var(--transition);
}
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-link.active { color: var(--accent-soft); background: rgba(124,111,247,0.12); }

/* ─── Main Layout ───────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px 60px;
}

/* ─── Hero ──────────────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 56px 0 40px;
}

.hero-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 900;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--accent-soft) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 520px;
    margin: 0 auto 32px;
}

/* ─── Search ────────────────────────────────────────────────────────────────── */
.search-wrap { max-width: 560px; margin: 0 auto; }

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-dim);
    pointer-events: none;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 12px 12px 12px 42px;
}
.search-input::placeholder { color: var(--text-dim); }

.search-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 20px;
    font-family: var(--font);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition);
    margin: 4px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.search-btn:hover { background: var(--accent-soft); }

/* ─── Filters ───────────────────────────────────────────────────────────────── */
.filters-row {
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}
.filters-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 0;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sort-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.sort-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.sort-tab:hover { color: var(--text); }
.sort-tab.active {
    background: var(--accent);
    color: #fff;
}

/* Toggle */
.clothes-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-left: auto;
}
.clothes-filter input { display: none; }

.toggle-track {
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}
.clothes-filter input:checked + .toggle-track { background: var(--accent); }

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}
.clothes-filter input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

.toggle-label { font-size: 0.875rem; font-weight: 600; color: var(--text-muted); }

/* ─── Mii Grid ──────────────────────────────────────────────────────────────── */
.mii-grid-section { padding-bottom: 40px; }

.mii-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

/* ─── Mii Card ──────────────────────────────────────────────────────────────── */
.mii-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
}
.mii-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 8px 28px var(--accent-glow);
    text-decoration: none;
}

.card-image-wrap {
    position: relative;
    aspect-ratio: 1;
    background: var(--surface2);
    overflow: hidden;
}

.card-mii-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.mii-card:hover .card-mii-img { transform: scale(1.04); }

.card-clothes-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.card-body {
    padding: 10px 12px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-name {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-author {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.card-likes {
    font-size: 0.78rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-date {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ─── States ────────────────────────────────────────────────────────────────── */
.loading-state,
.empty-state,
.error-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}
.spinner-lg { width: 52px; height: 52px; border-width: 4px; }

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

.hidden { display: none !important; }

/* ─── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.page-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font);
    font-weight: 700;
    font-size: 0.875rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-soft); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ─── Mii Detail Page ───────────────────────────────────────────────────────── */
.mii-detail-main { padding-top: 28px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 28px;
    text-decoration: none;
    transition: color var(--transition);
}
.back-link:hover { color: var(--text); text-decoration: none; }

.mii-detail-loading {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.detail-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 40px;
    align-items: start;
}

/* ─── Detail Images Panel ───────────────────────────────────────────────────── */
.detail-images { display: flex; flex-direction: column; gap: 16px; }

.main-image-wrap {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 1;
}

.main-mii-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(14,14,18,0.75);
    backdrop-filter: blur(8px);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid var(--border);
}

.outfit-images {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.outfit-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.outfit-image-wrap {
    position: relative;
    aspect-ratio: 1;
    background: var(--surface2);
}

.outfit-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.outfit-label-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}

.outfit-number {
    background: var(--accent);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 900;
    flex-shrink: 0;
}

.outfit-label-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.outfit-desc-inline {
    padding: 10px 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    line-height: 1.5;
}

/* ─── Detail Info Panel ─────────────────────────────────────────────────────── */
.detail-info { display: flex; flex-direction: column; gap: 20px; }

.detail-name {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 900;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.detail-meta { display: flex; flex-direction: column; gap: 8px; }

.meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}
.meta-icon { font-size: 1rem; }
.meta-value { color: var(--text-muted); }

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: rgba(124,111,247,0.12);
    border: 1px solid rgba(124,111,247,0.3);
    color: var(--accent-soft);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
}

.section-heading {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-description {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Internal links styled */
.detail-description a { color: var(--accent-soft); }
.detail-description a:hover { text-decoration: underline; }

/* Outfit instructions */
.outfit-instructions {
    background: linear-gradient(135deg, rgba(124,111,247,0.08), rgba(124,111,247,0.03));
    border: 1px solid rgba(124,111,247,0.25);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.outfit-intro {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.outfit-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.outfit-list-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.outfit-list-num {
    background: var(--accent);
    color: #fff;
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 900;
    flex-shrink: 0;
    margin-top: 1px;
}

.outfit-list-text {
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.5;
}
.outfit-list-text strong { color: var(--accent-soft); }

/* Related Miis */
.related-miis { }

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.related-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition);
}
.related-card:hover { border-color: var(--accent); text-decoration: none; }

.related-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--surface2);
}

.related-name {
    padding: 6px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Actions */
.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 11px 22px;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-soft);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent-soft);
}

.btn-download { font-size: 0.95rem; padding: 13px 26px; }

.sharemii-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.5;
}

/* Error card */
.error-card {
    text-align: center;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.error-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}

/* ─── About Page ────────────────────────────────────────────────────────────── */
.about-main { padding-top: 40px; }

.about-card {
    max-width: 700px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.about-card h1 {
    font-size: 1.8rem;
    font-weight: 900;
}
.about-card h2 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent-soft);
    margin-top: 4px;
}
.about-card p, .about-card li {
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.7;
}
.about-card ul {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.about-card strong { color: var(--text); }
.about-card code {
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent-soft);
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 20px 24px;
    font-size: 0.8rem;
    color: var(--text-dim);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent-soft); }

/* ─── Logo SVG fallback ─────────────────────────────────────────────────────── */
.logo-icon-fallback {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #b06ef5);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
    .detail-images {
        max-width: 380px;
        margin: 0 auto;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .main-content { padding: 0 14px 48px; }
    .hero { padding: 32px 0 28px; }
    .mii-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .filters-inner { gap: 10px; }
    .clothes-filter { margin-left: 0; }
    .about-card { padding: 24px 20px; }
    .detail-actions { flex-direction: column; }
    .btn-download { width: 100%; justify-content: center; }
}
