/* Member library — auth + signed-in dashboard */
#libCard,
#libCard * {
    box-sizing: border-box;
}

#libCard {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    transition: max-width 0.2s ease;
}

#libAuth,
#libMain {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

#libCard.lib-auth-mode {
    max-width: 420px;
    text-align: center;
    padding: 36px 28px 32px;
}

#libCard.lib-main-mode {
    max-width: 1180px;
    text-align: left;
    padding: 36px 32px 40px;
}

#libCard.lib-loading-mode {
    max-width: 420px;
    text-align: center;
    padding: 48px 28px 44px;
}

.lib-loading {
    display: none;
}

#libCard.lib-loading-mode .lib-loading {
    display: block;
}

#libCard.lib-loading-mode #libAuth,
#libCard.lib-loading-mode #libMain {
    display: none !important;
}

.lib-loading-inner {
    max-width: 20rem;
    margin: 0 auto;
}

.lib-loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 18px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: lib-spin 0.75s linear infinite;
}

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

.lib-loading-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.lib-loading-msg {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #64748b;
}

/* —— Auth —— */
.lib-auth-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
    font-size: 1.5rem;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.lib-auth-eyebrow {
    margin: 0 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #2563eb;
}

#libAuth h1 {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin: 0 0 10px;
}

.lib-auth-panel .flow-lead {
    margin: 0 auto 22px;
    max-width: 22rem;
    font-size: 0.92rem;
    line-height: 1.55;
}

.lib-auth-form {
    text-align: left;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px 18px 18px;
    margin-bottom: 4px;
}

.lib-auth-form .flow-form-group {
    min-width: 0;
    max-width: 100%;
}

.lib-auth-form .flow-form-group input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.lib-auth-form .flow-form-group:last-of-type {
    margin-bottom: 16px;
}

.lib-auth-form .flow-form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.lib-auth-form .flow-btn-primary {
    width: 100%;
    box-sizing: border-box;
    margin-top: 4px;
}

.lib-auth-switch {
    margin: 16px 0 0;
    padding: 12px 14px;
    font-size: 0.88rem;
    color: #64748b;
    background: #fff;
    border: 1px dashed #e2e8f0;
    border-radius: 10px;
}

.lib-auth-switch button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: #1d4ed8;
    cursor: pointer;
    text-decoration: none;
}

.lib-auth-switch button:hover {
    text-decoration: underline;
}

#libAuth .flow-support {
    margin-top: 18px;
}

#libCard.lib-auth-mode #libErr {
    text-align: center;
    margin-top: 14px;
}

/* —— Signed-in header —— */
.lib-main-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.lib-main-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.lib-signed-in {
    margin: 8px 0 0;
    font-size: 0.88rem;
    color: #64748b;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.lib-signed-in strong {
    color: #334155;
    font-weight: 600;
}

.lib-membership-header-cta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* Membership status badge / tag */
.lib-membership-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    line-height: 1.25;
}

.lib-membership-badge--active {
    padding: 2px 8px;
    border-radius: 6px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.lib-membership-badge--active .lib-membership-badge-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #047857;
}

.lib-membership-badge--inactive {
    flex-wrap: wrap;
    padding: 2px 8px 2px 6px;
    border-radius: 6px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    gap: 5px;
}

.lib-membership-badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #ea580c;
    flex-shrink: 0;
    animation: lib-membership-pulse 2s ease-in-out infinite;
}

@keyframes lib-membership-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

.lib-membership-badge-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: #9a3412;
    white-space: nowrap;
}

.lib-membership-badge--inactive .lib-membership-badge-title {
    font-weight: 600;
}

.lib-membership-badge-tag {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    color: #c2410c;
    padding: 0 5px;
    line-height: 1.35;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(251, 146, 60, 0.35);
    white-space: nowrap;
}

.lib-membership-status.is-active {
    color: #047857;
    font-weight: 600;
}

/* Toggle + CTA */
.lib-membership-toggle {
    appearance: none;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.lib-membership-cta--primary {
    border: none;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(180deg, #ea580c 0%, #c2410c 100%);
    box-shadow: 0 2px 0 #9a3412, 0 4px 14px rgba(234, 88, 12, 0.35);
}

.lib-membership-cta--primary:hover {
    background: linear-gradient(180deg, #f97316 0%, #ea580c 100%);
    box-shadow: 0 2px 0 #9a3412, 0 6px 18px rgba(234, 88, 12, 0.4);
    transform: translateY(-1px);
}

.lib-membership-cta--primary:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #9a3412, 0 2px 8px rgba(234, 88, 12, 0.3);
}

.lib-membership-toggle--secondary {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 999px;
}

.lib-membership-toggle--secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.lib-catalog-loading {
    grid-column: 1 / -1;
    margin: 0;
    padding: 28px 16px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    color: #64748b;
}

.lib-membership-panel {
    overflow: hidden;
    max-height: 2400px;
    opacity: 1;
    transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.25s ease;
}

.lib-membership-panel.is-collapsed,
.lib-membership-panel[hidden] {
    display: none !important;
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

.lib-membership-block--highlight {
    animation: lib-membership-flash 2.4s ease-out;
}

@keyframes lib-membership-flash {
    0% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.45); border-radius: 12px; }
    35% { box-shadow: 0 0 0 6px rgba(234, 88, 12, 0.15); }
    100% { box-shadow: none; }
}

#libLogout {
    padding: 10px 18px;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.lib-membership-block {
    margin: 0 0 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.lib-membership-heading {
    margin-bottom: 2px !important;
}

.lib-membership-hint {
    margin-bottom: 12px !important;
    font-size: 0.8rem !important;
}

.lib-membership-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 20px 24px;
    align-items: start;
}

.lib-membership-perks {
    min-width: 0;
}

.lib-perks-title {
    margin: 0 0 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.lib-perks-list {
    margin: 0;
    padding: 0 0 0 1.15rem;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #374151;
}

.lib-perks-list li + li {
    margin-top: 8px;
}

.lib-perks-list code {
    font-size: 0.85em;
    padding: 1px 4px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #334155;
}

.lib-perks-list a {
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}


.lib-plan-tier {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    height: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(30, 64, 175, 0.14);
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.lib-plan-tier.is-hero {
    border-color: #2563eb;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.12);
}

.lib-plan-tier-main {
    min-width: 0;
}

.lib-plan-tier-name {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.lib-plan-tier-dur {
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.35;
}

.lib-membership-intro-label {
    font-weight: 700;
    color: #c2410c;
}

.lib-plan-tier-pricing {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.lib-plan-tier-list {
    font-size: 0.92rem;
    font-weight: 700;
    color: #64748b;
    line-height: 1.2;
}

.lib-plan-tier-list s {
    color: #475569;
    text-decoration-thickness: 2px;
    text-decoration-color: #94a3b8;
    -webkit-text-decoration-color: #94a3b8;
}

.lib-plan-tier-save {
    font-size: 0.68rem;
    font-weight: 700;
    color: #b45309;
    line-height: 1.3;
}

.lib-plan-tier-price {
    font-size: 1.35rem;
    font-weight: 800;
    color: #047857;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.lib-plan-tier.is-hero .lib-plan-tier-price {
    color: #1d4ed8;
}

.lib-plan-tier-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px !important;
    font-size: 0.82rem !important;
    margin-top: auto;
}

.lib-plans.lib-plans--three {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
    width: 100%;
    align-self: stretch;
}

@media (max-width: 900px) {
    .lib-membership-layout {
        grid-template-columns: 1fr;
    }
    .lib-plans.lib-plans--three {
        grid-template-columns: 1fr;
    }
}

.lib-section-label {
    margin: 28px 0 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7280;
}

.lib-section-label:first-of-type {
    margin-top: 0;
}

.lib-section-title {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
}

.lib-section-hint {
    margin: 0 0 16px;
    font-size: 0.88rem;
    color: #6b7280;
    line-height: 1.5;
}

/* Plans (legacy grid — not used on library stack) */
.lib-plans:not(.lib-plans--three) {
    display: grid;
    gap: 14px;
    margin: 0;
}

@media (min-width: 720px) {
    .lib-plans:not(.lib-plans--three) {
        grid-template-columns: repeat(3, 1fr);
    }
}

.lib-plans--compact {
    gap: 10px;
}

.lib-plans--compact .lib-plan {
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.lib-plans--compact .lib-plan-head {
    padding: 8px 10px;
}

.lib-plans--compact .lib-plan-head h3 {
    font-size: 0.82rem;
}

.lib-plans--compact .lib-plan-body {
    padding: 8px 10px 10px;
}

.lib-plans--compact .lib-price {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.lib-plans--compact .lib-plan-dur {
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.lib-plans--compact .lib-plan .flow-btn {
    padding: 8px 10px;
    font-size: 0.82rem;
}

.lib-plan {
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(30, 64, 175, 0.12);
    background: #fff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.lib-plan.is-hero {
    border-color: #2563eb;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.12);
}

.lib-plan-head {
    padding: 14px 14px 12px;
    background: linear-gradient(145deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
}

.lib-plan.is-hero .lib-plan-head {
    background: linear-gradient(145deg, #1e40af 0%, #3b82f6 100%);
}

.lib-plan-head h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.lib-plan-body {
    padding: 14px 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lib-price {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0 0 4px;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.lib-plan-dur {
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: #64748b;
}

.lib-plan .flow-btn {
    width: 100%;
    box-sizing: border-box;
    margin-top: auto;
    padding: 11px 16px;
    font-size: 0.9rem;
}

/* Filters */
/* Catalog layout: sidebar filters + main grid */
.lib-catalog-layout {
    display: grid;
    grid-template-columns: minmax(200px, 220px) minmax(0, 1fr);
    gap: 20px 24px;
    align-items: start;
    margin-top: 8px;
}

.lib-filter-sidebar {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 120px);
    overflow: auto;
    padding: 14px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.lib-filter-group {
    border: none;
    margin: 0 0 14px;
    padding: 0;
    min-width: 0;
}

.lib-filter-group legend {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    padding: 0;
    margin-bottom: 8px;
}

.lib-filter-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lib-filter-group li + li {
    margin-top: 4px;
}

.lib-filter-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.82rem;
    line-height: 1.35;
    color: #374151;
    cursor: pointer;
}

.lib-filter-check input {
    margin-top: 3px;
    flex-shrink: 0;
}

.lib-filter-clear {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    font-size: 0.82rem;
}

.lib-catalog-main {
    min-width: 0;
}

.lib-download-nudge {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #fdba74;
    background: linear-gradient(135deg, #fffbeb 0%, #fff7ed 100%);
    box-shadow: 0 2px 10px rgba(234, 88, 12, 0.08);
}

.lib-download-nudge[hidden] {
    display: none !important;
}

.lib-download-nudge-text {
    margin: 0;
    flex: 1;
    font-size: 0.84rem;
    line-height: 1.45;
    font-weight: 600;
    color: #9a3412;
}

.lib-download-nudge-dismiss {
    flex-shrink: 0;
    appearance: none;
    border: none;
    background: transparent;
    color: #c2410c;
    font-size: 1.25rem;
    line-height: 1;
    padding: 2px 6px;
    margin: -2px -4px 0 0;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.85;
}

.lib-download-nudge-dismiss:hover {
    opacity: 1;
    background: rgba(234, 88, 12, 0.12);
}

.lib-search-row {
    margin-bottom: 12px;
}

.lib-search-row input[type="search"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 0.92rem;
    font-family: inherit;
    box-sizing: border-box;
    background: #fff;
    color: inherit;
}

.lib-search-row input[type="search"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.lib-catalog-main .results-meta {
    margin: 0 0 10px;
}

.lib-catalog-grid--compact {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    align-items: stretch;
}

.lib-mini-card {
    cursor: default;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.lib-mini-card .tool-card-top {
    flex: 1 1 auto;
    align-items: flex-start;
}

.lib-mini-top {
    align-items: flex-start;
}

.lib-mini-card .tool-logo,
.lib-mini-card .lib-mini-logo-ph {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: cover;
}

.lib-mini-logo-ph {
    background: #e2e8f0;
}

.lib-mini-head {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lib-mini-head .tool-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
    line-height: 1.3;
    margin-bottom: 0;
}

.lib-mini-version {
    min-height: 1.1em;
    margin: 2px 0 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
}

.lib-mini-badges {
    margin-bottom: 6px;
}

.lib-tag-link {
    text-decoration: none;
}

.lib-tag-link:hover {
    filter: brightness(0.95);
}

.lib-symbol-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 22px;
    align-content: flex-start;
}

.lib-symbol-tag {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    line-height: 1.3;
}

.lib-mini-body {
    padding-top: 0 !important;
    margin-top: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    flex-grow: 0;
}

.lib-downloads-block {
    margin-top: 4px;
}

.lib-downloads-block > .lib-section-label {
    margin-top: 28px;
}

.lib-catalog-main > .lib-section-title#libCatalogTitle {
    margin-top: 4px;
}

.lib-catalog-main > .lib-recent-section + #libCatalogTitle {
    margin-top: 0;
}

.lib-section-title--sub {
    font-size: 1.02rem;
    font-weight: 700;
}

.lib-recent-section {
    margin: 0 0 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.lib-recent-hint {
    margin-bottom: 14px !important;
    max-width: 52em;
}

.lib-recent-grid {
    margin-bottom: 0;
}

html[data-theme="dark"] .lib-recent-section {
    border-bottom-color: var(--pft-card-border);
}

.lib-mini-download-wrap {
    margin-top: auto;
    padding-top: 8px;
}

.lib-mini-download-wrap .lib-mini-download {
    width: 100%;
    box-sizing: border-box;
}

.lib-mini-details {
    display: block;
    margin-top: 8px;
    text-align: center;
    font-size: 0.76rem;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
}

.lib-mini-details:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.lib-mini-status {
    margin: 0 0 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #b45309;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-mini-download {
    font-size: 0.78rem !important;
    padding: 7px 8px !important;
}

.lib-mini-download:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lib-tools-empty {
    grid-column: 1 / -1;
    padding: 32px 16px;
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
}

#libCard.lib-main-mode #libErr {
    margin-top: 16px;
}

@media (max-width: 768px) {
    .lib-catalog-layout {
        grid-template-columns: 1fr;
    }
    .lib-filter-sidebar {
        position: static;
        max-height: none;
    }
}

@media (max-width: 480px) {
    #libCard.lib-auth-mode {
        padding: 28px 18px 24px;
    }
    #libCard.lib-main-mode {
        padding: 28px 18px 32px;
    }
    .lib-auth-form {
        padding: 16px 14px 14px;
    }
    .lib-catalog-grid--compact {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

/* —— Dark mode (library page) —— */
html[data-theme="dark"] .lib-loading-title {
    color: var(--pft-heading);
}

html[data-theme="dark"] .lib-loading-msg {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-loading-spinner {
    border-color: rgba(148, 163, 184, 0.35);
    border-top-color: var(--pft-accent);
}

html[data-theme="dark"] #libAuth h1,
html[data-theme="dark"] .lib-main-header h1,
html[data-theme="dark"] .lib-section-title {
    color: var(--pft-heading);
}

html[data-theme="dark"] .lib-auth-eyebrow {
    color: var(--pft-accent);
}

html[data-theme="dark"] .lib-auth-badge {
    background: var(--pft-accent-soft-bg);
    box-shadow: none;
}

html[data-theme="dark"] .lib-auth-form {
    background: var(--pft-card-muted-bg);
    border-color: var(--pft-card-border);
}

html[data-theme="dark"] .lib-auth-form .flow-form-group input:focus {
    border-color: var(--pft-nav-hover);
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.2);
}

html[data-theme="dark"] .lib-auth-switch {
    background: var(--pft-card-bg);
    border-color: var(--pft-card-border);
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-auth-switch button {
    color: var(--pft-link);
}

html[data-theme="dark"] .lib-main-header {
    border-bottom-color: var(--pft-card-border);
}

html[data-theme="dark"] .lib-signed-in {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-signed-in strong {
    color: var(--pft-text);
}

html[data-theme="dark"] .lib-membership-badge--active {
    background: rgba(6, 78, 59, 0.35);
    border-color: rgba(52, 211, 153, 0.35);
}

html[data-theme="dark"] .lib-membership-badge--active .lib-membership-badge-title {
    color: #6ee7b7;
}

html[data-theme="dark"] .lib-membership-badge--inactive {
    background: rgba(124, 45, 18, 0.4);
    border-color: rgba(251, 146, 60, 0.4);
}

html[data-theme="dark"] .lib-membership-badge-title {
    color: #fed7aa;
}

html[data-theme="dark"] .lib-membership-badge-tag {
    color: #ffedd5;
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(251, 146, 60, 0.35);
}

html[data-theme="dark"] .lib-membership-badge-dot {
    background: #fb923c;
}

html[data-theme="dark"] .lib-membership-cta--primary {
    color: #fff;
    box-shadow: 0 2px 0 #7c2d12, 0 4px 14px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .lib-membership-toggle--secondary {
    background: var(--pft-card-bg, #1e293b);
    border-color: var(--pft-card-border, #334155);
    color: var(--pft-text, #f1f5f9);
}

html[data-theme="dark"] .lib-membership-toggle--secondary:hover {
    background: #334155;
}

html[data-theme="dark"] .lib-catalog-loading {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-membership-block {
    border-bottom-color: var(--pft-card-border);
}

html[data-theme="dark"] .lib-section-label,
html[data-theme="dark"] .lib-section-hint,
html[data-theme="dark"] .lib-membership-hint,
html[data-theme="dark"] .lib-plan-dur {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-perks-title {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-perks-list {
    color: var(--pft-text);
}

html[data-theme="dark"] .lib-perks-list code {
    background: var(--pft-card-muted-bg);
    color: var(--pft-muted-2);
}

html[data-theme="dark"] .lib-perks-list a {
    color: var(--pft-link);
}

html[data-theme="dark"] .lib-plan-tier {
    background: var(--pft-card-bg);
    border-color: var(--pft-card-border);
    box-shadow: var(--pft-card-shadow);
}

html[data-theme="dark"] .lib-plan-tier.is-hero {
    border-color: rgba(96, 165, 250, 0.65);
    box-shadow: 0 2px 16px rgba(37, 99, 235, 0.22);
}

html[data-theme="dark"] .lib-plan-tier-name {
    color: var(--pft-heading);
}

html[data-theme="dark"] .lib-plan-tier-price {
    color: #6ee7b7;
}

html[data-theme="dark"] .lib-plan-tier.is-hero .lib-plan-tier-price {
    color: #93c5fd;
}

html[data-theme="dark"] .lib-membership-intro-label {
    color: #fdba74;
}

html[data-theme="dark"] .lib-plan-tier-save {
    color: #fdba74;
}

html[data-theme="dark"] .lib-plan-tier-list {
    color: #94a3b8;
}

html[data-theme="dark"] .lib-plan-tier-list s {
    color: #cbd5e1;
    text-decoration-color: #64748b;
    -webkit-text-decoration-color: #64748b;
}

html[data-theme="dark"] .lib-plan-tier-dur {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-plan {
    background: var(--pft-card-bg);
    border-color: var(--pft-card-border);
    box-shadow: var(--pft-card-shadow);
}

html[data-theme="dark"] .lib-plan.is-hero {
    border-color: rgba(96, 165, 250, 0.65);
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.25);
}

html[data-theme="dark"] .lib-price {
    color: var(--pft-heading);
}

/* Filter sidebar */
html[data-theme="dark"] .lib-filter-sidebar {
    background: var(--pft-filter-bg);
    border-color: var(--pft-filter-border);
    backdrop-filter: blur(8px);
}

html[data-theme="dark"] .lib-filter-group legend {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-filter-check {
    color: var(--pft-chip-text);
}

html[data-theme="dark"] .lib-filter-check input {
    accent-color: var(--pft-accent);
}

html[data-theme="dark"] .lib-filter-clear.flow-btn-secondary {
    background: var(--pft-cta-secondary-bg);
    color: var(--pft-cta-secondary-color);
    border: 1px solid var(--pft-cta-secondary-border);
    box-shadow: none;
}

html[data-theme="dark"] .lib-filter-clear.flow-btn-secondary:hover {
    background: var(--pft-cta-secondary-hover-bg);
}

html[data-theme="dark"] #libLogout.flow-btn-secondary {
    background: var(--pft-cta-secondary-bg);
    color: var(--pft-cta-secondary-color);
    border: 1px solid var(--pft-cta-secondary-border);
    box-shadow: none;
}

html[data-theme="dark"] #libLogout.flow-btn-secondary:hover {
    background: var(--pft-cta-secondary-hover-bg);
}

/* Catalog search + meta */
html[data-theme="dark"] .lib-search-row input[type="search"] {
    background: var(--pft-input-bg);
    border-color: var(--pft-input-border);
    color: var(--pft-input-text);
}

html[data-theme="dark"] .lib-search-row input[type="search"]::placeholder {
    color: var(--pft-muted);
}

html[data-theme="dark"] .lib-search-row input[type="search"]:focus {
    border-color: var(--pft-nav-hover);
    box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.22);
}

html[data-theme="dark"] .lib-catalog-main .results-meta {
    color: var(--pft-muted);
}

/* Tool cards (marketplace compact grid inside library) */
html[data-theme="dark"] #libMain .tool-card {
    background: var(--pft-card-bg);
    border-color: var(--pft-card-border);
    box-shadow: var(--pft-card-shadow);
}

html[data-theme="dark"] #libMain .tool-card:hover {
    border-color: rgba(147, 197, 253, 0.45);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
}

html[data-theme="dark"] #libMain .tool-card-top {
    background: var(--pft-card-top-bg);
    border-bottom-color: var(--pft-card-border);
}

html[data-theme="dark"] #libMain .tool-card .tool-logo,
html[data-theme="dark"] .lib-mini-logo-ph {
    background: var(--pft-card-logo-bg);
    border: 1px solid var(--pft-card-border);
}

html[data-theme="dark"] #libMain .tool-card .tool-name {
    color: var(--pft-card-name);
}

html[data-theme="dark"] #libMain .tool-card .tool-name:hover {
    color: var(--pft-link-hover);
}

html[data-theme="dark"] .lib-mini-version {
    color: var(--pft-muted);
}

html[data-theme="dark"] #libMain .tool-badge--platform {
    background: rgba(37, 99, 235, 0.35);
    color: #bfdbfe;
}

html[data-theme="dark"] #libMain .tool-badge--backtest,
html[data-theme="dark"] #libMain a.tool-badge--backtest.lib-tag-link {
    background: rgba(37, 99, 235, 0.22);
    color: #93c5fd;
    border: 1px solid rgba(147, 197, 253, 0.32);
}

html[data-theme="dark"] #libMain a.tool-badge--backtest.lib-tag-link:hover {
    background: rgba(37, 99, 235, 0.32);
    color: #dbeafe;
}

html[data-theme="dark"] .lib-symbol-tag {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(147, 197, 253, 0.28);
    color: #bfdbfe;
}

html[data-theme="dark"] .lib-download-nudge {
    border-color: rgba(251, 146, 60, 0.45);
    background: linear-gradient(135deg, rgba(124, 45, 18, 0.35) 0%, rgba(69, 26, 3, 0.5) 100%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .lib-download-nudge-text {
    color: #fed7aa;
}

html[data-theme="dark"] .lib-download-nudge-dismiss {
    color: #fdba74;
}

html[data-theme="dark"] .lib-download-nudge-dismiss:hover {
    background: rgba(251, 146, 60, 0.15);
}

html[data-theme="dark"] .lib-mini-details {
    color: var(--pft-link, #93c5fd);
}

html[data-theme="dark"] .lib-mini-status {
    color: var(--pft-gold-accent);
}

html[data-theme="dark"] #libMain .lib-mini-download:disabled {
    opacity: 0.42;
    filter: grayscale(0.15);
}

html[data-theme="dark"] .lib-tools-empty {
    color: var(--pft-muted);
}

html[data-theme="dark"] #libCard.lib-auth-mode #libErr,
html[data-theme="dark"] #libCard.lib-main-mode #libErr {
    color: var(--pft-error);
}
