:root {
    --csm-brown: #6b4226;
    --csm-brown-dark: #4a2d1a;
    --csm-brown-soft: #8b5a36;
    --csm-cranberry: #a33d4a;
    --csm-cranberry-dark: #8b2d3a;
    --csm-cranberry-deep: #6b1d2a;
    --csm-cranberry-soft: #b84d5a;
    --csm-border: #e5e7eb;
    --csm-border-strong: #d1d5db;
    --csm-text: #374151;
    --csm-text-muted: #6b7280;
    --csm-bg-soft: #f9f7f5;
}

.csm-muse-wrap {
    margin: 0 0 24px 0;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.csm-muse-panel {
    background: #fff;
    border: 1px solid var(--csm-border);
    border-radius: 12px;
    padding: 16px;
}

.csm-muse-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.csm-muse-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.csm-muse-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.csm-muse-prompt {
    width: 100%;
    min-height: 44px;
    padding: 12px 56px 12px 14px;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    color: var(--csm-text);
    background: #fff;
    border: 1px solid var(--csm-border-strong);
    border-radius: 10px;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.csm-muse-prompt:focus {
    outline: none;
    border-color: var(--csm-cranberry);
    box-shadow: 0 0 0 3px rgba(163, 61, 74, 0.12);
}

.csm-muse-prompt::placeholder {
    color: #9ca3af;
}

.csm-muse-counter {
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-size: 10px;
    font-weight: 500;
    color: #9ca3af;
    pointer-events: none;
    background: #fff;
    padding: 1px 4px;
}

.csm-muse-counter.is-near-limit {
    color: #c4634a;
    font-weight: 600;
}

.csm-muse-submit {
    flex-shrink: 0;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--csm-cranberry-dark) 0%, var(--csm-cranberry) 100%);
    border: 1px solid var(--csm-cranberry-dark);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    font-family: inherit;
    white-space: nowrap;
}

.csm-muse-submit:hover {
    background: linear-gradient(135deg, var(--csm-cranberry) 0%, var(--csm-cranberry-soft) 100%);
    border-color: var(--csm-cranberry);
}

.csm-muse-submit:active {
    transform: translateY(1px);
}

.csm-muse-submit:disabled,
.csm-muse-submit.is-loading {
    opacity: 0.55;
    cursor: wait;
}

.csm-muse-options {
    border: none;
    padding: 0;
    background: transparent;
}

.csm-muse-options > summary {
    padding: 4px 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--csm-text-muted);
    list-style: none;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.csm-muse-options > summary:hover {
    color: var(--csm-cranberry);
}

.csm-muse-options > summary::-webkit-details-marker { display: none; }

.csm-muse-options > summary::before {
    content: "+";
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    transition: transform 0.15s ease;
}

.csm-muse-options[open] > summary::before {
    content: "−";
}

.csm-muse-options-body {
    padding: 8px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.csm-muse-pref-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.csm-muse-pref-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--csm-text-muted);
    margin-right: 4px;
    flex-shrink: 0;
}

.csm-muse-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.csm-muse-pill {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--csm-text);
    background: #fff;
    border: 1px solid var(--csm-border);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
    line-height: 1.4;
}

.csm-muse-pill:hover {
    border-color: var(--csm-cranberry);
    color: var(--csm-cranberry);
}

.csm-muse-pill.is-active {
    background: var(--csm-cranberry);
    border-color: var(--csm-cranberry);
    color: #fff;
}

.csm-muse-error {
    margin-top: 4px;
    padding: 8px 12px;
    font-size: 13px;
    color: #8a3a1e;
    background: #fef3ec;
    border: 1px solid #f3c1a0;
    border-radius: 8px;
}

.csm-muse-result {
    margin-top: 12px;
    min-height: 0;
}

.csm-muse-pending {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 12px;
    background: linear-gradient(90deg, #fff7ed 0%, #fef3c7 100%);
    border: 1px solid #f59e0b;
    border-radius: 10px;
    color: #92400e;
    font-weight: 600;
    animation: csm-muse-pending-fade-in 0.25s ease-out;
}
.csm-muse-pending-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(146, 64, 14, 0.25);
    border-top-color: #92400e;
    border-radius: 50%;
    animation: csm-muse-pending-spin 0.8s linear infinite;
    flex-shrink: 0;
}
.csm-muse-pending-text { line-height: 1.3; }
@keyframes csm-muse-pending-spin {
    to { transform: rotate(360deg); }
}
@keyframes csm-muse-pending-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.csm-muse-candidates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.csm-muse-candidate-card {
    padding: 14px;
    background: #fff;
    border: 1px solid var(--csm-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: csmMuseCandidateAppear 0.35s ease;
    transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.15s ease;
}

.csm-muse-candidate-card:hover {
    border-color: var(--csm-cranberry);
}

.csm-muse-candidate-card.is-fading {
    opacity: 0;
    transform: translateY(-6px);
}

@keyframes csmMuseCandidateAppear {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.csm-muse-candidate-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: var(--csm-bg-soft);
}

.csm-muse-candidate-image.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0) 70%);
    background-size: 220% 100%;
    animation: csmMuseShimmer 1.6s linear infinite;
    pointer-events: none;
}

.csm-muse-candidate-image-slow {
    position: absolute;
    inset: auto 0 0 0;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 12px;
    text-align: center;
    z-index: 2;
    animation: csm-muse-pending-fade-in 0.3s ease-out;
}

.csm-muse-candidate-image-shimmer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(107, 66, 38, 0.25);
    font-size: 24px;
}

.csm-muse-candidate-image-shimmer::before {
    content: "✦";
    animation: csmMusePulse 2s ease-in-out infinite;
}

@keyframes csmMusePulse {
    0%, 100% { opacity: 0.3; transform: scale(0.92); }
    50% { opacity: 0.7; transform: scale(1.04); }
}

.csm-muse-candidate-image.is-ready {
    background: transparent;
}

.csm-muse-candidate-image-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    animation: csmMuseImageAppear 0.4s ease;
}

@keyframes csmMuseImageAppear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.csm-muse-candidate-image.is-failed::after {
    content: "image unavailable";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--csm-text-muted);
    font-size: 11px;
    font-style: italic;
}

.csm-muse-candidate-name {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--csm-brown-dark);
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.csm-muse-candidate-reason {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--csm-text-muted);
}

.csm-muse-candidate-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.csm-muse-candidate-bar-row {
    display: grid;
    grid-template-columns: 1fr 50px 32px;
    gap: 8px;
    align-items: center;
}

.csm-muse-candidate-bar-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--csm-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csm-muse-candidate-bar-origin {
    font-size: 9px;
    font-weight: 500;
    color: var(--csm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 2px;
}

.csm-muse-candidate-bar-track {
    height: 4px;
    background: #f3f0ed;
    border-radius: 999px;
    overflow: hidden;
}

.csm-muse-candidate-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--csm-cranberry-dark) 0%, var(--csm-cranberry) 100%);
    border-radius: 999px;
}

.csm-muse-candidate-bar-pct {
    font-size: 10px;
    font-weight: 700;
    color: var(--csm-text-muted);
    text-align: right;
}

.csm-muse-candidate-bar-notes {
    margin: 0 0 4px 0;
    font-size: 10px;
    color: var(--csm-text-muted);
    padding-left: 2px;
}

.csm-muse-pick-btn {
    margin-top: auto;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--csm-cranberry-dark) 0%, var(--csm-cranberry) 100%);
    border: 1px solid var(--csm-cranberry-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-family: inherit;
}

.csm-muse-pick-btn:hover {
    background: linear-gradient(135deg, var(--csm-cranberry) 0%, var(--csm-cranberry-soft) 100%);
    border-color: var(--csm-cranberry);
}

.csm-muse-pick-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.csm-muse-pick-btn.is-minting {
    background: var(--csm-cranberry-soft);
    border-color: var(--csm-cranberry-soft);
}

@keyframes csmMuseShimmer {
    to { background-position-x: -200%; }
}

.csm-muse-success {
    padding: 10px 14px;
    background: #f0f9f0;
    border: 1px solid #c8e0c0;
    border-radius: 8px;
    color: #3f6b30;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    animation: csmMuseCandidateAppear 0.35s ease;
}

.csm-gallery-songs-strip {
    margin: 0;
    padding: 8px 12px;
    background: var(--csm-bg-soft);
    border-bottom: 1px solid var(--csm-border);
    display: flex;
    flex-direction: column;
}

.csm-gallery-songs-strip .csm-gallery-song-list-primary {
    margin: 0;
}

.csm-gallery-songs-strip .csm-gallery-song-row {
    margin: 0;
    align-items: flex-start;
}

.csm-gallery-songs-strip .csm-gallery-song-info {
    min-width: 0;
    flex: 1;
}

.csm-gallery-songs-strip .csm-gallery-song-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
    min-height: 2.6em;
    line-height: 1.3;
    white-space: normal;
}

.csm-gallery-song-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.csm-gallery-song-play-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.csm-gallery-songs-toggle {
    width: 32px;
    height: 16px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--csm-border-strong);
    border-radius: 999px;
    color: var(--csm-text-muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.csm-gallery-songs-toggle:hover {
    color: var(--csm-cranberry);
    border-color: var(--csm-cranberry);
}

.csm-gallery-songs-strip.is-expanded .csm-gallery-songs-toggle {
    background: var(--csm-cranberry);
    border-color: var(--csm-cranberry);
    color: #fff;
}

.csm-gallery-songs-extra-inline {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--csm-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: csmMuseCandidateAppear 0.25s ease;
}

.csm-gallery-songs-extra-inline[hidden] {
    display: none !important;
}

.csm-gallery-songs-extra-inline .csm-gallery-song-row {
    align-items: center;
}

.csm-gallery-songs-extra-inline .csm-gallery-song-name {
    display: none;
}

.csm-gallery-songs-extra-inline .csm-gallery-song-style {
    font-size: 12px;
    font-weight: 500;
    color: var(--csm-text);
    line-height: 1.3;
}

.csm-gallery-music-generate-inline {
    width: 100%;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--csm-cranberry);
    background: transparent;
    border: 1px dashed var(--csm-border-strong);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.csm-gallery-music-generate-inline:hover {
    border-color: var(--csm-cranberry);
    color: var(--csm-cranberry-dark);
}

.csm-gallery-music-generate-strip {
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--csm-cranberry);
    background: transparent;
    border: 1px dashed var(--csm-border-strong);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.csm-gallery-music-generate-strip:hover {
    border-color: var(--csm-cranberry);
    color: var(--csm-cranberry-dark);
}

.csm-gallery-music-generate-strip.is-disabled,
.csm-gallery-music-generate-strip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.csm-gallery-more {
    margin: 4px 0 0 0;
    border-top: 1px solid var(--csm-border);
    padding-top: 8px;
}

.csm-gallery-more > summary {
    list-style: none;
    cursor: pointer;
    padding: 4px 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--csm-text-muted);
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.csm-gallery-more > summary::-webkit-details-marker { display: none; }

.csm-gallery-more > summary::before {
    content: "+";
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
}

.csm-gallery-more[open] > summary::before {
    content: "−";
}

.csm-gallery-more > summary:hover {
    color: var(--csm-cranberry);
}

.csm-gallery-more-body {
    padding: 8px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.csm-gallery-more-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.csm-gallery-more-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--csm-text-muted);
}

.csm-gallery-card-bottom {
    margin-top: auto;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.csm-gallery-card-bottom .csm-gallery-size-row {
    margin: 0;
}

.csm-gallery-card-bottom .csm-gallery-card-actions {
    margin: 0;
}

.csm-gallery-card.csm-just-minted {
    animation: csmMuseJustMinted 0.55s ease;
}

@keyframes csmMuseJustMinted {
    0% { opacity: 0; transform: translateY(-10px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.csm-explore-filters {
    margin: 16px 0 20px 0;
    padding: 0 0 14px 0;
    border-bottom: 1px solid var(--csm-border);
}

.csm-explore-filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.csm-explore-source-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--csm-bg-soft);
    border-radius: 999px;
    border: 1px solid var(--csm-border);
}

.csm-explore-source-pill {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--csm-text);
    background: transparent;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.csm-explore-source-pill:hover {
    color: var(--csm-cranberry);
}

.csm-explore-source-pill.is-active {
    background: var(--csm-cranberry);
    color: #fff;
}

.csm-explore-source-count {
    display: inline-block;
    margin-left: 4px;
    padding: 0 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

.csm-explore-source-pill:not(.is-active) .csm-explore-source-count {
    background: rgba(163, 61, 74, 0.1);
}

.csm-explore-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.csm-explore-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--csm-text-muted);
}

.csm-explore-filter-select {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--csm-text);
    background: #fff;
    border: 1px solid var(--csm-border-strong);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.csm-explore-filter-select:focus {
    outline: none;
    border-color: var(--csm-cranberry);
}

.csm-explore-filter-clear {
    margin-left: auto;
    font-size: 12px;
    color: var(--csm-text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.csm-explore-filter-clear:hover {
    color: var(--csm-cranberry);
}

@media (max-width: 640px) {
    .csm-muse-row { flex-direction: column; gap: 8px; }
    .csm-muse-submit { padding: 12px 20px; }
    .csm-muse-candidates { grid-template-columns: 1fr; }
    .csm-explore-source-toggle { flex-wrap: wrap; }
    .csm-explore-filter-form { gap: 10px; }
}
