/* ─── Collections: shared ─── */
.collections-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.collections-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.collections-head-text {
    min-width: 0;
}

.collections-head h1 {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.collections-lead {
    margin-top: 6px;
    max-width: 640px;
    color: var(--text-secondary);
    font-size: 15px;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.collections-lead:empty {
    display: none;
}

.collections-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.visibility-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    margin-bottom: 10px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.visibility-badge.is-public {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

.collection-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.collection-meta a {
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none;
}

.collection-meta a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ─── Collection cards (my collections) ─── */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.collection-card {
    display: block;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius-md);
}

.collection-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--bg-muted);
    color: var(--text-muted);
    isolation: isolate;
}

.collection-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
    transition: background-color 0.2s var(--ease);
    pointer-events: none;
}

:root[data-theme="dark"] .collection-cover::after {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.collection-card:hover .collection-cover::after {
    background-color: rgba(0, 0, 0, 0.08);
}

.collection-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s var(--ease);
}

.collection-card:hover .collection-cover img {
    transform: scale(1.04);
}

.collection-card-name {
    margin-top: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.collection-card-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.collection-card-meta svg {
    flex-shrink: 0;
}

/* ─── Collection page: image grid ─── */
.collection-images .image-card {
    position: relative;
}

.card-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    background: rgba(9, 9, 11, 0.6);
    color: #fff;
    opacity: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.15s var(--ease), background 0.15s var(--ease);
}

.image-card:hover .card-remove-btn,
.card-remove-btn:focus-visible {
    opacity: 1;
}

.card-remove-btn:hover {
    background: var(--danger);
}

@media (hover: none) {
    .card-remove-btn {
        opacity: 1;
    }
}

/* ─── Empty / error states ─── */
.state-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 420px;
    margin: 48px auto 0;
    padding: 40px 24px;
    text-align: center;
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-lg);
}

.state-panel svg {
    color: var(--text-muted);
}

.state-title {
    margin-top: 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.state-text {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.state-panel .btn-primary,
.state-panel .btn-secondary {
    margin-top: 18px;
    text-decoration: none;
}

.page-loader {
    display: flex;
    justify-content: center;
    padding: 80px 0;
}

/* ─── Forms (create / edit dialog) ─── */
.form-field {
    display: block;
}

.form-field + .form-field {
    margin-top: 14px;
}

.form-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-counter {
    color: var(--text-muted);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.text-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.text-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea.text-input {
    min-height: 80px;
    resize: vertical;
}

.button-group-split {
    justify-content: space-between;
}

.button-group-split > div {
    display: flex;
    gap: 8px;
}

.btn-danger-text {
    padding-left: 10px;
    padding-right: 10px;
    background: transparent;
    color: var(--danger);
}

.btn-danger-text:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 300;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: var(--text-primary);
    color: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    transform: translateX(-50%);
    animation: dropIn 0.15s var(--ease);
}

@media (max-width: 640px) {
    .collections-main {
        padding: 24px 12px 56px;
    }

    .collections-head {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        margin-bottom: 20px;
    }

    .collections-head h1 {
        font-size: 24px;
    }

    .collections-actions > * {
        flex: 1;
        justify-content: center;
        padding-left: 10px;
        padding-right: 10px;
        white-space: nowrap;
    }

    .collection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px 10px;
    }

    .button-group-split {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .button-group-split > div button {
        flex: 1;
    }
}

a.btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
}
