.komplex-pack-playlist {
    --kpl-border: var(--wp--preset--color--contrast-2, #3a3f47);
    --kpl-surface: var(--wp--preset--color--base-2, #16191f);
    --kpl-surface-2: var(--wp--preset--color--base, #101217);
    --kpl-text: var(--wp--preset--color--contrast, #f5f7fb);
    --kpl-muted: #9da6b5;
    --kpl-accent: var(--wp--preset--color--primary, #7d5cff);
    color: var(--kpl-text);
    container-type: inline-size;
    width: 100%;
}

.komplex-pack-playlist * { box-sizing: border-box; }
.kpl-layout { display: grid; grid-template-columns: 1fr; align-items: start; gap: 16px; width: 100%; }
.kpl-preview-card,
.kpl-playlist-card { background: var(--kpl-surface); border: 1px solid var(--kpl-border); border-radius: 14px; overflow: hidden; }
.kpl-preview-card { min-width: 0; }
.kpl-playlist-card { min-width: 0; display: flex; flex-direction: column; max-height: none; }
.kpl-preview-header { display: block; padding: 14px 16px; border-bottom: 1px solid var(--kpl-border); }
.kpl-preview-header:has(.kpl-edit-controls[hidden]) { display: none; }

.kpl-section-title { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--kpl-muted); }
.kpl-count { font-size: 13px; color: var(--kpl-muted); margin-top: 2px; }
.kpl-preview-actions { position: absolute; right: 12px; bottom: 12px; z-index: 3; display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; }

.kpl-button {
    appearance: none;
    border: 1px solid var(--kpl-border);
    border-radius: 9px;
    background: var(--kpl-surface-2);
    color: var(--kpl-text);
    height: 42px;
    min-height: 42px;
    padding: 0 13px;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
}
.kpl-button:hover:not(:disabled) { border-color: var(--kpl-accent); }
.kpl-button:disabled { opacity: .5; cursor: not-allowed; }
.kpl-add-button { flex: 0 0 auto; }

.kpl-preview-stage { position: relative; width: 100%; aspect-ratio: 16/9; background: #08090c; overflow: hidden; }
.kpl-preview-playlist-title { position: absolute; top: 12px; left: 14px; z-index: 3; max-width: calc(100% - 28px); color: #fff; opacity: .5; font-size: 14px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,.65); }
.kpl-preview-playlist-title:empty { display: none; }
.kpl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.kpl-no-webgl,
.kpl-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8,9,12,.82); z-index: 2; }
.kpl-loading[hidden],
.kpl-no-webgl[hidden] { display: none; }
.kpl-loading { grid-auto-flow: column; gap: 10px; align-content: center; justify-content: center; }
.kpl-throbber { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); border-top-color: currentColor; animation: kpl-spin .7s linear infinite; }
@keyframes kpl-spin { to { transform: rotate(360deg); } }

.kpl-status { min-height: 38px; padding: 10px 16px; border-top: 1px solid var(--kpl-border); font-size: 13px; color: var(--kpl-muted); }
.kpl-status.is-error { color: #ff8f8f; }
.kpl-error { white-space: pre-wrap; margin: 0; padding: 0 16px 12px; color: #ff8f8f; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.kpl-error:empty { display: none; }

.kpl-edit-controls { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: center; width: 100%; }
.kpl-edit-controls[hidden] { display: none; }
.kpl-edit-meta { display: grid; grid-template-columns: minmax(0, 4fr) minmax(140px, 1fr); gap: 8px; align-items: center; width: 100%; }
.kpl-edit-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; }
.kpl-add-form { display: flex; gap: 8px; align-items: center; width: 100%; }
.kpl-add-form[hidden] { display: none; }
.kpl-add-uuid,
.kpl-playlist-name,
.kpl-playlist-privacy {
    height: 42px;
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--kpl-border);
    border-radius: 9px;
    background: var(--kpl-surface-2);
    color: var(--kpl-text);
    padding: 0 11px;
    font: inherit;
}
.kpl-add-uuid { min-width: 260px; }
.kpl-playlist-name,
.kpl-playlist-privacy { min-width: 0; }
.kpl-playlist-privacy { cursor: pointer; }
.kpl-save-button { white-space: nowrap; }

.kpl-list-status { padding: 12px 16px; color: var(--kpl-muted); }
.kpl-list-status:empty { display: none; }
.kpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 16px; overflow: visible; min-height: 0; }
.kpl-pack { appearance: none; display: block; text-align: left; padding: 0; border: 1px solid var(--kpl-border); border-radius: 12px; background: var(--kpl-surface-2); color: var(--kpl-text); overflow: hidden; cursor: pointer; }
.kpl-pack:hover,
.kpl-pack.is-selected { border-color: var(--kpl-accent); background: var(--kpl-surface-2); box-shadow: 0 0 0 1px var(--kpl-accent); }
.kpl-thumb { aspect-ratio: 16/9; width: 100%; background: #0b0d11; display: grid; place-items: center; overflow: hidden; border-radius: 0; }
.kpl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kpl-thumb-fallback { font-size: 12px; color: var(--kpl-muted); }
.kpl-pack-copy { min-width: 0; padding: 8px 10px; }
.kpl-pack-title { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpl-pack-author { font-size: 12px; color: var(--kpl-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }

.kpl-playlist-footer { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--kpl-border); text-align: right; }
.kpl-playlist-footer .kpl-count { margin-top: 0; white-space: nowrap; }
.kpl-playlist-footer .kpl-section-title { white-space: nowrap; }
.kpl-version { text-align: right; margin-top: 6px; color: var(--kpl-muted); font-size: 11px; padding-right: 4px; }
.kpl-editor-placeholder { border: 1px dashed #777; padding: 18px; }
.kpl-editor-placeholder strong { display: block; margin-bottom: 10px; }

@container (max-width: 700px) {
    .kpl-preview-header { padding: 12px; }
    .kpl-add-form { width: 100%; flex-direction: row; align-items: center; }
    .kpl-add-uuid { min-width: 0; width: 100%; }
    .kpl-grid { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
    .kpl-save-button { width: auto; }
    .kpl-preview-actions { right: 10px; bottom: 10px; }
}

@media (max-width: 700px) {
    .kpl-preview-header { padding: 12px; }
    .kpl-add-form { width: 100%; flex-direction: row; align-items: center; }
    .kpl-add-uuid { min-width: 0; width: 100%; }
    .kpl-grid { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
    .kpl-save-button { width: auto; }
    .kpl-preview-actions { right: 10px; bottom: 10px; }
}

@container (max-width: 520px) {
    .kpl-edit-meta { grid-template-columns: 1fr; }
    .kpl-edit-actions { grid-template-columns: 1fr; }
    .kpl-save-button { width: 100%; }
}

@media (max-width: 520px) {
    .kpl-edit-meta { grid-template-columns: 1fr; }
    .kpl-edit-actions { grid-template-columns: 1fr; }
    .kpl-save-button { width: 100%; }
}

@media (max-width: 460px) {
    .kpl-grid { grid-template-columns: 1fr; }
}
