.hd-favorite-modal[hidden] { display: none; }

body.hd-favorite-modal-open { overflow: hidden; }

.hd-favorite-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 20px;
}

.hd-favorite-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.hd-favorite-dialog {
    position: relative;
    z-index: 1;
    width: min(520px, 100%);
    max-height: min(720px, calc(100vh - 40px));
    overflow: auto;
    padding: 22px;
    border: 1px solid var(--hd-border-strong);
    border-radius: 20px;
    background: #0b1120;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.48);
}

.hd-favorite-dialog-head,
.hd-favorite-dialog-actions,
.hd-favorite-library-head,
.hd-favorite-folder-row,
.hd-favorite-folder-link {
    display: flex;
    align-items: center;
}

.hd-favorite-dialog-head {
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.hd-favorite-dialog-head h2 {
    margin: 0;
    font-size: 21px;
}

.hd-favorite-dialog-close {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--hd-border);
    border-radius: 11px;
    color: var(--hd-text-soft);
    background: rgba(30, 41, 59, 0.55);
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.hd-favorite-dialog-close:hover {
    transform: translateY(-1px);
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(51, 65, 85, 0.72);
}

.hd-favorite-folder-options {
    display: grid;
    gap: 8px;
    max-height: 330px;
    overflow: auto;
    padding-right: 3px;
}

.hd-favorite-folder-option {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    min-height: 62px;
    padding: 10px 13px;
    border: 1px solid var(--hd-border);
    border-radius: 13px;
    background: rgba(15, 23, 42, 0.68);
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.hd-favorite-folder-option:hover {
    transform: translateY(-1px);
    border-color: rgba(34, 211, 238, 0.28);
    background: rgba(30, 41, 59, 0.72);
}

.hd-favorite-folder-option input {
    width: 18px;
    height: 18px;
    accent-color: #22d3ee;
}

.hd-favorite-folder-option-text {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.hd-favorite-folder-option-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--hd-text);
    font-size: 14px;
}

.hd-favorite-folder-option-text small {
    color: var(--hd-muted);
    font-size: 11px;
}

.hd-favorite-folder-checkmark {
    opacity: 0;
    color: #67e8f9;
    font-weight: 900;
}

.hd-favorite-folder-option:has(input:checked) {
    border-color: rgba(34, 211, 238, 0.42);
    background: rgba(34, 211, 238, 0.08);
}

.hd-favorite-folder-option:has(input:checked) .hd-favorite-folder-checkmark {
    opacity: 1;
}

.hd-favorite-quick-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    margin-top: 14px;
}

.hd-favorite-quick-create input {
    width: 100%;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid var(--hd-border);
    outline: none;
    border-radius: 11px;
    color: var(--hd-text);
    background: rgba(15, 23, 42, 0.78);
    font: inherit;
}

.hd-favorite-quick-create input:focus {
    border-color: rgba(34, 211, 238, 0.48);
    box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.06);
}

.hd-favorite-modal-status,
#favorite-page-status {
    min-height: 20px;
    margin-top: 9px;
    color: #94a3b8;
    font-size: 12px;
}

.hd-favorite-modal-status.is-error,
#favorite-page-status.is-error {
    color: #fda4af;
}

.hd-favorite-dialog-actions {
    justify-content: flex-end;
    gap: 9px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--hd-border);
}

.hd-favorite-library {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 20px;
    margin-top: 22px;
}

.hd-favorite-sidebar {
    align-self: start;
    padding: 12px;
    border: 1px solid var(--hd-border);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.48);
}

.hd-favorite-sidebar-title {
    padding: 5px 8px 10px;
    color: var(--hd-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hd-favorite-create-button {
    width: 100%;
    min-height: 44px;
    margin: 0 0 9px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(34, 211, 238, 0.25);
    border-radius: 11px;
    color: #cffafe;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.13), rgba(59, 130, 246, 0.08));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.hd-favorite-create-button:hover {
    transform: translateY(-1px);
    border-color: rgba(34, 211, 238, 0.48);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(59, 130, 246, 0.12));
    box-shadow: 0 10px 24px rgba(8, 145, 178, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hd-favorite-create-button:active {
    transform: translateY(0);
}

.hd-favorite-create-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: rgba(34, 211, 238, 0.12);
}

.hd-favorite-create-icon svg {
    width: 14px;
    height: 14px;
}

.hd-favorite-create-label {
    white-space: nowrap;
    line-height: 1;
}

.hd-favorite-folder-row {
    gap: 5px;
    margin-bottom: 4px;
}

.hd-favorite-folder-link {
    min-width: 0;
    flex: 1;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--hd-text-soft);
    font-size: 13px;
    font-weight: 700;
}

.hd-favorite-folder-link:hover,
.hd-favorite-folder-link.is-active {
    color: var(--hd-text);
    background: rgba(34, 211, 238, 0.08);
}

.hd-favorite-folder-link span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hd-favorite-folder-link small {
    flex: 0 0 auto;
    color: var(--hd-muted);
}

.hd-favorite-folder-tools {
    display: flex;
    gap: 3px;
}

.hd-favorite-icon-button {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--hd-muted);
    background: transparent;
    cursor: pointer;
}

.hd-favorite-icon-button:hover {
    color: var(--hd-text);
    background: rgba(148, 163, 184, 0.09);
}

.hd-favorite-icon-button.is-danger:hover {
    color: #fda4af;
    background: rgba(251, 113, 133, 0.08);
}

.hd-favorite-content {
    min-width: 0;
}

.hd-favorite-library-head {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.hd-favorite-library-head h2 {
    margin: 0;
    font-size: 20px;
}

.hd-favorite-library-head p {
    margin: 5px 0 0;
    color: var(--hd-muted);
    font-size: 12px;
}

.hd-favorite-folder-description {
    max-width: 760px;
    line-height: 1.65;
    color: var(--hd-text-soft) !important;
}

/* Dedicated collection creation modal */
.hd-favorite-create-modal .hd-favorite-modal-backdrop {
    background: rgba(1, 5, 16, 0.82);
}

.hd-favorite-create-dialog {
    width: min(560px, 100%);
    padding: 0;
    overflow: hidden;
    border-color: rgba(103, 232, 249, 0.16);
    border-radius: 24px;
    background:
        radial-gradient(circle at 8% 0%, rgba(34, 211, 238, 0.11), transparent 36%),
        linear-gradient(180deg, #0c1425 0%, #09101e 100%);
    box-shadow: 0 36px 120px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.015) inset;
}

.hd-favorite-create-hero {
    position: relative;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 15px;
    align-items: center;
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.hd-favorite-create-hero-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(103, 232, 249, 0.22);
    border-radius: 17px;
    color: #a5f3fc;
    background: linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(59, 130, 246, 0.08));
    box-shadow: 0 12px 28px rgba(6, 182, 212, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.hd-favorite-create-hero-icon svg {
    width: 29px;
    height: 29px;
}

.hd-favorite-create-hero .hd-eyebrow {
    margin: 0 0 4px;
}

.hd-favorite-create-hero h2 {
    margin: 0;
    color: var(--hd-text);
    font-size: 22px;
    line-height: 1.25;
}

.hd-favorite-create-hero p:last-child {
    margin: 6px 0 0;
    color: var(--hd-muted);
    font-size: 12px;
    line-height: 1.55;
}

.hd-favorite-create-form {
    padding: 22px 24px 24px;
}

.hd-favorite-field {
    display: block;
}

.hd-favorite-field + .hd-favorite-field {
    margin-top: 18px;
}

.hd-favorite-field-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
    color: #dbeafe;
    font-size: 13px;
    font-weight: 800;
}

.hd-favorite-field-label em {
    padding: 2px 6px;
    border-radius: 999px;
    color: #67e8f9;
    background: rgba(34, 211, 238, 0.09);
    font-size: 10px;
    font-style: normal;
    font-weight: 800;
}

.hd-favorite-field-label small {
    color: var(--hd-muted);
    font-size: 11px;
    font-weight: 600;
}

.hd-favorite-input-shell,
.hd-favorite-textarea-shell {
    position: relative;
}

.hd-favorite-input-shell input,
.hd-favorite-textarea-shell textarea {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.18);
    outline: none;
    border-radius: 13px;
    color: var(--hd-text);
    background: rgba(15, 23, 42, 0.74);
    font: inherit;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.hd-favorite-input-shell input {
    height: 48px;
    padding: 0 70px 0 14px;
}

.hd-favorite-textarea-shell textarea {
    min-height: 116px;
    resize: vertical;
    padding: 13px 64px 30px 14px;
    line-height: 1.6;
}

.hd-favorite-input-shell input::placeholder,
.hd-favorite-textarea-shell textarea::placeholder {
    color: #64748b;
}

.hd-favorite-input-shell input:focus,
.hd-favorite-textarea-shell textarea:focus {
    border-color: rgba(34, 211, 238, 0.56);
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.07);
}

.hd-favorite-char-count {
    position: absolute;
    right: 12px;
    bottom: 9px;
    color: #64748b;
    font-size: 10px;
    pointer-events: none;
}

.hd-favorite-input-shell .hd-favorite-char-count {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

.hd-favorite-char-count strong {
    color: #94a3b8;
    font-weight: 700;
}

.hd-favorite-create-actions {
    margin-top: 16px;
    padding-top: 18px;
}

.hd-favorite-action-button {
    min-width: 104px;
    min-height: 42px;
    white-space: nowrap;
}

.hd-favorite-create-submit {
    min-width: 128px;
}

@media (max-width: 820px) {
    .hd-favorite-library {
        grid-template-columns: 1fr;
    }

    .hd-favorite-sidebar {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 8px;
    }

    .hd-favorite-sidebar-title,
    .hd-favorite-folder-tools {
        display: none;
    }

    .hd-favorite-create-button {
        flex: 0 0 auto;
        width: auto;
        min-width: max-content;
        margin: 0;
        padding: 0 13px;
    }

    .hd-favorite-folder-row {
        flex: 0 0 auto;
        margin: 0;
    }

    .hd-favorite-folder-link {
        min-width: max-content;
        border: 1px solid var(--hd-border);
    }
}

@media (max-width: 560px) {
    .hd-favorite-modal {
        align-items: end;
        padding: 0;
    }

    .hd-favorite-dialog {
        width: 100%;
        max-height: 86vh;
        border-radius: 22px 22px 0 0;
        padding: 18px;
    }

    .hd-favorite-create-dialog {
        padding: 0;
        border-radius: 24px 24px 0 0;
    }

    .hd-favorite-folder-options {
        max-height: 42vh;
    }

    .hd-favorite-create-hero {
        grid-template-columns: 48px minmax(0, 1fr) auto;
        gap: 11px;
        padding: 20px 18px 17px;
    }

    .hd-favorite-create-hero-icon {
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }

    .hd-favorite-create-hero-icon svg {
        width: 24px;
        height: 24px;
    }

    .hd-favorite-create-hero h2 {
        font-size: 19px;
    }

    .hd-favorite-create-hero p:last-child {
        display: none;
    }

    .hd-favorite-create-form {
        padding: 18px;
    }

    .hd-favorite-dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .hd-favorite-action-button,
    .hd-favorite-create-submit {
        width: 100%;
        min-width: 0;
    }
}
