.lib-table-wrap {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 12rem);
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
}

.library-home .lib-table-wrap {
    max-width: 960px;
    margin: 0 auto;
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
}

.library-home .lib-files {
    overflow: visible;
}

.library-home .lib-title {
    overflow-wrap: break-word;
}

.library-shell .lib-table-wrap {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
}

.lib-table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
    border-collapse: collapse;
    font-size: 0.9rem;
}

/* Files hugs its pills; the title column absorbs the rest. */
.lib-col-title { width: auto; }
.lib-col-files { width: 1%; }

.lib-table th,
.lib-table td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.lib-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-card);
    box-shadow: 0 1px 0 var(--border);
}

.lib-table tbody tr:last-child th,
.lib-table tbody tr:last-child td {
    border-bottom: none;
}

/* The footer link needs the divider the last row gives up. */
.lib-table.has-more tbody tr:last-child th,
.lib-table.has-more tbody tr:last-child td {
    border-bottom: 1px solid var(--border);
}

.lib-table tfoot td {
    padding: 0;
    border-bottom: none;
}

.lib-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
}

.lib-more svg {
    width: 14px;
    height: 14px;
}

.lib-more:hover,
.lib-more:focus-visible {
    background: var(--bg-card-hover);
    color: var(--accent);
}

.lib-table tbody tr.is-gated {
    color: var(--text-muted);
}

.lib-table tbody tr.is-gated .lib-title {
    color: var(--text-primary);
}

.lib-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.lib-table tbody th {
    font-weight: 600;
    color: var(--text-primary);
    padding-right: 0.5rem;
}

.lib-title {
    display: block;
    overflow-wrap: anywhere;
}

.lib-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.lib-cat {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.lib-badge {
    flex-shrink: 0;
    padding: 0.05rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.lib-badge.is-free {
    border-color: var(--border);
    color: var(--text-muted);
}

.lib-badge.is-pro {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.lib-files {
    white-space: nowrap;
    overflow-x: auto;
    padding-left: 0.5rem;
}

.lib-pills {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    align-items: center;
}

.lib-pill {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.28rem 0.5rem 0.28rem 0.38rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
}

.lib-pill svg,
.lib-pill-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.lib-pill-icon {
    border-radius: 3px;
    object-fit: cover;
    background: #111;
}

.lib-pill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 9.25rem;
}

.lib-pills.is-single .lib-pill-name {
    overflow: visible;
    text-overflow: clip;
    max-width: none;
}

.lib-pill.is-link {
    cursor: pointer;
}

.lib-pill.is-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.lib-pill.is-locked {
    cursor: pointer;
    border-style: dashed;
}

.lib-pill.is-locked:hover,
.lib-pill.is-locked:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
}

.lib-pill.is-soon {
    opacity: 0.62;
    cursor: default;
}

.lib-gate {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(26, 26, 26, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

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

.lib-gate-card {
    position: relative;
    width: min(24rem, 100%);
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-dark);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.lib-gate-card h3 {
    padding-right: 2rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.lib-gate-note {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.lib-license {
    width: 100%;
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    letter-spacing: 1px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
}

.lib-license::placeholder {
    color: var(--text-muted);
    letter-spacing: 2px;
}

.lib-license:focus {
    outline: none;
    border-color: var(--accent);
}

.lib-license-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem;
}

.lib-license-preview span {
    font-weight: 600;
    color: var(--text-primary);
}

.lib-license-error {
    min-height: 1.2rem;
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: #dc2626;
}

.lib-gate-unlock {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.lib-gate-unlock:hover {
    background: var(--accent-hover);
}

.lib-gate-unlock:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.lib-gate-buy-wrap {
    margin-top: 1rem;
    text-align: center;
}

.lib-gate-buy-wrap p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.lib-gate-buy {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.lib-gate-buy:hover {
    color: var(--accent);
}

.lib-gate-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
}

.lib-gate-close svg {
    width: 14px;
    height: 14px;
}

.lib-gate-close:hover,
.lib-gate-close:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
}

@media (max-width: 900px) {
    .lib-pill-name {
        max-width: 8rem;
    }
}

@media (max-width: 768px) {
    .lib-table th,
    .lib-table td {
        padding: 0.6rem 0.65rem;
    }

    .lib-pill-name {
        display: none;
    }

    .lib-pill {
        padding: 0.35rem;
    }

    .lib-pills.is-single .lib-pill {
        padding: 0.28rem 0.5rem 0.28rem 0.38rem;
    }

    /* Keep the single-file name readable without starving the title column. */
    .lib-pills.is-single .lib-pill-name {
        display: inline;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 12rem;
    }

    .lib-table-wrap {
        max-height: calc(100dvh - 11rem);
    }

    .library-home .lib-table-wrap {
        max-height: none;
    }

    .library-shell .lib-table-wrap {
        max-height: none;
    }
}

@media (max-width: 480px) {
    .lib-pills.is-single .lib-pill-name {
        max-width: 8.5rem;
    }
}

/* Tightened so the table still fits a 320px phone without scrolling. */
@media (max-width: 360px) {
    .lib-table th,
    .lib-table td {
        padding: 0.6rem 0.4rem;
    }

    .lib-table tbody th {
        padding-right: 0.4rem;
    }

    .lib-files {
        padding-left: 0.4rem;
    }

    .lib-pills {
        gap: 0.25rem;
    }
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 1.5rem;
    align-items: start;
}

.editor-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    padding: 1.25rem;
}

.editor-card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.editor-card p.lede {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.editor-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.editor-field input[type="text"],
.editor-field input[type="url"],
.editor-field input[type="file"],
.editor-field select,
.editor-field textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
}

.editor-field textarea {
    min-height: 6.5rem;
    resize: vertical;
    line-height: 1.45;
}

.editor-toggle {
    display: flex;
    gap: 0.5rem;
}

.editor-toggle button {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

.editor-toggle button.is-active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.editor-submit,
.editor-signout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

.editor-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.editor-signout {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.editor-status {
    min-height: 1.2rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.editor-status.is-error { color: #dc2626; }
.editor-status.is-ok { color: #16a34a; }

.editor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.editor-item:last-child { border-bottom: none; }

.editor-item button {
    flex-shrink: 0;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: #dc2626;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.editor-gate-wrap {
    max-width: 26rem;
    margin: 2rem 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.editor-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1.25rem;
}

.editor-tab {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.editor-tab:hover {
    color: var(--text-primary);
}

.editor-tab.is-active {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: rgba(249, 115, 22, 0.35);
}

.roadmap-item {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}

.roadmap-item:last-child { border-bottom: none; }

.roadmap-item.is-done {
    opacity: 0.62;
}

.roadmap-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.roadmap-item-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.roadmap-item-actions button {
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.roadmap-item-actions .is-danger {
    color: #dc2626;
}

.roadmap-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.2rem;
}

.roadmap-pri {
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid var(--border);
}

.roadmap-pri.is-p1 {
    border-color: #dc2626;
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.roadmap-pri.is-p2 {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.roadmap-body {
    font-size: 0.88rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.roadmap-context {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: pre-wrap;
}

.roadmap-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.5rem 0 0;
}

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

    .editor-gate-wrap {
        margin: 2rem auto;
    }
}
