/* ==========================================================================
   PRIMARY HEADER - ULTRA COMPACT 2-ROW DESIGN
   ========================================================================== */

:root {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.5);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(15, 23, 42, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #f43f5e;
    --success: #10b981;
    --accent-gold: #fbbf24;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-dark);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(251, 191, 36, 0.03) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    padding: 0 20px 40px 20px;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

header {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.96);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 6px 20px;
    gap: 4px;
    /* Tight gap between main row and category row */
}

.header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    min-height: 48px;
    gap: 15px;
}

/* Branding & Title Combined */
.header-left {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    min-width: 200px;
}

.brand-stack {
    display: flex;
    flex-direction: column;
}

.brand-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
}

.app-main-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--primary);
    opacity: 0.9;
    white-space: nowrap;
}

.brand-slogan {
    font-size: 0.55rem;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: -2px;
    opacity: 0.7;
}

/* Search Bar: Now in Center of Main Row */
.header-center {
    flex: 1;
    max-width: 500px;
    display: flex;
    align-items: center;
}

.search-and-add {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

/* Category Row: Row 2 */
.category-row {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Breadcrumbs --- */
.breadcrumb-row {
    display: flex !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 5px 0 !important;
    padding: 0 5px !important;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb-item {
    cursor: pointer;
    transition: all 0.2s;
    -webkit-user-select: none;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.breadcrumb-item:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.breadcrumb-item.active {
    color: var(--primary);
    font-weight: 600;
}

.breadcrumb-separator {
    opacity: 0.4;
    font-size: 0.8rem;
}

/* Branding & Title Combined */
.header-left {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    min-width: 200px;
}

.header-right {
    display: flex;
    align-items: center;
    min-width: 250px;
    justify-content: flex-end;
}


@media (max-width: 1100px) {
    .header-left {
        min-width: auto;
    }

    .app-main-title {
        display: none;
    }
}

@media (max-width: 850px) {
    .header-center {
        display: none;
    }

    .header-left {
        flex: 1;
    }
}

/* Mobile Header Optimization (v2.9.2) */
@media (max-width: 480px) {
    header {
        padding: 4px 10px;
    }

    .header-main {
        min-height: 40px;
        gap: 8px;
    }

    .nav-icon-btn,
    .main-add-btn {
        width: 34px;
        height: 34px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .header-right {
        gap: 6px;
        min-width: auto;
    }

    .tool-actions,
    .user-actions {
        gap: 4px;
    }

    .v-divider {
        margin: 0 2px;
        height: 20px;
    }

    .lang-select {
        padding: 2px 4px;
        font-size: 0.75rem;
        max-width: 60px;
        /* Force compact */
    }

    .brand-name {
        font-size: 1.1rem;
    }

    .user-profile-box {
        top: 42px;
        right: 5px;
        width: 200px;
    }
}

.modal-overlay {
    z-index: 10000;
}



.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.brand-slogan {
    font-size: 0.55rem;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 1px;
    opacity: 0.8;
}

.bookmarklet-minimal-row {
    display: flex;
    gap: 6px;
    width: 100%;
    max-width: 1400px;
    justify-content: center;
    padding: 2px 0;
}

.mini-pill {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.mini-pill:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.mini-pill.launch {
    color: var(--accent-gold);
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 16px 10px 42px;
    border-radius: 12px;
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.25s;
}

.search-input-wrapper input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 0.95rem;
}

.main-add-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.main-add-btn:hover {
    transform: translateY(-2px) rotate(90deg);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.main-add-btn .plus-icon {
    font-size: 1.8rem;
    font-weight: 300;
}

.bookmarklet-pills {
    display: flex;
    gap: 12px;
}

.pill-btn {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 3px 12px;
    border-radius: 20px;
    transition: all 0.2s;
    white-space: nowrap;
}

.pill-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.pill-btn.launch {
    color: var(--accent-gold);
}

/* --- Right: Tools & Profile --- */
.header-right {
    flex: 0 0 auto;
    gap: 15px;
}

.tool-actions,
.user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.v-divider {
    width: 1px;
    height: 30px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 5px;
}

.nav-icon-btn {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-icon-btn.diamond:hover {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.3);
}

.nav-icon-btn.help:hover {
    color: #818cf8;
    border-color: rgba(129, 140, 248, 0.3);
}

.nav-icon-btn.check:hover {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.nav-icon-btn.status:hover {
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.3);
}

.status-card {
    max-width: 400px;
}

.status-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.status-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.status-value {
    font-size: 0.9rem;
    font-weight: 600;
}

.status-value.online {
    color: var(--success);
}

.status-value.offline {
    color: var(--danger);
}

.status-value.warning {
    color: var(--accent-gold);
}

.premium-select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}

/* Auth Section */
.auth-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.user-profile-box {
    position: absolute;
    top: 50px;
    right: 0;
    background: rgba(30, 41, 59, 0.95);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 5000;
    transform-origin: top right;
    animation: dropdownSlide 0.2s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Profile Content */
.user-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.email-text {
    font-size: 0.85rem;
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-badge-premium {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    padding: 3px 8px;
    border-radius: 6px;
    width: fit-content;
}

.user-badge-premium.admin {
    color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.15);
}

.logout-action {
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 8px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-action:hover {
    background: var(--danger);
    color: white;
}

/* Unified PWA Install Banner - Floating Style */
.install-banner {
    position: fixed;
    top: 70px;
    right: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
    padding: 10px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 5001;
    /* Higher than header, lower than profile dropdown */
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    animation: slideInRight 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 350px;
}

.install-banner.hidden {
    display: none;
}

.banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Changed from center */
    gap: 15px;
    flex-wrap: wrap;
}

.banner-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    /* white-space: nowrap; */
    /* Prevent text wrapping */
    flex: 1;
    /* Allow text to take available space */
}

.install-btn {
    background: white;
    color: var(--primary);
    border: none;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    /* Prevent button text wrapping */
    flex-shrink: 0;
    /* Prevent button shrinking */
}

.install-btn:hover {
    transform: scale(1.05);
    background: #f8fafc;
}

.close-banner-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

/* Install Guide */
.install-guide-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.guide-step {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    text-align: left;
}

.step-num {
    background: var(--primary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

/* Responsive Scaling */
@media (max-width: 1200px) {
    header {
        padding: 0 20px;
    }

    .header-main {
        gap: 20px;
    }

    .brand-slogan {
        display: none;
    }
}

/* Support for hidden text on buttons */
.nav-icon-btn .btn-text {
    display: none;
}

/* End Header Design */



/* Pricing Modal Specifics */
.pricing-card {
    max-width: 1100px;
    padding: 40px;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.plan-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
}

.plan-item.featured {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.plan-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.05em;
}

.plan-item.featured .plan-badge {
    background: var(--primary);
    color: white;
}

.plan-item h3 {
    font-size: 1.25rem;
    margin-bottom: 10px;
}

.plan-price {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
}

.plan-price span {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

.plan-item ul {
    list-style: none;
    margin-bottom: 30px;
    flex-grow: 1;
}

.plan-item li {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.plan-item li::before {
    content: '✓';
    color: var(--success);
    font-weight: bold;
}

.plan-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--glass-bg);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.plan-btn.primary {
    background: var(--primary);
    border: none;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.plan-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.plan-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
}

.lang-select {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.lang-select:hover {
    border-color: var(--primary);
}

.lang-select option {
    background: var(--bg-dark);
    color: var(--text-main);
}


.bookmarklet-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.compact-bookmarklet {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--card-border);
    cursor: grab;
    transition: all 0.2s;
    white-space: nowrap;
}

.compact-bookmarklet:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.compact-bookmarklet.main-link {
    color: var(--accent-gold);
    border-color: rgba(251, 191, 36, 0.2);
}

.compact-bookmarklet.main-link:hover {
    background: rgba(251, 191, 36, 0.08);
    border-color: var(--accent-gold);
}

.toolbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input-wrapper input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 16px;
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.add-btn-main {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.add-btn-main:hover {
    transform: scale(1.1) rotate(90deg);
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}



.category-filters::-webkit-scrollbar {
    display: none;
}

.filters-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Removed redundant gradient overlays for cleaner look */

.category-filters {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* IE and Edge */
    cursor: grab;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.category-filters:active {
    cursor: grabbing;
}

.manage-btn {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    z-index: 5;
}

.manage-btn:hover {
    background: var(--card-border);
    transform: rotate(45deg);
}

.category-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 5;
}

.toggle-btn {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.logout-pill {
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.logout-pill:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

.icon-btn.gold {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--accent-gold);
}

.icon-btn.gold:hover {
    background: var(--accent-gold);
    color: #000;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

/* Category Tree Panel */
.category-tree-panel {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    margin-top: 12px;
    padding: 16px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    animation: fadeInDown 0.3s ease-out;
}

.category-tree-panel.hidden {
    display: none;
}

.tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}

.tree-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.category-tree {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 8px;
}

.tree-node {
    margin-bottom: 4px;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    gap: 8px;
}

.tree-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tree-item.active {
    background: var(--primary);
    color: white;
}

.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-label {
    font-size: 0.85rem;
}

.tree-count {
    font-size: 0.7rem;
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.15);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: normal;
}

.tree-link {
    opacity: 0.8;
}

.tree-link:hover {
    color: var(--primary);
}

.tree-link .tree-label {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-children {
    margin-left: 18px;
    border-left: 1px solid var(--card-border);
    padding-left: 4px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.tree-children.collapsed {
    max-height: 0;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.manage-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
    padding-right: 5px;
}

.manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: default;
    transition: all 0.2s;
}

.manage-item.dragging {
    opacity: 0.4;
    border: 1px dashed var(--primary);
}

.manage-item.drag-over {
    border-top: 2px solid var(--primary);
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding-right: 10px;
    font-size: 1.2rem;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.manage-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.manage-item-name {
    font-weight: 500;
}

.manage-item-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.manage-actions {
    display: flex;
    gap: 5px;
}

.sort-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.sort-btn:hover {
    border-color: var(--primary);
    color: white;
}

.sort-btn.pin {
    color: #fbbf24;
}

.sort-btn.delete-cat:hover {
    border-color: var(--danger);
}

.modal-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.filter-tab {
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    position: relative;
    /* For dropdown */
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.filter-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Category Dropdown Menu */
.category-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 220px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    margin-top: 5px;
    display: none;
    /* Initially hidden */
}

/* Show dropdown on hover */
.filter-tab:hover .category-dropdown {
    display: block;
    animation: fadeInDown 0.2s ease-out;
}

.dropdown-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.dropdown-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.dropdown-link .link-icon {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.dropdown-action {
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--accent-gold);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.dropdown-action:hover {
    background: rgba(251, 191, 36, 0.1);
    color: white;
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 12px;
}

.filter-count {
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1px 6px;
    border-radius: 10px;
    opacity: 0.8;
}

.filter-tab.dragging-tab {
    opacity: 0.5;
    border: 1px dashed var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.filter-tab.drop-target-left {
    border-left: 4px solid var(--primary);
    transform: translateX(2px);
}

.filter-tab.drop-target-right {
    border-right: 4px solid var(--primary);
    transform: translateX(-2px);
}

.filter-tab.drag-over-center {
    background: rgba(99, 102, 241, 0.3) !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    transform: scale(1.05);
}

.filter-tab.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
    opacity: 1;
}

.link-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    padding: 10px 0 60px 0;
}

@media (max-width: 768px) {
    .link-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.link-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.link-card:hover {
    transform: translateY(-4px);
    background: rgba(45, 55, 72, 0.6);
    border-color: var(--primary);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.link-card.is-pinned {
    border-color: rgba(234, 179, 8, 0.4);
    background: rgba(234, 179, 8, 0.03);
}

.link-card.is-read {
    opacity: 0.75;
    background: rgba(255, 255, 255, 0.03);
}

.link-card.drop-target {
    border-top: 4px solid var(--primary);
    transform: translateY(4px);
}

.link-grid.global-drop-target {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 20px;
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.1);
}

.tree-item.drop-target {
    border-top: 2px solid var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.link-card:active {
    background: rgba(255, 255, 255, 0.08);
}

.link-info {
    width: 100%;
    margin-top: 10px;
}

.link-pin {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.3;
    transition: all 0.2s;
    filter: grayscale(1);
    z-index: 10;
}

.link-pin.active {
    opacity: 1;
    filter: none;
    transform: rotate(-15deg);
}

.link-pin:hover {
    opacity: 0.6;
    transform: scale(1.2);
}

.link-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-url {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-category-tag {
    display: inline-block;
    font-size: 0.7rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 6px;
}

.link-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.status-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.status-badge.unread {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--card-border);
}

.status-badge.read {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge:hover {
    transform: scale(1.05);
}

.status-badge.unread:hover {
    background: rgba(148, 163, 184, 0.2);
}

.status-badge.read:hover {
    background: rgba(16, 185, 129, 0.25);
}

.link-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
    justify-content: flex-end;
}

.action-btn {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn.open:hover {
    color: var(--success);
    border-color: var(--success);
}

.action-btn.edit:hover {
    color: var(--primary);
}

.action-btn.delete:hover {
    color: var(--danger);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 99999;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    position: relative;
    background: #1e293b;
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 32px;
    border: 1px solid var(--card-border);
    animation: slideUp 0.3s ease-out;
    scrollbar-width: thin;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    z-index: 10;
}

.close-btn:hover {
    color: white;
    transform: scale(1.1);
}

.help-card {
    max-width: 800px;
}

.modal-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 1.5rem;
    color: var(--text-main);
}

.help-content {
    display: grid;
    gap: 32px;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .help-content {
        grid-template-columns: 1fr 1fr;
    }
}

.help-content section h3 {
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 1.1rem;
}

.help-content ul {
    padding-left: 18px;
}

.help-content li {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-card h2 {
    margin-bottom: 20px;
    font-weight: 600;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: white;
    outline: none;
}

.forgot-password-container {
    text-align: right;
    margin-top: 8px;
}

#forgot-password-link {
    color: var(--primary);
    font-size: 0.8rem;
    text-decoration: none;
    transition: opacity 0.2s;
    cursor: pointer;
}

#forgot-password-link:hover {
    opacity: 0.8;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.secondary-btn {
    background: var(--glass-bg);
    color: var(--text-main);
    border: 1px solid var(--card-border);
}

/* 連結健康檢查標籤 */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
    font-weight: 600;
}

.health-badge.loading {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.health-badge.valid {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.health-badge.invalid {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.health-badge.loading::after {
    content: "...";
    animation: blink 1.5s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* Export/Import Selection List */
.export-import-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 20px 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.selection-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-user-select: none;
    user-select: none;
}

.selection-header {
    border-bottom: 1px solid var(--card-border);
    margin: 0 -8px 0 -8px;
    padding: 0 8px 8px 8px;
}

.all-selector {
    background: rgba(99, 102, 241, 0.1);
    border: 1px dashed var(--primary);
    margin-bottom: 8px;
}

.all-selector span {
    font-weight: 600;
    color: var(--primary);
}

.selection-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.selection-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.selection-item label {
    flex-grow: 1;
    cursor: pointer;
    font-size: 0.95rem;
}

/* Selection Bar (Floating) */
.selection-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(15, 23, 42, 0.9);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--primary);
    padding: 12px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    pointer-events: none;
}

.selection-bar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.selection-info {
    font-size: 0.95rem;
    color: var(--text-main);
}

.selection-info strong {
    color: var(--primary);
    font-size: 1.1rem;
    margin: 0 4px;
}

.selection-btn {
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.selection-btn:hover {
    background: var(--danger);
    color: white;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, 20px);
    pointer-events: none;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

/* 按鈕文字懸停展開效果 */
.btn-text {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

button:hover .btn-text {
    max-width: 150px;
    opacity: 1;
    margin-left: 8px;
}

.icon-btn.mini:hover .btn-text {
    margin-left: 5px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

button:hover .btn-icon {
    transform: scale(1.1);
}

.spinning {
    animation: rotate 1s linear infinite;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-auth-section {
    display: flex;
    align-items: center;
    padding-left: 12px;
    border-left: 1px solid var(--card-border);
    height: 36px;
}

.user-badge.premium {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.user-badge.admin {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.user-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
}

#user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-badge {
    background: var(--primary);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.mini-text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    margin-left: 4px;
}

.mini-text-btn:hover {
    color: var(--danger);
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--primary);
    color: white;
}

.auth-card {
    max-width: 400px;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Install Guide Modal */
.guide-section {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: left;
}

.guide-section h3 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.guide-section ol {
    padding-left: 20px;
    color: var(--text-muted);
}

.guide-section li {
    margin-bottom: 5px;
}

/* Duplicated PWA styles removed - using Unified Floating Banner above */
@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .install-banner {
        top: auto;
        bottom: 20px;
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    opacity: 0.8;
}