.msd-card-wrapper {
    max-width: 720px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #1e293b;
    border: 1px solid #f1f5f9;
}

.msd-card-header {
    text-align: center;
    margin-bottom: 24px;
}

.msd-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff8e6;
    color: #d97706;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.msd-pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #e28e3a;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(226, 142, 58, 0.4);
    animation: msd-pulse 1.8s infinite;
}

@keyframes msd-pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(226, 142, 58, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(226, 142, 58, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(226, 142, 58, 0); }
}

.msd-card-header h2 {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 8px 0;
}

.msd-card-header p {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

.msd-search-bar {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
    transition: all 0.2s ease;
}

.msd-search-bar:focus-within {
    border-color: #e28e3a;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(226, 142, 58, 0.15);
}

.msd-link-icon {
    width: 20px;
    height: 20px;
    color: #94a3b8;
    margin-right: 12px;
    flex-shrink: 0;
}

.msd-search-bar input {
    width: 100%;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 15px;
    color: #1e293b;
    padding: 8px 0;
}

/* Custom Gradient Buttons */
.msd-btn-primary, .msd-btn-process:not(:disabled) {
    background: linear-gradient(40deg, #EEBB58 0%, #E28E3A 100%) !important;
    color: #ffffff !important;
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(226, 142, 58, 0.3);
}

.msd-btn-primary:hover, .msd-btn-process:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(226, 142, 58, 0.4);
    opacity: 0.95;
}

.msd-btn-arrow {
    width: 18px;
    height: 18px;
}

.msd-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}

.msd-select-wrap label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.msd-select-wrap select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background-color: #f8fafc;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    outline: none;
    cursor: pointer;
}

.msd-select-wrap select:focus {
    border-color: #e28e3a;
    background-color: #fff;
}

.msd-field-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
    font-weight: 500;
}

.msd-result-area {
    margin-top: 24px;
}

.msd-result-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 20px;
}

.msd-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: #0f172a;
    word-break: break-word;
}

.msd-author {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 16px 0;
}

.msd-selection-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.msd-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.msd-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.msd-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #e28e3a;
    cursor: pointer;
}

.msd-btn-process {
    width: 100%;
}

.msd-btn-process:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
    box-shadow: none !important;
}

.msd-media-col video, .msd-media-col img {
    width: 100%;
    height: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
}

.msd-status-card {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 14px;
}

.msd-error-card {
    background: #fef2f2;
    color: #dc2626;
    padding: 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
}

.msd-loader-pulse {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
    .msd-card-wrapper { padding: 20px; }
    .msd-search-bar { flex-direction: column; gap: 10px; padding: 12px; }
    .msd-search-bar input { text-align: center; }
    .msd-btn-primary { width: 100%; }
    .msd-options-grid { grid-template-columns: 1fr; }
    .msd-result-card { grid-template-columns: 1fr; }
    .msd-media-col { order: -1; }
}
/* Playback and silent-download UX — scoped to this plugin only. */
.msd-card-wrapper .msd-media-col { min-width: 0; }
.msd-card-wrapper .msd-video-wrap { position: relative; width: 100%; }
.msd-card-wrapper .msd-video-wrap video {
    display: block;
    width: 100%;
    height: auto;
    min-height: 160px;
    max-height: 270px;
    object-fit: contain;
    background: #0f172a;
    border-radius: 12px;
}
.msd-card-wrapper .msd-preview-play {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 15px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.7);
    background: rgba(15,23,42,.88);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    z-index: 1;
    white-space: nowrap;
}
.msd-card-wrapper .msd-preview-play:hover,
.msd-card-wrapper .msd-preview-play:focus-visible {
    background: #e28e3a;
    color: #fff;
    border-color: #fff;
}
.msd-card-wrapper .msd-preview-play:disabled { opacity:.6; cursor:wait; }
.msd-card-wrapper .msd-preview-play[hidden] { display: none; }
.msd-card-wrapper .msd-preview-status,
.msd-card-wrapper .msd-convert-progress {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
    overflow-wrap: anywhere;
}
.msd-card-wrapper .msd-convert-progress[hidden] { display:none; }
.msd-card-wrapper .msd-convert-progress.msd-progress-error { color: #b91c1c; }
.msd-card-wrapper .msd-media-col audio { width:100%; }
@media (max-width:640px) {
    .msd-card-wrapper .msd-video-wrap video { max-height: 260px; }
    .msd-card-wrapper .msd-result-card > * { min-width: 0; }
}
.msd-card-wrapper .msd-mute-note {
    font-size: 12px;
    line-height: 1.55;
    color: #64748b;
    margin: 8px 0 12px;
}

/* v4.3.1: scoped form validation and strong theme-safe states. */
.msd-card-wrapper .msd-search-bar:has(input.msd-error-border),
.msd-card-wrapper .msd-select-wrap select.msd-error-border {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12) !important;
}
.msd-card-wrapper .msd-btn-primary:disabled,
.msd-card-wrapper .msd-btn-primary[aria-busy="true"] {
    cursor: wait;
    opacity: .72;
    transform: none;
}
.msd-card-wrapper .msd-btn-primary:hover,
.msd-card-wrapper .msd-btn-primary:focus-visible,
.msd-card-wrapper .msd-btn-process:not(:disabled):hover,
.msd-card-wrapper .msd-btn-process:not(:disabled):focus-visible {
    color: #fff !important;
}
.msd-card-wrapper input[name="url"]::placeholder { color: #64748b; opacity: 1; }
.msd-card-wrapper .msd-search-bar input { min-width: 0; }
.msd-card-wrapper .msd-btn-primary { flex-shrink: 0; }
.msd-card-wrapper .msd-field-error { overflow-wrap: anywhere; }
@media (max-width: 640px) {
    .msd-card-wrapper { min-width: 0; }
    .msd-card-wrapper .msd-search-bar { min-width: 0; }
    .msd-card-wrapper .msd-search-bar input { max-width: 100%; }
}

/* YouTube preview for the deferred, format-specific FastSaver workflow. */
.msd-card-wrapper .msd-embed-frame { display:block; width:100%; aspect-ratio:16 / 9; border:0; border-radius:12px; }
.msd-card-wrapper .msd-direct-fallback { margin:8px 0 0; font-size:12px; }
.msd-card-wrapper .msd-direct-fallback a { color:#2563eb; text-decoration:underline; }
