/* 用户首页收藏栏 */
.top-grid-fav-divider {
    height: 1px;
    margin: 0 6px;
    background: linear-gradient(to right, transparent, #e5e7eb 15%, #e5e7eb 85%, transparent);
}

.top-grid-fav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    padding: 1px 6px 2px;
    white-space: nowrap;
    overflow: visible;
    line-height: normal;
    position: relative;
    z-index: 2;
}

.top-grid-fav .item,
.top-grid-fav .fav-add-btn,
.top-grid-fav .fav-more-wrap {
    width: auto !important;
    flex: 0 0 auto;
    padding: 1px;
    margin: 0;
    line-height: 1;
    vertical-align: middle;
}

.top-grid-fav .item {
    flex-direction: column;
}

.top-grid-fav .item .name {
    display: none;
}

.top-grid-fav .fav-more-wrap .name {
    display: none;
}

.top-grid-fav .fav-empty-row {
    display: flex;
    align-items: center;
    width: 100%;
    flex: 1 1 100%;
}

.top-grid-fav .fav-empty-row .fav-empty-placeholder {
    flex: 1;
    width: auto;
}

.top-grid-fav .fav-add-btn--empty {
    flex-shrink: 0;
    width: 10%;
    min-width: 48px;
}

@media (max-width: 767px) {
    .top-grid-fav .fav-add-btn--empty {
        width: 20%;
    }
}

.top-grid-fav .fav-empty-placeholder {
    display: block;
    width: 100%;
    margin: 0;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.top-grid-fav .fav-empty-placeholder:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.top-grid-fav .fav-item {
    vertical-align: top;
}

.top-grid-fav .fav-item .icon {
    display: inline-block;
    width: 20px;
    height: 20px;
}

.top-grid-fav .fav-item .icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    vertical-align: top;
}

.top-grid-fav .fav-item:hover {
    transform: none;
}

.top-grid-fav .fav-letter-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    overflow: hidden;
    box-sizing: border-box;
    flex-shrink: 0;
}

.top-grid-fav .fav-letter-icon .fav-letter-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.top-grid-fav .fav-letter-icon--multi .fav-letter-text {
    font-size: 9px;
    letter-spacing: -0.4px;
}

.top-grid-fav .fav-add-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px 4px;
    vertical-align: middle;
}

.top-grid-fav .fav-add-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    color: #64748b;
    font-size: 12px;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.top-grid-fav .fav-add-btn:hover .fav-add-icon {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
}

.top-grid-fav .fav-more-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    border: none;
    background: transparent;
    padding: 2px 4px;
    z-index: 5;
}

.top-grid-fav .fav-more-wrap.is-open {
    z-index: 1300;
}

.top-grid-fav .fav-more-wrap--hidden {
    display: none !important;
}

.top-grid-fav .fav-more-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    color: #666;
}

.top-grid-fav .fav-more-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
}

.top-grid-fav .fav-more-btn:hover .fav-more-icon {
    border-color: #3b82f6;
    color: #3b82f6;
}

.top-grid-fav .fav-item.fav-item--overflow {
    display: none !important;
}

.fav-more-dropdown {
    display: none;
    position: fixed;
    min-width: 180px;
    max-width: 260px;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
    z-index: 10100;
    padding: 6px 0;
    pointer-events: auto;
}

.fav-more-dropdown.is-open {
    display: block !important;
}

.fav-more-dropdown a {
    display: block;
    padding: 8px 14px;
    color: #374151;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-more-dropdown a:hover {
    background: #f3f4f6;
    color: #111827;
}

@media (max-width: 360px) {
    .top-grid-fav .fav-item .icon,
    .top-grid-fav .fav-letter-icon,
    .top-grid-fav .fav-add-icon,
    .top-grid-fav .fav-more-icon {
        width: 18px;
        height: 18px;
    }

    .top-grid-fav .fav-letter-icon {
        font-size: 10px;
    }
}

/* 收藏弹窗 */
.fav-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10050;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.fav-modal-overlay.is-open {
    display: flex;
}

.fav-modal {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.fav-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    font-weight: 600;
}

.fav-modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
}

.fav-modal-body {
    padding: 16px 18px 8px;
}

.fav-form-group {
    margin-bottom: 14px;
}

.fav-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.fav-form-group input[type="text"],
.fav-form-group input[type="url"] {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.fav-form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.fav-icon-type-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.fav-icon-type-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}

.fav-icon-type-site-wrap.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fav-icon-type-site-wrap.is-disabled input {
    cursor: not-allowed;
}

.fav-letter-fields {
    display: none;
    margin-top: 10px;
}

.fav-letter-fields.is-visible {
    display: block;
}

.fav-color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.fav-color-preset {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}

.fav-color-preset.is-active {
    border-color: #111827;
    box-shadow: 0 0 0 2px #fff inset;
}

.fav-preview-wrap {
    margin-top: 12px;
    text-align: center;
}

.fav-preview-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.fav-preview-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fav-preview-icon img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
}

.fav-preview-letter {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    box-sizing: border-box;
    padding: 0 2px;
}

.fav-modal-foot {
    display: flex;
    gap: 10px;
    padding: 12px 18px 16px;
}

.fav-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: none;
}

.fav-btn-primary {
    background: #3b82f6;
    color: #fff;
}

.fav-btn-primary:hover {
    background: #2563eb;
}

.fav-btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.fav-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.fav-form-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 6px;
    min-height: 16px;
}

/* site.php 收藏按钮 */
.fav-site-btn {
    margin-top: 8px;
    background: #eab308 !important;
    color: #fff !important;
    border: none;
    cursor: pointer;
}

.fav-site-btn:hover {
    background: #ca8a04 !important;
    color: #fff !important;
}

.fav-site-btn.is-favorited {
    background: #16a34a !important;
}

.fav-site-btn.is-loading {
    opacity: 0.88;
    cursor: wait;
}

.fav-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 10050;
    max-width: min(92vw, 360px);
    padding: 12px 18px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    transform: translate(-50%, 16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.fav-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.fav-toast--error {
    background: rgba(185, 28, 28, 0.94);
}

@media (max-width: 640px) {
    .fav-toast {
        bottom: max(20px, env(safe-area-inset-bottom, 0px));
    }
}

body.dark-mode .top-grid-fav-divider {
    background: linear-gradient(to right, transparent, #374151 15%, #374151 85%, transparent);
}

body.dark-mode .top-grid-fav .fav-empty-placeholder {
    color: #9ca3af;
}

body.dark-mode .top-grid-fav .fav-empty-placeholder:hover {
    background: #374151;
    color: #e5e7eb;
}

body.dark-mode .fav-more-dropdown,
body.dark-mode .fav-modal {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

body.dark-mode .fav-more-dropdown a:hover {
    background: #374151;
}

body.dark-mode .fav-form-group input {
    background: #111827;
    border-color: #4b5563;
    color: #e5e7eb;
}
